@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,93 @@
|
|
|
1
|
+
const STALE_CONNECTION_TIMEOUT_MS = 45000;
|
|
2
|
+
const STALE_SWEEP_INTERVAL_MS = 5000;
|
|
3
|
+
export class ClientConnectionManager {
|
|
4
|
+
constructor(logger) {
|
|
5
|
+
this.logger = logger;
|
|
6
|
+
this.connections = new Map();
|
|
7
|
+
this.subscribers = new Set();
|
|
8
|
+
this.sweepTimer = setInterval(() => this.sweepStaleConnections(), STALE_SWEEP_INTERVAL_MS);
|
|
9
|
+
this.sweepTimer.unref?.();
|
|
10
|
+
}
|
|
11
|
+
shutdown() {
|
|
12
|
+
clearInterval(this.sweepTimer);
|
|
13
|
+
for (const connection of Array.from(this.connections.values())) {
|
|
14
|
+
this.disconnect(connection.key, "shutdown", false);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
subscribe(listener) {
|
|
18
|
+
this.subscribers.add(listener);
|
|
19
|
+
return () => this.subscribers.delete(listener);
|
|
20
|
+
}
|
|
21
|
+
register(input) {
|
|
22
|
+
const key = getConnectionKey(input);
|
|
23
|
+
const now = Date.now();
|
|
24
|
+
const existing = this.connections.get(key);
|
|
25
|
+
if (existing) {
|
|
26
|
+
this.logger.debug({ clientId: input.clientId, connectionId: input.connectionId }, "Replacing existing client connection");
|
|
27
|
+
this.disconnect(key, "replaced");
|
|
28
|
+
}
|
|
29
|
+
const connection = {
|
|
30
|
+
key,
|
|
31
|
+
clientId: input.clientId,
|
|
32
|
+
connectionId: input.connectionId,
|
|
33
|
+
connectedAt: now,
|
|
34
|
+
lastSeenAt: now,
|
|
35
|
+
close: input.close,
|
|
36
|
+
};
|
|
37
|
+
this.connections.set(key, connection);
|
|
38
|
+
this.logger.debug({ clientId: input.clientId, connectionId: input.connectionId }, "Client connected");
|
|
39
|
+
this.notify({ type: "connected", connection });
|
|
40
|
+
return () => this.disconnect(key, "closed");
|
|
41
|
+
}
|
|
42
|
+
pong(input) {
|
|
43
|
+
const key = getConnectionKey(input);
|
|
44
|
+
const connection = this.connections.get(key);
|
|
45
|
+
if (!connection) {
|
|
46
|
+
this.logger.debug({ clientId: input.clientId, connectionId: input.connectionId }, "Ignoring pong for unknown client connection");
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
connection.lastSeenAt = Date.now();
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
isConnected(input) {
|
|
53
|
+
return this.connections.has(getConnectionKey(input));
|
|
54
|
+
}
|
|
55
|
+
sweepStaleConnections() {
|
|
56
|
+
const cutoff = Date.now() - STALE_CONNECTION_TIMEOUT_MS;
|
|
57
|
+
for (const connection of Array.from(this.connections.values())) {
|
|
58
|
+
if (connection.lastSeenAt > cutoff)
|
|
59
|
+
continue;
|
|
60
|
+
this.logger.debug({ clientId: connection.clientId, connectionId: connection.connectionId }, "Client connection timed out");
|
|
61
|
+
this.disconnect(connection.key, "timeout");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
disconnect(key, reason, invokeClose = true) {
|
|
65
|
+
const connection = this.connections.get(key);
|
|
66
|
+
if (!connection)
|
|
67
|
+
return;
|
|
68
|
+
this.connections.delete(key);
|
|
69
|
+
this.logger.debug({ clientId: connection.clientId, connectionId: connection.connectionId, reason }, "Client disconnected");
|
|
70
|
+
if (invokeClose) {
|
|
71
|
+
try {
|
|
72
|
+
connection.close();
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
this.logger.warn({ err: error, clientId: connection.clientId, connectionId: connection.connectionId }, "Failed to close stale client connection");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
this.notify({ type: "disconnected", connection, reason });
|
|
79
|
+
}
|
|
80
|
+
notify(event) {
|
|
81
|
+
for (const subscriber of this.subscribers) {
|
|
82
|
+
try {
|
|
83
|
+
subscriber(event);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
this.logger.warn({ err: error, eventType: event.type }, "Client connection subscriber failed");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function getConnectionKey(input) {
|
|
92
|
+
return `${input.clientId}:${input.connectionId}`;
|
|
93
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import os from "os";
|
|
2
|
+
import path from "path";
|
|
3
|
+
function resolvePath(inputPath) {
|
|
4
|
+
if (inputPath.startsWith("~/")) {
|
|
5
|
+
return path.join(os.homedir(), inputPath.slice(2));
|
|
6
|
+
}
|
|
7
|
+
return path.resolve(inputPath);
|
|
8
|
+
}
|
|
9
|
+
function isYamlPath(filePath) {
|
|
10
|
+
const lower = filePath.toLowerCase();
|
|
11
|
+
return lower.endsWith(".yaml") || lower.endsWith(".yml");
|
|
12
|
+
}
|
|
13
|
+
function isJsonPath(filePath) {
|
|
14
|
+
return filePath.toLowerCase().endsWith(".json");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve CodeNomad's config location into a stable base directory + derived file paths.
|
|
18
|
+
*
|
|
19
|
+
* Supported inputs:
|
|
20
|
+
* - Directory: "~/.config/codenomad"
|
|
21
|
+
* - YAML file: "~/.config/codenomad/config.yaml" (or any *.yml/*.yaml)
|
|
22
|
+
* - Legacy JSON file: "~/.config/codenomad/config.json"
|
|
23
|
+
*/
|
|
24
|
+
export function resolveConfigLocation(raw) {
|
|
25
|
+
const trimmed = (raw ?? "").trim();
|
|
26
|
+
const fallback = "~/.config/codenomad/config.json";
|
|
27
|
+
const input = trimmed.length > 0 ? trimmed : fallback;
|
|
28
|
+
const resolvedInput = resolvePath(input);
|
|
29
|
+
if (isYamlPath(resolvedInput)) {
|
|
30
|
+
const baseDir = path.dirname(resolvedInput);
|
|
31
|
+
return {
|
|
32
|
+
baseDir,
|
|
33
|
+
configYamlPath: resolvedInput,
|
|
34
|
+
stateYamlPath: path.join(baseDir, "state.yaml"),
|
|
35
|
+
legacyJsonPath: path.join(baseDir, "config.json"),
|
|
36
|
+
instancesDir: path.join(baseDir, "instances"),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (isJsonPath(resolvedInput)) {
|
|
40
|
+
const baseDir = path.dirname(resolvedInput);
|
|
41
|
+
return {
|
|
42
|
+
baseDir,
|
|
43
|
+
configYamlPath: path.join(baseDir, "config.yaml"),
|
|
44
|
+
stateYamlPath: path.join(baseDir, "state.yaml"),
|
|
45
|
+
legacyJsonPath: resolvedInput,
|
|
46
|
+
instancesDir: path.join(baseDir, "instances"),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const baseDir = resolvedInput;
|
|
50
|
+
return {
|
|
51
|
+
baseDir,
|
|
52
|
+
configYamlPath: path.join(baseDir, "config.yaml"),
|
|
53
|
+
stateYamlPath: path.join(baseDir, "state.yaml"),
|
|
54
|
+
legacyJsonPath: path.join(baseDir, "config.json"),
|
|
55
|
+
instancesDir: path.join(baseDir, "instances"),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const ModelPreferenceSchema = z.object({
|
|
3
|
+
providerId: z.string(),
|
|
4
|
+
modelId: z.string(),
|
|
5
|
+
});
|
|
6
|
+
const AgentModelSelectionSchema = z.record(z.string(), ModelPreferenceSchema);
|
|
7
|
+
const AgentModelSelectionsSchema = z.record(z.string(), AgentModelSelectionSchema);
|
|
8
|
+
const PreferencesSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
showThinkingBlocks: z.boolean().default(false),
|
|
11
|
+
thinkingBlocksExpansion: z.enum(["expanded", "collapsed"]).default("expanded"),
|
|
12
|
+
showTimelineTools: z.boolean().default(true),
|
|
13
|
+
promptSubmitOnEnter: z.boolean().default(false),
|
|
14
|
+
lastUsedBinary: z.string().optional(),
|
|
15
|
+
locale: z.string().optional(),
|
|
16
|
+
environmentVariables: z.record(z.string()).default({}),
|
|
17
|
+
modelRecents: z.array(ModelPreferenceSchema).default([]),
|
|
18
|
+
modelFavorites: z.array(ModelPreferenceSchema).default([]),
|
|
19
|
+
modelThinkingSelections: z.record(z.string(), z.string()).default({}),
|
|
20
|
+
diffViewMode: z.enum(["split", "unified"]).default("split"),
|
|
21
|
+
toolOutputExpansion: z.enum(["expanded", "collapsed"]).default("expanded"),
|
|
22
|
+
diagnosticsExpansion: z.enum(["expanded", "collapsed"]).default("expanded"),
|
|
23
|
+
showUsageMetrics: z.boolean().default(true),
|
|
24
|
+
autoCleanupBlankSessions: z.boolean().default(true),
|
|
25
|
+
listeningMode: z.enum(["local", "all"]).default("local"),
|
|
26
|
+
logLevel: z.enum(["DEBUG", "INFO", "WARN", "ERROR"]).default("DEBUG"),
|
|
27
|
+
// OS notifications
|
|
28
|
+
osNotificationsEnabled: z.boolean().default(false),
|
|
29
|
+
osNotificationsAllowWhenVisible: z.boolean().default(false),
|
|
30
|
+
notifyOnNeedsInput: z.boolean().default(true),
|
|
31
|
+
notifyOnIdle: z.boolean().default(true),
|
|
32
|
+
})
|
|
33
|
+
// Preserve unknown preference keys so newer configs survive older binaries.
|
|
34
|
+
.passthrough();
|
|
35
|
+
const RecentFolderSchema = z.object({
|
|
36
|
+
path: z.string(),
|
|
37
|
+
lastAccessed: z.number().nonnegative(),
|
|
38
|
+
});
|
|
39
|
+
const OpenCodeBinarySchema = z.object({
|
|
40
|
+
path: z.string(),
|
|
41
|
+
version: z.string().optional(),
|
|
42
|
+
lastUsed: z.number().nonnegative(),
|
|
43
|
+
label: z.string().optional(),
|
|
44
|
+
});
|
|
45
|
+
const ConfigFileSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
preferences: PreferencesSchema.default({}),
|
|
48
|
+
recentFolders: z.array(RecentFolderSchema).default([]),
|
|
49
|
+
opencodeBinaries: z.array(OpenCodeBinarySchema).default([]),
|
|
50
|
+
theme: z.enum(["light", "dark", "system"]).optional(),
|
|
51
|
+
})
|
|
52
|
+
// Preserve unknown top-level keys so optional future features survive downgrades.
|
|
53
|
+
.passthrough();
|
|
54
|
+
// On-disk config.yaml only stores stable configuration (not volatile state like recent folders).
|
|
55
|
+
const ConfigYamlSchema = z
|
|
56
|
+
.object({
|
|
57
|
+
preferences: PreferencesSchema.default({}),
|
|
58
|
+
opencodeBinaries: z.array(OpenCodeBinarySchema).default([]),
|
|
59
|
+
theme: z.enum(["light", "dark", "system"]).optional(),
|
|
60
|
+
})
|
|
61
|
+
.passthrough();
|
|
62
|
+
// On-disk state.yaml stores server-scoped mutable state (per-server, not per-client).
|
|
63
|
+
const StateFileSchema = z
|
|
64
|
+
.object({
|
|
65
|
+
recentFolders: z.array(RecentFolderSchema).default([]),
|
|
66
|
+
})
|
|
67
|
+
.passthrough();
|
|
68
|
+
const DEFAULT_CONFIG = ConfigFileSchema.parse({});
|
|
69
|
+
const DEFAULT_CONFIG_YAML = ConfigYamlSchema.parse({});
|
|
70
|
+
const DEFAULT_STATE = StateFileSchema.parse({});
|
|
71
|
+
export { ModelPreferenceSchema, AgentModelSelectionSchema, AgentModelSelectionsSchema, PreferencesSchema, RecentFolderSchema, OpenCodeBinarySchema, ConfigFileSchema, ConfigYamlSchema, StateFileSchema, DEFAULT_CONFIG, DEFAULT_CONFIG_YAML, DEFAULT_STATE, };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
export class EventBus extends EventEmitter {
|
|
3
|
+
constructor(logger) {
|
|
4
|
+
super();
|
|
5
|
+
this.logger = logger;
|
|
6
|
+
}
|
|
7
|
+
publish(event) {
|
|
8
|
+
if (event.type !== "instance.event" && event.type !== "instance.eventStatus") {
|
|
9
|
+
this.logger?.debug({ type: event.type }, "Publishing workspace event");
|
|
10
|
+
if (this.logger?.isLevelEnabled("trace")) {
|
|
11
|
+
this.logger.trace({ event }, "Workspace event payload");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return super.emit(event.type, event);
|
|
15
|
+
}
|
|
16
|
+
onEvent(listener) {
|
|
17
|
+
const handler = (event) => listener(event);
|
|
18
|
+
this.on("workspace.created", handler);
|
|
19
|
+
this.on("workspace.started", handler);
|
|
20
|
+
this.on("workspace.error", handler);
|
|
21
|
+
this.on("workspace.stopped", handler);
|
|
22
|
+
this.on("workspace.log", handler);
|
|
23
|
+
this.on("sidecar.updated", handler);
|
|
24
|
+
this.on("sidecar.removed", handler);
|
|
25
|
+
this.on("storage.configChanged", handler);
|
|
26
|
+
this.on("storage.stateChanged", handler);
|
|
27
|
+
this.on("instance.dataChanged", handler);
|
|
28
|
+
this.on("instance.event", handler);
|
|
29
|
+
this.on("instance.eventStatus", handler);
|
|
30
|
+
return () => {
|
|
31
|
+
this.off("workspace.created", handler);
|
|
32
|
+
this.off("workspace.started", handler);
|
|
33
|
+
this.off("workspace.error", handler);
|
|
34
|
+
this.off("workspace.stopped", handler);
|
|
35
|
+
this.off("workspace.log", handler);
|
|
36
|
+
this.off("sidecar.updated", handler);
|
|
37
|
+
this.off("sidecar.removed", handler);
|
|
38
|
+
this.off("storage.configChanged", handler);
|
|
39
|
+
this.off("storage.stateChanged", handler);
|
|
40
|
+
this.off("instance.dataChanged", handler);
|
|
41
|
+
this.off("instance.event", handler);
|
|
42
|
+
this.off("instance.eventStatus", handler);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { afterEach, describe, it } from "node:test";
|
|
6
|
+
import { FileSystemBrowser } from "../browser";
|
|
7
|
+
import { WINDOWS_DRIVES_ROOT } from "../../api-types";
|
|
8
|
+
const tempRoots = [];
|
|
9
|
+
describe("FileSystemBrowser", () => {
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
for (const directory of tempRoots.splice(0)) {
|
|
12
|
+
fs.rmSync(directory, { recursive: true, force: true });
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
it("starts unrestricted browsing from the configured root", () => {
|
|
16
|
+
const rootDir = createTempRoot();
|
|
17
|
+
fs.mkdirSync(path.join(rootDir, "project"));
|
|
18
|
+
const browser = new FileSystemBrowser({ rootDir, unrestricted: true });
|
|
19
|
+
const listing = browser.browse();
|
|
20
|
+
assert.equal(listing.metadata.scope, "unrestricted");
|
|
21
|
+
assert.equal(listing.metadata.currentPath, rootDir);
|
|
22
|
+
assert.equal(listing.metadata.rootPath, rootDir);
|
|
23
|
+
assert.equal(listing.metadata.displayPath, rootDir);
|
|
24
|
+
assert.equal(listing.metadata.pathKind, "absolute");
|
|
25
|
+
assert.ok(listing.entries.some((entry) => entry.name === "project" && entry.absolutePath === path.join(rootDir, "project")));
|
|
26
|
+
});
|
|
27
|
+
it("treats dot as the configured unrestricted root", () => {
|
|
28
|
+
const rootDir = createTempRoot();
|
|
29
|
+
const browser = new FileSystemBrowser({ rootDir, unrestricted: true });
|
|
30
|
+
const listing = browser.browse(".");
|
|
31
|
+
assert.equal(listing.metadata.currentPath, rootDir);
|
|
32
|
+
assert.equal(listing.metadata.rootPath, rootDir);
|
|
33
|
+
});
|
|
34
|
+
it("allows unrestricted browsing outside the configured root", () => {
|
|
35
|
+
const rootDir = createTempRoot();
|
|
36
|
+
const parentDir = path.dirname(rootDir);
|
|
37
|
+
const browser = new FileSystemBrowser({ rootDir, unrestricted: true });
|
|
38
|
+
const listing = browser.browse(parentDir);
|
|
39
|
+
assert.equal(listing.metadata.currentPath, parentDir);
|
|
40
|
+
assert.equal(listing.metadata.rootPath, rootDir);
|
|
41
|
+
assert.ok(listing.entries.some((entry) => entry.absolutePath === rootDir));
|
|
42
|
+
});
|
|
43
|
+
it("creates folders under the configured unrestricted root by default", () => {
|
|
44
|
+
const rootDir = createTempRoot();
|
|
45
|
+
const browser = new FileSystemBrowser({ rootDir, unrestricted: true });
|
|
46
|
+
const created = browser.createFolder(undefined, "created-folder");
|
|
47
|
+
assert.equal(created.path, path.join(rootDir, "created-folder"));
|
|
48
|
+
assert.equal(created.absolutePath, path.join(rootDir, "created-folder"));
|
|
49
|
+
assert.equal(fs.statSync(created.absolutePath).isDirectory(), true);
|
|
50
|
+
});
|
|
51
|
+
it("reports the configured root for the Windows drives pseudo-root", () => {
|
|
52
|
+
const rootDir = createTempRoot();
|
|
53
|
+
const browser = new FileSystemBrowser({ rootDir, unrestricted: true, platform: "win32" });
|
|
54
|
+
const listing = browser.browse(WINDOWS_DRIVES_ROOT);
|
|
55
|
+
assert.equal(listing.metadata.scope, "unrestricted");
|
|
56
|
+
assert.equal(listing.metadata.currentPath, WINDOWS_DRIVES_ROOT);
|
|
57
|
+
assert.equal(listing.metadata.rootPath, rootDir);
|
|
58
|
+
assert.equal(listing.metadata.pathKind, "drives");
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
function createTempRoot() {
|
|
62
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "codenomad-browser-"));
|
|
63
|
+
tempRoots.push(root);
|
|
64
|
+
return fs.realpathSync(root);
|
|
65
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { beforeEach, describe, it } from "node:test";
|
|
3
|
+
import { clearWorkspaceSearchCache, getWorkspaceCandidates, refreshWorkspaceCandidates, WORKSPACE_CANDIDATE_CACHE_TTL_MS, } from "../search-cache";
|
|
4
|
+
describe("workspace search cache", () => {
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
clearWorkspaceSearchCache();
|
|
7
|
+
});
|
|
8
|
+
it("expires cached candidates after the TTL", () => {
|
|
9
|
+
const workspacePath = "/tmp/workspace";
|
|
10
|
+
const startTime = 1000;
|
|
11
|
+
refreshWorkspaceCandidates(workspacePath, () => [createEntry("file-a")], startTime);
|
|
12
|
+
const beforeExpiry = getWorkspaceCandidates(workspacePath, startTime + WORKSPACE_CANDIDATE_CACHE_TTL_MS - 1);
|
|
13
|
+
assert.ok(beforeExpiry);
|
|
14
|
+
assert.equal(beforeExpiry.length, 1);
|
|
15
|
+
assert.equal(beforeExpiry[0].name, "file-a");
|
|
16
|
+
const afterExpiry = getWorkspaceCandidates(workspacePath, startTime + WORKSPACE_CANDIDATE_CACHE_TTL_MS + 1);
|
|
17
|
+
assert.equal(afterExpiry, undefined);
|
|
18
|
+
});
|
|
19
|
+
it("replaces cached entries when manually refreshed", () => {
|
|
20
|
+
const workspacePath = "/tmp/workspace";
|
|
21
|
+
refreshWorkspaceCandidates(workspacePath, () => [createEntry("file-a")], 5000);
|
|
22
|
+
const initial = getWorkspaceCandidates(workspacePath, 5001);
|
|
23
|
+
assert.ok(initial);
|
|
24
|
+
assert.equal(initial[0].name, "file-a");
|
|
25
|
+
refreshWorkspaceCandidates(workspacePath, () => [createEntry("file-b")], 6000);
|
|
26
|
+
const refreshed = getWorkspaceCandidates(workspacePath, 6001);
|
|
27
|
+
assert.ok(refreshed);
|
|
28
|
+
assert.equal(refreshed[0].name, "file-b");
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
function createEntry(name) {
|
|
32
|
+
return {
|
|
33
|
+
name,
|
|
34
|
+
path: name,
|
|
35
|
+
absolutePath: `/tmp/${name}`,
|
|
36
|
+
type: "file",
|
|
37
|
+
size: 1,
|
|
38
|
+
modifiedAt: new Date().toISOString(),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import os from "os";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { WINDOWS_DRIVES_ROOT, } from "../api-types";
|
|
5
|
+
const WINDOWS_DRIVE_LETTERS = Array.from({ length: 26 }, (_, i) => String.fromCharCode(65 + i));
|
|
6
|
+
export class FileSystemBrowser {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.root = path.resolve(options.rootDir);
|
|
9
|
+
this.unrestricted = Boolean(options.unrestricted);
|
|
10
|
+
this.homeDir = os.homedir();
|
|
11
|
+
this.isWindows = (options.platform ?? process.platform) === "win32";
|
|
12
|
+
}
|
|
13
|
+
list(relativePath = ".", options = {}) {
|
|
14
|
+
if (this.unrestricted) {
|
|
15
|
+
throw new Error("Relative listing is unavailable when running with unrestricted root");
|
|
16
|
+
}
|
|
17
|
+
const includeFiles = options.includeFiles ?? true;
|
|
18
|
+
const normalizedPath = this.normalizeRelativePath(relativePath);
|
|
19
|
+
const absolutePath = this.toRestrictedAbsolute(normalizedPath);
|
|
20
|
+
return this.readDirectoryEntries(absolutePath, {
|
|
21
|
+
includeFiles,
|
|
22
|
+
formatPath: (entryName) => this.buildRelativePath(normalizedPath, entryName),
|
|
23
|
+
formatAbsolutePath: (entryName) => this.resolveRestrictedAbsoluteChild(normalizedPath, entryName),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
browse(targetPath, options = {}) {
|
|
27
|
+
const includeFiles = options.includeFiles ?? true;
|
|
28
|
+
if (this.unrestricted) {
|
|
29
|
+
return this.listUnrestricted(targetPath, includeFiles);
|
|
30
|
+
}
|
|
31
|
+
return this.listRestrictedWithMetadata(targetPath, includeFiles);
|
|
32
|
+
}
|
|
33
|
+
createFolder(parentPath, folderName) {
|
|
34
|
+
const name = this.normalizeFolderName(folderName);
|
|
35
|
+
if (this.unrestricted) {
|
|
36
|
+
const resolvedParent = this.resolveUnrestrictedPath(parentPath);
|
|
37
|
+
if (this.isWindows && resolvedParent === WINDOWS_DRIVES_ROOT) {
|
|
38
|
+
throw new Error("Cannot create folders at drive root");
|
|
39
|
+
}
|
|
40
|
+
this.assertDirectoryExists(resolvedParent);
|
|
41
|
+
const absolutePath = this.resolveAbsoluteChild(resolvedParent, name);
|
|
42
|
+
fs.mkdirSync(absolutePath);
|
|
43
|
+
return { path: absolutePath, absolutePath };
|
|
44
|
+
}
|
|
45
|
+
const normalizedParent = this.normalizeRelativePath(parentPath);
|
|
46
|
+
const parentAbsolute = this.toRestrictedAbsolute(normalizedParent);
|
|
47
|
+
this.assertDirectoryExists(parentAbsolute);
|
|
48
|
+
const relativePath = this.buildRelativePath(normalizedParent, name);
|
|
49
|
+
const absolutePath = this.toRestrictedAbsolute(relativePath);
|
|
50
|
+
fs.mkdirSync(absolutePath);
|
|
51
|
+
return { path: relativePath, absolutePath };
|
|
52
|
+
}
|
|
53
|
+
writeFile(relativePath, contents) {
|
|
54
|
+
if (this.unrestricted) {
|
|
55
|
+
throw new Error("writeFile is not available in unrestricted mode");
|
|
56
|
+
}
|
|
57
|
+
const resolved = this.toRestrictedAbsolute(relativePath);
|
|
58
|
+
fs.writeFileSync(resolved, contents, "utf-8");
|
|
59
|
+
}
|
|
60
|
+
readFile(relativePath) {
|
|
61
|
+
if (this.unrestricted) {
|
|
62
|
+
throw new Error("readFile is not available in unrestricted mode");
|
|
63
|
+
}
|
|
64
|
+
const resolved = this.toRestrictedAbsolute(relativePath);
|
|
65
|
+
return fs.readFileSync(resolved, "utf-8");
|
|
66
|
+
}
|
|
67
|
+
listRestrictedWithMetadata(relativePath, includeFiles) {
|
|
68
|
+
const normalizedPath = this.normalizeRelativePath(relativePath);
|
|
69
|
+
const absolutePath = this.toRestrictedAbsolute(normalizedPath);
|
|
70
|
+
const entries = this.readDirectoryEntries(absolutePath, {
|
|
71
|
+
includeFiles,
|
|
72
|
+
formatPath: (entryName) => this.buildRelativePath(normalizedPath, entryName),
|
|
73
|
+
formatAbsolutePath: (entryName) => this.resolveRestrictedAbsoluteChild(normalizedPath, entryName),
|
|
74
|
+
});
|
|
75
|
+
const metadata = {
|
|
76
|
+
scope: "restricted",
|
|
77
|
+
currentPath: normalizedPath,
|
|
78
|
+
parentPath: normalizedPath === "." ? undefined : this.getRestrictedParent(normalizedPath),
|
|
79
|
+
rootPath: this.root,
|
|
80
|
+
homePath: this.homeDir,
|
|
81
|
+
displayPath: this.resolveRestrictedAbsolute(normalizedPath),
|
|
82
|
+
pathKind: "relative",
|
|
83
|
+
};
|
|
84
|
+
return { entries, metadata };
|
|
85
|
+
}
|
|
86
|
+
listUnrestricted(targetPath, includeFiles) {
|
|
87
|
+
const resolvedPath = this.resolveUnrestrictedPath(targetPath);
|
|
88
|
+
if (this.isWindows && resolvedPath === WINDOWS_DRIVES_ROOT) {
|
|
89
|
+
return this.listWindowsDrives();
|
|
90
|
+
}
|
|
91
|
+
const entries = this.readDirectoryEntries(resolvedPath, {
|
|
92
|
+
includeFiles,
|
|
93
|
+
formatPath: (entryName) => this.resolveAbsoluteChild(resolvedPath, entryName),
|
|
94
|
+
formatAbsolutePath: (entryName) => this.resolveAbsoluteChild(resolvedPath, entryName),
|
|
95
|
+
});
|
|
96
|
+
const parentPath = this.getUnrestrictedParent(resolvedPath);
|
|
97
|
+
const metadata = {
|
|
98
|
+
scope: "unrestricted",
|
|
99
|
+
currentPath: resolvedPath,
|
|
100
|
+
parentPath,
|
|
101
|
+
rootPath: this.root,
|
|
102
|
+
homePath: this.homeDir,
|
|
103
|
+
displayPath: resolvedPath,
|
|
104
|
+
pathKind: "absolute",
|
|
105
|
+
};
|
|
106
|
+
return { entries, metadata };
|
|
107
|
+
}
|
|
108
|
+
listWindowsDrives() {
|
|
109
|
+
if (!this.isWindows) {
|
|
110
|
+
throw new Error("Drive listing is only supported on Windows hosts");
|
|
111
|
+
}
|
|
112
|
+
const entries = [];
|
|
113
|
+
for (const letter of WINDOWS_DRIVE_LETTERS) {
|
|
114
|
+
const drivePath = `${letter}:\\`;
|
|
115
|
+
try {
|
|
116
|
+
if (fs.existsSync(drivePath)) {
|
|
117
|
+
entries.push({
|
|
118
|
+
name: `${letter}:`,
|
|
119
|
+
path: drivePath,
|
|
120
|
+
absolutePath: drivePath,
|
|
121
|
+
type: "directory",
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
// Ignore inaccessible drives
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Provide a generic UNC root entry so users can navigate to network shares manually.
|
|
130
|
+
entries.push({
|
|
131
|
+
name: "UNC Network",
|
|
132
|
+
path: "\\\\",
|
|
133
|
+
absolutePath: "\\\\",
|
|
134
|
+
type: "directory",
|
|
135
|
+
});
|
|
136
|
+
const metadata = {
|
|
137
|
+
scope: "unrestricted",
|
|
138
|
+
currentPath: WINDOWS_DRIVES_ROOT,
|
|
139
|
+
parentPath: undefined,
|
|
140
|
+
rootPath: this.root,
|
|
141
|
+
homePath: this.homeDir,
|
|
142
|
+
displayPath: "Drives",
|
|
143
|
+
pathKind: "drives",
|
|
144
|
+
};
|
|
145
|
+
return { entries, metadata };
|
|
146
|
+
}
|
|
147
|
+
normalizeFolderName(input) {
|
|
148
|
+
const name = input.trim();
|
|
149
|
+
if (!name) {
|
|
150
|
+
throw new Error("Folder name is required");
|
|
151
|
+
}
|
|
152
|
+
if (name === "." || name === "..") {
|
|
153
|
+
throw new Error("Invalid folder name");
|
|
154
|
+
}
|
|
155
|
+
if (name.startsWith("~")) {
|
|
156
|
+
throw new Error("Invalid folder name");
|
|
157
|
+
}
|
|
158
|
+
if (name.includes("/") || name.includes("\\")) {
|
|
159
|
+
throw new Error("Folder name must not include path separators");
|
|
160
|
+
}
|
|
161
|
+
if (name.includes("\u0000")) {
|
|
162
|
+
throw new Error("Invalid folder name");
|
|
163
|
+
}
|
|
164
|
+
return name;
|
|
165
|
+
}
|
|
166
|
+
assertDirectoryExists(directory) {
|
|
167
|
+
if (!fs.existsSync(directory)) {
|
|
168
|
+
throw new Error(`Directory does not exist: ${directory}`);
|
|
169
|
+
}
|
|
170
|
+
const stats = fs.statSync(directory);
|
|
171
|
+
if (!stats.isDirectory()) {
|
|
172
|
+
throw new Error(`Path is not a directory: ${directory}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
readDirectoryEntries(directory, options) {
|
|
176
|
+
const dirents = fs.readdirSync(directory, { withFileTypes: true });
|
|
177
|
+
const results = [];
|
|
178
|
+
for (const entry of dirents) {
|
|
179
|
+
const absoluteEntryPath = path.join(directory, entry.name);
|
|
180
|
+
let stats;
|
|
181
|
+
try {
|
|
182
|
+
// Use fs.statSync (not Dirent.isDirectory) so symlinks to directories
|
|
183
|
+
// are treated as directories in directory-only listings.
|
|
184
|
+
stats = fs.statSync(absoluteEntryPath);
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
// Skip entries we cannot stat (insufficient permissions, etc.)
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const isDirectory = stats.isDirectory();
|
|
191
|
+
if (!options.includeFiles && !isDirectory) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
results.push({
|
|
195
|
+
name: entry.name,
|
|
196
|
+
path: options.formatPath(entry.name),
|
|
197
|
+
absolutePath: options.formatAbsolutePath(entry.name),
|
|
198
|
+
type: isDirectory ? "directory" : "file",
|
|
199
|
+
size: isDirectory ? undefined : stats.size,
|
|
200
|
+
modifiedAt: stats.mtime.toISOString(),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return results.sort((a, b) => a.name.localeCompare(b.name));
|
|
204
|
+
}
|
|
205
|
+
normalizeRelativePath(input) {
|
|
206
|
+
if (!input || input === "." || input === "./" || input === "/") {
|
|
207
|
+
return ".";
|
|
208
|
+
}
|
|
209
|
+
if (path.isAbsolute(input)) {
|
|
210
|
+
const resolved = path.resolve(input);
|
|
211
|
+
const relativeToRoot = path.relative(this.root, resolved);
|
|
212
|
+
if (relativeToRoot === "") {
|
|
213
|
+
return ".";
|
|
214
|
+
}
|
|
215
|
+
if (this.isOutsideRoot(relativeToRoot)) {
|
|
216
|
+
throw new Error("Access outside of root is not allowed");
|
|
217
|
+
}
|
|
218
|
+
return relativeToRoot.replace(/\\+/g, "/");
|
|
219
|
+
}
|
|
220
|
+
let normalized = input.replace(/\\+/g, "/");
|
|
221
|
+
if (normalized.startsWith("./")) {
|
|
222
|
+
normalized = normalized.replace(/^\.\/+/, "");
|
|
223
|
+
}
|
|
224
|
+
if (normalized.startsWith("/")) {
|
|
225
|
+
normalized = normalized.replace(/^\/+/g, "");
|
|
226
|
+
}
|
|
227
|
+
return normalized === "" ? "." : normalized;
|
|
228
|
+
}
|
|
229
|
+
buildRelativePath(parent, child) {
|
|
230
|
+
if (!parent || parent === ".") {
|
|
231
|
+
return this.normalizeRelativePath(child);
|
|
232
|
+
}
|
|
233
|
+
return this.normalizeRelativePath(`${parent}/${child}`);
|
|
234
|
+
}
|
|
235
|
+
resolveRestrictedAbsolute(relativePath) {
|
|
236
|
+
return this.toRestrictedAbsolute(relativePath);
|
|
237
|
+
}
|
|
238
|
+
resolveRestrictedAbsoluteChild(parent, child) {
|
|
239
|
+
const normalized = this.buildRelativePath(parent, child);
|
|
240
|
+
return this.toRestrictedAbsolute(normalized);
|
|
241
|
+
}
|
|
242
|
+
toRestrictedAbsolute(relativePath) {
|
|
243
|
+
const normalized = this.normalizeRelativePath(relativePath);
|
|
244
|
+
const target = path.resolve(this.root, normalized);
|
|
245
|
+
const relativeToRoot = path.relative(this.root, target);
|
|
246
|
+
if (this.isOutsideRoot(relativeToRoot)) {
|
|
247
|
+
throw new Error("Access outside of root is not allowed");
|
|
248
|
+
}
|
|
249
|
+
return target;
|
|
250
|
+
}
|
|
251
|
+
isOutsideRoot(relativeToRoot) {
|
|
252
|
+
return relativeToRoot === ".." || relativeToRoot.startsWith(`..${path.sep}`) || path.isAbsolute(relativeToRoot);
|
|
253
|
+
}
|
|
254
|
+
resolveUnrestrictedPath(input) {
|
|
255
|
+
if (!input || input === "." || input === "./") {
|
|
256
|
+
return this.root;
|
|
257
|
+
}
|
|
258
|
+
if (this.isWindows) {
|
|
259
|
+
if (input === WINDOWS_DRIVES_ROOT) {
|
|
260
|
+
return WINDOWS_DRIVES_ROOT;
|
|
261
|
+
}
|
|
262
|
+
const normalized = path.win32.normalize(input);
|
|
263
|
+
if (/^[a-zA-Z]:/.test(normalized) || normalized.startsWith("\\\\")) {
|
|
264
|
+
return normalized;
|
|
265
|
+
}
|
|
266
|
+
return path.win32.resolve(this.homeDir, normalized);
|
|
267
|
+
}
|
|
268
|
+
if (input.startsWith("/")) {
|
|
269
|
+
return path.posix.normalize(input);
|
|
270
|
+
}
|
|
271
|
+
return path.posix.resolve(this.homeDir, input);
|
|
272
|
+
}
|
|
273
|
+
resolveAbsoluteChild(parent, child) {
|
|
274
|
+
if (this.isWindows) {
|
|
275
|
+
return path.win32.normalize(path.win32.join(parent, child));
|
|
276
|
+
}
|
|
277
|
+
return path.posix.normalize(path.posix.join(parent, child));
|
|
278
|
+
}
|
|
279
|
+
getRestrictedParent(relativePath) {
|
|
280
|
+
const normalized = this.normalizeRelativePath(relativePath);
|
|
281
|
+
if (normalized === ".") {
|
|
282
|
+
return undefined;
|
|
283
|
+
}
|
|
284
|
+
const segments = normalized.split("/");
|
|
285
|
+
segments.pop();
|
|
286
|
+
return segments.length === 0 ? "." : segments.join("/");
|
|
287
|
+
}
|
|
288
|
+
getUnrestrictedParent(currentPath) {
|
|
289
|
+
if (this.isWindows) {
|
|
290
|
+
const normalized = path.win32.normalize(currentPath);
|
|
291
|
+
const parsed = path.win32.parse(normalized);
|
|
292
|
+
if (normalized === WINDOWS_DRIVES_ROOT) {
|
|
293
|
+
return undefined;
|
|
294
|
+
}
|
|
295
|
+
if (normalized === parsed.root) {
|
|
296
|
+
return WINDOWS_DRIVES_ROOT;
|
|
297
|
+
}
|
|
298
|
+
return path.win32.dirname(normalized);
|
|
299
|
+
}
|
|
300
|
+
const normalized = path.posix.normalize(currentPath);
|
|
301
|
+
if (normalized === "/") {
|
|
302
|
+
return undefined;
|
|
303
|
+
}
|
|
304
|
+
return path.posix.dirname(normalized);
|
|
305
|
+
}
|
|
306
|
+
}
|