@cjhyy/code-shell 0.1.0-alpha.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/CHANGELOG.md +109 -0
- package/LICENSE +21 -0
- package/README.md +177 -0
- package/dist/agent/coordinator.d.ts +49 -0
- package/dist/anthropic-NENYS535.js +9 -0
- package/dist/anthropic-XMTTVNSH.cjs +9 -0
- package/dist/arena/arena.d.ts +43 -0
- package/dist/arena/context/context-tools.d.ts +16 -0
- package/dist/arena/detect-mode.d.ts +20 -0
- package/dist/arena/digest-builder.d.ts +25 -0
- package/dist/arena/index.cjs +103 -0
- package/dist/arena/index.d.ts +29 -0
- package/dist/arena/index.js +103 -0
- package/dist/arena/iterate/convergence.d.ts +25 -0
- package/dist/arena/iterate/formats/index.d.ts +22 -0
- package/dist/arena/iterate/index.d.ts +11 -0
- package/dist/arena/iterate/iterative-arena.d.ts +23 -0
- package/dist/arena/iterate/parse.d.ts +42 -0
- package/dist/arena/iterate/phases/argue.d.ts +22 -0
- package/dist/arena/iterate/phases/revise.d.ts +16 -0
- package/dist/arena/iterate/phases/tournament.d.ts +34 -0
- package/dist/arena/iterate/tools/web-tools.d.ts +13 -0
- package/dist/arena/iterate/types.d.ts +152 -0
- package/dist/arena/ledger.d.ts +47 -0
- package/dist/arena/lenses/architecture.d.ts +5 -0
- package/dist/arena/lenses/engineering.d.ts +5 -0
- package/dist/arena/lenses/general.d.ts +5 -0
- package/dist/arena/lenses/index.d.ts +16 -0
- package/dist/arena/lenses/product.d.ts +5 -0
- package/dist/arena/model-presets.d.ts +14 -0
- package/dist/arena/phases/adjudication.d.ts +24 -0
- package/dist/arena/phases/build-consensus.d.ts +29 -0
- package/dist/arena/phases/claim-registry.d.ts +26 -0
- package/dist/arena/phases/cross-review.d.ts +45 -0
- package/dist/arena/phases/debate-rounds.d.ts +27 -0
- package/dist/arena/phases/participant-research.d.ts +38 -0
- package/dist/arena/phases/planning-detail-expansion.d.ts +38 -0
- package/dist/arena/planner.d.ts +27 -0
- package/dist/arena/providers/docs.d.ts +6 -0
- package/dist/arena/providers/git.d.ts +8 -0
- package/dist/arena/providers/index.d.ts +16 -0
- package/dist/arena/providers/none.d.ts +7 -0
- package/dist/arena/providers/repo.d.ts +6 -0
- package/dist/arena/render/session.d.ts +17 -0
- package/dist/arena/render/terminal.d.ts +33 -0
- package/dist/arena/strategies/discussion.d.ts +25 -0
- package/dist/arena/strategies/index.d.ts +15 -0
- package/dist/arena/strategies/language-wrapper.d.ts +17 -0
- package/dist/arena/strategies/lens-wrapper.d.ts +16 -0
- package/dist/arena/strategies/planning.d.ts +30 -0
- package/dist/arena/strategies/review.d.ts +26 -0
- package/dist/arena/strategies/utils.d.ts +34 -0
- package/dist/arena/tools/selector.d.ts +17 -0
- package/dist/arena/transitions.d.ts +48 -0
- package/dist/arena/types.d.ts +499 -0
- package/dist/arena-46QQ6BZQ.js +261 -0
- package/dist/arena-HZZZ2GJH.cjs +261 -0
- package/dist/bootstrap/setup.d.ts +14 -0
- package/dist/bootstrap/state.d.ts +160 -0
- package/dist/bridge-4ZRXVWBN.js +98 -0
- package/dist/bridge-W476QDFH.cjs +98 -0
- package/dist/chunk-3EAEC566.cjs +136 -0
- package/dist/chunk-3EUDE77E.cjs +1252 -0
- package/dist/chunk-3QR52LL5.cjs +105 -0
- package/dist/chunk-4PKZPFCD.js +136 -0
- package/dist/chunk-4RRUP4MM.js +86 -0
- package/dist/chunk-4SFPFHMG.js +132 -0
- package/dist/chunk-5LHVI777.cjs +246 -0
- package/dist/chunk-6JOOLG6F.js +104 -0
- package/dist/chunk-6ZIROYXX.js +207 -0
- package/dist/chunk-7RMAR2Y3.js +6511 -0
- package/dist/chunk-BE6IPRDM.js +224 -0
- package/dist/chunk-BHGIJ2DJ.js +41 -0
- package/dist/chunk-BMH65OVB.cjs +224 -0
- package/dist/chunk-C7JBCO5V.js +80 -0
- package/dist/chunk-CSO5EOEP.cjs +132 -0
- package/dist/chunk-DI7RDLOS.js +47 -0
- package/dist/chunk-DICG4AB7.cjs +73 -0
- package/dist/chunk-EL2RL5DG.cjs +101 -0
- package/dist/chunk-FGZGCFJX.cjs +207 -0
- package/dist/chunk-FUOKLKR2.js +101 -0
- package/dist/chunk-FVP7XJGS.cjs +4577 -0
- package/dist/chunk-HD7MT5XU.cjs +86 -0
- package/dist/chunk-IJSHQGMP.cjs +45 -0
- package/dist/chunk-IMMTBZ33.cjs +63 -0
- package/dist/chunk-J5XW6UYL.js +291 -0
- package/dist/chunk-JT2WSQSR.cjs +335 -0
- package/dist/chunk-KO2FPF7G.js +93 -0
- package/dist/chunk-LRAY5IYC.cjs +291 -0
- package/dist/chunk-NG73UR3L.cjs +285 -0
- package/dist/chunk-NZ4DQ72D.cjs +664 -0
- package/dist/chunk-O6F2EF2Z.js +73 -0
- package/dist/chunk-OG4MIQJ6.js +335 -0
- package/dist/chunk-QHDYFC5U.cjs +6511 -0
- package/dist/chunk-R32DJSJE.cjs +41 -0
- package/dist/chunk-S74VVJBF.js +285 -0
- package/dist/chunk-SK62UVS6.js +105 -0
- package/dist/chunk-SQZHPD3S.js +4577 -0
- package/dist/chunk-UK2SU23S.cjs +93 -0
- package/dist/chunk-VKGNCYRL.js +258 -0
- package/dist/chunk-WFQF3RT4.cjs +104 -0
- package/dist/chunk-WHRTARDJ.cjs +258 -0
- package/dist/chunk-WRZJUQ5Z.js +664 -0
- package/dist/chunk-X4HAERTQ.js +63 -0
- package/dist/chunk-XHC2JMEC.cjs +80 -0
- package/dist/chunk-YZ25SSWJ.js +222 -0
- package/dist/chunk-ZJV3YSY3.cjs +222 -0
- package/dist/chunk-ZRSSGYA5.js +246 -0
- package/dist/chunk-ZXYDDJEJ.js +1252 -0
- package/dist/cli/commands/arena.d.ts +29 -0
- package/dist/cli/commands/builtin/advanced-commands.d.ts +5 -0
- package/dist/cli/commands/builtin/core-commands.d.ts +5 -0
- package/dist/cli/commands/builtin/extra-commands.d.ts +6 -0
- package/dist/cli/commands/builtin/git-commands.d.ts +5 -0
- package/dist/cli/commands/builtin/more-commands.d.ts +7 -0
- package/dist/cli/commands/builtin/permissions-command.d.ts +5 -0
- package/dist/cli/commands/builtin/utility-commands.d.ts +5 -0
- package/dist/cli/commands/registry.d.ts +64 -0
- package/dist/cli/commands/repl.d.ts +21 -0
- package/dist/cli/commands/run.d.ts +21 -0
- package/dist/cli/commands/runs.d.ts +14 -0
- package/dist/cli/cost-tracker.d.ts +57 -0
- package/dist/cli/exit.d.ts +12 -0
- package/dist/cli/input/ndjson-reader.d.ts +31 -0
- package/dist/cli/input-compiler.d.ts +5 -0
- package/dist/cli/main.cjs +19674 -0
- package/dist/cli/main.d.ts +5 -0
- package/dist/cli/main.js +19674 -0
- package/dist/cli/onboarding.d.ts +26 -0
- package/dist/cli/output/renderer.d.ts +28 -0
- package/dist/cli/output/terminal-ui.d.ts +50 -0
- package/dist/cli/updater.d.ts +10 -0
- package/dist/compaction-44I55TLI.cjs +32 -0
- package/dist/compaction-CCHWA4G6.js +32 -0
- package/dist/context/compaction.d.ts +83 -0
- package/dist/context/manager.d.ts +99 -0
- package/dist/context/token-counter.d.ts +27 -0
- package/dist/coordinator-5HY7ALO2.js +7 -0
- package/dist/coordinator-INDLPVMF.cjs +7 -0
- package/dist/cost-tracker-IWYAUPXH.js +9 -0
- package/dist/cost-tracker-JXTJQQWE.cjs +9 -0
- package/dist/cron/scheduler.d.ts +34 -0
- package/dist/devtools-KIY3LWQJ.js +6 -0
- package/dist/devtools-LRP47DDV.cjs +6 -0
- package/dist/engine/cost-store.d.ts +22 -0
- package/dist/engine/engine.d.ts +101 -0
- package/dist/engine/model-facade.d.ts +24 -0
- package/dist/engine/query.d.ts +50 -0
- package/dist/engine/streaming-tool-queue.d.ts +34 -0
- package/dist/engine/token-budget.d.ts +22 -0
- package/dist/engine/tool-summary.d.ts +13 -0
- package/dist/engine/turn-loop.d.ts +62 -0
- package/dist/engine/turn-state.d.ts +14 -0
- package/dist/exceptions.d.ts +44 -0
- package/dist/file-history-HZWO2WQ5.js +7 -0
- package/dist/file-history-UQQILIY7.cjs +7 -0
- package/dist/git/utils.d.ts +35 -0
- package/dist/git/worktree.d.ts +36 -0
- package/dist/hooks/events.d.ts +35 -0
- package/dist/hooks/registry.d.ts +15 -0
- package/dist/index.cjs +336 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +336 -0
- package/dist/ink/Ansi.d.ts +10 -0
- package/dist/ink/bidi.d.ts +15 -0
- package/dist/ink/clearTerminal.d.ts +13 -0
- package/dist/ink/colorize.d.ts +16 -0
- package/dist/ink/components/AlternateScreen.d.ts +21 -0
- package/dist/ink/components/App.d.ts +70 -0
- package/dist/ink/components/AppContext.d.ts +11 -0
- package/dist/ink/components/Box.d.ts +49 -0
- package/dist/ink/components/Button.d.ts +36 -0
- package/dist/ink/components/ClockContext.d.ts +9 -0
- package/dist/ink/components/CursorDeclarationContext.d.ts +22 -0
- package/dist/ink/components/ErrorOverview.d.ts +5 -0
- package/dist/ink/components/Link.d.ts +7 -0
- package/dist/ink/components/Newline.d.ts +12 -0
- package/dist/ink/components/NoSelect.d.ts +19 -0
- package/dist/ink/components/RawAnsi.d.ts +16 -0
- package/dist/ink/components/ScrollBox.d.ts +78 -0
- package/dist/ink/components/Spacer.d.ts +5 -0
- package/dist/ink/components/StdinContext.d.ts +27 -0
- package/dist/ink/components/TerminalFocusContext.d.ts +10 -0
- package/dist/ink/components/TerminalSizeContext.d.ts +5 -0
- package/dist/ink/components/Text.d.ts +55 -0
- package/dist/ink/constants.d.ts +1 -0
- package/dist/ink/cursor.d.ts +8 -0
- package/dist/ink/devtools.d.ts +5 -0
- package/dist/ink/dom.d.ts +76 -0
- package/dist/ink/events/click-event.d.ts +31 -0
- package/dist/ink/events/dispatcher.d.ts +40 -0
- package/dist/ink/events/emitter.d.ts +5 -0
- package/dist/ink/events/event-handlers.d.ts +46 -0
- package/dist/ink/events/event.d.ts +5 -0
- package/dist/ink/events/focus-event.d.ts +13 -0
- package/dist/ink/events/input-event.d.ts +30 -0
- package/dist/ink/events/keyboard-event.d.ts +19 -0
- package/dist/ink/events/paste-event.d.ts +8 -0
- package/dist/ink/events/resize-event.d.ts +9 -0
- package/dist/ink/events/terminal-event.d.ts +54 -0
- package/dist/ink/events/terminal-focus-event.d.ts +13 -0
- package/dist/ink/focus.d.ts +43 -0
- package/dist/ink/frame.d.ts +94 -0
- package/dist/ink/get-max-width.d.ts +17 -0
- package/dist/ink/hit-test.d.ts +33 -0
- package/dist/ink/hooks/use-animation-frame.d.ts +26 -0
- package/dist/ink/hooks/use-app.d.ts +5 -0
- package/dist/ink/hooks/use-declared-cursor.d.ts +26 -0
- package/dist/ink/hooks/use-input.d.ts +37 -0
- package/dist/ink/hooks/use-interval.d.ts +18 -0
- package/dist/ink/hooks/use-search-highlight.d.ts +30 -0
- package/dist/ink/hooks/use-selection.d.ts +39 -0
- package/dist/ink/hooks/use-stdin.d.ts +5 -0
- package/dist/ink/hooks/use-tab-status.d.ts +13 -0
- package/dist/ink/hooks/use-terminal-focus.d.ts +10 -0
- package/dist/ink/hooks/use-terminal-title.d.ts +12 -0
- package/dist/ink/hooks/use-terminal-viewport.d.ts +29 -0
- package/dist/ink/index.d.ts +20 -0
- package/dist/ink/ink.d.ts +369 -0
- package/dist/ink/instances.d.ts +3 -0
- package/dist/ink/layout/engine.d.ts +2 -0
- package/dist/ink/layout/geometry.d.ts +30 -0
- package/dist/ink/layout/node.d.ts +125 -0
- package/dist/ink/layout/yoga.d.ts +56 -0
- package/dist/ink/line-width-cache.d.ts +1 -0
- package/dist/ink/log-update.d.ts +17 -0
- package/dist/ink/measure-element.d.ts +16 -0
- package/dist/ink/measure-text.d.ts +6 -0
- package/dist/ink/node-cache.d.ts +20 -0
- package/dist/ink/optimizer.d.ts +15 -0
- package/dist/ink/output.d.ts +119 -0
- package/dist/ink/parse-keypress.d.ts +111 -0
- package/dist/ink/reconciler.d.ts +11 -0
- package/dist/ink/render-border.d.ts +24 -0
- package/dist/ink/render-node-to-output.d.ts +45 -0
- package/dist/ink/render-to-screen.d.ts +46 -0
- package/dist/ink/renderer.d.ts +14 -0
- package/dist/ink/root.d.ts +74 -0
- package/dist/ink/screen.d.ts +269 -0
- package/dist/ink/searchHighlight.d.ts +20 -0
- package/dist/ink/selection.d.ts +229 -0
- package/dist/ink/squash-text-nodes.d.ts +22 -0
- package/dist/ink/stringWidth.d.ts +1 -0
- package/dist/ink/styles.d.ts +306 -0
- package/dist/ink/supports-hyperlinks.d.ts +13 -0
- package/dist/ink/tabstops.d.ts +1 -0
- package/dist/ink/terminal-focus-state.d.ts +6 -0
- package/dist/ink/terminal-querier.d.ts +129 -0
- package/dist/ink/terminal.d.ts +46 -0
- package/dist/ink/termio/ansi.d.ts +65 -0
- package/dist/ink/termio/csi.d.ts +165 -0
- package/dist/ink/termio/dec.d.ts +37 -0
- package/dist/ink/termio/esc.d.ts +12 -0
- package/dist/ink/termio/osc.d.ts +173 -0
- package/dist/ink/termio/parser.d.ts +35 -0
- package/dist/ink/termio/sgr.d.ts +8 -0
- package/dist/ink/termio/tokenize.d.ts +45 -0
- package/dist/ink/termio/types.d.ts +190 -0
- package/dist/ink/termio.d.ts +24 -0
- package/dist/ink/useTerminalNotification.d.ts +28 -0
- package/dist/ink/warn.d.ts +1 -0
- package/dist/ink/widest-line.d.ts +1 -0
- package/dist/ink/wrap-text.d.ts +2 -0
- package/dist/ink/wrapAnsi.d.ts +7 -0
- package/dist/llm/client-base.d.ts +22 -0
- package/dist/llm/client-factory.d.ts +10 -0
- package/dist/llm/model-pool.d.ts +60 -0
- package/dist/llm/providers/anthropic.d.ts +19 -0
- package/dist/llm/providers/openai.d.ts +19 -0
- package/dist/llm/types.d.ts +21 -0
- package/dist/loader-DXFSUB4R.cjs +91 -0
- package/dist/loader-J5UID6CV.js +91 -0
- package/dist/logging/logger.d.ts +19 -0
- package/dist/lsp/client.d.ts +41 -0
- package/dist/lsp/manager.d.ts +40 -0
- package/dist/lsp/servers.d.ts +16 -0
- package/dist/manager-ETWDOCHN.cjs +9 -0
- package/dist/manager-HGMQNEJB.cjs +11 -0
- package/dist/manager-HUAQOORS.js +9 -0
- package/dist/manager-VJIZ2CQC.js +11 -0
- package/dist/mcp-manager-G4G2QASE.cjs +8 -0
- package/dist/mcp-manager-OKXHHWYR.js +8 -0
- package/dist/memory-AP747G5H.js +7 -0
- package/dist/memory-BH3BYUN5.cjs +7 -0
- package/dist/native-ts/yoga-layout/enums.d.ts +117 -0
- package/dist/native-ts/yoga-layout/index.d.ts +270 -0
- package/dist/onboarding-6WEPV7C2.js +11 -0
- package/dist/onboarding-QM5DY2TU.cjs +11 -0
- package/dist/openai-5HQGBL4L.js +9 -0
- package/dist/openai-656VWUQW.cjs +9 -0
- package/dist/plugins/loader.d.ts +72 -0
- package/dist/plugins/types.d.ts +4 -0
- package/dist/preset/index.d.ts +60 -0
- package/dist/product/define.d.ts +60 -0
- package/dist/product/index.cjs +23 -0
- package/dist/product/index.d.ts +5 -0
- package/dist/product/index.js +23 -0
- package/dist/product/types.d.ts +116 -0
- package/dist/prompt/composer.d.ts +42 -0
- package/dist/prompt/instruction-scanner.d.ts +54 -0
- package/dist/prompt/section-cache.d.ts +15 -0
- package/dist/prompt/section-loader.d.ts +26 -0
- package/dist/protocol/client.d.ts +64 -0
- package/dist/protocol/index.d.ts +4 -0
- package/dist/protocol/server.d.ts +49 -0
- package/dist/protocol/transport.d.ts +36 -0
- package/dist/protocol/types.d.ts +150 -0
- package/dist/react-compiler-runtime-shim.d.ts +1 -0
- package/dist/remote/bridge.d.ts +37 -0
- package/dist/run/ArtifactTracker.d.ts +38 -0
- package/dist/run/CheckpointWriter.d.ts +53 -0
- package/dist/run/EngineRunner.d.ts +70 -0
- package/dist/run/Evaluator.d.ts +56 -0
- package/dist/run/FileRunStore.d.ts +39 -0
- package/dist/run/Heartbeat.d.ts +54 -0
- package/dist/run/RunApprovalBackend.d.ts +53 -0
- package/dist/run/RunLock.d.ts +40 -0
- package/dist/run/RunManager.d.ts +76 -0
- package/dist/run/RunQueue.d.ts +27 -0
- package/dist/run/RunStore.d.ts +25 -0
- package/dist/run/factory.d.ts +57 -0
- package/dist/run/index.cjs +50 -0
- package/dist/run/index.d.ts +17 -0
- package/dist/run/index.js +50 -0
- package/dist/run/types.d.ts +136 -0
- package/dist/services/analytics.d.ts +29 -0
- package/dist/services/auto-dream.d.ts +35 -0
- package/dist/services/compact.d.ts +56 -0
- package/dist/services/diagnostics.d.ts +41 -0
- package/dist/services/extract-memories.d.ts +27 -0
- package/dist/services/index.d.ts +11 -0
- package/dist/services/notifier.d.ts +25 -0
- package/dist/services/oauth.d.ts +27 -0
- package/dist/services/session-memory.d.ts +37 -0
- package/dist/session/file-history.d.ts +41 -0
- package/dist/session/memory.d.ts +45 -0
- package/dist/session/session-manager.d.ts +23 -0
- package/dist/session/transcript.d.ts +39 -0
- package/dist/session-manager-JIIBCFTC.js +8 -0
- package/dist/session-manager-UQKB564H.cjs +8 -0
- package/dist/settings/manager.d.ts +27 -0
- package/dist/settings/schema.d.ts +676 -0
- package/dist/skills/index.d.ts +7 -0
- package/dist/skills/matcher.d.ts +21 -0
- package/dist/skills/scanner.d.ts +30 -0
- package/dist/skills-63RBYQRX.js +13 -0
- package/dist/skills-V3BPLW3D.cjs +13 -0
- package/dist/token-counter-CHAXW5O7.cjs +13 -0
- package/dist/token-counter-DSOZGZ5Q.js +13 -0
- package/dist/tool-summary-5P2GKRA4.cjs +31 -0
- package/dist/tool-summary-J2ICNMWP.js +31 -0
- package/dist/tool-system/builtin/agent.d.ts +35 -0
- package/dist/tool-system/builtin/arena.d.ts +18 -0
- package/dist/tool-system/builtin/ask-user.d.ts +12 -0
- package/dist/tool-system/builtin/bash.d.ts +6 -0
- package/dist/tool-system/builtin/brief.d.ts +6 -0
- package/dist/tool-system/builtin/config.d.ts +6 -0
- package/dist/tool-system/builtin/cron.d.ts +10 -0
- package/dist/tool-system/builtin/edit.d.ts +6 -0
- package/dist/tool-system/builtin/file-cache.d.ts +11 -0
- package/dist/tool-system/builtin/glob.d.ts +6 -0
- package/dist/tool-system/builtin/grep.d.ts +6 -0
- package/dist/tool-system/builtin/index.d.ts +10 -0
- package/dist/tool-system/builtin/lsp.d.ts +6 -0
- package/dist/tool-system/builtin/mcp-tools.d.ts +10 -0
- package/dist/tool-system/builtin/notebook-edit.d.ts +6 -0
- package/dist/tool-system/builtin/plan.d.ts +18 -0
- package/dist/tool-system/builtin/powershell.d.ts +6 -0
- package/dist/tool-system/builtin/read.d.ts +6 -0
- package/dist/tool-system/builtin/remote-trigger.d.ts +6 -0
- package/dist/tool-system/builtin/repl.d.ts +6 -0
- package/dist/tool-system/builtin/send-message.d.ts +6 -0
- package/dist/tool-system/builtin/skill.d.ts +6 -0
- package/dist/tool-system/builtin/sleep.d.ts +6 -0
- package/dist/tool-system/builtin/task.d.ts +51 -0
- package/dist/tool-system/builtin/tool-search.d.ts +12 -0
- package/dist/tool-system/builtin/web-fetch.d.ts +6 -0
- package/dist/tool-system/builtin/web-search.d.ts +6 -0
- package/dist/tool-system/builtin/worktree.d.ts +10 -0
- package/dist/tool-system/builtin/write.d.ts +6 -0
- package/dist/tool-system/executor.d.ts +25 -0
- package/dist/tool-system/mcp-manager.d.ts +50 -0
- package/dist/tool-system/permission.d.ts +69 -0
- package/dist/tool-system/registry.d.ts +24 -0
- package/dist/tool-system/validation.d.ts +5 -0
- package/dist/types.d.ts +260 -0
- package/dist/ui/App.d.ts +14 -0
- package/dist/ui/components/AgentBlock.d.ts +32 -0
- package/dist/ui/components/BabyHand.d.ts +1 -0
- package/dist/ui/components/Banner.d.ts +8 -0
- package/dist/ui/components/CodeBlock.d.ts +7 -0
- package/dist/ui/components/CommandInput.d.ts +13 -0
- package/dist/ui/components/ContextUsageBar.d.ts +7 -0
- package/dist/ui/components/DiffView.d.ts +6 -0
- package/dist/ui/components/DogLogo.d.ts +1 -0
- package/dist/ui/components/FullscreenLayout.d.ts +51 -0
- package/dist/ui/components/KunHead.d.ts +1 -0
- package/dist/ui/components/KunLogo.d.ts +1 -0
- package/dist/ui/components/MessageContent.d.ts +22 -0
- package/dist/ui/components/PermissionDialog.d.ts +8 -0
- package/dist/ui/components/PermissionPrompt.d.ts +8 -0
- package/dist/ui/components/ScrollView.d.ts +34 -0
- package/dist/ui/components/Spinner.d.ts +8 -0
- package/dist/ui/components/SpinnerWithVerb.d.ts +13 -0
- package/dist/ui/components/StatusLine.d.ts +22 -0
- package/dist/ui/components/StructuredDiff.d.ts +8 -0
- package/dist/ui/components/TaskList.d.ts +6 -0
- package/dist/ui/components/TextInput.d.ts +9 -0
- package/dist/ui/components/ThemedBox.d.ts +19 -0
- package/dist/ui/components/ThemedText.d.ts +26 -0
- package/dist/ui/components/ToolCall.d.ts +21 -0
- package/dist/ui/components/VirtualMessageList.d.ts +24 -0
- package/dist/ui/hooks/useCostSummary.d.ts +1 -0
- package/dist/ui/index.d.ts +12 -0
- package/dist/ui/input-history.d.ts +61 -0
- package/dist/ui/store.d.ts +82 -0
- package/dist/ui/terminal-renderer.d.ts +45 -0
- package/dist/ui/theme.d.ts +36 -0
- package/dist/ui/vim-mode.d.ts +25 -0
- package/dist/updater-AVD4LKTQ.js +183 -0
- package/dist/updater-URVNPDPW.cjs +183 -0
- package/dist/utils/debug.d.ts +57 -0
- package/dist/utils/earlyInput.d.ts +43 -0
- package/dist/utils/env.d.ts +24 -0
- package/dist/utils/envUtils.d.ts +51 -0
- package/dist/utils/execFileNoThrow.d.ts +39 -0
- package/dist/utils/format.d.ts +44 -0
- package/dist/utils/fullscreen.d.ts +47 -0
- package/dist/utils/intl.d.ts +22 -0
- package/dist/utils/lockfile.d.ts +15 -0
- package/dist/utils/log.d.ts +56 -0
- package/dist/utils/semver.d.ts +5 -0
- package/dist/utils/sliceAnsi.d.ts +12 -0
- package/dist/utils/systemTheme.d.ts +40 -0
- package/dist/utils/theme.d.ts +91 -0
- package/dist/utils/toolDisplay.d.ts +31 -0
- package/dist/utils/truncate.d.ts +40 -0
- package/dist/voice/index.d.ts +35 -0
- package/dist/voice-KTZ7PAGO.js +80 -0
- package/dist/voice-KZE25GKB.cjs +80 -0
- package/package.json +130 -0
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_esm_shims
|
|
3
|
+
} from "./chunk-DI7RDLOS.js";
|
|
4
|
+
|
|
5
|
+
// src/cli/onboarding.ts
|
|
6
|
+
init_esm_shims();
|
|
7
|
+
import chalk from "chalk";
|
|
8
|
+
import { mkdirSync, writeFileSync, readFileSync, existsSync } from "fs";
|
|
9
|
+
import { join } from "path";
|
|
10
|
+
import { homedir } from "os";
|
|
11
|
+
var PROVIDERS = [
|
|
12
|
+
{
|
|
13
|
+
id: "openrouter",
|
|
14
|
+
name: "OpenRouter (\u63A8\u8350 \u2014 \u652F\u6301\u6240\u6709\u6A21\u578B)",
|
|
15
|
+
envKey: "OPENROUTER_API_KEY",
|
|
16
|
+
provider: "openai",
|
|
17
|
+
baseUrl: "https://openrouter.ai/api/v1",
|
|
18
|
+
defaultModel: "anthropic/claude-sonnet-4.6",
|
|
19
|
+
keyUrl: "https://openrouter.ai/keys",
|
|
20
|
+
keyPrefix: "sk-or-",
|
|
21
|
+
models: [
|
|
22
|
+
"anthropic/claude-opus-4.6",
|
|
23
|
+
"anthropic/claude-sonnet-4.6",
|
|
24
|
+
"anthropic/claude-haiku-4.5",
|
|
25
|
+
"openai/gpt-5.4",
|
|
26
|
+
"openai/gpt-4o",
|
|
27
|
+
"openai/o4-mini",
|
|
28
|
+
"google/gemini-3.1-pro-preview",
|
|
29
|
+
"google/gemini-3-flash-preview",
|
|
30
|
+
"google/gemini-2.5-pro",
|
|
31
|
+
"deepseek/deepseek-v3.2",
|
|
32
|
+
"deepseek/deepseek-r1",
|
|
33
|
+
"qwen/qwen3-coder",
|
|
34
|
+
"qwen/qwen3-235b-a22b",
|
|
35
|
+
"meta-llama/llama-4-maverick",
|
|
36
|
+
"mistralai/devstral-medium"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "anthropic",
|
|
41
|
+
name: "Anthropic (\u76F4\u8FDE Claude API)",
|
|
42
|
+
envKey: "ANTHROPIC_API_KEY",
|
|
43
|
+
provider: "anthropic",
|
|
44
|
+
baseUrl: "https://api.anthropic.com",
|
|
45
|
+
defaultModel: "claude-sonnet-4-6",
|
|
46
|
+
keyUrl: "https://console.anthropic.com/settings/keys",
|
|
47
|
+
keyPrefix: "sk-ant-",
|
|
48
|
+
models: [
|
|
49
|
+
"claude-opus-4-6",
|
|
50
|
+
"claude-sonnet-4-6",
|
|
51
|
+
"claude-haiku-4-5"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: "openai",
|
|
56
|
+
name: "OpenAI",
|
|
57
|
+
envKey: "OPENAI_API_KEY",
|
|
58
|
+
provider: "openai",
|
|
59
|
+
baseUrl: "https://api.openai.com/v1",
|
|
60
|
+
defaultModel: "gpt-5.4",
|
|
61
|
+
keyUrl: "https://platform.openai.com/api-keys",
|
|
62
|
+
keyPrefix: "sk-",
|
|
63
|
+
models: ["gpt-5.4", "gpt-5.4-mini", "gpt-4o", "o4-mini", "o3"]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "custom",
|
|
67
|
+
name: "\u81EA\u5B9A\u4E49 (\u4EFB\u4F55 OpenAI \u517C\u5BB9 API)",
|
|
68
|
+
envKey: "",
|
|
69
|
+
provider: "openai",
|
|
70
|
+
baseUrl: "",
|
|
71
|
+
defaultModel: "",
|
|
72
|
+
keyUrl: "",
|
|
73
|
+
keyPrefix: "",
|
|
74
|
+
models: []
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
var BACK = /* @__PURE__ */ Symbol("back");
|
|
78
|
+
function arrowSelect(options, title, opts) {
|
|
79
|
+
return new Promise((resolve, reject) => {
|
|
80
|
+
let cursor = 0;
|
|
81
|
+
const stdin = process.stdin;
|
|
82
|
+
const allowBack = opts?.allowBack ?? true;
|
|
83
|
+
if (typeof stdin.setRawMode !== "function") {
|
|
84
|
+
reject(new Error("Interactive onboarding requires a TTY. Set an API key via environment variable instead."));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const wasRaw = stdin.isRaw;
|
|
88
|
+
const wasFlowing = stdin.readableFlowing;
|
|
89
|
+
const backHint = allowBack ? chalk.dim(" (ESC \u8FD4\u56DE)") : "";
|
|
90
|
+
function render() {
|
|
91
|
+
const lines = options.length + 1;
|
|
92
|
+
process.stdout.write(`\x1B[${lines}A\x1B[J`);
|
|
93
|
+
console.log(chalk.dim(` ${title}`) + backHint);
|
|
94
|
+
for (let i = 0; i < options.length; i++) {
|
|
95
|
+
const opt = options[i];
|
|
96
|
+
const selected = i === cursor;
|
|
97
|
+
const prefix = selected ? chalk.cyan("\u276F ") : " ";
|
|
98
|
+
const label = selected ? chalk.bold.cyan(opt.label) : chalk.white(opt.label);
|
|
99
|
+
const hint = opt.hint ? chalk.dim(` ${opt.hint}`) : "";
|
|
100
|
+
console.log(` ${prefix}${label}${hint}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
console.log(chalk.dim(` ${title}`) + backHint);
|
|
104
|
+
for (const opt of options) {
|
|
105
|
+
const hint = opt.hint ? chalk.dim(` ${opt.hint}`) : "";
|
|
106
|
+
console.log(` ${opt.label}${hint}`);
|
|
107
|
+
}
|
|
108
|
+
render();
|
|
109
|
+
stdin.setRawMode(true);
|
|
110
|
+
stdin.resume();
|
|
111
|
+
function onData(data) {
|
|
112
|
+
const key = data.toString();
|
|
113
|
+
if (key === "\x1B[A" || key === "k") {
|
|
114
|
+
cursor = cursor > 0 ? cursor - 1 : options.length - 1;
|
|
115
|
+
render();
|
|
116
|
+
} else if (key === "\x1B[B" || key === "j") {
|
|
117
|
+
cursor = cursor < options.length - 1 ? cursor + 1 : 0;
|
|
118
|
+
render();
|
|
119
|
+
} else if (key === "\r" || key === "\n") {
|
|
120
|
+
cleanup();
|
|
121
|
+
resolve(options[cursor].value);
|
|
122
|
+
} else if (key === "\x1B" && allowBack) {
|
|
123
|
+
cleanup();
|
|
124
|
+
resolve(BACK);
|
|
125
|
+
} else if (key === "") {
|
|
126
|
+
cleanup();
|
|
127
|
+
process.exit(1);
|
|
128
|
+
} else {
|
|
129
|
+
const num = parseInt(key, 10);
|
|
130
|
+
if (num >= 1 && num <= options.length) {
|
|
131
|
+
cursor = num - 1;
|
|
132
|
+
render();
|
|
133
|
+
cleanup();
|
|
134
|
+
resolve(options[cursor].value);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function cleanup() {
|
|
139
|
+
stdin.removeListener("data", onData);
|
|
140
|
+
stdin.setRawMode(wasRaw ?? false);
|
|
141
|
+
if (wasFlowing) {
|
|
142
|
+
stdin.resume();
|
|
143
|
+
} else {
|
|
144
|
+
stdin.pause();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
stdin.on("data", onData);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function textPrompt(question) {
|
|
151
|
+
return new Promise((resolve, reject) => {
|
|
152
|
+
const stdin = process.stdin;
|
|
153
|
+
let buffer = "";
|
|
154
|
+
if (typeof stdin.setRawMode !== "function") {
|
|
155
|
+
reject(new Error("Interactive onboarding requires a TTY. Set an API key via environment variable instead."));
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const wasRaw = stdin.isRaw;
|
|
159
|
+
const wasFlowing = stdin.readableFlowing;
|
|
160
|
+
process.stdout.write(question);
|
|
161
|
+
stdin.setRawMode(true);
|
|
162
|
+
stdin.resume();
|
|
163
|
+
function onData(data) {
|
|
164
|
+
const ch = data.toString();
|
|
165
|
+
if (ch === "\x1B") {
|
|
166
|
+
cleanup();
|
|
167
|
+
process.stdout.write("\n");
|
|
168
|
+
resolve(BACK);
|
|
169
|
+
} else if (ch === "") {
|
|
170
|
+
cleanup();
|
|
171
|
+
process.exit(1);
|
|
172
|
+
} else if (ch === "\r" || ch === "\n") {
|
|
173
|
+
cleanup();
|
|
174
|
+
process.stdout.write("\n");
|
|
175
|
+
resolve(buffer.trim());
|
|
176
|
+
} else if (ch === "\x7F" || ch === "\b") {
|
|
177
|
+
if (buffer.length > 0) {
|
|
178
|
+
buffer = buffer.slice(0, -1);
|
|
179
|
+
process.stdout.write("\b \b");
|
|
180
|
+
}
|
|
181
|
+
} else if (ch >= " ") {
|
|
182
|
+
buffer += ch;
|
|
183
|
+
process.stdout.write(ch);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function cleanup() {
|
|
187
|
+
stdin.removeListener("data", onData);
|
|
188
|
+
stdin.setRawMode(wasRaw ?? false);
|
|
189
|
+
if (wasFlowing) {
|
|
190
|
+
stdin.resume();
|
|
191
|
+
} else {
|
|
192
|
+
stdin.pause();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
stdin.on("data", onData);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
async function confirm(question) {
|
|
199
|
+
const result = await arrowSelect(
|
|
200
|
+
[
|
|
201
|
+
{ label: "\u662F", value: "yes" },
|
|
202
|
+
{ label: "\u5426", value: "no" }
|
|
203
|
+
],
|
|
204
|
+
question
|
|
205
|
+
);
|
|
206
|
+
if (result === BACK) return BACK;
|
|
207
|
+
return result === "yes";
|
|
208
|
+
}
|
|
209
|
+
async function validateApiKey(baseUrl, apiKey) {
|
|
210
|
+
try {
|
|
211
|
+
if (baseUrl.includes("openrouter")) {
|
|
212
|
+
const res2 = await fetch("https://openrouter.ai/api/v1/auth/key", {
|
|
213
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
214
|
+
});
|
|
215
|
+
const data = await res2.json();
|
|
216
|
+
return !data.error;
|
|
217
|
+
}
|
|
218
|
+
const url = baseUrl.replace(/\/$/, "") + "/models";
|
|
219
|
+
const res = await fetch(url, {
|
|
220
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
221
|
+
});
|
|
222
|
+
return res.status !== 401 && res.status !== 403;
|
|
223
|
+
} catch {
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function hasApiKey() {
|
|
228
|
+
if (process.env.OPENROUTER_API_KEY || process.env.ANTHROPIC_API_KEY || process.env.OPENAI_API_KEY) {
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
const settingsPaths = [
|
|
232
|
+
join(homedir(), ".code-shell", "settings.json"),
|
|
233
|
+
join(homedir(), ".claude", "settings.json")
|
|
234
|
+
];
|
|
235
|
+
for (const p of settingsPaths) {
|
|
236
|
+
if (existsSync(p)) {
|
|
237
|
+
try {
|
|
238
|
+
const data = JSON.parse(readFileSync(p, "utf-8"));
|
|
239
|
+
if (data?.model?.apiKey) return true;
|
|
240
|
+
} catch {
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
async function runOnboarding() {
|
|
247
|
+
console.log();
|
|
248
|
+
console.log(chalk.bold.cyan(" \u2726 Code Shell \u2014 \u9996\u6B21\u914D\u7F6E"));
|
|
249
|
+
console.log(chalk.dim(" \u2500".repeat(25)));
|
|
250
|
+
let step = "provider";
|
|
251
|
+
let selected = PROVIDERS[0];
|
|
252
|
+
let apiKey = "";
|
|
253
|
+
let model = "";
|
|
254
|
+
let poolModels = [];
|
|
255
|
+
while (step !== "done") {
|
|
256
|
+
switch (step) {
|
|
257
|
+
// ─── Step 1: Provider ────────────────────────────────────
|
|
258
|
+
case "provider": {
|
|
259
|
+
console.log();
|
|
260
|
+
const providerId = await arrowSelect(
|
|
261
|
+
PROVIDERS.map((p) => ({ label: p.name, value: p.id })),
|
|
262
|
+
"\u9009\u62E9 API \u63D0\u4F9B\u5546 (\u2191\u2193 \u79FB\u52A8, Enter \u786E\u8BA4):",
|
|
263
|
+
{ allowBack: false }
|
|
264
|
+
// first step, no back
|
|
265
|
+
);
|
|
266
|
+
if (providerId === BACK) break;
|
|
267
|
+
selected = PROVIDERS.find((p) => p.id === providerId);
|
|
268
|
+
if (selected.id === "custom") {
|
|
269
|
+
const customResult = await configureCustomProvider();
|
|
270
|
+
if (customResult === BACK) break;
|
|
271
|
+
saveSettings(customResult);
|
|
272
|
+
printSuccess(selected.name, customResult.model);
|
|
273
|
+
return customResult;
|
|
274
|
+
}
|
|
275
|
+
step = "apikey";
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
// ─── Step 2: API Key ─────────────────────────────────────
|
|
279
|
+
case "apikey": {
|
|
280
|
+
console.log();
|
|
281
|
+
if (selected.keyUrl) {
|
|
282
|
+
console.log(chalk.dim(` \u83B7\u53D6 API Key: ${chalk.underline(selected.keyUrl)}`));
|
|
283
|
+
}
|
|
284
|
+
console.log();
|
|
285
|
+
const keyResult = await textPrompt(chalk.cyan(` ${selected.envKey || "API Key"}: `));
|
|
286
|
+
if (keyResult === BACK) {
|
|
287
|
+
step = "provider";
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
if (!keyResult) {
|
|
291
|
+
console.log(chalk.yellow(" \u26A0 \u8BF7\u8F93\u5165 API Key (ESC \u8FD4\u56DE\u4E0A\u4E00\u6B65)"));
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
process.stdout.write(chalk.dim(" \u9A8C\u8BC1 Key..."));
|
|
295
|
+
const valid = await validateApiKey(selected.baseUrl, keyResult);
|
|
296
|
+
if (!valid) {
|
|
297
|
+
console.log(chalk.red(" \u2717 \u65E0\u6548"));
|
|
298
|
+
console.log(chalk.yellow(" \u26A0 API Key \u9A8C\u8BC1\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u540E\u91CD\u8BD5 (ESC \u8FD4\u56DE\u4E0A\u4E00\u6B65)"));
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
console.log(chalk.green(" \u2713"));
|
|
302
|
+
apiKey = keyResult;
|
|
303
|
+
step = "model_pool";
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
// ─── Step 3: Model Pool — select which models to enable ──
|
|
307
|
+
case "model_pool": {
|
|
308
|
+
if (selected.models.length <= 1) {
|
|
309
|
+
poolModels = [...selected.models];
|
|
310
|
+
model = selected.defaultModel;
|
|
311
|
+
step = "arena_ask";
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
console.log();
|
|
315
|
+
console.log(chalk.dim(" \u9009\u62E9\u8981\u52A0\u5165\u6A21\u578B\u6C60\u7684\u6A21\u578B (\u6A21\u578B\u6C60\u4E2D\u7684\u6A21\u578B\u53EF\u901A\u8FC7 /model \u968F\u65F6\u5207\u6362)"));
|
|
316
|
+
const poolResult = await selectModelPool(selected.models, selected.defaultModel);
|
|
317
|
+
if (poolResult === BACK) {
|
|
318
|
+
step = "apikey";
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
poolModels = poolResult;
|
|
322
|
+
if (poolModels.length === 0) {
|
|
323
|
+
poolModels = [selected.defaultModel];
|
|
324
|
+
}
|
|
325
|
+
step = "default_model";
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
// ─── Step 4: Default Model — pick from pool ──────────────
|
|
329
|
+
case "default_model": {
|
|
330
|
+
if (poolModels.length === 1) {
|
|
331
|
+
model = poolModels[0];
|
|
332
|
+
saveSettings({ provider: selected.provider, model, apiKey, baseUrl: selected.baseUrl }, selected, poolModels);
|
|
333
|
+
step = "arena_ask";
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
console.log();
|
|
337
|
+
const modelResult = await arrowSelect(
|
|
338
|
+
poolModels.map((m) => ({
|
|
339
|
+
label: m,
|
|
340
|
+
value: m,
|
|
341
|
+
hint: m === selected.defaultModel ? "(\u63A8\u8350)" : void 0
|
|
342
|
+
})),
|
|
343
|
+
"\u9009\u62E9\u9ED8\u8BA4\u6A21\u578B (\u65E5\u5E38\u5BF9\u8BDD\u4F7F\u7528):"
|
|
344
|
+
);
|
|
345
|
+
if (modelResult === BACK) {
|
|
346
|
+
step = "model_pool";
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
model = modelResult;
|
|
350
|
+
saveSettings({ provider: selected.provider, model, apiKey, baseUrl: selected.baseUrl }, selected, poolModels);
|
|
351
|
+
step = "arena_ask";
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
// ─── Step 5: Arena? ─────────────────────────────────────
|
|
355
|
+
case "arena_ask": {
|
|
356
|
+
saveSettings({ provider: selected.provider, model, apiKey, baseUrl: selected.baseUrl }, selected, poolModels);
|
|
357
|
+
if (poolModels.length < 2) {
|
|
358
|
+
step = "done";
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
console.log();
|
|
362
|
+
const wantArena = await confirm("\u662F\u5426\u914D\u7F6E Arena \u591A\u6A21\u578B\u5BF9\u6BD4? (\u53EF\u5728 /arena \u4E2D\u4F7F\u7528\u591A\u4E2A\u6A21\u578B)");
|
|
363
|
+
if (wantArena === BACK) {
|
|
364
|
+
step = "default_model";
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
if (wantArena) {
|
|
368
|
+
step = "arena_config";
|
|
369
|
+
} else {
|
|
370
|
+
step = "done";
|
|
371
|
+
}
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
// ─── Step 6: Arena config — pick from pool ───────────────
|
|
375
|
+
case "arena_config": {
|
|
376
|
+
await configureArenaFromPool(poolModels, model);
|
|
377
|
+
step = "done";
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
const result = { provider: selected.provider, model, apiKey, baseUrl: selected.baseUrl };
|
|
383
|
+
printSuccess(selected.name, model);
|
|
384
|
+
const stdin = process.stdin;
|
|
385
|
+
if (typeof stdin.setRawMode === "function") {
|
|
386
|
+
stdin.setRawMode(false);
|
|
387
|
+
}
|
|
388
|
+
stdin.removeAllListeners("data");
|
|
389
|
+
return result;
|
|
390
|
+
}
|
|
391
|
+
async function selectModelPool(available, defaultModel) {
|
|
392
|
+
const preselected = /* @__PURE__ */ new Set();
|
|
393
|
+
preselected.add(defaultModel);
|
|
394
|
+
const selected = new Set(preselected);
|
|
395
|
+
while (true) {
|
|
396
|
+
console.log();
|
|
397
|
+
console.log(chalk.dim(" \u5F53\u524D\u6A21\u578B\u6C60:"));
|
|
398
|
+
if (selected.size === 0) {
|
|
399
|
+
console.log(chalk.dim(" (\u7A7A)"));
|
|
400
|
+
} else {
|
|
401
|
+
for (const m of selected) {
|
|
402
|
+
console.log(` ${chalk.cyan("\u2713")} ${m}`);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
console.log();
|
|
406
|
+
const notInPool = available.filter((m) => !selected.has(m));
|
|
407
|
+
const options = [
|
|
408
|
+
...notInPool.length > 0 ? [{ label: "\u6DFB\u52A0\u6A21\u578B", value: "add" }] : [],
|
|
409
|
+
...selected.size > 0 ? [{ label: "\u79FB\u9664\u6A21\u578B", value: "remove" }] : [],
|
|
410
|
+
{ label: selected.size > 0 ? `\u2713 \u786E\u8BA4 (${selected.size} \u4E2A\u6A21\u578B)` : "\u8DF3\u8FC7", value: "done" }
|
|
411
|
+
];
|
|
412
|
+
const action = await arrowSelect(options, "\u6A21\u578B\u6C60\u64CD\u4F5C:", { allowBack: true });
|
|
413
|
+
if (action === BACK) return BACK;
|
|
414
|
+
if (action === "done") return [...selected];
|
|
415
|
+
if (action === "add") {
|
|
416
|
+
console.log();
|
|
417
|
+
const choice = await arrowSelect(
|
|
418
|
+
notInPool.map((m) => ({
|
|
419
|
+
label: m,
|
|
420
|
+
value: m,
|
|
421
|
+
hint: m === defaultModel ? "(\u63A8\u8350)" : void 0
|
|
422
|
+
})),
|
|
423
|
+
"\u6DFB\u52A0\u5230\u6A21\u578B\u6C60:"
|
|
424
|
+
);
|
|
425
|
+
if (choice !== BACK) {
|
|
426
|
+
selected.add(choice);
|
|
427
|
+
console.log(chalk.green(` \u2713 \u5DF2\u6DFB\u52A0: ${modelDisplayName(choice)}`));
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
if (action === "remove") {
|
|
431
|
+
const inPool = [...selected];
|
|
432
|
+
console.log();
|
|
433
|
+
const choice = await arrowSelect(
|
|
434
|
+
inPool.map((m) => ({ label: m, value: m })),
|
|
435
|
+
"\u4ECE\u6A21\u578B\u6C60\u79FB\u9664:"
|
|
436
|
+
);
|
|
437
|
+
if (choice !== BACK) {
|
|
438
|
+
selected.delete(choice);
|
|
439
|
+
console.log(chalk.yellow(` \u2717 \u5DF2\u79FB\u9664: ${modelDisplayName(choice)}`));
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
async function configureArenaFromPool(poolModels, defaultModel) {
|
|
445
|
+
const participants = /* @__PURE__ */ new Set();
|
|
446
|
+
console.log();
|
|
447
|
+
console.log(chalk.dim(` \u4ECE\u6A21\u578B\u6C60\u4E2D\u9009\u62E9\u53C2\u4E0E Arena \u5BF9\u6BD4\u7684\u6A21\u578B (\u9ED8\u8BA4\u5BF9\u8BDD\u6A21\u578B: ${chalk.white(defaultModel)})`));
|
|
448
|
+
while (true) {
|
|
449
|
+
console.log();
|
|
450
|
+
if (participants.size > 0) {
|
|
451
|
+
console.log(chalk.dim(" \u5F53\u524D Arena \u9635\u5BB9:"));
|
|
452
|
+
let idx = 0;
|
|
453
|
+
for (const m of participants) {
|
|
454
|
+
idx++;
|
|
455
|
+
console.log(` ${chalk.dim(`${idx}.`)} ${chalk.cyan(modelDisplayName(m))} ${chalk.dim(`(${m})`)}`);
|
|
456
|
+
}
|
|
457
|
+
} else {
|
|
458
|
+
console.log(chalk.dim(" \u5F53\u524D Arena \u9635\u5BB9: (\u7A7A)"));
|
|
459
|
+
}
|
|
460
|
+
console.log();
|
|
461
|
+
const notInArena = poolModels.filter((m) => !participants.has(m));
|
|
462
|
+
const options = [
|
|
463
|
+
...notInArena.length > 0 ? [{ label: "\u4ECE\u6A21\u578B\u6C60\u6DFB\u52A0", value: "add" }] : [],
|
|
464
|
+
...participants.size > 0 ? [{ label: "\u79FB\u9664\u6700\u540E\u6DFB\u52A0\u7684", value: "remove" }] : [],
|
|
465
|
+
{
|
|
466
|
+
label: participants.size >= 2 ? `\u2713 \u5B8C\u6210\u914D\u7F6E (${participants.size} \u4E2A\u6A21\u578B)` : "\u8DF3\u8FC7 (\u81F3\u5C11\u9700\u8981 2 \u4E2A\u6A21\u578B)",
|
|
467
|
+
value: "done"
|
|
468
|
+
}
|
|
469
|
+
];
|
|
470
|
+
const action = await arrowSelect(options, "\u64CD\u4F5C:", { allowBack: true });
|
|
471
|
+
if (action === BACK || action === "done") break;
|
|
472
|
+
if (action === "add") {
|
|
473
|
+
console.log();
|
|
474
|
+
const choice = await arrowSelect(
|
|
475
|
+
notInArena.map((m) => ({ label: `${modelDisplayName(m)} ${chalk.dim(m)}`, value: m })),
|
|
476
|
+
"\u9009\u62E9\u6A21\u578B:"
|
|
477
|
+
);
|
|
478
|
+
if (choice !== BACK) {
|
|
479
|
+
participants.add(choice);
|
|
480
|
+
console.log(chalk.green(` \u2713 \u5DF2\u6DFB\u52A0: ${modelDisplayName(choice)}`));
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (action === "remove" && participants.size > 0) {
|
|
484
|
+
const arr = [...participants];
|
|
485
|
+
const removed = arr.pop();
|
|
486
|
+
participants.delete(removed);
|
|
487
|
+
console.log(chalk.yellow(` \u2717 \u5DF2\u79FB\u9664: ${modelDisplayName(removed)}`));
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
if (participants.size >= 2) {
|
|
491
|
+
const arenaKeys = [...participants].map((m) => modelKey(m));
|
|
492
|
+
saveArenaSettingsByKeys(arenaKeys);
|
|
493
|
+
console.log();
|
|
494
|
+
console.log(chalk.green(` \u2713 Arena \u5DF2\u914D\u7F6E ${participants.size} \u4E2A\u6A21\u578B`));
|
|
495
|
+
} else {
|
|
496
|
+
console.log(chalk.dim(" \u8DF3\u8FC7 Arena \u914D\u7F6E (\u9700\u8981\u81F3\u5C11 2 \u4E2A\u6A21\u578B)"));
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
async function configureCustomProvider() {
|
|
500
|
+
console.log();
|
|
501
|
+
const baseUrl = await textPrompt(chalk.cyan(" API Base URL: "));
|
|
502
|
+
if (baseUrl === BACK) return BACK;
|
|
503
|
+
const apiKey = await textPrompt(chalk.cyan(" API Key: "));
|
|
504
|
+
if (apiKey === BACK) return BACK;
|
|
505
|
+
const model = await textPrompt(chalk.cyan(" \u6A21\u578B\u540D\u79F0: "));
|
|
506
|
+
if (model === BACK) return BACK;
|
|
507
|
+
return {
|
|
508
|
+
provider: "openai",
|
|
509
|
+
model: model || "gpt-4o",
|
|
510
|
+
apiKey: apiKey || "",
|
|
511
|
+
baseUrl: baseUrl || "http://localhost:11434/v1"
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
var KNOWN_MAX_OUTPUT = {
|
|
515
|
+
"anthropic/claude-opus-4.6": 32e3,
|
|
516
|
+
"anthropic/claude-opus-4-6": 32e3,
|
|
517
|
+
"claude-opus-4-6": 32e3,
|
|
518
|
+
"anthropic/claude-sonnet-4.6": 16e3,
|
|
519
|
+
"anthropic/claude-sonnet-4-6": 16e3,
|
|
520
|
+
"claude-sonnet-4-6": 16e3,
|
|
521
|
+
"anthropic/claude-haiku-4.5": 8192,
|
|
522
|
+
"anthropic/claude-haiku-4-5": 8192,
|
|
523
|
+
"claude-haiku-4-5": 8192,
|
|
524
|
+
"openai/gpt-5.4": 32e3,
|
|
525
|
+
"gpt-5.4": 32e3,
|
|
526
|
+
"openai/gpt-4o": 16384,
|
|
527
|
+
"gpt-4o": 16384,
|
|
528
|
+
"openai/o4-mini": 1e5,
|
|
529
|
+
"o4-mini": 1e5,
|
|
530
|
+
"openai/o3": 1e5,
|
|
531
|
+
"o3": 1e5,
|
|
532
|
+
"google/gemini-3.1-pro-preview": 65536,
|
|
533
|
+
"google/gemini-3-flash-preview": 65536,
|
|
534
|
+
"google/gemini-2.5-pro": 65536,
|
|
535
|
+
"deepseek/deepseek-v3.2": 8192,
|
|
536
|
+
"deepseek/deepseek-r1": 8192,
|
|
537
|
+
"qwen/qwen3-coder": 16384,
|
|
538
|
+
"qwen/qwen3-235b-a22b": 8192,
|
|
539
|
+
"meta-llama/llama-4-maverick": 32e3,
|
|
540
|
+
"mistralai/devstral-medium": 24e3
|
|
541
|
+
};
|
|
542
|
+
function modelKey(model) {
|
|
543
|
+
const slash = model.lastIndexOf("/");
|
|
544
|
+
const base = slash >= 0 ? model.slice(slash + 1) : model;
|
|
545
|
+
if (base.startsWith("claude-")) {
|
|
546
|
+
const parts = base.split("-");
|
|
547
|
+
return parts.length >= 2 ? `${parts[0]}-${parts[1]}` : parts[0];
|
|
548
|
+
}
|
|
549
|
+
if (base.startsWith("gpt-")) {
|
|
550
|
+
const rest = base.slice(4);
|
|
551
|
+
if (/^\d/.test(rest)) return "gpt";
|
|
552
|
+
return `gpt${rest.split("-")[0]}`;
|
|
553
|
+
}
|
|
554
|
+
if (base.startsWith("gemini-")) {
|
|
555
|
+
if (base.includes("flash")) return "gemini-flash";
|
|
556
|
+
if (base.includes("pro")) return "gemini-pro";
|
|
557
|
+
return "gemini";
|
|
558
|
+
}
|
|
559
|
+
if (base.startsWith("deepseek-")) {
|
|
560
|
+
if (base.includes("r1")) return "deepseek-r1";
|
|
561
|
+
return "deepseek";
|
|
562
|
+
}
|
|
563
|
+
if (base.startsWith("qwen")) {
|
|
564
|
+
if (base.includes("coder")) return "qwen-coder";
|
|
565
|
+
return "qwen";
|
|
566
|
+
}
|
|
567
|
+
if (/^o\d/.test(base)) return base.split("-")[0];
|
|
568
|
+
if (base.startsWith("llama")) return "llama";
|
|
569
|
+
if (base.startsWith("devstral")) return "devstral";
|
|
570
|
+
return base.split("-")[0] ?? base;
|
|
571
|
+
}
|
|
572
|
+
function buildModelPool(provider, apiKey) {
|
|
573
|
+
return provider.models.map((m) => ({
|
|
574
|
+
key: modelKey(m),
|
|
575
|
+
label: modelDisplayName(m),
|
|
576
|
+
provider: provider.provider,
|
|
577
|
+
model: m,
|
|
578
|
+
baseUrl: provider.baseUrl,
|
|
579
|
+
apiKey,
|
|
580
|
+
maxOutputTokens: KNOWN_MAX_OUTPUT[m]
|
|
581
|
+
}));
|
|
582
|
+
}
|
|
583
|
+
function modelDisplayName(model) {
|
|
584
|
+
const slash = model.lastIndexOf("/");
|
|
585
|
+
const base = slash >= 0 ? model.slice(slash + 1) : model;
|
|
586
|
+
const parts = base.split("-");
|
|
587
|
+
if (parts[0] === "claude") {
|
|
588
|
+
const variant = parts[1] ?? "";
|
|
589
|
+
return `Claude ${variant.charAt(0).toUpperCase() + variant.slice(1)}`;
|
|
590
|
+
}
|
|
591
|
+
if (base.startsWith("gpt-")) return `GPT-${parts.slice(1).join("-")}`;
|
|
592
|
+
if (base.startsWith("gemini-")) return `Gemini ${parts.slice(1).join("-")}`;
|
|
593
|
+
return base.charAt(0).toUpperCase() + base.slice(1);
|
|
594
|
+
}
|
|
595
|
+
function printSuccess(providerName, model) {
|
|
596
|
+
console.log();
|
|
597
|
+
console.log(chalk.green(" \u2713 \u914D\u7F6E\u5DF2\u4FDD\u5B58"));
|
|
598
|
+
console.log(chalk.dim(` Provider: ${providerName}`));
|
|
599
|
+
console.log(chalk.dim(` Model: ${model}`));
|
|
600
|
+
console.log(chalk.dim(` Config: ~/.code-shell/settings.json`));
|
|
601
|
+
console.log();
|
|
602
|
+
}
|
|
603
|
+
function saveSettings(result, providerDef, poolModels) {
|
|
604
|
+
const dir = join(homedir(), ".code-shell");
|
|
605
|
+
const file = join(dir, "settings.json");
|
|
606
|
+
mkdirSync(dir, { recursive: true });
|
|
607
|
+
let existing = {};
|
|
608
|
+
if (existsSync(file)) {
|
|
609
|
+
try {
|
|
610
|
+
existing = JSON.parse(readFileSync(file, "utf-8"));
|
|
611
|
+
} catch {
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
const updated = {
|
|
615
|
+
...existing,
|
|
616
|
+
model: {
|
|
617
|
+
...typeof existing.model === "object" ? existing.model : {},
|
|
618
|
+
provider: result.provider,
|
|
619
|
+
name: result.model,
|
|
620
|
+
apiKey: result.apiKey,
|
|
621
|
+
baseUrl: result.baseUrl
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
if (providerDef && poolModels && poolModels.length > 0) {
|
|
625
|
+
const allEntries = buildModelPool(providerDef, result.apiKey);
|
|
626
|
+
const selectedSet = new Set(poolModels);
|
|
627
|
+
updated.models = allEntries.filter((e) => selectedSet.has(e.model));
|
|
628
|
+
}
|
|
629
|
+
writeFileSync(file, JSON.stringify(updated, null, 2) + "\n", "utf-8");
|
|
630
|
+
}
|
|
631
|
+
function saveArenaSettingsByKeys(keys) {
|
|
632
|
+
const dir = join(homedir(), ".code-shell");
|
|
633
|
+
const file = join(dir, "settings.json");
|
|
634
|
+
let existing = {};
|
|
635
|
+
if (existsSync(file)) {
|
|
636
|
+
try {
|
|
637
|
+
existing = JSON.parse(readFileSync(file, "utf-8"));
|
|
638
|
+
} catch {
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
const updated = {
|
|
642
|
+
...existing,
|
|
643
|
+
arena: { participants: keys }
|
|
644
|
+
};
|
|
645
|
+
writeFileSync(file, JSON.stringify(updated, null, 2) + "\n", "utf-8");
|
|
646
|
+
}
|
|
647
|
+
async function reconfigure() {
|
|
648
|
+
const file = join(homedir(), ".code-shell", "settings.json");
|
|
649
|
+
if (existsSync(file)) {
|
|
650
|
+
try {
|
|
651
|
+
const settings = JSON.parse(readFileSync(file, "utf-8"));
|
|
652
|
+
delete settings.model?.apiKey;
|
|
653
|
+
writeFileSync(file, JSON.stringify(settings, null, 2) + "\n", "utf-8");
|
|
654
|
+
} catch {
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
return runOnboarding();
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
export {
|
|
661
|
+
hasApiKey,
|
|
662
|
+
runOnboarding,
|
|
663
|
+
reconfigure
|
|
664
|
+
};
|