Skip to content

majiayu000/spellbook / skills/cliproxy-newapi-stack

cliproxy-newapi-stack

Flagged

在已经过独立验证的 CLIProxyAPI upstream 之上部署 NewAPI 计费层,把 Codex/Claude/Gemini/Qwen 等订阅账号包装成可计费的 OpenAI 兼容 API。本 Skill 不负责新建裸 CLIProxyAPI;负责 NewAPI Docker 部署、容器到宿主桥接、模型计费倍率、参数化额度修正、多账号 OAuth 凭据热加载和双路径验证。当用户说“给现有 cliproxy 加 NewAPI”“配置 NewAPI 渠道接已运行的 cliproxy”“NewAPI 价格不对”“给现有部署加账号”“172.17.0.1 容器网络”或“408 冷却放大故障”时触发。

FileKindSize
SKILL.mdskill md10.0 KB
agents/openai.yamlconfig248 B
references/multi-account.mdmarkdown2.6 KB
references/newapi-pricing.mdmarkdown2.8 KB
references/troubleshooting.mdmarkdown2.9 KB
scripts/add_codex_account.shexecutablescript2.9 KB
scripts/deploy_newapi.shexecutablescript1.9 KB
scripts/lib/validation.shscript3.3 KB
scripts/set_pricing.pyexecutablescript5.8 KB
scripts/test_security_validation.shexecutablescript3.1 KB
scripts/topup.shexecutablescript1.8 KB
scripts/verify_stack.shexecutablescript4.9 KB

scripts/add_codex_account.sh

View on GitHub
#!/usr/bin/env bash
# Add a new OAuth account (codex/claude/qwen/iflow/gemini) to an existing
# CLIProxyAPI deployment by running OAuth locally and syncing the credential
# JSON to the VPS auth-dir. CLIProxyAPI watcher hot-loads the new file —
# no restart needed.
#
# Usage:
#   PROVIDER=codex SSH_TARGET=root@host SSH_KEY=~/.ssh/id_ed25519 \
#     CLIPROXY_LOCAL=/path/to/CLIProxyAPI \
#     ./add_codex_account.sh

set -euo pipefail

SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=skills/cliproxy-newapi-stack/scripts/lib/validation.sh
. "$SCRIPT_DIR/lib/validation.sh"

: "${PROVIDER:=codex}"   # one of: codex|claude|qwen|iflow|antigravity|gemini
: "${SSH_TARGET:?SSH_TARGET required}"
: "${SSH_KEY:=$HOME/.ssh/id_ed25519}"
: "${CLIPROXY_LOCAL:=$PWD}"
: "${LOCAL_AUTH_DIR:=$HOME/.cli-proxy-api}"
: "${REMOTE_AUTH_DIR:=/root/.cli-proxy-api}"

case "$PROVIDER" in
  codex)        FLAG=-codex-login        ;;
  claude)       FLAG=-claude-login       ;;
  qwen)         FLAG=-qwen-login         ;;
  iflow)        FLAG=-iflow-login        ;;
  antigravity)  FLAG=-antigravity-login  ;;
  gemini)       FLAG=-login              ;;
  *) echo "unknown PROVIDER=$PROVIDER" >&2; exit 2 ;;
esac

require_safe_ssh_target SSH_TARGET "$SSH_TARGET"
require_absolute_safe_path REMOTE_AUTH_DIR "$REMOTE_AUTH_DIR"

mkdir -p "$LOCAL_AUTH_DIR"
echo ">> Capturing existing credentials before login"
before=$(find "$LOCAL_AUTH_DIR" -maxdepth 1 -type f -name "${PROVIDER}-*.json" -print | sort)

echo ">> Run OAuth in browser for the NEW account (logout/incognito as needed)"
( cd "$CLIPROXY_LOCAL" && go run ./cmd/server "$FLAG" -config config.yaml )

after=$(find "$LOCAL_AUTH_DIR" -maxdepth 1 -type f -name "${PROVIDER}-*.json" -print | sort)
new=$(comm -13 <(printf '%s\n' "$before" | sed '/^$/d') <(printf '%s\n' "$after" | sed '/^$/d') || true)

if [ -z "$new" ]; then
  echo "no new credential file detected; aborting"
  exit 1
fi

echo ">> New credential(s):"
echo "$new"

echo ">> Syncing to $SSH_TARGET:$REMOTE_AUTH_DIR"
ssh -i "$SSH_KEY" -- "$SSH_TARGET" bash -s -- "$REMOTE_AUTH_DIR" <<'REMOTE'
  set -euo pipefail
  remote_auth_dir=$1
  mkdir -p -- "$remote_auth_dir"
REMOTE
while IFS= read -r f; do
  [ -n "$f" ] && scp -i "$SSH_KEY" -- "$f" "$SSH_TARGET:$REMOTE_AUTH_DIR/"
done <<< "$new"

echo ">> Watcher should auto-load. Tailing log for confirmation..."
ssh -i "$SSH_KEY" -- "$SSH_TARGET" \
  "tail -n 100 /root/CLIProxyAPI/cli-proxy-api.log | grep -iE 'auth file changed|added' | tail -n 5"

echo ">> Listing remote credentials"
ssh -i "$SSH_KEY" -- "$SSH_TARGET" bash -s -- "$REMOTE_AUTH_DIR" "$PROVIDER" <<'REMOTE'
  set -euo pipefail
  remote_auth_dir=$1
  provider=$2
  shopt -s nullglob
  files=("${remote_auth_dir}/${provider}-"*.json)
  if ((${#files[@]} == 0)); then
    echo "no remote credentials found for provider ${provider}" >&2
    exit 1
  fi
  ls -l -- "${files[@]}"
REMOTE
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 321kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall