@dyyz1993/codenomad 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -0
- package/dist/api-types.js +1 -0
- package/dist/auth/auth-store.js +134 -0
- package/dist/auth/http-auth.js +37 -0
- package/dist/auth/manager.js +140 -0
- package/dist/auth/password-hash.js +32 -0
- package/dist/auth/session-manager.js +17 -0
- package/dist/auth/token-manager.js +27 -0
- package/dist/background-processes/manager.js +576 -0
- package/dist/bin.js +24 -0
- package/dist/cli-upgrade.js +53 -0
- package/dist/cli-upgrade.test.js +31 -0
- package/dist/clients/connection-manager.js +93 -0
- package/dist/config/location.js +57 -0
- package/dist/config/schema.js +71 -0
- package/dist/events/bus.js +45 -0
- package/dist/filesystem/__tests__/browser.test.js +65 -0
- package/dist/filesystem/__tests__/search-cache.test.js +40 -0
- package/dist/filesystem/browser.js +306 -0
- package/dist/filesystem/search-cache.js +43 -0
- package/dist/filesystem/search.js +135 -0
- package/dist/index.js +477 -0
- package/dist/launcher.js +149 -0
- package/dist/loader.js +21 -0
- package/dist/logger.js +109 -0
- package/dist/opencode-config/README.md +32 -0
- package/dist/opencode-config/opencode.jsonc +3 -0
- package/dist/opencode-config/package-lock.json +380 -0
- package/dist/opencode-config/package.json +9 -0
- package/dist/opencode-config/plugin/codenomad.ts +62 -0
- package/dist/opencode-config/plugin/lib/background-process.ts +265 -0
- package/dist/opencode-config/plugin/lib/client.ts +133 -0
- package/dist/opencode-config/plugin/lib/request.ts +214 -0
- package/dist/opencode-config.js +26 -0
- package/dist/plugins/channel.js +40 -0
- package/dist/plugins/handlers.js +17 -0
- package/dist/plugins/voice-mode.js +78 -0
- package/dist/releases/dev-release-monitor.js +75 -0
- package/dist/releases/release-monitor.js +107 -0
- package/dist/server/__tests__/network-addresses.test.js +68 -0
- package/dist/server/__tests__/remote-proxy.test.js +204 -0
- package/dist/server/http-server.js +926 -0
- package/dist/server/network-addresses.js +114 -0
- package/dist/server/remote-proxy.js +466 -0
- package/dist/server/routes/auth-pages/login.html +135 -0
- package/dist/server/routes/auth-pages/token.html +93 -0
- package/dist/server/routes/auth.js +148 -0
- package/dist/server/routes/background-processes.js +78 -0
- package/dist/server/routes/events.js +66 -0
- package/dist/server/routes/filesystem.js +43 -0
- package/dist/server/routes/meta.js +44 -0
- package/dist/server/routes/plugin.js +70 -0
- package/dist/server/routes/remote-proxy.js +42 -0
- package/dist/server/routes/remote-servers.js +142 -0
- package/dist/server/routes/settings.js +69 -0
- package/dist/server/routes/sidecars.js +46 -0
- package/dist/server/routes/speech.js +63 -0
- package/dist/server/routes/storage.js +52 -0
- package/dist/server/routes/workspaces.js +221 -0
- package/dist/server/routes/worktrees.js +156 -0
- package/dist/server/tls.js +224 -0
- package/dist/settings/binaries.js +37 -0
- package/dist/settings/merge-patch.js +33 -0
- package/dist/settings/migrate.js +238 -0
- package/dist/settings/public-config.js +33 -0
- package/dist/settings/service.js +101 -0
- package/dist/settings/yaml-doc-store.js +96 -0
- package/dist/sidecars/manager.js +193 -0
- package/dist/speech/providers/openai-compatible.js +189 -0
- package/dist/speech/service.js +58 -0
- package/dist/storage/instance-store.js +56 -0
- package/dist/ui/__tests__/remote-ui.test.js +67 -0
- package/dist/ui/remote-ui.js +462 -0
- package/dist/workspaces/__tests__/git-worktrees.test.js +43 -0
- package/dist/workspaces/__tests__/spawn.test.js +140 -0
- package/dist/workspaces/git-mutations.js +98 -0
- package/dist/workspaces/git-status.js +323 -0
- package/dist/workspaces/git-worktrees.js +216 -0
- package/dist/workspaces/instance-events.js +180 -0
- package/dist/workspaces/manager.js +368 -0
- package/dist/workspaces/opencode-auth.js +34 -0
- package/dist/workspaces/opencode-auth.test.js +34 -0
- package/dist/workspaces/runtime.js +366 -0
- package/dist/workspaces/spawn.js +219 -0
- package/dist/workspaces/worktree-directory.js +74 -0
- package/dist/workspaces/worktree-map.js +116 -0
- package/package.json +50 -0
- package/public/apple-touch-icon-180x180.png +0 -0
- package/public/assets/ChangesTab-BRNmSjeC.js +2 -0
- package/public/assets/CodeNomad-Icon-bmTWNPXy.png +0 -0
- package/public/assets/DiffToolbar-DPPgfx42.js +1 -0
- package/public/assets/FilesTab-sEeGPOoz.js +2 -0
- package/public/assets/GitChangesTab-tJ-TCq0c.js +2 -0
- package/public/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/public/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/public/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/public/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/public/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/public/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/public/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/public/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/public/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/public/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/public/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/public/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/public/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/public/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/public/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/public/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/public/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/public/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/public/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/public/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/public/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/public/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/public/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/public/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/public/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/public/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/public/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/public/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/public/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/public/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/public/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/public/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/public/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/public/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/public/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/public/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/public/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/public/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/public/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/public/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/public/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/public/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/public/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/public/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/public/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/public/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/public/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/public/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/public/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/public/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/public/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/public/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/public/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/public/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/public/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/public/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/public/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/public/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/public/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/public/assets/SplitFilePanel-CHqNLZvU.js +1 -0
- package/public/assets/StatusTab-DMd0ByCA.js +1 -0
- package/public/assets/abap-BdImnpbu.js +1 -0
- package/public/assets/actionscript-3-CfeIJUat.js +1 -0
- package/public/assets/ada-bCR0ucgS.js +1 -0
- package/public/assets/align-justify-BWapkGTe.js +1 -0
- package/public/assets/andromeeda-C-Jbm3Hp.js +1 -0
- package/public/assets/angular-html-CU67Zn6k.js +1 -0
- package/public/assets/angular-ts-BwZT4LLn.js +1 -0
- package/public/assets/apache-Pmp26Uib.js +1 -0
- package/public/assets/apex-DhZLUxFE.js +1 -0
- package/public/assets/apl-dKokRX4l.js +1 -0
- package/public/assets/applescript-Co6uUVPk.js +1 -0
- package/public/assets/ara-BRHolxvo.js +1 -0
- package/public/assets/asciidoc-Dv7Oe6Be.js +1 -0
- package/public/assets/asm-D_Q5rh1f.js +1 -0
- package/public/assets/astro-CbQHKStN.js +1 -0
- package/public/assets/aurora-x-D-2ljcwZ.js +1 -0
- package/public/assets/awk-DMzUqQB5.js +1 -0
- package/public/assets/ayu-dark-Cv9koXgw.js +1 -0
- package/public/assets/ballerina-BFfxhgS-.js +1 -0
- package/public/assets/bat-BkioyH1T.js +1 -0
- package/public/assets/beancount-k_qm7-4y.js +1 -0
- package/public/assets/berry-D08WgyRC.js +1 -0
- package/public/assets/bibtex-CHM0blh-.js +1 -0
- package/public/assets/bicep-Bmn6On1c.js +1 -0
- package/public/assets/blade-DVc8C-J4.js +1 -0
- package/public/assets/bsl-BO_Y6i37.js +1 -0
- package/public/assets/bundle-full-CXlKQh5B.js +13 -0
- package/public/assets/c-BIGW1oBm.js +1 -0
- package/public/assets/cadence-Bv_4Rxtq.js +1 -0
- package/public/assets/cairo-KRGpt6FW.js +1 -0
- package/public/assets/catppuccin-frappe-DFWUc33u.js +1 -0
- package/public/assets/catppuccin-latte-C9dUb6Cb.js +1 -0
- package/public/assets/catppuccin-macchiato-DQyhUUbL.js +1 -0
- package/public/assets/catppuccin-mocha-D87Tk5Gz.js +1 -0
- package/public/assets/clarity-D53aC0YG.js +1 -0
- package/public/assets/clojure-P80f7IUj.js +1 -0
- package/public/assets/cmake-D1j8_8rp.js +1 -0
- package/public/assets/cobol-nwyudZeR.js +1 -0
- package/public/assets/codeowners-Bp6g37R7.js +1 -0
- package/public/assets/codeql-DsOJ9woJ.js +1 -0
- package/public/assets/coffee-Ch7k5sss.js +1 -0
- package/public/assets/common-lisp-Cg-RD9OK.js +1 -0
- package/public/assets/coq-DkFqJrB1.js +1 -0
- package/public/assets/cpp-CofmeUqb.js +1 -0
- package/public/assets/crystal-tKQVLTB8.js +1 -0
- package/public/assets/csharp-CX12Zw3r.js +1 -0
- package/public/assets/css-DPfMkruS.js +1 -0
- package/public/assets/csv-fuZLfV_i.js +1 -0
- package/public/assets/cue-D82EKSYY.js +1 -0
- package/public/assets/cypher-COkxafJQ.js +1 -0
- package/public/assets/d-85-TOEBH.js +1 -0
- package/public/assets/dark-plus-eOWES_5F.js +1 -0
- package/public/assets/dart-CF10PKvl.js +1 -0
- package/public/assets/dax-CEL-wOlO.js +1 -0
- package/public/assets/desktop-BmXAJ9_W.js +1 -0
- package/public/assets/diff-D97Zzqfu.js +1 -0
- package/public/assets/diff-viewer-BFtW5J8P.js +1 -0
- package/public/assets/docker-BcOcwvcX.js +1 -0
- package/public/assets/dotenv-Da5cRb03.js +1 -0
- package/public/assets/dracula-BzJJZx-M.js +1 -0
- package/public/assets/dracula-soft-BXkSAIEj.js +1 -0
- package/public/assets/dream-maker-BtqSS_iP.js +1 -0
- package/public/assets/edge-BkV0erSs.js +1 -0
- package/public/assets/elixir-CDX3lj18.js +1 -0
- package/public/assets/elm-DbKCFpqz.js +1 -0
- package/public/assets/emacs-lisp-C9XAeP06.js +1 -0
- package/public/assets/erb-BOJIQeun.js +1 -0
- package/public/assets/erlang-DsQrWhSR.js +1 -0
- package/public/assets/everforest-dark-BgDCqdQA.js +1 -0
- package/public/assets/everforest-light-C8M2exoo.js +1 -0
- package/public/assets/fast-diff-vendor-DgdwVvTQ.js +1 -0
- package/public/assets/fennel-BYunw83y.js +1 -0
- package/public/assets/fish-BvzEVeQv.js +1 -0
- package/public/assets/fluent-C4IJs8-o.js +1 -0
- package/public/assets/fortran-fixed-form-BZjJHVRy.js +1 -0
- package/public/assets/fortran-free-form-D22FLkUw.js +1 -0
- package/public/assets/fsharp-CXgrBDvD.js +1 -0
- package/public/assets/gdresource-B7Tvp0Sc.js +1 -0
- package/public/assets/gdscript-DTMYz4Jt.js +1 -0
- package/public/assets/gdshader-DkwncUOv.js +1 -0
- package/public/assets/genie-D0YGMca9.js +1 -0
- package/public/assets/gherkin-DyxjwDmM.js +1 -0
- package/public/assets/git-commit-F4YmCXRG.js +1 -0
- package/public/assets/git-diff-vendor-CSgooKT_.js +52 -0
- package/public/assets/git-diff-vendor-HAZkIolJ.css +19 -0
- package/public/assets/git-rebase-r7XF79zn.js +1 -0
- package/public/assets/github-dark-DHJKELXO.js +1 -0
- package/public/assets/github-dark-default-Cuk6v7N8.js +1 -0
- package/public/assets/github-dark-dimmed-DH5Ifo-i.js +1 -0
- package/public/assets/github-dark-high-contrast-E3gJ1_iC.js +1 -0
- package/public/assets/github-light-DAi9KRSo.js +1 -0
- package/public/assets/github-light-default-D7oLnXFd.js +1 -0
- package/public/assets/github-light-high-contrast-BfjtVDDH.js +1 -0
- package/public/assets/gleam-BspZqrRM.js +1 -0
- package/public/assets/glimmer-js-Rg0-pVw9.js +1 -0
- package/public/assets/glimmer-ts-U6CK756n.js +1 -0
- package/public/assets/glsl-DplSGwfg.js +1 -0
- package/public/assets/gnuplot-DdkO51Og.js +1 -0
- package/public/assets/go-Dn2_MT6a.js +1 -0
- package/public/assets/graphql-ChdNCCLP.js +1 -0
- package/public/assets/groovy-gcz8RCvz.js +1 -0
- package/public/assets/gruvbox-dark-hard-CFHQjOhq.js +1 -0
- package/public/assets/gruvbox-dark-medium-GsRaNv29.js +1 -0
- package/public/assets/gruvbox-dark-soft-CVdnzihN.js +1 -0
- package/public/assets/gruvbox-light-hard-CH1njM8p.js +1 -0
- package/public/assets/gruvbox-light-medium-DRw_LuNl.js +1 -0
- package/public/assets/gruvbox-light-soft-hJgmCMqR.js +1 -0
- package/public/assets/hack-CaT9iCJl.js +1 -0
- package/public/assets/haml-B8DHNrY2.js +1 -0
- package/public/assets/handlebars-BL8al0AC.js +1 -0
- package/public/assets/haskell-Df6bDoY_.js +1 -0
- package/public/assets/haxe-CzTSHFRz.js +1 -0
- package/public/assets/hcl-BWvSN4gD.js +1 -0
- package/public/assets/highlight-vendor-8FKMu9os.js +10 -0
- package/public/assets/hjson-D5-asLiD.js +1 -0
- package/public/assets/hlsl-D3lLCCz7.js +1 -0
- package/public/assets/houston-DnULxvSX.js +1 -0
- package/public/assets/html-GMplVEZG.js +1 -0
- package/public/assets/html-derivative-BFtXZ54Q.js +1 -0
- package/public/assets/http-jrhK8wxY.js +1 -0
- package/public/assets/hurl-irOxFIW8.js +1 -0
- package/public/assets/hxml-Bvhsp5Yf.js +1 -0
- package/public/assets/hy-DFXneXwc.js +1 -0
- package/public/assets/imba-DGztddWO.js +1 -0
- package/public/assets/index-Bdy3MTIn.js +1 -0
- package/public/assets/index-BvRe9GiS.js +1 -0
- package/public/assets/index-Ctq8RqRf.js +1 -0
- package/public/assets/index-D-NvysdX.js +1 -0
- package/public/assets/index-D6RMBXUk.js +2 -0
- package/public/assets/index-DXI9DoVB.css +1 -0
- package/public/assets/index-DYWkPhKo.js +1 -0
- package/public/assets/index-D_FDiI6a.js +1 -0
- package/public/assets/index-Dty5bSHf.js +1 -0
- package/public/assets/index-H16e4Rqc.js +1 -0
- package/public/assets/ini-BEwlwnbL.js +1 -0
- package/public/assets/java-CylS5w8V.js +1 -0
- package/public/assets/javascript-wDzz0qaB.js +1 -0
- package/public/assets/jinja-4LBKfQ-Z.js +1 -0
- package/public/assets/jison-wvAkD_A8.js +1 -0
- package/public/assets/json-Cp-IABpG.js +1 -0
- package/public/assets/json5-C9tS-k6U.js +1 -0
- package/public/assets/jsonc-Des-eS-w.js +1 -0
- package/public/assets/jsonl-DcaNXYhu.js +1 -0
- package/public/assets/jsonnet-DFQXde-d.js +1 -0
- package/public/assets/jssm-C2t-YnRu.js +1 -0
- package/public/assets/jsx-g9-lgVsj.js +1 -0
- package/public/assets/julia-C8NyazO9.js +1 -0
- package/public/assets/kanagawa-dragon-CkXjmgJE.js +1 -0
- package/public/assets/kanagawa-lotus-CfQXZHmo.js +1 -0
- package/public/assets/kanagawa-wave-DWedfzmr.js +1 -0
- package/public/assets/kdl-DV7GczEv.js +1 -0
- package/public/assets/kotlin-BdnUsdx6.js +1 -0
- package/public/assets/kusto-BvAqAH-y.js +1 -0
- package/public/assets/laserwave-DUszq2jm.js +1 -0
- package/public/assets/latex-BUKiar2Z.js +1 -0
- package/public/assets/lean-DP1Csr6i.js +1 -0
- package/public/assets/less-B1dDrJ26.js +1 -0
- package/public/assets/light-plus-B7mTdjB0.js +1 -0
- package/public/assets/liquid-DYVedYrR.js +1 -0
- package/public/assets/llvm-BtvRca6l.js +1 -0
- package/public/assets/loading-CmEVQgyj.css +1 -0
- package/public/assets/loading-W2Y_wR0P.js +1 -0
- package/public/assets/log-2UxHyX5q.js +1 -0
- package/public/assets/logo-BtOb2qkB.js +1 -0
- package/public/assets/lua-BbnMAYS6.js +1 -0
- package/public/assets/luau-CXu1NL6O.js +1 -0
- package/public/assets/main-Bala0YJ4.js +57 -0
- package/public/assets/make-CHLpvVh8.js +1 -0
- package/public/assets/markdown-Cvjx9yec.js +1 -0
- package/public/assets/markdown-Db8cvZ4Z.js +315 -0
- package/public/assets/marko-CPi9NSCl.js +1 -0
- package/public/assets/material-theme-D5KoaKCx.js +1 -0
- package/public/assets/material-theme-darker-BfHTSMKl.js +1 -0
- package/public/assets/material-theme-lighter-B0m2ddpp.js +1 -0
- package/public/assets/material-theme-ocean-CyktbL80.js +1 -0
- package/public/assets/material-theme-palenight-Csfq5Kiy.js +1 -0
- package/public/assets/matlab-D7o27uSR.js +1 -0
- package/public/assets/mdc-DUICxH0z.js +1 -0
- package/public/assets/mdx-Cmh6b_Ma.js +1 -0
- package/public/assets/mermaid-DKYwYmdq.js +1 -0
- package/public/assets/min-dark-CafNBF8u.js +1 -0
- package/public/assets/min-light-CTRr51gU.js +1 -0
- package/public/assets/mipsasm-CKIfxQSi.js +1 -0
- package/public/assets/mojo-1DNp92w6.js +1 -0
- package/public/assets/monaco-viewer-DWQqXKm3.js +26 -0
- package/public/assets/monokai-D4h5O-jR.js +1 -0
- package/public/assets/move-Bu9oaDYs.js +1 -0
- package/public/assets/narrat-DRg8JJMk.js +1 -0
- package/public/assets/nextflow-CUEJCptM.js +1 -0
- package/public/assets/nginx-DknmC5AR.js +1 -0
- package/public/assets/night-owl-C39BiMTA.js +1 -0
- package/public/assets/nim-CVrawwO9.js +1 -0
- package/public/assets/nix-BbRYJGeE.js +1 -0
- package/public/assets/nord-Ddv68eIx.js +1 -0
- package/public/assets/nushell-C-sUppwS.js +1 -0
- package/public/assets/objective-c-DXmwc3jG.js +1 -0
- package/public/assets/objective-cpp-CLxacb5B.js +1 -0
- package/public/assets/ocaml-C0hk2d4L.js +1 -0
- package/public/assets/one-dark-pro-DVMEJ2y_.js +1 -0
- package/public/assets/one-light-PoHY5YXO.js +1 -0
- package/public/assets/pascal-D93ZcfNL.js +1 -0
- package/public/assets/perl-C0TMdlhV.js +1 -0
- package/public/assets/php-CDn_0X-4.js +1 -0
- package/public/assets/pkl-u5AG7uiY.js +1 -0
- package/public/assets/plastic-3e1v2bzS.js +1 -0
- package/public/assets/plsql-ChMvpjG-.js +1 -0
- package/public/assets/po-BTJTHyun.js +1 -0
- package/public/assets/poimandres-CS3Unz2-.js +1 -0
- package/public/assets/polar-C0HS_06l.js +1 -0
- package/public/assets/postcss-CXtECtnM.js +1 -0
- package/public/assets/powerquery-CEu0bR-o.js +1 -0
- package/public/assets/powershell-Dpen1YoG.js +1 -0
- package/public/assets/prisma-Dd19v3D-.js +1 -0
- package/public/assets/prolog-CbFg5uaA.js +1 -0
- package/public/assets/proto-DyJlTyXw.js +1 -0
- package/public/assets/pug-CGlum2m_.js +1 -0
- package/public/assets/puppet-BMWR74SV.js +1 -0
- package/public/assets/purescript-CklMAg4u.js +1 -0
- package/public/assets/python-B6aJPvgy.js +1 -0
- package/public/assets/qml-3beO22l8.js +1 -0
- package/public/assets/qmldir-C8lEn-DE.js +1 -0
- package/public/assets/qss-IeuSbFQv.js +1 -0
- package/public/assets/r-DiinP2Uv.js +1 -0
- package/public/assets/racket-BqYA7rlc.js +1 -0
- package/public/assets/raku-DXvB9xmW.js +1 -0
- package/public/assets/razor-WgofotgN.js +1 -0
- package/public/assets/red-bN70gL4F.js +1 -0
- package/public/assets/reg-C-SQnVFl.js +1 -0
- package/public/assets/regexp-CDVJQ6XC.js +1 -0
- package/public/assets/rel-C3B-1QV4.js +1 -0
- package/public/assets/riscv-BM1_JUlF.js +1 -0
- package/public/assets/rose-pine-BHrmToEH.js +1 -0
- package/public/assets/rose-pine-dawn-CnK8MTSM.js +1 -0
- package/public/assets/rose-pine-moon-NleAzG8P.js +1 -0
- package/public/assets/rosmsg-BJDFO7_C.js +1 -0
- package/public/assets/rst-B0xPkSld.js +1 -0
- package/public/assets/ruby-BvKwtOVI.js +1 -0
- package/public/assets/rust-B1yitclQ.js +1 -0
- package/public/assets/sas-cz2c8ADy.js +1 -0
- package/public/assets/sass-Cj5Yp3dK.js +1 -0
- package/public/assets/scala-C151Ov-r.js +1 -0
- package/public/assets/scheme-C98Dy4si.js +1 -0
- package/public/assets/scss-OYdSNvt2.js +1 -0
- package/public/assets/sdbl-DVxCFoDh.js +1 -0
- package/public/assets/shaderlab-Dg9Lc6iA.js +1 -0
- package/public/assets/shellscript-Yzrsuije.js +1 -0
- package/public/assets/shellsession-BADoaaVG.js +1 -0
- package/public/assets/slack-dark-BthQWCQV.js +1 -0
- package/public/assets/slack-ochin-DqwNpetd.js +1 -0
- package/public/assets/smalltalk-BERRCDM3.js +1 -0
- package/public/assets/snazzy-light-Bw305WKR.js +1 -0
- package/public/assets/solarized-dark-DXbdFlpD.js +1 -0
- package/public/assets/solarized-light-L9t79GZl.js +1 -0
- package/public/assets/solidity-BbcW6ACK.js +1 -0
- package/public/assets/soy-Brmx7dQM.js +1 -0
- package/public/assets/sparql-rVzFXLq3.js +1 -0
- package/public/assets/splunk-BtCnVYZw.js +1 -0
- package/public/assets/sql-BLtJtn59.js +1 -0
- package/public/assets/ssh-config-_ykCGR6B.js +1 -0
- package/public/assets/stata-BH5u7GGu.js +1 -0
- package/public/assets/stylus-BEDo0Tqx.js +1 -0
- package/public/assets/svelte-3Dk4HxPD.js +1 -0
- package/public/assets/swift-Dg5xB15N.js +1 -0
- package/public/assets/synthwave-84-CbfX1IO0.js +1 -0
- package/public/assets/system-verilog-CnnmHF94.js +1 -0
- package/public/assets/systemd-4A_iFExJ.js +1 -0
- package/public/assets/talonscript-CkByrt1z.js +1 -0
- package/public/assets/tasl-QIJgUcNo.js +1 -0
- package/public/assets/tcl-dwOrl1Do.js +1 -0
- package/public/assets/templ-W15q3VgB.js +1 -0
- package/public/assets/terraform-BETggiCN.js +1 -0
- package/public/assets/tex-Cppo0RY3.js +1 -0
- package/public/assets/tokyo-night-hegEt444.js +1 -0
- package/public/assets/toml-vGWfd6FD.js +1 -0
- package/public/assets/tool-call-D0BYXlFe.js +59 -0
- package/public/assets/ts-tags-zn1MmPIZ.js +1 -0
- package/public/assets/tsv-B_m7g4N7.js +1 -0
- package/public/assets/tsx-COt5Ahok.js +1 -0
- package/public/assets/turtle-BsS91CYL.js +1 -0
- package/public/assets/twig-CO9l9SDP.js +1 -0
- package/public/assets/typescript-BPQ3VLAy.js +1 -0
- package/public/assets/typespec-Df68jz8_.js +1 -0
- package/public/assets/typst-DHCkPAjA.js +1 -0
- package/public/assets/unified-picker-QgONWj_1.js +1 -0
- package/public/assets/v-BcVCzyr7.js +1 -0
- package/public/assets/vala-CsfeWuGM.js +1 -0
- package/public/assets/vb-D17OF-Vu.js +1 -0
- package/public/assets/verilog-BQ8w6xss.js +1 -0
- package/public/assets/vesper-DU1UobuO.js +1 -0
- package/public/assets/vhdl-CeAyd5Ju.js +1 -0
- package/public/assets/viml-CJc9bBzg.js +1 -0
- package/public/assets/vitesse-black-Bkuqu6BP.js +1 -0
- package/public/assets/vitesse-dark-D0r3Knsf.js +1 -0
- package/public/assets/vitesse-light-CVO1_9PV.js +1 -0
- package/public/assets/vue-CCoi5OLL.js +1 -0
- package/public/assets/vue-html-DAAvJJDi.js +1 -0
- package/public/assets/vue-vine-_Ih-lPRR.js +1 -0
- package/public/assets/vyper-CDx5xZoG.js +1 -0
- package/public/assets/wasm-CG6Dc4jp.js +1 -0
- package/public/assets/wasm-MzD3tlZU.js +1 -0
- package/public/assets/wenyan-BV7otONQ.js +1 -0
- package/public/assets/wgsl-Dx-B1_4e.js +1 -0
- package/public/assets/wikitext-BhOHFoWU.js +1 -0
- package/public/assets/wit-5i3qLPDT.js +1 -0
- package/public/assets/wolfram-lXgVvXCa.js +1 -0
- package/public/assets/wrap-text-CEH9wOr_.js +1 -0
- package/public/assets/xml-sdJ4AIDG.js +1 -0
- package/public/assets/xsl-CtQFsRM5.js +1 -0
- package/public/assets/yaml-Buea-lGh.js +1 -0
- package/public/assets/zenscript-DVFEvuxE.js +1 -0
- package/public/assets/zig-VOosw3JB.js +1 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +42 -0
- package/public/loading.html +33 -0
- package/public/logo.png +0 -0
- package/public/manifest.webmanifest +1 -0
- package/public/maskable-icon-512x512.png +0 -0
- package/public/monaco/vs/base/browser/ui/codicons/codicon/codicon.ttf +0 -0
- package/public/monaco/vs/base/worker/workerMain.js +31 -0
- package/public/monaco/vs/basic-languages/cpp/cpp.js +10 -0
- package/public/monaco/vs/basic-languages/kotlin/kotlin.js +10 -0
- package/public/monaco/vs/basic-languages/markdown/markdown.js +10 -0
- package/public/monaco/vs/basic-languages/python/python.js +10 -0
- package/public/monaco/vs/editor/editor.main.css +8 -0
- package/public/monaco/vs/editor/editor.main.js +798 -0
- package/public/monaco/vs/language/css/cssMode.js +13 -0
- package/public/monaco/vs/language/css/cssWorker.js +77 -0
- package/public/monaco/vs/language/html/htmlMode.js +13 -0
- package/public/monaco/vs/language/html/htmlWorker.js +454 -0
- package/public/monaco/vs/language/json/jsonMode.js +19 -0
- package/public/monaco/vs/language/json/jsonWorker.js +42 -0
- package/public/monaco/vs/language/typescript/tsMode.js +20 -0
- package/public/monaco/vs/language/typescript/tsWorker.js +51328 -0
- package/public/monaco/vs/loader.js +11 -0
- package/public/monaco.worker.js +7 -0
- package/public/pwa-192x192.png +0 -0
- package/public/pwa-512x512.png +0 -0
- package/public/pwa-64x64.png +0 -0
- package/public/registerSW.js +1 -0
- package/public/sw.js +1 -0
- package/public/ui-version.json +3 -0
- package/public/workbox-60d14903.js +1 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { promises as fsp } from "fs";
|
|
3
|
+
import os from "os";
|
|
4
|
+
import path from "path";
|
|
5
|
+
const DEFAULT_INSTANCE_DATA = {
|
|
6
|
+
messageHistory: [],
|
|
7
|
+
agentModelSelections: {},
|
|
8
|
+
};
|
|
9
|
+
export class InstanceStore {
|
|
10
|
+
constructor(baseDir = path.join(os.homedir(), ".config", "codenomad", "instances")) {
|
|
11
|
+
this.instancesDir = baseDir;
|
|
12
|
+
fs.mkdirSync(this.instancesDir, { recursive: true });
|
|
13
|
+
}
|
|
14
|
+
async read(id) {
|
|
15
|
+
try {
|
|
16
|
+
const filePath = this.resolvePath(id);
|
|
17
|
+
const content = await fsp.readFile(filePath, "utf-8");
|
|
18
|
+
const parsed = JSON.parse(content);
|
|
19
|
+
return { ...DEFAULT_INSTANCE_DATA, ...parsed };
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error.code === "ENOENT") {
|
|
23
|
+
return DEFAULT_INSTANCE_DATA;
|
|
24
|
+
}
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async write(id, data) {
|
|
29
|
+
const filePath = this.resolvePath(id);
|
|
30
|
+
await fsp.mkdir(path.dirname(filePath), { recursive: true });
|
|
31
|
+
await fsp.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
|
|
32
|
+
}
|
|
33
|
+
async delete(id) {
|
|
34
|
+
try {
|
|
35
|
+
const filePath = this.resolvePath(id);
|
|
36
|
+
await fsp.unlink(filePath);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (error.code !== "ENOENT") {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
resolvePath(id) {
|
|
45
|
+
const filename = this.sanitizeId(id);
|
|
46
|
+
return path.join(this.instancesDir, `${filename}.json`);
|
|
47
|
+
}
|
|
48
|
+
sanitizeId(id) {
|
|
49
|
+
return id
|
|
50
|
+
.replace(/[\\/]/g, "_")
|
|
51
|
+
.replace(/[^a-zA-Z0-9_.-]/g, "_")
|
|
52
|
+
.replace(/_{2,}/g, "_")
|
|
53
|
+
.replace(/^_|_$/g, "")
|
|
54
|
+
.toLowerCase();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { mkdir } from "node:fs/promises";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { afterEach, beforeEach, describe, it } from "node:test";
|
|
7
|
+
import { resolveUi } from "../remote-ui";
|
|
8
|
+
const noopLogger = {
|
|
9
|
+
debug: () => { },
|
|
10
|
+
info: () => { },
|
|
11
|
+
warn: () => { },
|
|
12
|
+
error: () => { },
|
|
13
|
+
trace: () => { },
|
|
14
|
+
child: () => noopLogger,
|
|
15
|
+
isLevelEnabled: () => false,
|
|
16
|
+
};
|
|
17
|
+
let tempRoot;
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
tempRoot = mkdtempSync(path.join(os.tmpdir(), "codenomad-ui-test-"));
|
|
20
|
+
});
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
rmSync(tempRoot, { recursive: true, force: true });
|
|
23
|
+
});
|
|
24
|
+
describe("resolveUi local version preference", () => {
|
|
25
|
+
it("prefers bundled when bundled version is higher", async () => {
|
|
26
|
+
const bundledDir = path.join(tempRoot, "bundled");
|
|
27
|
+
const configDir = path.join(tempRoot, "config");
|
|
28
|
+
const currentDir = path.join(configDir, "ui", "current");
|
|
29
|
+
await mkdir(bundledDir, { recursive: true });
|
|
30
|
+
await mkdir(currentDir, { recursive: true });
|
|
31
|
+
writeFileSync(path.join(bundledDir, "index.html"), "<html>bundled</html>");
|
|
32
|
+
writeFileSync(path.join(bundledDir, "ui-version.json"), JSON.stringify({ uiVersion: "0.8.1" }));
|
|
33
|
+
writeFileSync(path.join(currentDir, "index.html"), "<html>current</html>");
|
|
34
|
+
writeFileSync(path.join(currentDir, "ui-version.json"), JSON.stringify({ uiVersion: "0.8.0" }));
|
|
35
|
+
const result = await resolveUi({
|
|
36
|
+
serverVersion: "0.8.1",
|
|
37
|
+
bundledUiDir: bundledDir,
|
|
38
|
+
autoUpdate: false,
|
|
39
|
+
configDir,
|
|
40
|
+
logger: noopLogger,
|
|
41
|
+
});
|
|
42
|
+
assert.equal(result.source, "bundled");
|
|
43
|
+
assert.equal(result.uiStaticDir, bundledDir);
|
|
44
|
+
assert.equal(result.uiVersion, "0.8.1");
|
|
45
|
+
});
|
|
46
|
+
it("prefers bundled when bundled and downloaded versions are equal", async () => {
|
|
47
|
+
const bundledDir = path.join(tempRoot, "bundled");
|
|
48
|
+
const configDir = path.join(tempRoot, "config");
|
|
49
|
+
const currentDir = path.join(configDir, "ui", "current");
|
|
50
|
+
await mkdir(bundledDir, { recursive: true });
|
|
51
|
+
await mkdir(currentDir, { recursive: true });
|
|
52
|
+
writeFileSync(path.join(bundledDir, "index.html"), "<html>bundled</html>");
|
|
53
|
+
writeFileSync(path.join(bundledDir, "ui-version.json"), JSON.stringify({ uiVersion: "0.8.1" }));
|
|
54
|
+
writeFileSync(path.join(currentDir, "index.html"), "<html>current</html>");
|
|
55
|
+
writeFileSync(path.join(currentDir, "ui-version.json"), JSON.stringify({ uiVersion: "0.8.1" }));
|
|
56
|
+
const result = await resolveUi({
|
|
57
|
+
serverVersion: "0.8.1",
|
|
58
|
+
bundledUiDir: bundledDir,
|
|
59
|
+
autoUpdate: false,
|
|
60
|
+
configDir,
|
|
61
|
+
logger: noopLogger,
|
|
62
|
+
});
|
|
63
|
+
assert.equal(result.source, "bundled");
|
|
64
|
+
assert.equal(result.uiStaticDir, bundledDir);
|
|
65
|
+
assert.equal(result.uiVersion, "0.8.1");
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
import { createHash } from "crypto";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { promises as fsp } from "fs";
|
|
4
|
+
import os from "os";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { Readable } from "stream";
|
|
7
|
+
import { fetch } from "undici";
|
|
8
|
+
import yauzl from "yauzl";
|
|
9
|
+
const DEFAULT_MANIFEST_URL = "https://ui.codenomad.neuralnomads.ai/version.json";
|
|
10
|
+
const MANIFEST_TIMEOUT_MS = 5000;
|
|
11
|
+
const ZIP_TIMEOUT_MS = 30000;
|
|
12
|
+
export async function resolveUi(options) {
|
|
13
|
+
const manifestUrl = options.manifestUrl ?? DEFAULT_MANIFEST_URL;
|
|
14
|
+
if (options.uiDevServerUrl) {
|
|
15
|
+
return {
|
|
16
|
+
uiDevServerUrl: options.uiDevServerUrl,
|
|
17
|
+
source: "dev-proxy",
|
|
18
|
+
supported: true,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (options.overrideUiDir) {
|
|
22
|
+
const resolved = await resolveStaticUiDir(options.overrideUiDir);
|
|
23
|
+
return {
|
|
24
|
+
uiStaticDir: resolved ?? options.overrideUiDir,
|
|
25
|
+
source: "override",
|
|
26
|
+
uiVersion: await readUiVersion(resolved ?? options.overrideUiDir),
|
|
27
|
+
supported: true,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const uiRoot = resolveUiCacheRoot(options.configDir);
|
|
31
|
+
const currentDir = path.join(uiRoot, "current");
|
|
32
|
+
const previousDir = path.join(uiRoot, "previous");
|
|
33
|
+
if (!options.autoUpdate) {
|
|
34
|
+
return await resolveFromCacheOrBundled({
|
|
35
|
+
logger: options.logger,
|
|
36
|
+
bundledUiDir: options.bundledUiDir,
|
|
37
|
+
currentDir,
|
|
38
|
+
previousDir,
|
|
39
|
+
supported: true,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
let manifest = null;
|
|
43
|
+
try {
|
|
44
|
+
manifest = await fetchManifest(manifestUrl, options.logger);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
options.logger.debug({ err: error }, "Remote UI manifest unavailable; using cached/bundled UI");
|
|
48
|
+
}
|
|
49
|
+
if (!manifest) {
|
|
50
|
+
return await resolveFromCacheOrBundled({
|
|
51
|
+
logger: options.logger,
|
|
52
|
+
bundledUiDir: options.bundledUiDir,
|
|
53
|
+
currentDir,
|
|
54
|
+
previousDir,
|
|
55
|
+
supported: true,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const supported = compareSemverCore(options.serverVersion, manifest.minServerVersion) >= 0;
|
|
59
|
+
if (!supported) {
|
|
60
|
+
const message = "Upgrade App to use latest features";
|
|
61
|
+
return await resolveFromCacheOrBundled({
|
|
62
|
+
logger: options.logger,
|
|
63
|
+
bundledUiDir: options.bundledUiDir,
|
|
64
|
+
currentDir,
|
|
65
|
+
previousDir,
|
|
66
|
+
supported: false,
|
|
67
|
+
message,
|
|
68
|
+
latestServerVersion: manifest.latestServerVersion,
|
|
69
|
+
latestServerUrl: manifest.latestServerUrl,
|
|
70
|
+
minServerVersion: manifest.minServerVersion,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const bestLocal = await pickBestLocalUi({
|
|
74
|
+
logger: options.logger,
|
|
75
|
+
bundledUiDir: options.bundledUiDir,
|
|
76
|
+
currentDir,
|
|
77
|
+
previousDir,
|
|
78
|
+
});
|
|
79
|
+
const remoteIsNewer = !bestLocal ||
|
|
80
|
+
compareSemverMaybe(manifest.latestUIVersion, bestLocal.uiVersion) > 0;
|
|
81
|
+
if (!remoteIsNewer) {
|
|
82
|
+
return await resolveFromCacheOrBundled({
|
|
83
|
+
logger: options.logger,
|
|
84
|
+
bundledUiDir: options.bundledUiDir,
|
|
85
|
+
currentDir,
|
|
86
|
+
previousDir,
|
|
87
|
+
supported: true,
|
|
88
|
+
latestServerVersion: manifest.latestServerVersion,
|
|
89
|
+
latestServerUrl: manifest.latestServerUrl,
|
|
90
|
+
minServerVersion: manifest.minServerVersion,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
await installRemoteUi({
|
|
95
|
+
manifest,
|
|
96
|
+
uiRoot,
|
|
97
|
+
currentDir,
|
|
98
|
+
previousDir,
|
|
99
|
+
logger: options.logger,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
options.logger.warn({ err: error }, "Failed to install remote UI; falling back");
|
|
104
|
+
return await resolveFromCacheOrBundled({
|
|
105
|
+
logger: options.logger,
|
|
106
|
+
bundledUiDir: options.bundledUiDir,
|
|
107
|
+
currentDir,
|
|
108
|
+
previousDir,
|
|
109
|
+
supported: true,
|
|
110
|
+
latestServerVersion: manifest.latestServerVersion,
|
|
111
|
+
latestServerUrl: manifest.latestServerUrl,
|
|
112
|
+
minServerVersion: manifest.minServerVersion,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const installed = await resolveStaticUiDir(currentDir);
|
|
116
|
+
if (installed) {
|
|
117
|
+
return {
|
|
118
|
+
uiStaticDir: installed,
|
|
119
|
+
source: "downloaded",
|
|
120
|
+
uiVersion: await readUiVersion(installed),
|
|
121
|
+
supported: true,
|
|
122
|
+
latestServerVersion: manifest.latestServerVersion,
|
|
123
|
+
latestServerUrl: manifest.latestServerUrl,
|
|
124
|
+
minServerVersion: manifest.minServerVersion,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return await resolveFromCacheOrBundled({
|
|
128
|
+
logger: options.logger,
|
|
129
|
+
bundledUiDir: options.bundledUiDir,
|
|
130
|
+
currentDir,
|
|
131
|
+
previousDir,
|
|
132
|
+
supported: true,
|
|
133
|
+
latestServerVersion: manifest.latestServerVersion,
|
|
134
|
+
latestServerUrl: manifest.latestServerUrl,
|
|
135
|
+
minServerVersion: manifest.minServerVersion,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function resolveUiCacheRoot(configDir) {
|
|
139
|
+
if (configDir) {
|
|
140
|
+
return path.join(configDir, "ui");
|
|
141
|
+
}
|
|
142
|
+
return path.join(os.homedir(), ".config", "codenomad", "ui");
|
|
143
|
+
}
|
|
144
|
+
async function resolveFromCacheOrBundled(args) {
|
|
145
|
+
const bestLocal = await pickBestLocalUi({
|
|
146
|
+
logger: args.logger,
|
|
147
|
+
bundledUiDir: args.bundledUiDir,
|
|
148
|
+
currentDir: args.currentDir,
|
|
149
|
+
previousDir: args.previousDir,
|
|
150
|
+
});
|
|
151
|
+
if (bestLocal) {
|
|
152
|
+
return {
|
|
153
|
+
uiStaticDir: bestLocal.uiStaticDir,
|
|
154
|
+
source: bestLocal.source,
|
|
155
|
+
uiVersion: bestLocal.uiVersion,
|
|
156
|
+
supported: args.supported,
|
|
157
|
+
message: args.message,
|
|
158
|
+
latestServerVersion: args.latestServerVersion,
|
|
159
|
+
latestServerUrl: args.latestServerUrl,
|
|
160
|
+
minServerVersion: args.minServerVersion,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
args.logger.warn({ bundledUiDir: args.bundledUiDir }, "No UI assets found");
|
|
164
|
+
return {
|
|
165
|
+
uiStaticDir: args.bundledUiDir,
|
|
166
|
+
source: "missing",
|
|
167
|
+
supported: args.supported,
|
|
168
|
+
message: args.message,
|
|
169
|
+
latestServerVersion: args.latestServerVersion,
|
|
170
|
+
latestServerUrl: args.latestServerUrl,
|
|
171
|
+
minServerVersion: args.minServerVersion,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
async function pickBestLocalUi(args) {
|
|
175
|
+
const candidates = [];
|
|
176
|
+
const currentResolved = await resolveStaticUiDir(args.currentDir);
|
|
177
|
+
if (currentResolved) {
|
|
178
|
+
candidates.push({
|
|
179
|
+
uiStaticDir: currentResolved,
|
|
180
|
+
source: "downloaded",
|
|
181
|
+
uiVersion: await readUiVersion(currentResolved),
|
|
182
|
+
priority: 1,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
const bundledResolved = await resolveStaticUiDir(args.bundledUiDir);
|
|
186
|
+
if (bundledResolved) {
|
|
187
|
+
candidates.push({
|
|
188
|
+
uiStaticDir: bundledResolved,
|
|
189
|
+
source: "bundled",
|
|
190
|
+
uiVersion: await readUiVersion(bundledResolved),
|
|
191
|
+
priority: 2,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
const previousResolved = await resolveStaticUiDir(args.previousDir);
|
|
195
|
+
if (previousResolved) {
|
|
196
|
+
candidates.push({
|
|
197
|
+
uiStaticDir: previousResolved,
|
|
198
|
+
source: "previous",
|
|
199
|
+
uiVersion: await readUiVersion(previousResolved),
|
|
200
|
+
priority: 0,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
if (candidates.length === 0) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
candidates.sort((a, b) => {
|
|
207
|
+
const versionCmp = compareSemverMaybe(a.uiVersion, b.uiVersion);
|
|
208
|
+
if (versionCmp !== 0)
|
|
209
|
+
return -versionCmp;
|
|
210
|
+
return b.priority - a.priority;
|
|
211
|
+
});
|
|
212
|
+
const best = candidates[0];
|
|
213
|
+
if (!best)
|
|
214
|
+
return null;
|
|
215
|
+
return { uiStaticDir: best.uiStaticDir, source: best.source, uiVersion: best.uiVersion };
|
|
216
|
+
}
|
|
217
|
+
function compareSemverMaybe(a, b) {
|
|
218
|
+
if (!a && !b)
|
|
219
|
+
return 0;
|
|
220
|
+
if (!a)
|
|
221
|
+
return -1;
|
|
222
|
+
if (!b)
|
|
223
|
+
return 1;
|
|
224
|
+
return compareSemverCore(a, b);
|
|
225
|
+
}
|
|
226
|
+
async function resolveStaticUiDir(uiDir) {
|
|
227
|
+
try {
|
|
228
|
+
const indexPath = path.join(uiDir, "index.html");
|
|
229
|
+
await fsp.access(indexPath, fs.constants.R_OK);
|
|
230
|
+
return uiDir;
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
async function readUiVersion(uiDir) {
|
|
237
|
+
try {
|
|
238
|
+
const content = await fsp.readFile(path.join(uiDir, "ui-version.json"), "utf-8");
|
|
239
|
+
const parsed = JSON.parse(content);
|
|
240
|
+
return parsed.uiVersion ?? parsed.version;
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
return undefined;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
async function fetchManifest(url, logger) {
|
|
247
|
+
const controller = new AbortController();
|
|
248
|
+
const timeout = setTimeout(() => controller.abort(), MANIFEST_TIMEOUT_MS);
|
|
249
|
+
try {
|
|
250
|
+
const response = await fetch(url, {
|
|
251
|
+
signal: controller.signal,
|
|
252
|
+
headers: {
|
|
253
|
+
Accept: "application/json",
|
|
254
|
+
"User-Agent": "CodeNomad-CLI",
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
if (!response.ok) {
|
|
258
|
+
throw new Error(`Manifest responded with ${response.status}`);
|
|
259
|
+
}
|
|
260
|
+
const json = (await response.json());
|
|
261
|
+
validateManifest(json);
|
|
262
|
+
return json;
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
logger.debug({ err: error, url }, "Failed to fetch remote UI manifest");
|
|
266
|
+
throw error;
|
|
267
|
+
}
|
|
268
|
+
finally {
|
|
269
|
+
clearTimeout(timeout);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function validateManifest(manifest) {
|
|
273
|
+
const required = ["minServerVersion", "latestUIVersion", "uiPackageURL", "sha256"];
|
|
274
|
+
for (const key of required) {
|
|
275
|
+
const value = manifest[key];
|
|
276
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
277
|
+
throw new Error(`Manifest missing ${key}`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (!/^https:\/\//i.test(manifest.uiPackageURL)) {
|
|
281
|
+
throw new Error("uiPackageURL must be https");
|
|
282
|
+
}
|
|
283
|
+
if (!/^[a-f0-9]{64}$/i.test(manifest.sha256.trim())) {
|
|
284
|
+
throw new Error("sha256 must be 64 hex chars");
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
async function installRemoteUi(args) {
|
|
288
|
+
await fsp.mkdir(args.uiRoot, { recursive: true });
|
|
289
|
+
const tmpDir = path.join(args.uiRoot, `tmp-${Date.now()}`);
|
|
290
|
+
const zipPath = path.join(args.uiRoot, `ui-${args.manifest.latestUIVersion}.zip`);
|
|
291
|
+
try {
|
|
292
|
+
await downloadFile(args.manifest.uiPackageURL, zipPath, args.logger);
|
|
293
|
+
const digest = await sha256File(zipPath);
|
|
294
|
+
if (digest.toLowerCase() !== args.manifest.sha256.toLowerCase()) {
|
|
295
|
+
throw new Error(`sha256 mismatch for UI zip (expected ${args.manifest.sha256}, got ${digest})`);
|
|
296
|
+
}
|
|
297
|
+
await extractZip(zipPath, tmpDir);
|
|
298
|
+
const indexPath = path.join(tmpDir, "index.html");
|
|
299
|
+
if (!fs.existsSync(indexPath)) {
|
|
300
|
+
throw new Error("Extracted UI missing index.html");
|
|
301
|
+
}
|
|
302
|
+
await rotateDirs({ currentDir: args.currentDir, previousDir: args.previousDir, logger: args.logger });
|
|
303
|
+
fs.rmSync(args.currentDir, { recursive: true, force: true });
|
|
304
|
+
fs.renameSync(tmpDir, args.currentDir);
|
|
305
|
+
}
|
|
306
|
+
finally {
|
|
307
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
308
|
+
fs.rmSync(zipPath, { force: true });
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
async function rotateDirs(args) {
|
|
312
|
+
try {
|
|
313
|
+
if (fs.existsSync(args.previousDir)) {
|
|
314
|
+
fs.rmSync(args.previousDir, { recursive: true, force: true });
|
|
315
|
+
}
|
|
316
|
+
if (fs.existsSync(args.currentDir)) {
|
|
317
|
+
fs.renameSync(args.currentDir, args.previousDir);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
args.logger.warn({ err: error }, "Failed to rotate UI cache directories");
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
async function downloadFile(url, targetPath, logger) {
|
|
325
|
+
const controller = new AbortController();
|
|
326
|
+
const timeout = setTimeout(() => controller.abort(), ZIP_TIMEOUT_MS);
|
|
327
|
+
try {
|
|
328
|
+
const response = await fetch(url, {
|
|
329
|
+
signal: controller.signal,
|
|
330
|
+
headers: {
|
|
331
|
+
Accept: "application/octet-stream",
|
|
332
|
+
"User-Agent": "CodeNomad-CLI",
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
if (!response.ok || !response.body) {
|
|
336
|
+
throw new Error(`UI zip download failed with ${response.status}`);
|
|
337
|
+
}
|
|
338
|
+
await fsp.mkdir(path.dirname(targetPath), { recursive: true });
|
|
339
|
+
const fileStream = fs.createWriteStream(targetPath);
|
|
340
|
+
const body = response.body;
|
|
341
|
+
if (!body) {
|
|
342
|
+
throw new Error("UI zip response missing body");
|
|
343
|
+
}
|
|
344
|
+
const nodeStream = Readable.fromWeb(body);
|
|
345
|
+
await new Promise((resolve, reject) => {
|
|
346
|
+
nodeStream.pipe(fileStream);
|
|
347
|
+
nodeStream.on("error", reject);
|
|
348
|
+
fileStream.on("error", reject);
|
|
349
|
+
fileStream.on("finish", () => resolve());
|
|
350
|
+
});
|
|
351
|
+
logger.debug({ url, targetPath }, "Downloaded remote UI bundle");
|
|
352
|
+
}
|
|
353
|
+
finally {
|
|
354
|
+
clearTimeout(timeout);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
async function sha256File(filePath) {
|
|
358
|
+
const hash = createHash("sha256");
|
|
359
|
+
const stream = fs.createReadStream(filePath);
|
|
360
|
+
await new Promise((resolve, reject) => {
|
|
361
|
+
stream.on("data", (chunk) => hash.update(chunk));
|
|
362
|
+
stream.on("error", reject);
|
|
363
|
+
stream.on("end", () => resolve());
|
|
364
|
+
});
|
|
365
|
+
return hash.digest("hex");
|
|
366
|
+
}
|
|
367
|
+
async function extractZip(zipPath, targetDir) {
|
|
368
|
+
await fsp.mkdir(targetDir, { recursive: true });
|
|
369
|
+
await new Promise((resolve, reject) => {
|
|
370
|
+
yauzl.open(zipPath, { lazyEntries: true }, (openErr, zipfile) => {
|
|
371
|
+
if (openErr || !zipfile) {
|
|
372
|
+
reject(openErr ?? new Error("Unable to open zip"));
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
const root = path.resolve(targetDir);
|
|
376
|
+
const closeWithError = (error) => {
|
|
377
|
+
try {
|
|
378
|
+
zipfile.close();
|
|
379
|
+
}
|
|
380
|
+
catch {
|
|
381
|
+
// ignore
|
|
382
|
+
}
|
|
383
|
+
reject(error);
|
|
384
|
+
};
|
|
385
|
+
zipfile.readEntry();
|
|
386
|
+
zipfile.on("entry", (entry) => {
|
|
387
|
+
// Normalize and guard against zip-slip.
|
|
388
|
+
const entryPath = entry.fileName.replace(/\\/g, "/");
|
|
389
|
+
const segments = entryPath.split("/").filter(Boolean);
|
|
390
|
+
if (segments.some((segment) => segment === "..") || path.isAbsolute(entryPath)) {
|
|
391
|
+
closeWithError(new Error(`Invalid zip entry path: ${entry.fileName}`));
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
const destination = path.resolve(targetDir, entryPath);
|
|
395
|
+
if (!destination.startsWith(root + path.sep) && destination !== root) {
|
|
396
|
+
closeWithError(new Error(`Zip entry escapes target dir: ${entry.fileName}`));
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
const isDirectory = entry.fileName.endsWith("/");
|
|
400
|
+
if (isDirectory) {
|
|
401
|
+
fsp
|
|
402
|
+
.mkdir(destination, { recursive: true })
|
|
403
|
+
.then(() => zipfile.readEntry())
|
|
404
|
+
.catch((error) => closeWithError(error));
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
fsp
|
|
408
|
+
.mkdir(path.dirname(destination), { recursive: true })
|
|
409
|
+
.then(() => {
|
|
410
|
+
zipfile.openReadStream(entry, (streamErr, readStream) => {
|
|
411
|
+
if (streamErr || !readStream) {
|
|
412
|
+
closeWithError(streamErr ?? new Error("Unable to read zip entry"));
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
const writeStream = fs.createWriteStream(destination);
|
|
416
|
+
const cleanup = (error) => {
|
|
417
|
+
readStream.destroy();
|
|
418
|
+
writeStream.destroy();
|
|
419
|
+
if (error) {
|
|
420
|
+
closeWithError(error);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
readStream.on("error", cleanup);
|
|
424
|
+
writeStream.on("error", cleanup);
|
|
425
|
+
writeStream.on("finish", () => zipfile.readEntry());
|
|
426
|
+
readStream.pipe(writeStream);
|
|
427
|
+
});
|
|
428
|
+
})
|
|
429
|
+
.catch((error) => closeWithError(error));
|
|
430
|
+
});
|
|
431
|
+
zipfile.on("end", () => {
|
|
432
|
+
zipfile.close();
|
|
433
|
+
resolve();
|
|
434
|
+
});
|
|
435
|
+
zipfile.on("error", (error) => closeWithError(error));
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
function compareSemverCore(a, b) {
|
|
440
|
+
const pa = parseSemverCore(a);
|
|
441
|
+
const pb = parseSemverCore(b);
|
|
442
|
+
if (pa.major !== pb.major)
|
|
443
|
+
return pa.major > pb.major ? 1 : -1;
|
|
444
|
+
if (pa.minor !== pb.minor)
|
|
445
|
+
return pa.minor > pb.minor ? 1 : -1;
|
|
446
|
+
if (pa.patch !== pb.patch)
|
|
447
|
+
return pa.patch > pb.patch ? 1 : -1;
|
|
448
|
+
return 0;
|
|
449
|
+
}
|
|
450
|
+
function parseSemverCore(value) {
|
|
451
|
+
const core = value.trim().replace(/^v/i, "").split("-", 1)[0] ?? "0.0.0";
|
|
452
|
+
const parts = core.split(".");
|
|
453
|
+
const parsePart = (input) => {
|
|
454
|
+
const n = Number.parseInt((input ?? "0").replace(/[^0-9]/g, ""), 10);
|
|
455
|
+
return Number.isFinite(n) ? n : 0;
|
|
456
|
+
};
|
|
457
|
+
return {
|
|
458
|
+
major: parsePart(parts[0]),
|
|
459
|
+
minor: parsePart(parts[1]),
|
|
460
|
+
patch: parsePart(parts[2]),
|
|
461
|
+
};
|
|
462
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { describe, it } from "node:test";
|
|
6
|
+
import { listWorktrees } from "../git-worktrees";
|
|
7
|
+
describe("listWorktrees", () => {
|
|
8
|
+
it("uses the selected workspace folder for the root worktree directory", async () => {
|
|
9
|
+
const temp = mkdtempSync(path.join(tmpdir(), "codenomad-git-worktrees-"));
|
|
10
|
+
const binDir = path.join(temp, "bin");
|
|
11
|
+
const repoRoot = path.join(temp, "repo");
|
|
12
|
+
const workspaceFolder = path.join(repoRoot, "proj-1");
|
|
13
|
+
const originalPath = process.env.PATH;
|
|
14
|
+
try {
|
|
15
|
+
mkdirSync(binDir, { recursive: true });
|
|
16
|
+
mkdirSync(workspaceFolder, { recursive: true });
|
|
17
|
+
const gitPath = path.join(binDir, process.platform === "win32" ? "git.cmd" : "git");
|
|
18
|
+
const porcelain = [
|
|
19
|
+
`worktree ${repoRoot}`,
|
|
20
|
+
"HEAD 1111111",
|
|
21
|
+
"branch refs/heads/main",
|
|
22
|
+
"",
|
|
23
|
+
].join("\n");
|
|
24
|
+
if (process.platform === "win32") {
|
|
25
|
+
writeFileSync(gitPath, `@echo off\r\nif "%1"=="worktree" if "%2"=="list" if "%3"=="--porcelain" (\r\necho ${porcelain.replace(/\n/g, "\r\necho ")}\r\nexit /b 0\r\n)\r\nexit /b 1\r\n`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
writeFileSync(gitPath, `#!/bin/sh\nif [ "$1" = "worktree" ] && [ "$2" = "list" ] && [ "$3" = "--porcelain" ]; then\nprintf '%s\n' '${porcelain.replace(/'/g, "'\\''")}'\nexit 0\nfi\nexit 1\n`, { mode: 0o755 });
|
|
29
|
+
}
|
|
30
|
+
process.env.PATH = `${binDir}${path.delimiter}${originalPath ?? ""}`;
|
|
31
|
+
const worktrees = await listWorktrees({ repoRoot, workspaceFolder });
|
|
32
|
+
assert.equal(worktrees[0]?.slug, "root");
|
|
33
|
+
assert.equal(worktrees[0]?.directory, workspaceFolder);
|
|
34
|
+
assert.equal(worktrees[0]?.kind, "root");
|
|
35
|
+
assert.equal(worktrees[0]?.branch, "main");
|
|
36
|
+
assert.notEqual(worktrees[0]?.directory, repoRoot);
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
process.env.PATH = originalPath;
|
|
40
|
+
rmSync(temp, { recursive: true, force: true });
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|