#!/usr/bin/env bash # shellcheck disable=SC2034 # variables consumed by lib/common.sh # arkclaude — launch Claude Code on Volcengine Ark's Coding Plan # (Anthropic-compatible endpoint). # # Volcengine Ark is a multi-model aggregator — one Coding Plan subscription # gives access to doubao, Kimi, DeepSeek, GLM, MiniMax, and more. # # Endpoint: https://ark.cn-beijing.volces.com/api/coding # # Reads ARK_API_KEY from the environment first, then falls back to # ~/.zshrc / ~/.bashrc / ~/.bash_profile / ~/.profile if not already exported. # # Quick start (no install needed): # chmod +x arkclaude # ./arkclaude # # Optional — make it globally available: # sudo mv arkclaude /usr/local/bin/ && sudo chmod +x /usr/local/bin/arkclaude # # Use: # arkclaude # doubao-seed-2.0-code (default code model) # arkclaude plus # doubao-seed-2.0-pro (balanced flagship) # arkclaude fast # doubao-seed-2.0-lite (cheap / fast) # arkclaude kimi # kimi-k2.7-code (Kimi code model) # arkclaude deepseek # deepseek-v4-pro # arkclaude glm # glm-5.2 # arkclaude minimax # minimax-m2.7 # arkclaude long # request max context window # arkclaude effort max # set reasoning effort (low|medium|high|xhigh|max) # arkclaude update # git pull latest from this repo # arkclaude --help # any remaining flag is forwarded to claude # # Optional env overrides: # ARK_MODEL=doubao-seed-2.0-code # main model (any model on ARK) # ARK_FLASH_MODEL=doubao-seed-2.0-lite # flash / haiku / subagent tier # ARK_BASE_URL=https://.../api/coding # custom Anthropic-compatible base URL # ARK_CTX=1048576 # max context tokens (defaults to 1M with `long`) # ARK_OUTPUT=8000 # cap output tokens # ARK_EFFORT=max # CLAUDE_CODE_EFFORT_LEVEL # # In-session switch: # /model doubao-seed-2.0-lite # switch to the lite tier # /model kimi-k2.7-code # switch to Kimi # /model doubao-seed-2.0-code # switch back to doubao code # set -euo pipefail # Resolve symlink to find the real script directory. _SELF="$0" if [ -L "$_SELF" ]; then _LINK="$(readlink "$_SELF")" case "$_LINK" in /*) _SELF="$_LINK" ;; *) _SELF="$(cd "$(dirname "$_SELF")" && pwd)/$_LINK" ;; esac fi SELF_DIR="$(cd "$(dirname "$_SELF")" && pwd)" if [ -f "$SELF_DIR/lib/common.sh" ]; then source "$SELF_DIR/lib/common.sh" elif [ -f "$SELF_DIR/../lib/common.sh" ]; then source "$SELF_DIR/../lib/common.sh" else echo "arkclaude: cannot find lib/common.sh. Reinstall or cd to repo." >&2; exit 1; fi check_version "arkclaude" "$@" # Handle the update subcommand before the API-key check so it works key-less. if [ $# -gt 0 ] && [ "$1" = "update" ]; then do_update "arkclaude" "ARKCLAUDE_HOME" fi API_KEY="$(resolve_api_key "ARK_API_KEY")" if [ -z "$API_KEY" ]; then echo "❌ ARK_API_KEY not found." >&2 echo " Add one line to ~/.zshrc or ~/.bashrc:" >&2 echo " export ARK_API_KEY=your_ark_api_key" >&2 echo " Get your key at: https://console.volcengine.com/ark" >&2 exit 1 fi BASE_URL="${ARK_BASE_URL:-https://ark.cn-beijing.volces.com/api/coding}" # Default model lineup. PRO_MODEL="${ARK_MODEL:-doubao-seed-2.0-code}" PLUS_MODEL="${ARK_PLUS_MODEL:-doubao-seed-2.0-pro}" FLASH_MODEL="${ARK_FLASH_MODEL:-doubao-seed-2.0-lite}" LONG_CTX=0 EFFORT="${ARK_EFFORT:-}" # Model aliases for quick switching (translate shorthand → full model name). MAIN_MODEL="" while [ $# -gt 0 ]; do case "$1" in # ---- Tier aliases ---- max|pro|code) MAIN_MODEL="$PRO_MODEL"; shift ;; plus) MAIN_MODEL="$PLUS_MODEL"; shift ;; fast|flash|lite) MAIN_MODEL="$FLASH_MODEL"; shift ;; # ---- Provider aliases ---- kimi) MAIN_MODEL="kimi-k2.7-code"; shift ;; kimi-pro|kimi-k2) MAIN_MODEL="kimi-k2.6"; shift ;; deepseek) MAIN_MODEL="deepseek-v4-pro"; shift ;; deepseek-flash) MAIN_MODEL="deepseek-v4-flash"; shift ;; glm) MAIN_MODEL="glm-5.2"; shift ;; minimax) MAIN_MODEL="minimax-m2.7"; shift ;; # ---- Context & effort ---- long) LONG_CTX=1; shift ;; effort) case "${2:-}" in low|medium|high|xhigh|max) EFFORT="$2"; shift 2 ;; *) echo "arkclaude: invalid effort level '${2:-}'. Use: low medium high xhigh max" >&2; exit 1 ;; esac ;; # ---- Other ---- --) shift; break ;; *) break ;; esac done # Default to pro if no alias matched. if [ -z "$MAIN_MODEL" ]; then MAIN_MODEL="$PRO_MODEL" fi # ---- Surface another model in the /model picker ---- # Pick a smart alternate based on which model family the user chose. case "$MAIN_MODEL" in "$PRO_MODEL") OTHER_MODEL="$PLUS_MODEL" OTHER_DESC="Doubao Seed 2.0 Pro — balanced flagship" ;; "$PLUS_MODEL") OTHER_MODEL="$PRO_MODEL" OTHER_DESC="Doubao Seed 2.0 Code — code specialist" ;; "$FLASH_MODEL") OTHER_MODEL="$PRO_MODEL" OTHER_DESC="Doubao Seed 2.0 Code — code specialist" ;; kimi-k2.7-code) OTHER_MODEL="kimi-k2.6" OTHER_DESC="Kimi K2.6 — full reasoning" ;; kimi-k2.6) OTHER_MODEL="kimi-k2.7-code" OTHER_DESC="Kimi K2.7 Code — code specialist" ;; deepseek-v4-pro) OTHER_MODEL="deepseek-v4-flash" OTHER_DESC="DeepSeek V4 Flash — fast tier" ;; deepseek-v4-flash) OTHER_MODEL="deepseek-v4-pro" OTHER_DESC="DeepSeek V4 Pro — full reasoning" ;; *) # Unknown/custom model — expose doubao code as a safe fallback. OTHER_MODEL="$PRO_MODEL" OTHER_DESC="Doubao Seed 2.0 Code — code specialist" ;; esac export_anthropic_base # Subagents run on the cheapest tier. export CLAUDE_CODE_SUBAGENT_MODEL="$FLASH_MODEL" set_custom_model "$OTHER_MODEL" "$MAIN_MODEL" "$OTHER_DESC" CTX="${ARK_CTX:-}" OUTPUT_CAP="${ARK_OUTPUT:-}" apply_context_and_effort show_banner_and_launch "Ark" "$@"