@thaut/claude-ide 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/claude-ide.js +23 -0
- package/package.json +75 -4
- package/server/add-dirs.ts +126 -0
- package/server/auth.test.ts +148 -0
- package/server/auth.ts +235 -0
- package/server/bang.ts +54 -0
- package/server/btw-instructions.ts +19 -0
- package/server/btw-policy.ts +17 -0
- package/server/btw.ts +143 -0
- package/server/child-env.ts +29 -0
- package/server/cli-control.ts +255 -0
- package/server/cli-files.ts +55 -0
- package/server/cli-info.ts +73 -0
- package/server/config/account.ts +65 -0
- package/server/config/agents.ts +186 -0
- package/server/config/mcp.ts +86 -0
- package/server/config/memory.ts +193 -0
- package/server/config/paths.ts +156 -0
- package/server/config/plugins.ts +204 -0
- package/server/config/routes.ts +95 -0
- package/server/config/settings.ts +246 -0
- package/server/config.ts +46 -0
- package/server/db.ts +121 -0
- package/server/directories.test.ts +180 -0
- package/server/directories.ts +87 -0
- package/server/dist-version.ts +69 -0
- package/server/durable-tasks.ts +61 -0
- package/server/file-transfers.ts +79 -0
- package/server/files.test.ts +127 -0
- package/server/files.ts +386 -0
- package/server/fs-queue.ts +14 -0
- package/server/fsutil.ts +144 -0
- package/server/git.ts +86 -0
- package/server/goal-state.test.ts +64 -0
- package/server/goal-state.ts +78 -0
- package/server/history-pages.test.ts +619 -0
- package/server/history-pages.ts +513 -0
- package/server/http-channel-manager.ts +468 -0
- package/server/http-channel-pull.test.ts +314 -0
- package/server/http-channel-push.test.ts +364 -0
- package/server/http-channel-registration.test.ts +291 -0
- package/server/http-channel-routes.ts +73 -0
- package/server/http-channel-store.ts +142 -0
- package/server/http-channel-test-fixture.ts +103 -0
- package/server/ide-messages-mcp.test.ts +82 -0
- package/server/ide-messages-mcp.ts +47 -0
- package/server/idecron-mcp.ts +65 -0
- package/server/idecron.test.ts +79 -0
- package/server/idecron.ts +271 -0
- package/server/index.ts +336 -0
- package/server/live-session.test.ts +1126 -0
- package/server/live-session.ts +1165 -0
- package/server/project-routes.ts +46 -0
- package/server/projects.test.ts +28 -0
- package/server/push.ts +315 -0
- package/server/report-cache.ts +28 -0
- package/server/session-aliases.test.ts +57 -0
- package/server/session-aliases.ts +50 -0
- package/server/session-branch.ts +71 -0
- package/server/session-dirs.ts +189 -0
- package/server/session-file.test.ts +134 -0
- package/server/session-file.ts +113 -0
- package/server/session-messaging.test.ts +297 -0
- package/server/session-messaging.ts +165 -0
- package/server/sessions.ts +638 -0
- package/server/subagents.test.ts +43 -0
- package/server/subagents.ts +58 -0
- package/server/tool-images.test.ts +76 -0
- package/server/tool-images.ts +45 -0
- package/server/turn-changes.ts +308 -0
- package/server/worktree-git.ts +87 -0
- package/server/worktrees.ts +138 -0
- package/server/ws.test.ts +195 -0
- package/server/ws.ts +197 -0
- package/shared/agent-model.ts +15 -0
- package/shared/agent-tasks.ts +12 -0
- package/shared/config.ts +175 -0
- package/shared/directories.ts +12 -0
- package/shared/files.ts +51 -0
- package/shared/http-channels.ts +63 -0
- package/shared/message-window.ts +189 -0
- package/shared/project.ts +77 -0
- package/shared/protocol.ts +203 -0
- package/shared/task-types.ts +4 -0
- package/shared/todos.ts +40 -0
- package/shared/write-policy.ts +9 -0
- package/web/dist/assets/AgentView-wrTKgcJ3.js +1 -0
- package/web/dist/assets/AnnotationSelection-BZmNmwVW.js +7 -0
- package/web/dist/assets/ChangesView-G1WTzh4q.js +2 -0
- package/web/dist/assets/FilesView-DPgAbYt_.js +6 -0
- package/web/dist/assets/Form-BKTwiYyw.js +1 -0
- package/web/dist/assets/HomePage-Dq2apjBe.js +1 -0
- package/web/dist/assets/Markdown-IwP-xF29.js +67 -0
- package/web/dist/assets/MessageList-DD9GypSy.js +15 -0
- package/web/dist/assets/Modal-g2rv8I_n.js +1 -0
- package/web/dist/assets/NotificationSettings-DpuLO_Bv.js +1 -0
- package/web/dist/assets/OverviewPage-Dx6miabE.js +1 -0
- package/web/dist/assets/ProjectHome-CousyTLL.js +1 -0
- package/web/dist/assets/SessionView-CPVL7_HO.js +2 -0
- package/web/dist/assets/SettingsPage-D_oYSnW2.js +7 -0
- package/web/dist/assets/WorktreesView-C7e0HV__.js +1 -0
- package/web/dist/assets/abap-CLvhMVsD.js +1 -0
- package/web/dist/assets/actionscript-3-Cs6JJXT5.js +1 -0
- package/web/dist/assets/ada-X3Y2mlq2.js +1 -0
- package/web/dist/assets/ahk-DwADkxyd.js +1 -0
- package/web/dist/assets/ahk2-_6rzW9BS.js +1 -0
- package/web/dist/assets/andromeeda-vGVdxbeo.js +1 -0
- package/web/dist/assets/angular-html-Cw29lun8.js +1 -0
- package/web/dist/assets/angular-ts-BXz-O3SJ.js +1 -0
- package/web/dist/assets/apache-U0d_L8uA.js +1 -0
- package/web/dist/assets/apex-KFGFyKwG.js +1 -0
- package/web/dist/assets/apl-xBchdRhy.js +1 -0
- package/web/dist/assets/applescript-CCn79oCD.js +1 -0
- package/web/dist/assets/ara-4CJ0cIlV.js +1 -0
- package/web/dist/assets/asciidoc-SCjQUq34.js +1 -0
- package/web/dist/assets/asm-Cmm7eHzH.js +1 -0
- package/web/dist/assets/astro-1q6DGuN3.js +1 -0
- package/web/dist/assets/aurora-x-CDeNXAV0.js +1 -0
- package/web/dist/assets/awk-BWXHIvNe.js +1 -0
- package/web/dist/assets/ayu-dark-DluEY0Gj.js +1 -0
- package/web/dist/assets/ayu-light-C3h-C4tm.js +1 -0
- package/web/dist/assets/ayu-mirage-Bqwy1Gya.js +1 -0
- package/web/dist/assets/ballerina-B7ZEbQpA.js +1 -0
- package/web/dist/assets/bat-qdxAdBWQ.js +1 -0
- package/web/dist/assets/beancount-C2IN4Vk8.js +1 -0
- package/web/dist/assets/berry-DKpUyyne.js +1 -0
- package/web/dist/assets/bibtex-Ci_nEsc7.js +1 -0
- package/web/dist/assets/bicep-CUHmPFLl.js +1 -0
- package/web/dist/assets/bird2-CYIUgYqB.js +1 -0
- package/web/dist/assets/blade-Cqdv4oZN.js +1 -0
- package/web/dist/assets/bsl-CVED6lJ1.js +1 -0
- package/web/dist/assets/c-D9gIxSfx.js +1 -0
- package/web/dist/assets/c3-D0apG41V.js +1 -0
- package/web/dist/assets/cadence-CQ2zXKGN.js +1 -0
- package/web/dist/assets/cairo-DRAZz75c.js +1 -0
- package/web/dist/assets/catppuccin-frappe-C9Q5zVZY.js +1 -0
- package/web/dist/assets/catppuccin-latte-CtsyrtPq.js +1 -0
- package/web/dist/assets/catppuccin-macchiato-R8nAf1vR.js +1 -0
- package/web/dist/assets/catppuccin-mocha-DjuaAJKi.js +1 -0
- package/web/dist/assets/chapel-CuseGurG.js +1 -0
- package/web/dist/assets/clarity-CtfBBspg.js +1 -0
- package/web/dist/assets/clojure-DqKBuwfJ.js +1 -0
- package/web/dist/assets/cmake-Bj61d0ZC.js +1 -0
- package/web/dist/assets/cobol-Bdpj3Qoh.js +1 -0
- package/web/dist/assets/codeowners-C8r90Shi.js +1 -0
- package/web/dist/assets/codeql-oeQT6MSM.js +1 -0
- package/web/dist/assets/coffee-Sk8pHFjs.js +1 -0
- package/web/dist/assets/common-lisp-Cv5bFMCO.js +1 -0
- package/web/dist/assets/coq-CGaSfhwR.js +1 -0
- package/web/dist/assets/core-BxI4V4-T.js +12 -0
- package/web/dist/assets/cpp-BQfBYKx3.js +1 -0
- package/web/dist/assets/crystal-B3j7DoOZ.js +1 -0
- package/web/dist/assets/csharp-dmMxLVLW.js +1 -0
- package/web/dist/assets/css-DpFbYmRh.js +1 -0
- package/web/dist/assets/csv-Dx-8-gkx.js +1 -0
- package/web/dist/assets/cue-CE9AQfxI.js +1 -0
- package/web/dist/assets/cypher-ClKdZ_lG.js +1 -0
- package/web/dist/assets/d-qD-0Kul2.js +1 -0
- package/web/dist/assets/dark-plus-Cs2F2srj.js +1 -0
- package/web/dist/assets/dart-CHZY9Xhz.js +1 -0
- package/web/dist/assets/dax-BkyTk9wS.js +1 -0
- package/web/dist/assets/desktop-Dlh5hvp9.js +1 -0
- package/web/dist/assets/diff-woXpYk--.js +1 -0
- package/web/dist/assets/docker-IyjqRm3v.js +1 -0
- package/web/dist/assets/dotenv-CuH5my32.js +1 -0
- package/web/dist/assets/dracula-BHWKrbxM.js +1 -0
- package/web/dist/assets/dracula-soft-5eyTD99u.js +1 -0
- package/web/dist/assets/dream-maker-DW3nJb8Q.js +1 -0
- package/web/dist/assets/edge-DXQWmXTB.js +1 -0
- package/web/dist/assets/elixir-CrDIY2Vo.js +1 -0
- package/web/dist/assets/elm-BslFEg8K.js +1 -0
- package/web/dist/assets/emacs-lisp-DR2vtWaj.js +1 -0
- package/web/dist/assets/engine-javascript-DJg3-Vu2.js +141 -0
- package/web/dist/assets/erb-CUYhg0Ws.js +1 -0
- package/web/dist/assets/erlang-BXdgHVfi.js +1 -0
- package/web/dist/assets/everforest-dark-sB-x3p7T.js +1 -0
- package/web/dist/assets/everforest-light-Df2xbC6M.js +1 -0
- package/web/dist/assets/fennel-DQxkIbk2.js +1 -0
- package/web/dist/assets/fish-BJitypiv.js +1 -0
- package/web/dist/assets/fluent-C03EYrpw.js +1 -0
- package/web/dist/assets/format-DrBC7w0A.js +1 -0
- package/web/dist/assets/fortran-fixed-form-D6mN0kjy.js +1 -0
- package/web/dist/assets/fortran-free-form-CYNrtFtB.js +1 -0
- package/web/dist/assets/fsharp-CwoEF39o.js +1 -0
- package/web/dist/assets/gdresource-CZkFGo3B.js +1 -0
- package/web/dist/assets/gdscript-DYvRD3hg.js +1 -0
- package/web/dist/assets/gdshader-CBce3t8t.js +1 -0
- package/web/dist/assets/genie-CV2tkWYe.js +1 -0
- package/web/dist/assets/gherkin-DExj1W_8.js +1 -0
- package/web/dist/assets/git-commit-dUGrvm6Q.js +1 -0
- package/web/dist/assets/git-rebase-4zCRqF28.js +1 -0
- package/web/dist/assets/github-dark-C-LZuMrd.js +1 -0
- package/web/dist/assets/github-dark-default-DXG-b-1a.js +1 -0
- package/web/dist/assets/github-dark-dimmed-Bx1FflLF.js +1 -0
- package/web/dist/assets/github-dark-high-contrast-B_tTalzw.js +1 -0
- package/web/dist/assets/github-light-EUqPIrTm.js +1 -0
- package/web/dist/assets/github-light-default-BXViO-2h.js +1 -0
- package/web/dist/assets/github-light-high-contrast-B68TUdTA.js +1 -0
- package/web/dist/assets/gleam-CSRkHgEL.js +1 -0
- package/web/dist/assets/glimmer-js-7adTRvH4.js +1 -0
- package/web/dist/assets/glimmer-ts-IdSskDYw.js +1 -0
- package/web/dist/assets/glsl-Qzy53KDt.js +1 -0
- package/web/dist/assets/gn-CAXYAgV-.js +1 -0
- package/web/dist/assets/gnuplot-7GGW24-e.js +1 -0
- package/web/dist/assets/go-rLFTqkRN.js +1 -0
- package/web/dist/assets/graphql-CV_puxbB.js +1 -0
- package/web/dist/assets/groovy-CacY0gHj.js +1 -0
- package/web/dist/assets/gruvbox-dark-hard-C820rvS2.js +1 -0
- package/web/dist/assets/gruvbox-dark-medium-BPjhmG05.js +1 -0
- package/web/dist/assets/gruvbox-dark-soft-MrdJrrXF.js +1 -0
- package/web/dist/assets/gruvbox-light-hard-BC_s9l72.js +1 -0
- package/web/dist/assets/gruvbox-light-medium-BAWPOn9u.js +1 -0
- package/web/dist/assets/gruvbox-light-soft-BSMLrYjP.js +1 -0
- package/web/dist/assets/hack-C5GPjiLV.js +1 -0
- package/web/dist/assets/haml-BQ5YR1DQ.js +1 -0
- package/web/dist/assets/handlebars-DnhRK9A1.js +1 -0
- package/web/dist/assets/haskell-D8IpX4py.js +1 -0
- package/web/dist/assets/haxe-C8oCnwJJ.js +1 -0
- package/web/dist/assets/hcl-Dh228itO.js +1 -0
- package/web/dist/assets/highlight.worker-CY-ZeDAl.js +1 -0
- package/web/dist/assets/hjson-CxZEssPk.js +1 -0
- package/web/dist/assets/hlsl-Cvrh5tZx.js +1 -0
- package/web/dist/assets/horizon-CE9ld1lL.js +1 -0
- package/web/dist/assets/horizon-bright-DSNQnXHK.js +1 -0
- package/web/dist/assets/houston-CsvMBhTu.js +1 -0
- package/web/dist/assets/html-CmHiEKV9.js +1 -0
- package/web/dist/assets/html-derivative-BXE-rYIK.js +1 -0
- package/web/dist/assets/http-DPjjqtcL.js +1 -0
- package/web/dist/assets/hurl-AMBpSloO.js +1 -0
- package/web/dist/assets/hxml-D7Y24wKF.js +1 -0
- package/web/dist/assets/hy-CZbG8q4J.js +1 -0
- package/web/dist/assets/imba-DsUTQ-LC.js +1 -0
- package/web/dist/assets/index-DNPnl4sh.css +2 -0
- package/web/dist/assets/index-DQh72lEx.js +14 -0
- package/web/dist/assets/ini-B5eOa1yu.js +1 -0
- package/web/dist/assets/java-CEM7Tdw_.js +1 -0
- package/web/dist/assets/javascript-CU3PLowd.js +1 -0
- package/web/dist/assets/jinja-fR0x_9Xy.js +1 -0
- package/web/dist/assets/jison-BoKsxs5M.js +1 -0
- package/web/dist/assets/json-BM2FWsRB.js +1 -0
- package/web/dist/assets/json5-BR5RXkoi.js +1 -0
- package/web/dist/assets/jsonc-CYpm1nAK.js +1 -0
- package/web/dist/assets/jsonl-CmCQp5Yx.js +1 -0
- package/web/dist/assets/jsonnet-CJTPZ8u_.js +1 -0
- package/web/dist/assets/jssm-DXw9l8Rf.js +1 -0
- package/web/dist/assets/jsx-B5fTecQP.js +1 -0
- package/web/dist/assets/julia-DGyDG39_.js +1 -0
- package/web/dist/assets/just-B-RyLcSR.js +1 -0
- package/web/dist/assets/kanagawa-dragon-Bozd7klA.js +1 -0
- package/web/dist/assets/kanagawa-lotus-BmuOG9ZW.js +1 -0
- package/web/dist/assets/kanagawa-wave-BML5mF2J.js +1 -0
- package/web/dist/assets/kdl-CsD5j6eV.js +1 -0
- package/web/dist/assets/kotlin-DhhofPvG.js +1 -0
- package/web/dist/assets/kusto-C7mF5XQf.js +1 -0
- package/web/dist/assets/langs-CciPKqaF.js +1 -0
- package/web/dist/assets/laserwave-C_8bwKvT.js +1 -0
- package/web/dist/assets/latex-CV1pQelm.js +1 -0
- package/web/dist/assets/lean-CewbzKMR.js +1 -0
- package/web/dist/assets/less-DVTAwKKz.js +1 -0
- package/web/dist/assets/lib-DlcVMUqT.js +1 -0
- package/web/dist/assets/light-plus-DVQuIRkW.js +1 -0
- package/web/dist/assets/liquid-9p05RSzQ.js +1 -0
- package/web/dist/assets/llvm-DqHOMS-s.js +1 -0
- package/web/dist/assets/log-BNLmms1o.js +1 -0
- package/web/dist/assets/logo-Cluzi2Zq.js +1 -0
- package/web/dist/assets/lua-CIPVh0S-.js +1 -0
- package/web/dist/assets/luau-VGWVLoqX.js +1 -0
- package/web/dist/assets/make-Dixweg8N.js +1 -0
- package/web/dist/assets/markdown-BYOwaDjH.js +1 -0
- package/web/dist/assets/marko-h2h6YUMS.js +1 -0
- package/web/dist/assets/material-theme-Bm3Qr25_.js +1 -0
- package/web/dist/assets/material-theme-darker-2IIEA8gg.js +1 -0
- package/web/dist/assets/material-theme-lighter-uhdI0v04.js +1 -0
- package/web/dist/assets/material-theme-ocean-CHQ94UKr.js +1 -0
- package/web/dist/assets/material-theme-palenight-B5W6OYN7.js +1 -0
- package/web/dist/assets/matlab-D7qyCx1q.js +1 -0
- package/web/dist/assets/mdc-yAyZMdoC.js +1 -0
- package/web/dist/assets/mdx-DQZ5AkYe.js +1 -0
- package/web/dist/assets/mermaid-BxpfTIzt.js +1 -0
- package/web/dist/assets/message-font-size-DoaZfwkT.js +1 -0
- package/web/dist/assets/min-dark-BSWPekZh.js +1 -0
- package/web/dist/assets/min-light-DDpmG2fV.js +1 -0
- package/web/dist/assets/mipsasm-BMqwQI7S.js +1 -0
- package/web/dist/assets/mojo-fg40_ntQ.js +1 -0
- package/web/dist/assets/monokai-BscAjiQZ.js +1 -0
- package/web/dist/assets/moonbit-D9W784E_.js +1 -0
- package/web/dist/assets/move-BYnGhZoM.js +1 -0
- package/web/dist/assets/narrat-_X_XdTYD.js +1 -0
- package/web/dist/assets/nextflow-BoTnSBQ_.js +1 -0
- package/web/dist/assets/nextflow-groovy-D7IRt6Pp.js +1 -0
- package/web/dist/assets/nginx-jWINucNT.js +1 -0
- package/web/dist/assets/night-owl-DhmEMT88.js +1 -0
- package/web/dist/assets/night-owl-light-eJ-hLW7d.js +1 -0
- package/web/dist/assets/nim-Dtt9DZ0t.js +1 -0
- package/web/dist/assets/nix-Cl_7024t.js +1 -0
- package/web/dist/assets/nord-Cb4Vim4T.js +1 -0
- package/web/dist/assets/nsis-CjNLYCLg.js +1 -0
- package/web/dist/assets/nushell--0fT3PI1.js +1 -0
- package/web/dist/assets/objective-c-D1A_Heim.js +1 -0
- package/web/dist/assets/objective-cpp-BsSzOQcm.js +1 -0
- package/web/dist/assets/ocaml-O90oeIOV.js +1 -0
- package/web/dist/assets/odin-B1RWQWA5.js +1 -0
- package/web/dist/assets/one-dark-pro-C6YyR8OD.js +1 -0
- package/web/dist/assets/one-light-D7Lr4KcI.js +1 -0
- package/web/dist/assets/openscad-BUDT5pXO.js +1 -0
- package/web/dist/assets/org-ClD5huOa.js +1 -0
- package/web/dist/assets/pascal-4ZHwLPI5.js +1 -0
- package/web/dist/assets/perl-BFegxyeJ.js +1 -0
- package/web/dist/assets/php-B-qOA3Y4.js +1 -0
- package/web/dist/assets/pkl-ot-7Btpt.js +1 -0
- package/web/dist/assets/plastic-DQwYfKfQ.js +1 -0
- package/web/dist/assets/plsql-DGHpHOYJ.js +1 -0
- package/web/dist/assets/po-BiJDBrnU.js +1 -0
- package/web/dist/assets/poimandres-DRFjx7u4.js +1 -0
- package/web/dist/assets/polar-C7UOKdEL.js +1 -0
- package/web/dist/assets/postcss-BXeXVLqQ.js +1 -0
- package/web/dist/assets/powerquery-DNMTfnFr.js +1 -0
- package/web/dist/assets/powershell-QtSnmXcu.js +1 -0
- package/web/dist/assets/prisma-DMgNhnYS.js +1 -0
- package/web/dist/assets/prolog-iXnhIJG7.js +1 -0
- package/web/dist/assets/proto-DB4EqR-F.js +1 -0
- package/web/dist/assets/pug-Cq0NBPu-.js +1 -0
- package/web/dist/assets/puppet-CDv2pdJW.js +1 -0
- package/web/dist/assets/purescript-9MfHhQsQ.js +1 -0
- package/web/dist/assets/python-gzcpVVnB.js +1 -0
- package/web/dist/assets/qml-CYUsa87k.js +1 -0
- package/web/dist/assets/qmldir-DCQb3MpD.js +1 -0
- package/web/dist/assets/qss-Fe1Jh2GI.js +1 -0
- package/web/dist/assets/r-4xJhgbOf.js +1 -0
- package/web/dist/assets/racket-DcIDlBhZ.js +1 -0
- package/web/dist/assets/raku-B3gFvitq.js +1 -0
- package/web/dist/assets/razor-BlHaOHx8.js +1 -0
- package/web/dist/assets/rbs-C0MpOrj4.js +1 -0
- package/web/dist/assets/react-B4UGpcWC.js +1 -0
- package/web/dist/assets/red-CYlAq2b0.js +1 -0
- package/web/dist/assets/reg-CRGYupPL.js +1 -0
- package/web/dist/assets/regexp-BUSxjv2o.js +1 -0
- package/web/dist/assets/rel-BtDbiS_P.js +1 -0
- package/web/dist/assets/riscv-Ckw8ddFX.js +1 -0
- package/web/dist/assets/ron-VUp2lXgN.js +1 -0
- package/web/dist/assets/rose-pine-aMsaMD1D.js +1 -0
- package/web/dist/assets/rose-pine-dawn-8PwUyIlP.js +1 -0
- package/web/dist/assets/rose-pine-moon-DO-qXg-I.js +1 -0
- package/web/dist/assets/rosmsg-CAekHB0j.js +1 -0
- package/web/dist/assets/rst-zjfguEh7.js +1 -0
- package/web/dist/assets/ruby-4oR9waBK.js +1 -0
- package/web/dist/assets/rust-DpiIf5JO.js +1 -0
- package/web/dist/assets/sas-Do4V_2i9.js +1 -0
- package/web/dist/assets/sass-DXrisJhu.js +1 -0
- package/web/dist/assets/scala-BiFt_7mu.js +1 -0
- package/web/dist/assets/scheme-DQCgrYNe.js +1 -0
- package/web/dist/assets/scss-CW6JPtag.js +1 -0
- package/web/dist/assets/sdbl-bTVj8UrX.js +1 -0
- package/web/dist/assets/shaderlab-C4rnI7x0.js +1 -0
- package/web/dist/assets/shellscript-zBmOMFJh.js +1 -0
- package/web/dist/assets/shellsession-DxGUTWaf.js +1 -0
- package/web/dist/assets/slack-dark-DnToyrRv.js +1 -0
- package/web/dist/assets/slack-ochin-B2OO5cIa.js +1 -0
- package/web/dist/assets/smalltalk-BHpQb5nM.js +1 -0
- package/web/dist/assets/smithy-Dgaz7aur.js +1 -0
- package/web/dist/assets/snazzy-light-4G7pJPwS.js +1 -0
- package/web/dist/assets/solarized-dark-b97czJOk.js +1 -0
- package/web/dist/assets/solarized-light-DFPxpIYQ.js +1 -0
- package/web/dist/assets/solidity-Bj7E1mRn.js +1 -0
- package/web/dist/assets/soy-DVtw20Yn.js +1 -0
- package/web/dist/assets/sparql-C0ia5K60.js +1 -0
- package/web/dist/assets/splunk-BC2Px7Mm.js +1 -0
- package/web/dist/assets/sql-DGCM-jag.js +1 -0
- package/web/dist/assets/ssh-config-BgfXC-Er.js +1 -0
- package/web/dist/assets/stata-DfuMOXna.js +1 -0
- package/web/dist/assets/stylus-B6D30XZt.js +1 -0
- package/web/dist/assets/surrealql-CBoRWxfR.js +1 -0
- package/web/dist/assets/svelte-g_uCUem5.js +1 -0
- package/web/dist/assets/swift-CyEgAFGc.js +1 -0
- package/web/dist/assets/synthwave-84-nFMaYfgc.js +1 -0
- package/web/dist/assets/system-verilog-Dh5ihWbf.js +1 -0
- package/web/dist/assets/systemd-BxMlprV5.js +1 -0
- package/web/dist/assets/talonscript-CohzipZa.js +1 -0
- package/web/dist/assets/tasl-DMoTqEGO.js +1 -0
- package/web/dist/assets/tcl-CZd0xW_V.js +1 -0
- package/web/dist/assets/templ-N5C1hJ4Y.js +1 -0
- package/web/dist/assets/terraform-DswuEJGm.js +1 -0
- package/web/dist/assets/tex-mx6xDwuK.js +1 -0
- package/web/dist/assets/themes-CNElGaXw.js +1 -0
- package/web/dist/assets/tokyo-night-oM2G3aXe.js +1 -0
- package/web/dist/assets/toml-CcmNWLt0.js +1 -0
- package/web/dist/assets/ts-tags-C-j71FRb.js +1 -0
- package/web/dist/assets/tsv-sltzmVWM.js +1 -0
- package/web/dist/assets/tsx-z04y7qR9.js +1 -0
- package/web/dist/assets/turtle-ByJddavk.js +1 -0
- package/web/dist/assets/twig-Bz57G_nl.js +1 -0
- package/web/dist/assets/typescript-RMqVTmzR.js +1 -0
- package/web/dist/assets/typespec-BGhR2SqG.js +1 -0
- package/web/dist/assets/typst-BgkqA2Pg.js +1 -0
- package/web/dist/assets/v-DBj4K9d_.js +1 -0
- package/web/dist/assets/vala-zf12oZj6.js +1 -0
- package/web/dist/assets/vb-DOwzaHZ0.js +1 -0
- package/web/dist/assets/verilog-B2gwz-sJ.js +1 -0
- package/web/dist/assets/vesper-DdrHHSXu.js +1 -0
- package/web/dist/assets/vhdl-BroJfC0k.js +1 -0
- package/web/dist/assets/viml-DvXPmvsu.js +1 -0
- package/web/dist/assets/vitesse-black-fwtXNY1n.js +1 -0
- package/web/dist/assets/vitesse-dark-BZCL-v6S.js +1 -0
- package/web/dist/assets/vitesse-light-VbXTXTou.js +1 -0
- package/web/dist/assets/vue-CQgvQytb.js +1 -0
- package/web/dist/assets/vue-html-Dhl6fh9l.js +1 -0
- package/web/dist/assets/vue-vine-Dw_uU59K.js +1 -0
- package/web/dist/assets/vyper-CgoNMtux.js +1 -0
- package/web/dist/assets/wasm-ByWQv1Qj.js +1 -0
- package/web/dist/assets/wenyan-C8pVoKbM.js +1 -0
- package/web/dist/assets/wgsl-BsKzXJz4.js +1 -0
- package/web/dist/assets/wikitext-ClFFjSW2.js +1 -0
- package/web/dist/assets/wit-DdvCle-K.js +1 -0
- package/web/dist/assets/wolfram-DLL8P-h_.js +1 -0
- package/web/dist/assets/xml-B49klYQ3.js +1 -0
- package/web/dist/assets/xsl-D7tnD3qq.js +1 -0
- package/web/dist/assets/yaml-DNQ5_xkL.js +1 -0
- package/web/dist/assets/zenscript-BnlCZFoB.js +1 -0
- package/web/dist/assets/zig-CMLA9XwU.js +1 -0
- package/web/dist/icons/apple-touch-icon.png +0 -0
- package/web/dist/icons/badge-96.png +0 -0
- package/web/dist/icons/icon-192.png +0 -0
- package/web/dist/icons/icon-512.png +0 -0
- package/web/dist/icons/icon.svg +4 -0
- package/web/dist/icons/maskable-192.png +0 -0
- package/web/dist/icons/maskable-512.png +0 -0
- package/web/dist/index.html +30 -0
- package/web/dist/manifest.webmanifest +20 -0
- package/web/dist/sw.js +176 -0
- package/web/dist/version.json +1 -0
- package/web/src/App.tsx +97 -0
- package/web/src/agent-history-flow.test.ts +191 -0
- package/web/src/agent-history-flow.ts +58 -0
- package/web/src/agent-owners.ts +30 -0
- package/web/src/annotation-selection.test.ts +36 -0
- package/web/src/annotation-selection.ts +123 -0
- package/web/src/annotations.test.ts +279 -0
- package/web/src/annotations.ts +191 -0
- package/web/src/api.ts +27 -0
- package/web/src/auth-events.ts +11 -0
- package/web/src/auth-lifecycle.test.ts +105 -0
- package/web/src/clipboard.ts +32 -0
- package/web/src/components/ActivityNotifier.tsx +22 -0
- package/web/src/components/AnnotationEditor.tsx +135 -0
- package/web/src/components/AnnotationSelection.tsx +122 -0
- package/web/src/components/Automation.tsx +390 -0
- package/web/src/components/CodeView.tsx +121 -0
- package/web/src/components/Composer.tsx +552 -0
- package/web/src/components/ComposerAnnotations.tsx +45 -0
- package/web/src/components/Confirmation.tsx +91 -0
- package/web/src/components/CopyButton.tsx +23 -0
- package/web/src/components/DiffView.tsx +94 -0
- package/web/src/components/DirectoryPicker.tsx +230 -0
- package/web/src/components/FileCopyMenu.tsx +58 -0
- package/web/src/components/FileEntryActions.tsx +95 -0
- package/web/src/components/ImagePreview.tsx +68 -0
- package/web/src/components/Items.tsx +608 -0
- package/web/src/components/Markdown.tsx +73 -0
- package/web/src/components/MessageList.tsx +458 -0
- package/web/src/components/Modal.tsx +72 -0
- package/web/src/components/NotificationEntry.tsx +31 -0
- package/web/src/components/NotificationSettings.tsx +226 -0
- package/web/src/components/NotificationToasts.tsx +59 -0
- package/web/src/components/OpenTabs.tsx +112 -0
- package/web/src/components/Pending.tsx +175 -0
- package/web/src/components/ProjectExtras.tsx +299 -0
- package/web/src/components/ProjectNav.tsx +47 -0
- package/web/src/components/SessionActions.tsx +271 -0
- package/web/src/components/SessionChannels.tsx +288 -0
- package/web/src/components/SessionExtras.tsx +263 -0
- package/web/src/components/SettingsLink.tsx +21 -0
- package/web/src/components/Shell.tsx +320 -0
- package/web/src/components/SvgPreview.tsx +18 -0
- package/web/src/components/TodoPanel.tsx +37 -0
- package/web/src/components/VersionNotice.tsx +40 -0
- package/web/src/components/icons.tsx +43 -0
- package/web/src/diff.ts +62 -0
- package/web/src/drafts.test.ts +80 -0
- package/web/src/drafts.ts +64 -0
- package/web/src/format.ts +5 -0
- package/web/src/highlight.worker.ts +49 -0
- package/web/src/hooks.ts +59 -0
- package/web/src/item-view-state.test.ts +51 -0
- package/web/src/item-view-state.ts +43 -0
- package/web/src/live-history-flow.test.ts +77 -0
- package/web/src/live-merge.test.ts +64 -0
- package/web/src/live-merge.ts +50 -0
- package/web/src/live-message-hydration.test.ts +253 -0
- package/web/src/live.ts +404 -0
- package/web/src/main.tsx +27 -0
- package/web/src/markdown-assets.test.ts +70 -0
- package/web/src/markdown-assets.ts +78 -0
- package/web/src/markdown-html.test.ts +84 -0
- package/web/src/markdown-html.ts +60 -0
- package/web/src/markdown-svg.test.ts +37 -0
- package/web/src/markdown-svg.ts +42 -0
- package/web/src/markdown-tables.test.ts +34 -0
- package/web/src/markdown-tables.ts +17 -0
- package/web/src/message-bodies.ts +117 -0
- package/web/src/message-cache.test.ts +208 -0
- package/web/src/message-cache.ts +158 -0
- package/web/src/message-font-size.test.ts +41 -0
- package/web/src/message-font-size.ts +57 -0
- package/web/src/message-time.test.ts +32 -0
- package/web/src/message-time.ts +26 -0
- package/web/src/notify.ts +132 -0
- package/web/src/open-tabs.test.ts +69 -0
- package/web/src/open-tabs.ts +110 -0
- package/web/src/pages/AgentView.tsx +138 -0
- package/web/src/pages/ChangesView.tsx +193 -0
- package/web/src/pages/FilesView.tsx +406 -0
- package/web/src/pages/HomePage.tsx +96 -0
- package/web/src/pages/LoginPage.tsx +56 -0
- package/web/src/pages/OverviewPage.tsx +124 -0
- package/web/src/pages/ProjectHome.tsx +136 -0
- package/web/src/pages/SessionView.tsx +238 -0
- package/web/src/pages/WorktreesView.tsx +197 -0
- package/web/src/pages/settings/AccountPage.tsx +149 -0
- package/web/src/pages/settings/AgentsPage.tsx +182 -0
- package/web/src/pages/settings/ConfigPage.tsx +181 -0
- package/web/src/pages/settings/GeneralPage.tsx +27 -0
- package/web/src/pages/settings/HooksPage.tsx +244 -0
- package/web/src/pages/settings/McpPage.tsx +310 -0
- package/web/src/pages/settings/MemoryPage.tsx +309 -0
- package/web/src/pages/settings/PermissionsPage.tsx +160 -0
- package/web/src/pages/settings/PluginsPage.tsx +251 -0
- package/web/src/pages/settings/SettingsPage.tsx +141 -0
- package/web/src/pages/settings/SkillsPage.tsx +142 -0
- package/web/src/pages/settings/ui.tsx +165 -0
- package/web/src/preference-document.ts +133 -0
- package/web/src/project-actions.ts +18 -0
- package/web/src/project-files-state.test.ts +49 -0
- package/web/src/project-files-state.ts +64 -0
- package/web/src/project-images.ts +13 -0
- package/web/src/pwa.ts +33 -0
- package/web/src/queryClient.ts +5 -0
- package/web/src/reasoning-preference.test.ts +39 -0
- package/web/src/reasoning-preference.ts +42 -0
- package/web/src/session-confirmations.ts +36 -0
- package/web/src/stream-replay.test.ts +163 -0
- package/web/src/styles.css +231 -0
- package/web/src/tool-result-body.test.ts +115 -0
- package/web/src/transcript.test.ts +186 -0
- package/web/src/transcript.ts +583 -0
- package/web/src/turns.test.ts +338 -0
- package/web/src/turns.ts +178 -0
- package/web/src/ui/Button.tsx +60 -0
- package/web/src/ui/Controls.tsx +227 -0
- package/web/src/ui/Form.tsx +203 -0
- package/web/src/ui/MenuPopover.tsx +144 -0
- package/web/src/ui/Popover.tsx +147 -0
- package/web/src/ui/ResizablePane.tsx +110 -0
- package/web/src/ui/Select.tsx +150 -0
- package/web/src/ui/icons.tsx +270 -0
- package/web/src/unsaved.tsx +99 -0
- package/web/src/user-text.test.ts +60 -0
- package/web/src/user-text.ts +35 -0
- package/web/src/uuid.ts +12 -0
- package/README.md +0 -3
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import type { AvailablePlugin, InstalledPlugin, Marketplace, PluginActionResult, PluginListing, SkillInfo } from "../../shared/config.ts";
|
|
5
|
+
import { cached, invalidate, skillsDialog } from "../cli-control.ts";
|
|
6
|
+
import { splitFrontmatter } from "./agents.ts";
|
|
7
|
+
import { ConfigError, configDir, parseJsonOutput, runClaude } from "./paths.ts";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Plugins and marketplaces (/plugin) via `claude plugin … --json`, and skills
|
|
11
|
+
* (user, project, plugin) listed from their SKILL.md files plus the CLI's skills dialog.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
type RawInstalled = { id: string; version?: string; scope: string; enabled: boolean; installPath?: string };
|
|
15
|
+
|
|
16
|
+
async function readJson(file: string): Promise<Record<string, unknown> | null> {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(await fs.readFile(file, "utf8")) as Record<string, unknown>;
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function installed(cwd: string): Promise<RawInstalled[]> {
|
|
25
|
+
const r = await runClaude(["plugin", "list", "--json"], cwd);
|
|
26
|
+
const list = parseJsonOutput<RawInstalled[]>(r.stdout);
|
|
27
|
+
if (!Array.isArray(list)) throw new ConfigError(502, (r.stderr || r.stdout).trim() || "无法读取插件列表");
|
|
28
|
+
return list;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function listPlugins(root: string | null): Promise<PluginListing> {
|
|
32
|
+
const cwd = root ?? os.homedir();
|
|
33
|
+
const [plugins, mr] = await Promise.all([installed(cwd), runClaude(["plugin", "marketplace", "list", "--json"], cwd)]);
|
|
34
|
+
const marketplaces = parseJsonOutput<Marketplace[]>(mr.stdout) ?? [];
|
|
35
|
+
return {
|
|
36
|
+
installed: await Promise.all(plugins.map(
|
|
37
|
+
async (p): Promise<InstalledPlugin> => ({
|
|
38
|
+
id: p.id,
|
|
39
|
+
version: p.version,
|
|
40
|
+
scope: p.scope,
|
|
41
|
+
enabled: p.enabled,
|
|
42
|
+
installPath: p.installPath,
|
|
43
|
+
description: p.installPath ? (((await readJson(path.join(p.installPath, ".claude-plugin", "plugin.json")))?.description as string | undefined) ?? undefined) : undefined,
|
|
44
|
+
}),
|
|
45
|
+
)),
|
|
46
|
+
marketplaces: Array.isArray(marketplaces) ? marketplaces : [],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function availablePlugins(root: string | null): Promise<AvailablePlugin[]> {
|
|
51
|
+
const cwd = root ?? os.homedir();
|
|
52
|
+
return cached(`available:${cwd}`, 5 * 60_000, async () => {
|
|
53
|
+
const r = await runClaude(["plugin", "list", "--available", "--json"], cwd, { timeoutMs: 120_000 });
|
|
54
|
+
const out = parseJsonOutput<{ available?: AvailablePlugin[] }>(r.stdout);
|
|
55
|
+
if (!out) throw new ConfigError(502, (r.stderr || r.stdout).trim() || "无法读取可安装的插件");
|
|
56
|
+
return (out.available ?? []).map((p) => ({
|
|
57
|
+
pluginId: p.pluginId,
|
|
58
|
+
name: p.name,
|
|
59
|
+
description: p.description,
|
|
60
|
+
marketplaceName: p.marketplaceName,
|
|
61
|
+
installCount: p.installCount,
|
|
62
|
+
}));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._@/:-]{0,200}$/;
|
|
67
|
+
const ACTIONS = new Set(["install", "uninstall", "enable", "disable", "update"]);
|
|
68
|
+
|
|
69
|
+
type CliJson = { outcome?: string; message?: string; shownCommand?: { sha256?: string; command?: unknown; kind?: string } };
|
|
70
|
+
|
|
71
|
+
function toResult(r: { code: number; stdout: string; stderr: string }): PluginActionResult {
|
|
72
|
+
const j = parseJsonOutput<CliJson>(r.stdout);
|
|
73
|
+
if (j?.shownCommand?.sha256 && r.code !== 0) {
|
|
74
|
+
return { ok: false, message: j.message ?? "需要确认插件市场声明的命令", confirm: { sha256: j.shownCommand.sha256, command: j.shownCommand.command, kind: j.shownCommand.kind } };
|
|
75
|
+
}
|
|
76
|
+
const ok = r.code === 0 && (j?.outcome === undefined || j.outcome === "ok");
|
|
77
|
+
return { ok, message: (j?.message ?? (r.stderr || r.stdout)).trim() || (ok ? "完成" : "失败") };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function pluginAction(
|
|
81
|
+
root: string | null,
|
|
82
|
+
body: { action?: string; plugin?: string; scope?: string; acceptCommand?: string },
|
|
83
|
+
): Promise<PluginActionResult> {
|
|
84
|
+
const action = String(body.action ?? "");
|
|
85
|
+
const plugin = String(body.plugin ?? "").trim();
|
|
86
|
+
if (!ACTIONS.has(action)) throw new ConfigError(400, "未知操作");
|
|
87
|
+
if (!ID_RE.test(plugin)) throw new ConfigError(400, "插件名不合法");
|
|
88
|
+
const args = ["plugin", action, plugin, "--json"];
|
|
89
|
+
if (body.scope) {
|
|
90
|
+
if (!["user", "project", "local"].includes(body.scope)) throw new ConfigError(400, "未知的作用域");
|
|
91
|
+
if (body.scope !== "user" && !root) throw new ConfigError(400, "项目作用域需要先选择项目");
|
|
92
|
+
args.push("-s", body.scope);
|
|
93
|
+
}
|
|
94
|
+
if (action === "install" && body.acceptCommand) {
|
|
95
|
+
if (!/^[0-9a-f]{64}$/.test(body.acceptCommand)) throw new ConfigError(400, "确认码不正确");
|
|
96
|
+
args.push("--accept-command", body.acceptCommand);
|
|
97
|
+
}
|
|
98
|
+
const r = await runClaude(args, root ?? os.homedir(), { timeoutMs: 300_000 });
|
|
99
|
+
invalidate("init:");
|
|
100
|
+
invalidate("available:");
|
|
101
|
+
return toResult(r);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export async function marketplaceAction(root: string | null, body: { action?: string; source?: string; name?: string; scope?: string }): Promise<PluginActionResult> {
|
|
105
|
+
const cwd = root ?? os.homedir();
|
|
106
|
+
let args: string[];
|
|
107
|
+
if (body.action === "add") {
|
|
108
|
+
const source = String(body.source ?? "").trim();
|
|
109
|
+
if (!source || source.startsWith("-")) throw new ConfigError(400, "请填写来源(owner/repo、git 地址、URL 或本地路径)");
|
|
110
|
+
args = ["plugin", "marketplace", "add", source, "--json"];
|
|
111
|
+
if (body.scope && body.scope !== "user") {
|
|
112
|
+
if (!["project", "local"].includes(body.scope) || !root) throw new ConfigError(400, "未知的作用域");
|
|
113
|
+
args.push("--scope", body.scope);
|
|
114
|
+
}
|
|
115
|
+
} else if (body.action === "remove" || body.action === "update") {
|
|
116
|
+
const name = String(body.name ?? "").trim();
|
|
117
|
+
if (!ID_RE.test(name)) throw new ConfigError(400, "名称不合法");
|
|
118
|
+
args = ["plugin", "marketplace", body.action, name, ...(body.action === "remove" ? ["--json"] : [])];
|
|
119
|
+
} else throw new ConfigError(400, "未知操作");
|
|
120
|
+
const r = await runClaude(args, cwd, { timeoutMs: 300_000 });
|
|
121
|
+
invalidate("available:");
|
|
122
|
+
return toResult(r);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ---------- skills ----------
|
|
126
|
+
|
|
127
|
+
async function skillMeta(file: string): Promise<{ name?: string; description: string }> {
|
|
128
|
+
try {
|
|
129
|
+
const { entries } = splitFrontmatter((await fs.readFile(file, "utf8")).slice(0, 16_384));
|
|
130
|
+
const val = (k: string) => {
|
|
131
|
+
const e = entries?.find((x) => x.key === k);
|
|
132
|
+
if (!e) return undefined;
|
|
133
|
+
const first = e.lines[0].slice(e.lines[0].indexOf(":") + 1).trim();
|
|
134
|
+
const v = /^[|>][-+]?$/.test(first) ? e.lines.slice(1).map((l) => l.trim()).join(" ") : [first, ...e.lines.slice(1).map((l) => l.trim())].join(" ");
|
|
135
|
+
return v.replace(/^["']|["']$/g, "").trim();
|
|
136
|
+
};
|
|
137
|
+
return { name: val("name"), description: val("description") ?? "" };
|
|
138
|
+
} catch {
|
|
139
|
+
return { description: "" };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function scanSkills(dir: string, source: string, plugin?: string, prefix = ""): Promise<SkillInfo[]> {
|
|
144
|
+
let names: string[] = [];
|
|
145
|
+
try {
|
|
146
|
+
names = (await fs.readdir(dir)).sort();
|
|
147
|
+
} catch {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
const out: SkillInfo[] = [];
|
|
151
|
+
for (const n of names) {
|
|
152
|
+
const file = path.join(dir, n, "SKILL.md");
|
|
153
|
+
let fileExists = true;
|
|
154
|
+
try { await fs.access(file); } catch { fileExists = false; }
|
|
155
|
+
if (!fileExists) continue;
|
|
156
|
+
const meta = await skillMeta(file);
|
|
157
|
+
out.push({ name: prefix + (meta.name || n), source, description: meta.description, path: file, ...(plugin ? { plugin } : {}) });
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async function scanCommands(dir: string, source: string): Promise<SkillInfo[]> {
|
|
163
|
+
let names: string[] = [];
|
|
164
|
+
try {
|
|
165
|
+
names = (await fs.readdir(dir)).filter((n) => n.endsWith(".md")).sort();
|
|
166
|
+
} catch {
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
return Promise.all(names.map(async (n) => {
|
|
170
|
+
const file = path.join(dir, n);
|
|
171
|
+
return { name: n.slice(0, -3), source: `${source}-command`, description: (await skillMeta(file)).description, path: file };
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export async function listSkills(root: string | null): Promise<SkillInfo[]> {
|
|
176
|
+
const cwd = root ?? os.homedir();
|
|
177
|
+
const skills: SkillInfo[] = [...await scanSkills(path.join(configDir, "skills"), "user"), ...await scanCommands(path.join(configDir, "commands"), "user")];
|
|
178
|
+
if (root) skills.push(...await scanSkills(path.join(root, ".claude", "skills"), "project"), ...await scanCommands(path.join(root, ".claude", "commands"), "project"));
|
|
179
|
+
const plugins = await installed(cwd).catch(() => [] as RawInstalled[]);
|
|
180
|
+
for (const p of plugins) {
|
|
181
|
+
if (!p.installPath) continue;
|
|
182
|
+
const short = p.id.split("@")[0];
|
|
183
|
+
skills.push(...await scanSkills(path.join(p.installPath, "skills"), "plugin", p.id, `${short}:`));
|
|
184
|
+
}
|
|
185
|
+
// The CLI's view adds state (on/off) and descriptions it derived itself.
|
|
186
|
+
const dialog = await skillsDialog(cwd).catch(() => null);
|
|
187
|
+
if (dialog) {
|
|
188
|
+
for (const s of skills) {
|
|
189
|
+
const d = dialog.skills.find((x) => x.name === s.name);
|
|
190
|
+
if (d) {
|
|
191
|
+
s.state = d.state;
|
|
192
|
+
if (!s.description) s.description = d.description;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return skills;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export async function readSkill(root: string | null, file: string) {
|
|
200
|
+
const skills = await listSkills(root);
|
|
201
|
+
const hit = skills.find((s) => s.path === file);
|
|
202
|
+
if (!hit || !hit.path) throw new ConfigError(404, "技能不存在");
|
|
203
|
+
return { path: hit.path, content: await fs.readFile(hit.path, "utf8") };
|
|
204
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import type { Context, Hono } from "hono";
|
|
3
|
+
import { projectPath } from "../sessions.ts";
|
|
4
|
+
import { cancelMcpAuth, startMcpAuth, submitMcpAuth } from "../cli-control.ts";
|
|
5
|
+
import { ConfigError } from "./paths.ts";
|
|
6
|
+
import { deleteMemoryFile, listMemory, readMemoryFile, setAutoMemory, writeMemoryFile } from "./memory.ts";
|
|
7
|
+
import { applyHookOp, applyPermissionOp, getSettingsInfo, listHooks, listPermissions, setSetting } from "./settings.ts";
|
|
8
|
+
import { deleteAgent, listAgents, saveAgent } from "./agents.ts";
|
|
9
|
+
import { addMcp, getMcpText, listMcp, logoutMcp, removeMcp, setMcpEnabled } from "./mcp.ts";
|
|
10
|
+
import { availablePlugins, listPlugins, listSkills, marketplaceAction, pluginAction, readSkill } from "./plugins.ts";
|
|
11
|
+
import { accountStatus, doctor } from "./account.ts";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* /api/config/* — settings pages. `?project=<pid>` (or `project` in the JSON body)
|
|
15
|
+
* selects the project whose project-level config is shown; without it only
|
|
16
|
+
* user-level config is available.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
type Handler = (c: Context, root: string | null, body: Record<string, any>) => Promise<unknown> | unknown;
|
|
20
|
+
|
|
21
|
+
function wrap(fn: Handler) {
|
|
22
|
+
return async (c: Context) => {
|
|
23
|
+
try {
|
|
24
|
+
const body = c.req.method === "GET" || c.req.method === "DELETE" ? {} : await c.req.json().catch(() => ({}));
|
|
25
|
+
const pid = c.req.query("project") || (typeof body?.project === "string" ? body.project : "");
|
|
26
|
+
const root = pid ? projectPath(pid) : null;
|
|
27
|
+
return c.json((await fn(c, root, body ?? {})) ?? { ok: true });
|
|
28
|
+
} catch (err) {
|
|
29
|
+
if (err instanceof ConfigError) return c.json({ error: err.message }, err.status);
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const q = (c: Context, k: string) => c.req.query(k) ?? "";
|
|
36
|
+
|
|
37
|
+
export function registerConfigRoutes(app: Hono) {
|
|
38
|
+
// memory
|
|
39
|
+
app.get("/api/config/memory", wrap((_c, root) => listMemory(root)));
|
|
40
|
+
app.get("/api/config/memory/file", wrap((c, root) => readMemoryFile(root, q(c, "path"))));
|
|
41
|
+
app.put("/api/config/memory/file", wrap((_c, root, b) => writeMemoryFile(root, b)));
|
|
42
|
+
app.delete("/api/config/memory/file", wrap((c, root) => deleteMemoryFile(root, q(c, "path"))));
|
|
43
|
+
app.put("/api/config/memory/auto", wrap((_c, root, b) => setAutoMemory(root, b.enabled === true)));
|
|
44
|
+
|
|
45
|
+
// permissions, hooks, settings
|
|
46
|
+
app.get("/api/config/permissions", wrap((_c, root) => listPermissions(root)));
|
|
47
|
+
app.post("/api/config/permissions", wrap((_c, root, b) => applyPermissionOp(root, b as never)));
|
|
48
|
+
app.get("/api/config/hooks", wrap((_c, root) => listHooks(root)));
|
|
49
|
+
app.post("/api/config/hooks", wrap((_c, root, b) => applyHookOp(root, b as never)));
|
|
50
|
+
app.get("/api/config/settings", wrap((_c, root) => getSettingsInfo(root)));
|
|
51
|
+
app.put("/api/config/settings", wrap((_c, root, b) => setSetting(root, b)));
|
|
52
|
+
|
|
53
|
+
// agents
|
|
54
|
+
app.get("/api/config/agents", wrap((_c, root) => listAgents(root)));
|
|
55
|
+
app.put("/api/config/agents", wrap((_c, root, b) => saveAgent(root, b as never)));
|
|
56
|
+
app.delete("/api/config/agents", wrap((c, root) => deleteAgent(root, q(c, "scope"), q(c, "file"))));
|
|
57
|
+
|
|
58
|
+
// MCP
|
|
59
|
+
app.get("/api/config/mcp", wrap((_c, root) => listMcp(root)));
|
|
60
|
+
app.post("/api/config/mcp", wrap((_c, root, b) => addMcp(root, b as never)));
|
|
61
|
+
app.delete("/api/config/mcp", wrap((c, root) => removeMcp(root, q(c, "name"), q(c, "scope"))));
|
|
62
|
+
app.get("/api/config/mcp/get", wrap((c, root) => getMcpText(root, q(c, "name"))));
|
|
63
|
+
app.post("/api/config/mcp/toggle", wrap((_c, root, b) => setMcpEnabled(root, String(b.name ?? ""), b.enabled === true)));
|
|
64
|
+
app.post("/api/config/mcp/logout", wrap((_c, root, b) => logoutMcp(root, String(b.name ?? ""))));
|
|
65
|
+
app.post(
|
|
66
|
+
"/api/config/mcp/auth/start",
|
|
67
|
+
wrap(async (_c, root, b) => {
|
|
68
|
+
const r = await startMcpAuth(root ?? os.homedir(), String(b.name ?? ""));
|
|
69
|
+
return { flowId: r.flowId, authUrl: r.authUrl ?? null, requiresUserAction: r.requiresUserAction !== false, callbackPort: r.callbackPort };
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
app.post(
|
|
73
|
+
"/api/config/mcp/auth/submit",
|
|
74
|
+
wrap(async (_c, _root, b) => {
|
|
75
|
+
try {
|
|
76
|
+
return { ok: true, result: await submitMcpAuth(String(b.flowId ?? ""), String(b.url ?? "")) };
|
|
77
|
+
} catch (err) {
|
|
78
|
+
throw new ConfigError(400, (err as Error).message);
|
|
79
|
+
}
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
app.post("/api/config/mcp/auth/cancel", wrap((_c, _root, b) => cancelMcpAuth(String(b.flowId ?? ""))));
|
|
83
|
+
|
|
84
|
+
// plugins, marketplaces, skills
|
|
85
|
+
app.get("/api/config/plugins", wrap((_c, root) => listPlugins(root)));
|
|
86
|
+
app.get("/api/config/plugins/available", wrap((_c, root) => availablePlugins(root)));
|
|
87
|
+
app.post("/api/config/plugins", wrap((_c, root, b) => pluginAction(root, b)));
|
|
88
|
+
app.post("/api/config/marketplaces", wrap((_c, root, b) => marketplaceAction(root, b)));
|
|
89
|
+
app.get("/api/config/skills", wrap((_c, root) => listSkills(root)));
|
|
90
|
+
app.get("/api/config/skills/file", wrap((c, root) => readSkill(root, q(c, "path"))));
|
|
91
|
+
|
|
92
|
+
// account
|
|
93
|
+
app.get("/api/config/account", wrap(() => accountStatus()));
|
|
94
|
+
app.get("/api/config/doctor", wrap((_c, root) => doctor(root)));
|
|
95
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import {
|
|
3
|
+
PERMISSION_KINDS,
|
|
4
|
+
type HookCommand,
|
|
5
|
+
type HookGroup,
|
|
6
|
+
type HookLayer,
|
|
7
|
+
type HookOp,
|
|
8
|
+
type HooksListing,
|
|
9
|
+
type PermissionKind,
|
|
10
|
+
type PermissionLayer,
|
|
11
|
+
type PermissionOp,
|
|
12
|
+
type SettingsInfo,
|
|
13
|
+
type SettingsLayer,
|
|
14
|
+
type SettingsScope,
|
|
15
|
+
} from "../../shared/config.ts";
|
|
16
|
+
import { effectiveSettings, hooksListing, initInfo } from "../cli-control.ts";
|
|
17
|
+
import { ConfigError, readJsonFile, settingsFile, updateJsonFile } from "./paths.ts";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Permission rules, hooks and plain settings (/permissions, /hooks, /config):
|
|
21
|
+
* read and written directly in the settings.json files of each layer.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
type Obj = Record<string, unknown>;
|
|
25
|
+
const isObj = (v: unknown): v is Obj => !!v && typeof v === "object" && !Array.isArray(v);
|
|
26
|
+
|
|
27
|
+
export function scopesFor(root: string | null): SettingsScope[] {
|
|
28
|
+
return root ? ["user", "project", "local"] : ["user"];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function layerFile(scope: SettingsScope, root: string | null): string {
|
|
32
|
+
const f = settingsFile(scope, root);
|
|
33
|
+
if (!f) throw new ConfigError(400, "项目级设置需要先选择项目");
|
|
34
|
+
return f;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function parseScope(v: unknown, root: string | null): SettingsScope {
|
|
38
|
+
if (v !== "user" && v !== "project" && v !== "local") throw new ConfigError(400, "未知的层级");
|
|
39
|
+
if (v !== "user" && !root) throw new ConfigError(400, "项目级设置需要先选择项目");
|
|
40
|
+
return v;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// ---------- permissions ----------
|
|
44
|
+
|
|
45
|
+
export async function listPermissions(root: string | null): Promise<PermissionLayer[]> {
|
|
46
|
+
return Promise.all(scopesFor(root).map(async (scope) => {
|
|
47
|
+
const file = layerFile(scope, root);
|
|
48
|
+
const { data, exists } = await readJsonFile(file);
|
|
49
|
+
const perms = isObj(data.permissions) ? data.permissions : {};
|
|
50
|
+
const lists = Object.fromEntries(
|
|
51
|
+
PERMISSION_KINDS.map((k) => [k, Array.isArray(perms[k]) ? (perms[k] as unknown[]).filter((x): x is string => typeof x === "string") : []]),
|
|
52
|
+
) as Record<PermissionKind, string[]>;
|
|
53
|
+
return { scope, path: file, exists, lists };
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function applyPermissionOp(root: string | null, body: PermissionOp) {
|
|
58
|
+
const scope = parseScope(body?.scope, root);
|
|
59
|
+
const kind = body.kind;
|
|
60
|
+
if (!PERMISSION_KINDS.includes(kind)) throw new ConfigError(400, "未知的规则类型");
|
|
61
|
+
const value = typeof body.value === "string" ? body.value.trim() : "";
|
|
62
|
+
if (!value) throw new ConfigError(400, "规则不能为空");
|
|
63
|
+
await updateJsonFile(layerFile(scope, root), (d) => {
|
|
64
|
+
const perms: Obj = isObj(d.permissions) ? d.permissions : {};
|
|
65
|
+
const list = Array.isArray(perms[kind]) ? [...(perms[kind] as unknown[])] : [];
|
|
66
|
+
if (body.op === "add") {
|
|
67
|
+
if (list.includes(value)) throw new ConfigError(409, "这条规则已经存在");
|
|
68
|
+
list.push(value);
|
|
69
|
+
} else if (body.op === "remove") {
|
|
70
|
+
const i = list.indexOf(value);
|
|
71
|
+
if (i < 0) throw new ConfigError(404, "规则不存在(可能已被修改)");
|
|
72
|
+
list.splice(i, 1);
|
|
73
|
+
} else if (body.op === "replace") {
|
|
74
|
+
const i = list.indexOf(body.old);
|
|
75
|
+
if (i < 0) throw new ConfigError(404, "规则不存在(可能已被修改)");
|
|
76
|
+
if (body.old !== value && list.includes(value)) throw new ConfigError(409, "这条规则已经存在");
|
|
77
|
+
list[i] = value;
|
|
78
|
+
} else {
|
|
79
|
+
throw new ConfigError(400, "未知操作");
|
|
80
|
+
}
|
|
81
|
+
if (list.length) perms[kind] = list;
|
|
82
|
+
else delete perms[kind];
|
|
83
|
+
if (Object.keys(perms).length) d.permissions = perms;
|
|
84
|
+
else delete d.permissions;
|
|
85
|
+
});
|
|
86
|
+
return listPermissions(root);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ---------- hooks ----------
|
|
90
|
+
|
|
91
|
+
function readHooks(data: Obj): Record<string, HookGroup[]> {
|
|
92
|
+
if (!isObj(data.hooks)) return {};
|
|
93
|
+
const out: Record<string, HookGroup[]> = {};
|
|
94
|
+
for (const [event, groups] of Object.entries(data.hooks)) {
|
|
95
|
+
if (!Array.isArray(groups)) continue;
|
|
96
|
+
out[event] = groups.filter(isObj).map((g) => ({
|
|
97
|
+
...(typeof g.matcher === "string" ? { matcher: g.matcher } : {}),
|
|
98
|
+
hooks: Array.isArray(g.hooks) ? (g.hooks.filter(isObj) as HookCommand[]) : [],
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const SETTINGS_SOURCES = new Set(["userSettings", "projectSettings", "localSettings"]);
|
|
105
|
+
|
|
106
|
+
export async function listHooks(root: string | null): Promise<HooksListing> {
|
|
107
|
+
const layers: HookLayer[] = await Promise.all(scopesFor(root).map(async (scope) => {
|
|
108
|
+
const file = layerFile(scope, root);
|
|
109
|
+
const { data, exists } = await readJsonFile(file);
|
|
110
|
+
return { scope, path: file, exists, hooks: readHooks(data) };
|
|
111
|
+
}));
|
|
112
|
+
let events: HooksListing["events"] = [];
|
|
113
|
+
let readonly: HooksListing["readonly"] = [];
|
|
114
|
+
try {
|
|
115
|
+
const l = await hooksListing(root ?? os.homedir());
|
|
116
|
+
events = l.eventCatalog.map((e) => ({ name: e.name, summary: e.summary, supportsMatcher: e.supportsMatcher }));
|
|
117
|
+
readonly = l.hooks
|
|
118
|
+
.filter((h) => !SETTINGS_SOURCES.has(h.source))
|
|
119
|
+
.map((h) => ({ event: h.event, matcher: h.matcher, source: h.source, label: h.sourceLabel, text: h.displayText }));
|
|
120
|
+
} catch {
|
|
121
|
+
// The listing is a nicety (summaries, plugin hooks); the files are the truth.
|
|
122
|
+
}
|
|
123
|
+
return { layers, events, readonly };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function cleanHook(h: HookCommand): HookCommand {
|
|
127
|
+
if (!isObj(h) || typeof h.type !== "string") throw new ConfigError(400, "钩子格式不正确");
|
|
128
|
+
if (h.type === "command") {
|
|
129
|
+
const command = typeof h.command === "string" ? h.command.trim() : "";
|
|
130
|
+
if (!command) throw new ConfigError(400, "命令不能为空");
|
|
131
|
+
const out: HookCommand = { ...h, type: "command", command };
|
|
132
|
+
if (h.timeout === undefined || h.timeout === null || (h.timeout as unknown) === "") delete out.timeout;
|
|
133
|
+
else {
|
|
134
|
+
const t = Number(h.timeout);
|
|
135
|
+
if (!Number.isFinite(t) || t <= 0) throw new ConfigError(400, "超时时间必须是正数(秒)");
|
|
136
|
+
out.timeout = t;
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
return h;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export async function applyHookOp(root: string | null, body: HookOp) {
|
|
144
|
+
const scope = parseScope(body?.scope, root);
|
|
145
|
+
const event = typeof body.event === "string" ? body.event.trim() : "";
|
|
146
|
+
if (!/^[A-Za-z]+$/.test(event)) throw new ConfigError(400, "未知的事件");
|
|
147
|
+
await updateJsonFile(layerFile(scope, root), (d) => {
|
|
148
|
+
const hooks: Obj = isObj(d.hooks) ? d.hooks : {};
|
|
149
|
+
const groups: Obj[] = Array.isArray(hooks[event]) ? [...(hooks[event] as Obj[])] : [];
|
|
150
|
+
const add = (matcher: string | undefined, hook: HookCommand) => {
|
|
151
|
+
const m = matcher?.trim() || undefined;
|
|
152
|
+
const g = groups.find((x) => isObj(x) && (typeof x.matcher === "string" && x.matcher ? x.matcher : undefined) === m);
|
|
153
|
+
if (g) g.hooks = [...(Array.isArray(g.hooks) ? g.hooks : []), hook];
|
|
154
|
+
else groups.push({ ...(m !== undefined ? { matcher: m } : {}), hooks: [hook] });
|
|
155
|
+
};
|
|
156
|
+
const at = (gi: number, hi: number) => {
|
|
157
|
+
const g = groups[gi];
|
|
158
|
+
if (!isObj(g) || !Array.isArray(g.hooks) || !isObj(g.hooks[hi])) throw new ConfigError(404, "钩子不存在(可能已被修改)");
|
|
159
|
+
return g as Obj & { hooks: unknown[] };
|
|
160
|
+
};
|
|
161
|
+
const removeAt = (gi: number, hi: number) => {
|
|
162
|
+
const g = at(gi, hi);
|
|
163
|
+
g.hooks = g.hooks.filter((_, i) => i !== hi);
|
|
164
|
+
if (!g.hooks.length) groups.splice(gi, 1);
|
|
165
|
+
};
|
|
166
|
+
if (body.op === "add") add(body.matcher, cleanHook(body.hook));
|
|
167
|
+
else if (body.op === "remove") removeAt(body.group, body.index);
|
|
168
|
+
else if (body.op === "replace") {
|
|
169
|
+
const hook = cleanHook(body.hook);
|
|
170
|
+
const g = at(body.group, body.index);
|
|
171
|
+
const oldMatcher = typeof g.matcher === "string" && g.matcher ? g.matcher : undefined;
|
|
172
|
+
const newMatcher = body.matcher?.trim() || undefined;
|
|
173
|
+
if (oldMatcher === newMatcher) g.hooks = g.hooks.map((h, i) => (i === body.index ? hook : h));
|
|
174
|
+
else {
|
|
175
|
+
removeAt(body.group, body.index);
|
|
176
|
+
add(newMatcher, hook);
|
|
177
|
+
}
|
|
178
|
+
} else throw new ConfigError(400, "未知操作");
|
|
179
|
+
if (groups.length) hooks[event] = groups;
|
|
180
|
+
else delete hooks[event];
|
|
181
|
+
if (Object.keys(hooks).length) d.hooks = hooks;
|
|
182
|
+
else delete d.hooks;
|
|
183
|
+
});
|
|
184
|
+
return listHooks(root);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// ---------- plain settings (/config) ----------
|
|
188
|
+
|
|
189
|
+
type KeySpec = { type: "string" } | { type: "boolean" } | { type: "number"; min?: number } | { type: "enum"; values: string[] };
|
|
190
|
+
|
|
191
|
+
/** Settings the /config page edits. Anything else in the files is left untouched. */
|
|
192
|
+
export const CONFIG_KEYS: Record<string, KeySpec> = {
|
|
193
|
+
model: { type: "string" },
|
|
194
|
+
effortLevel: { type: "enum", values: ["low", "medium", "high", "xhigh"] },
|
|
195
|
+
outputStyle: { type: "string" },
|
|
196
|
+
alwaysThinkingEnabled: { type: "boolean" },
|
|
197
|
+
showThinkingSummaries: { type: "boolean" },
|
|
198
|
+
language: { type: "string" },
|
|
199
|
+
includeGitInstructions: { type: "boolean" },
|
|
200
|
+
respectGitignore: { type: "boolean" },
|
|
201
|
+
cleanupPeriodDays: { type: "number", min: 1 },
|
|
202
|
+
autoUpdatesChannel: { type: "enum", values: ["latest", "stable", "rc"] },
|
|
203
|
+
autoMemoryEnabled: { type: "boolean" },
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export async function getSettingsInfo(root: string | null): Promise<SettingsInfo> {
|
|
207
|
+
const layers: SettingsLayer[] = await Promise.all(scopesFor(root).map(async (scope) => {
|
|
208
|
+
const file = layerFile(scope, root);
|
|
209
|
+
const { data, exists } = await readJsonFile(file);
|
|
210
|
+
return { scope, path: file, exists, settings: data };
|
|
211
|
+
}));
|
|
212
|
+
const cwd = root ?? os.homedir();
|
|
213
|
+
const [effective, init] = await Promise.all([effectiveSettings(cwd).catch(() => null), initInfo(cwd).catch(() => null)]);
|
|
214
|
+
return {
|
|
215
|
+
layers,
|
|
216
|
+
effective: effective?.effective ?? {},
|
|
217
|
+
outputStyles: init?.available_output_styles ?? ["default"],
|
|
218
|
+
models: (init?.models ?? []).map((m) => ({ value: m.value, displayName: m.displayName, description: m.description })),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export async function setSetting(root: string | null, body: { scope?: unknown; key?: unknown; value?: unknown }) {
|
|
223
|
+
const scope = parseScope(body.scope, root);
|
|
224
|
+
const key = String(body.key ?? "");
|
|
225
|
+
const spec = CONFIG_KEYS[key];
|
|
226
|
+
if (!spec) throw new ConfigError(400, "不支持修改这个设置");
|
|
227
|
+
let value = body.value;
|
|
228
|
+
if (value === null || value === undefined || value === "") value = undefined;
|
|
229
|
+
else if (spec.type === "string") {
|
|
230
|
+
if (typeof value !== "string") throw new ConfigError(400, "应为文本");
|
|
231
|
+
value = value.trim() || undefined;
|
|
232
|
+
} else if (spec.type === "boolean") {
|
|
233
|
+
if (typeof value !== "boolean") throw new ConfigError(400, "应为开或关");
|
|
234
|
+
} else if (spec.type === "number") {
|
|
235
|
+
const n = Number(value);
|
|
236
|
+
if (!Number.isFinite(n) || (spec.min !== undefined && n < spec.min)) throw new ConfigError(400, "数值不正确");
|
|
237
|
+
value = n;
|
|
238
|
+
} else if (spec.type === "enum") {
|
|
239
|
+
if (!spec.values.includes(String(value))) throw new ConfigError(400, "取值不正确");
|
|
240
|
+
}
|
|
241
|
+
updateJsonFile(layerFile(scope, root), (d) => {
|
|
242
|
+
if (value === undefined) delete d[key];
|
|
243
|
+
else d[key] = value;
|
|
244
|
+
});
|
|
245
|
+
return getSettingsInfo(root);
|
|
246
|
+
}
|
package/server/config.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import crypto from "node:crypto";
|
|
5
|
+
|
|
6
|
+
function expandHome(p: string): string {
|
|
7
|
+
return p.startsWith("~/") ? path.join(os.homedir(), p.slice(2)) : p;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const dataDir = path.resolve(expandHome(process.env.CLAUDE_IDE_DATA_DIR ?? "~/.claude-ide"));
|
|
11
|
+
fs.mkdirSync(dataDir, { recursive: true, mode: 0o700 });
|
|
12
|
+
|
|
13
|
+
/** The password file is authoritative. CLAUDE_IDE_PASSWORD only seeds a new
|
|
14
|
+
* installation; it never overrides an existing/missing deployed credential. */
|
|
15
|
+
function loadPassword(): { password: string; generated: boolean } {
|
|
16
|
+
const file = path.join(dataDir, "password");
|
|
17
|
+
try {
|
|
18
|
+
return { password: fs.readFileSync(file, "utf8").trim(), generated: false };
|
|
19
|
+
} catch (err) {
|
|
20
|
+
// Only a brand-new installation generates a password. A missing/unreadable
|
|
21
|
+
// credential on an existing installation stays unavailable until repaired.
|
|
22
|
+
if ((err as NodeJS.ErrnoException).code !== "ENOENT" || fs.existsSync(path.join(dataDir, "ide.sqlite"))) {
|
|
23
|
+
return { password: "", generated: false };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const password = process.env.CLAUDE_IDE_PASSWORD || crypto.randomBytes(12).toString("base64url");
|
|
27
|
+
fs.writeFileSync(file, password + "\n", { mode: 0o600 });
|
|
28
|
+
return { password, generated: !process.env.CLAUDE_IDE_PASSWORD };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { password, generated } = loadPassword();
|
|
32
|
+
|
|
33
|
+
export const config = {
|
|
34
|
+
port: Number(process.env.CLAUDE_IDE_PORT ?? 8787),
|
|
35
|
+
host: process.env.CLAUDE_IDE_HOST ?? "0.0.0.0",
|
|
36
|
+
dataDir,
|
|
37
|
+
password,
|
|
38
|
+
passwordGenerated: generated,
|
|
39
|
+
passwordFile: path.join(dataDir, "password"),
|
|
40
|
+
/** Overrides the model for every session (tests use Haiku). */
|
|
41
|
+
modelOverride: process.env.CLAUDE_IDE_MODEL || undefined,
|
|
42
|
+
production: process.env.NODE_ENV === "production",
|
|
43
|
+
/** Idle CLI processes are stopped after this long (resumed on the next message). */
|
|
44
|
+
idleReapMs: Number(process.env.CLAUDE_IDE_IDLE_MINUTES ?? 15) * 60_000,
|
|
45
|
+
webDist: path.resolve(import.meta.dirname, "../web/dist"),
|
|
46
|
+
};
|