claude-ccx 0.1.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.
Files changed (3) hide show
  1. package/README.md +164 -0
  2. package/install.js +74 -0
  3. package/package.json +30 -0
package/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # CCX — Claude Code eXecutor
2
+
3
+ 管理多套 Claude Code API 配置,一键切换,即时启动。
4
+
5
+ 所有配置存储在 [Gitee Gist](https://gitee.com/gists) 云端,跨机器同步,本地零存储。
6
+
7
+ ## 功能特性
8
+
9
+ - **云端配置管理** — 配置文件以 JSON 形式存储在 Gitee Gist,任何机器 `ccx init` 即可使用
10
+ - **交互式选择器** — 上下键选择 profile,支持搜索过滤
11
+ - **完整 CRUD** — 新建、编辑、删除、查看、设置默认配置
12
+ - **透明启动** — 通过 `syscall.Exec` 直接替换进程为 `claude`,无子进程开销
13
+ - **非 TTY 兼容** — 在 IDE Run Panel 等非终端环境自动回退为数字编号选择
14
+
15
+ ## 安装
16
+
17
+ ### 通过 npm(推荐)
18
+
19
+ ```bash
20
+ npm install -g claude-ccx
21
+ ```
22
+
23
+ ### 通过 GitHub Releases
24
+
25
+ 从 [Releases](https://github.com/fanxing-6/ccx/releases) 下载 `ccx_linux_amd64.tar.gz`:
26
+
27
+ ```bash
28
+ curl -Lo ccx.tar.gz https://github.com/fanxing-6/ccx/releases/latest/download/ccx_linux_amd64.tar.gz
29
+ tar -xzf ccx.tar.gz
30
+ sudo mv ccx /usr/local/bin/
31
+ ```
32
+
33
+ ### 从源码构建
34
+
35
+ ```bash
36
+ git clone https://github.com/fanxing-6/ccx.git
37
+ cd ccx
38
+ go build -o ccx .
39
+ ```
40
+
41
+ ## 前置条件
42
+
43
+ 1. **Claude Code CLI** 已安装并在 `$PATH` 中([安装文档](https://docs.anthropic.com/en/docs/claude-code))
44
+ 2. **Gitee 账号** 及 Personal Access Token(需要 Gist 读写权限)
45
+ 3. **一个 Gitee Gist** 用于存储配置(在 [gitee.com/gists](https://gitee.com/gists) 创建)
46
+
47
+ ## 快速开始
48
+
49
+ ### 1. 初始化
50
+
51
+ ```bash
52
+ ccx init
53
+ ```
54
+
55
+ 按提示输入:
56
+ - Gitee Personal Access Token
57
+ - Gitee 用户名
58
+ - Gist ID(Gist URL 中 `codes/` 后面的部分)
59
+ - Claude 命令名(默认 `claude`)
60
+
61
+ ### 2. 添加配置
62
+
63
+ ```bash
64
+ ccx add my-api
65
+ ```
66
+
67
+ 交互式引导输入 API Token、Base URL、模型等参数。也可用编辑器模式:
68
+
69
+ ```bash
70
+ ccx add my-api --editor
71
+ ```
72
+
73
+ ### 3. 启动
74
+
75
+ ```bash
76
+ # 交互式选择
77
+ ccx
78
+
79
+ # 直接指定 profile
80
+ ccx my-api
81
+
82
+ # 危险模式(跳过权限确认)
83
+ ccx -d my-api
84
+ ```
85
+
86
+ ## 命令参考
87
+
88
+ | 命令 | 说明 |
89
+ |------|------|
90
+ | `ccx` | 交互式选择 profile 并启动 Claude Code |
91
+ | `ccx <name>` | 直接使用指定 profile 启动 |
92
+ | `ccx init` | 初始化 Gitee 连接配置 |
93
+ | `ccx list` | 列出所有 profile |
94
+ | `ccx info <name>` | 查看 profile 详情 |
95
+ | `ccx add <name>` | 创建新 profile(交互式引导) |
96
+ | `ccx add <name> --editor` | 创建新 profile(编辑器模式) |
97
+ | `ccx edit <name>` | 编辑已有 profile |
98
+ | `ccx remove <name>` | 删除 profile |
99
+ | `ccx default <name>` | 设置默认 profile |
100
+
101
+ **别名**: `list` → `ls`,`remove` → `rm`
102
+
103
+ **全局 Flag**: `-d` / `--dangerous` — 为 claude 追加 `--dangerously-skip-permissions`
104
+
105
+ ## 配置结构
106
+
107
+ ### Profile(存储在 Gitee Gist)
108
+
109
+ 每个 profile 是一个 `settings-<name>.json` 文件,内容即 `claude --settings` 接受的 JSON:
110
+
111
+ ```json
112
+ {
113
+ "env": {
114
+ "ANTHROPIC_AUTH_TOKEN": "sk-xxx",
115
+ "ANTHROPIC_BASE_URL": "https://api.example.com/v1",
116
+ "ANTHROPIC_MODEL": "claude-sonnet-4-20250514",
117
+ "ANTHROPIC_DEFAULT_HAIKU_MODEL": "",
118
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "",
119
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "",
120
+ "API_TIMEOUT_MS": "600000"
121
+ }
122
+ }
123
+ ```
124
+
125
+ ### 本地配置(`~/.config/ccx/config.json`)
126
+
127
+ 仅存储 Gitee 连接信息,不含任何 profile 数据:
128
+
129
+ ```json
130
+ {
131
+ "gitee_token": "your-token",
132
+ "gist_id": "your-gist-id",
133
+ "gist_owner": "your-username",
134
+ "claude_command": "claude",
135
+ "default_profile": "my-api"
136
+ }
137
+ ```
138
+
139
+ ## 交互式界面
140
+
141
+ ```
142
+ 选择 Claude Code 配置:
143
+ ▸ volc api.volc.com/v1 [claude-sonnet-4-20250514]
144
+ openai api.openai.com/v1 [gpt-4]
145
+ local localhost:8080
146
+ ⚙ 配置管理
147
+ ```
148
+
149
+ 选择「⚙ 配置管理」进入二级菜单,可新建、修改、删除配置或设置默认值,操作完成后自动返回。
150
+
151
+ ## 适用场景
152
+
153
+ - 有多个 API 供应商(官方、中转、自建)需要频繁切换
154
+ - 需要在不同机器间共享 Claude Code 配置
155
+ - 希望用不同模型配置应对不同任务
156
+
157
+ ## 系统要求
158
+
159
+ - Linux amd64
160
+ - Node.js 14+(仅 npm 安装方式需要)
161
+
162
+ ## License
163
+
164
+ MIT
package/install.js ADDED
@@ -0,0 +1,74 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const https = require("https");
4
+ const http = require("http");
5
+ const { execSync } = require("child_process");
6
+
7
+ const pkg = require("./package.json");
8
+ const version = pkg.version;
9
+
10
+ const BINARY_NAME = "ccx";
11
+ const DOWNLOAD_URL = `https://github.com/fanxing-6/ccx/releases/download/v${version}/ccx_linux_amd64.tar.gz`;
12
+
13
+ const binDir = path.join(__dirname, "bin");
14
+ const binPath = path.join(binDir, BINARY_NAME);
15
+ const tmpFile = path.join(__dirname, "ccx.tar.gz");
16
+
17
+ function followRedirects(url, maxRedirects = 5) {
18
+ return new Promise((resolve, reject) => {
19
+ if (maxRedirects <= 0) {
20
+ reject(new Error("重定向次数过多"));
21
+ return;
22
+ }
23
+
24
+ const client = url.startsWith("https") ? https : http;
25
+ client
26
+ .get(url, (res) => {
27
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
28
+ followRedirects(res.headers.location, maxRedirects - 1).then(resolve, reject);
29
+ return;
30
+ }
31
+ if (res.statusCode !== 200) {
32
+ reject(new Error(`下载失败: HTTP ${res.statusCode} — ${url}`));
33
+ return;
34
+ }
35
+ resolve(res);
36
+ })
37
+ .on("error", reject);
38
+ });
39
+ }
40
+
41
+ async function install() {
42
+ if (process.platform !== "linux" || process.arch !== "x64") {
43
+ console.error(`ccx 目前仅支持 linux/x64,当前平台: ${process.platform}/${process.arch}`);
44
+ process.exit(1);
45
+ }
46
+
47
+ console.log(`正在下载 ccx v${version}...`);
48
+
49
+ fs.mkdirSync(binDir, { recursive: true });
50
+
51
+ // 下载 tar.gz 到临时文件
52
+ const res = await followRedirects(DOWNLOAD_URL);
53
+ await new Promise((resolve, reject) => {
54
+ const ws = fs.createWriteStream(tmpFile);
55
+ res.pipe(ws);
56
+ ws.on("finish", resolve);
57
+ ws.on("error", reject);
58
+ res.on("error", reject);
59
+ });
60
+
61
+ // 用系统 tar 解压(Linux 环境必定有 tar)
62
+ execSync(`tar -xzf "${tmpFile}" -C "${binDir}" ${BINARY_NAME}`, { stdio: "inherit" });
63
+
64
+ // 清理临时文件
65
+ fs.unlinkSync(tmpFile);
66
+
67
+ fs.chmodSync(binPath, 0o755);
68
+ console.log(`ccx v${version} 安装成功: ${binPath}`);
69
+ }
70
+
71
+ install().catch((err) => {
72
+ console.error(`安装 ccx 失败: ${err.message}`);
73
+ process.exit(1);
74
+ });
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "claude-ccx",
3
+ "version": "0.1.0",
4
+ "description": "Claude Code eXecutor — 多配置管理与快速切换工具",
5
+ "bin": {
6
+ "ccx": "./bin/ccx"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js"
10
+ },
11
+ "os": [
12
+ "linux"
13
+ ],
14
+ "cpu": [
15
+ "x64"
16
+ ],
17
+ "keywords": [
18
+ "claude",
19
+ "claude-code",
20
+ "cli",
21
+ "profile",
22
+ "config"
23
+ ],
24
+ "author": "fanxing-6",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/fanxing-6/ccx.git"
29
+ }
30
+ }