@washanhanzi/claude-code-router 1.1.2 → 2.0.1
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/.github/workflows/docker-publish.yml +85 -0
- package/.github/workflows/docs.yml +55 -0
- package/README.md +46 -4
- package/README_zh.md +71 -4
- package/dist/cli.js +982 -88486
- package/dist/index.html +43 -257
- package/package.json +29 -28
- package/pnpm-workspace.yaml +3 -0
- package/tsconfig.base.json +17 -0
- package/.dockerignore +0 -2
- package/Dockerfile +0 -7
- package/custom-router.example.js +0 -3
- package/docker-compose.yml +0 -10
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
name: Build and Publish Docker Image
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*.*.*'
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
env:
|
|
10
|
+
DOCKER_IMAGE: musistudio/claude-code-router
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build-and-push:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
packages: write
|
|
18
|
+
id-token: write
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout repository
|
|
22
|
+
uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- name: Setup Node.js
|
|
25
|
+
uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: 20
|
|
28
|
+
|
|
29
|
+
- name: Install pnpm
|
|
30
|
+
uses: pnpm/action-setup@v4
|
|
31
|
+
with:
|
|
32
|
+
version: latest
|
|
33
|
+
|
|
34
|
+
- name: Get version
|
|
35
|
+
id: version
|
|
36
|
+
run: |
|
|
37
|
+
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
38
|
+
VERSION=${GITHUB_REF#refs/tags/}
|
|
39
|
+
else
|
|
40
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
41
|
+
fi
|
|
42
|
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
43
|
+
echo "Docker image version: $VERSION"
|
|
44
|
+
|
|
45
|
+
- name: Install dependencies
|
|
46
|
+
run: pnpm install --frozen-lockfile
|
|
47
|
+
|
|
48
|
+
- name: Build packages
|
|
49
|
+
run: |
|
|
50
|
+
pnpm build
|
|
51
|
+
|
|
52
|
+
- name: Set up Docker Buildx
|
|
53
|
+
uses: docker/setup-buildx-action@v3
|
|
54
|
+
|
|
55
|
+
- name: Login to Docker Hub
|
|
56
|
+
uses: docker/login-action@v3
|
|
57
|
+
with:
|
|
58
|
+
username: ${{ secrets.DOCKER_USERNAME }}
|
|
59
|
+
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
60
|
+
|
|
61
|
+
- name: Extract metadata
|
|
62
|
+
id: meta
|
|
63
|
+
uses: docker/metadata-action@v5
|
|
64
|
+
with:
|
|
65
|
+
images: ${{ env.DOCKER_IMAGE }}
|
|
66
|
+
tags: |
|
|
67
|
+
type=semver,pattern={{version}},value=${{ steps.version.outputs.version }}
|
|
68
|
+
type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.version }}
|
|
69
|
+
type=raw,value=latest
|
|
70
|
+
type=sha
|
|
71
|
+
|
|
72
|
+
- name: Build and push Docker image
|
|
73
|
+
uses: docker/build-push-action@v5
|
|
74
|
+
with:
|
|
75
|
+
context: .
|
|
76
|
+
file: ./packages/server/Dockerfile
|
|
77
|
+
platforms: linux/amd64,linux/arm64
|
|
78
|
+
push: true
|
|
79
|
+
tags: ${{ steps.meta.outputs.tags }}
|
|
80
|
+
labels: ${{ steps.meta.outputs.labels }}
|
|
81
|
+
cache-from: type=gha
|
|
82
|
+
cache-to: type=gha,mode=max
|
|
83
|
+
|
|
84
|
+
- name: Image digest
|
|
85
|
+
run: echo "Image pushed with digest ${{ steps.meta.outputs.digest }}"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: Deploy Docs to GitHub Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
paths:
|
|
8
|
+
- 'docs/**'
|
|
9
|
+
- '.github/workflows/docs.yml'
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
pages: write
|
|
15
|
+
id-token: write
|
|
16
|
+
|
|
17
|
+
concurrency:
|
|
18
|
+
group: pages
|
|
19
|
+
cancel-in-progress: false
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
build:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- name: Checkout
|
|
26
|
+
uses: actions/checkout@v4
|
|
27
|
+
|
|
28
|
+
- name: Setup Node.js
|
|
29
|
+
uses: actions/setup-node@v4
|
|
30
|
+
with:
|
|
31
|
+
node-version: 20
|
|
32
|
+
|
|
33
|
+
- name: Install dependencies
|
|
34
|
+
working-directory: ./docs
|
|
35
|
+
run: npm install
|
|
36
|
+
|
|
37
|
+
- name: Build Docusaurus
|
|
38
|
+
working-directory: ./docs
|
|
39
|
+
run: npm run build
|
|
40
|
+
|
|
41
|
+
- name: Upload artifact
|
|
42
|
+
uses: actions/upload-pages-artifact@v3
|
|
43
|
+
with:
|
|
44
|
+
path: ./docs/build
|
|
45
|
+
|
|
46
|
+
deploy:
|
|
47
|
+
environment:
|
|
48
|
+
name: github-pages
|
|
49
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
50
|
+
runs-on: ubuntu-latest
|
|
51
|
+
needs: build
|
|
52
|
+
steps:
|
|
53
|
+
- name: Deploy to GitHub Pages
|
|
54
|
+
id: deployment
|
|
55
|
+
uses: actions/deploy-pages@v4
|
package/README.md
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
> This project is sponsored by Z.ai, supporting us with their GLM CODING PLAN.
|
|
11
|
-
> GLM CODING PLAN is a subscription service designed for AI coding, starting at just $3/month. It provides access to their flagship GLM-4.
|
|
11
|
+
> GLM CODING PLAN is a subscription service designed for AI coding, starting at just $3/month. It provides access to their flagship GLM-4.7 model across 10+ popular AI coding tools (Claude Code, Cline, Roo Code, etc.), offering developers top-tier, fast, and stable coding experiences.
|
|
12
12
|
> Get 10% OFF GLM CODING PLAN:https://z.ai/subscribe?ic=8JVLJQFSKB
|
|
13
13
|
|
|
14
|
-
>
|
|
14
|
+
> [Progressive Disclosure of Agent Tools from the Perspective of CLI Tool Style](/blog/en/progressive-disclosure-of-agent-tools-from-the-perspective-of-cli-tool-style.md)
|
|
15
15
|
|
|
16
|
-
>
|
|
16
|
+
> A powerful tool to route Claude Code requests to different models and customize any request.
|
|
17
17
|
|
|
18
18
|

|
|
19
19
|
|
|
@@ -255,7 +255,45 @@ This command provides an interactive interface to:
|
|
|
255
255
|
|
|
256
256
|
The CLI tool validates all inputs and provides helpful prompts to guide you through the configuration process, making it easy to manage complex setups without editing JSON files manually.
|
|
257
257
|
|
|
258
|
-
### 6.
|
|
258
|
+
### 6. Presets Management
|
|
259
|
+
|
|
260
|
+
Presets allow you to save, share, and reuse configurations easily. You can export your current configuration as a preset and install presets from files or URLs.
|
|
261
|
+
|
|
262
|
+
```shell
|
|
263
|
+
# Export current configuration as a preset
|
|
264
|
+
ccr preset export my-preset
|
|
265
|
+
|
|
266
|
+
# Export with metadata
|
|
267
|
+
ccr preset export my-preset --description "My OpenAI config" --author "Your Name" --tags "openai,production"
|
|
268
|
+
|
|
269
|
+
# Install a preset from local directory
|
|
270
|
+
ccr preset install /path/to/preset
|
|
271
|
+
|
|
272
|
+
# List all installed presets
|
|
273
|
+
ccr preset list
|
|
274
|
+
|
|
275
|
+
# Show preset information
|
|
276
|
+
ccr preset info my-preset
|
|
277
|
+
|
|
278
|
+
# Delete a preset
|
|
279
|
+
ccr preset delete my-preset
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**Preset Features:**
|
|
283
|
+
- **Export**: Save your current configuration as a preset directory (with manifest.json)
|
|
284
|
+
- **Install**: Install presets from local directories
|
|
285
|
+
- **Sensitive Data Handling**: API keys and other sensitive data are automatically sanitized during export (marked as `{{field}}` placeholders)
|
|
286
|
+
- **Dynamic Configuration**: Presets can include input schemas for collecting required information during installation
|
|
287
|
+
- **Version Control**: Each preset includes version metadata for tracking updates
|
|
288
|
+
|
|
289
|
+
**Preset File Structure:**
|
|
290
|
+
```
|
|
291
|
+
~/.claude-code-router/presets/
|
|
292
|
+
├── my-preset/
|
|
293
|
+
│ └── manifest.json # Contains configuration and metadata
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### 7. Activate Command (Environment Variables Setup)
|
|
259
297
|
|
|
260
298
|
The `activate` command allows you to set up environment variables globally in your shell, enabling you to use the `claude` command directly or integrate Claude Code Router with applications built using the Agent SDK.
|
|
261
299
|
|
|
@@ -681,6 +719,10 @@ A huge thank you to all our sponsors for their generous support!
|
|
|
681
719
|
- \*勤
|
|
682
720
|
- \*\*锟
|
|
683
721
|
- \*涛
|
|
722
|
+
- \*\*明
|
|
723
|
+
- \*知
|
|
724
|
+
- \*语
|
|
725
|
+
- \*瓜
|
|
684
726
|
|
|
685
727
|
|
|
686
728
|
(If your name is masked, please contact me via my homepage email to update it with your GitHub username.)
|
package/README_zh.md
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
<hr>
|
|
8
8
|
|
|
9
9
|

|
|
10
|
-
> GLM CODING PLAN 是专为AI编码打造的订阅套餐,每月最低仅需20元,即可在十余款主流AI编码工具如Claude Code、中畅享智谱旗舰模型GLM-4.
|
|
10
|
+
> GLM CODING PLAN 是专为AI编码打造的订阅套餐,每月最低仅需20元,即可在十余款主流AI编码工具如Claude Code、中畅享智谱旗舰模型GLM-4.7,为开发者提供顶尖的编码体验。
|
|
11
11
|
> 智谱AI为本软件提供了特别优惠,使用以下链接购买可以享受九折优惠:https://www.bigmodel.cn/claude-code?ic=RRVJPB5SII
|
|
12
12
|
|
|
13
|
-
>
|
|
13
|
+
> [从CLI工具风格看工具渐进式披露](/blog/zh/从CLI工具风格看工具渐进式披露.md)
|
|
14
14
|
|
|
15
|
-
>
|
|
15
|
+
> 一款强大的工具,可将 Claude Code 请求路由到不同的模型,并自定义任何请求。
|
|
16
16
|
|
|
17
17
|

|
|
18
18
|
|
|
@@ -205,7 +205,70 @@ ccr ui
|
|
|
205
205
|
|
|
206
206
|

|
|
207
207
|
|
|
208
|
-
### 5.
|
|
208
|
+
### 5. CLI 模型管理
|
|
209
|
+
|
|
210
|
+
对于偏好终端工作流的用户,可以使用交互式 CLI 模型选择器:
|
|
211
|
+
|
|
212
|
+
```shell
|
|
213
|
+
ccr model
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
该命令提供交互式界面来:
|
|
217
|
+
|
|
218
|
+
- 查看当前配置
|
|
219
|
+
- 查看所有配置的模型(default、background、think、longContext、webSearch、image)
|
|
220
|
+
- 切换模型:快速更改每个路由器类型使用的模型
|
|
221
|
+
- 添加新模型:向现有提供商添加模型
|
|
222
|
+
- 创建新提供商:设置完整的提供商配置,包括:
|
|
223
|
+
- 提供商名称和 API 端点
|
|
224
|
+
- API 密钥
|
|
225
|
+
- 可用模型
|
|
226
|
+
- Transformer 配置,支持:
|
|
227
|
+
- 多个转换器(openrouter、deepseek、gemini 等)
|
|
228
|
+
- Transformer 选项(例如,带自定义限制的 maxtoken)
|
|
229
|
+
- 特定于提供商的路由(例如,OpenRouter 提供商偏好)
|
|
230
|
+
|
|
231
|
+
CLI 工具验证所有输入并提供有用的提示来引导您完成配置过程,使管理复杂的设置变得容易,无需手动编辑 JSON 文件。
|
|
232
|
+
|
|
233
|
+
### 6. 预设管理
|
|
234
|
+
|
|
235
|
+
预设允许您轻松保存、共享和重用配置。您可以将当前配置导出为预设,并从文件或 URL 安装预设。
|
|
236
|
+
|
|
237
|
+
```shell
|
|
238
|
+
# 将当前配置导出为预设
|
|
239
|
+
ccr preset export my-preset
|
|
240
|
+
|
|
241
|
+
# 使用元数据导出
|
|
242
|
+
ccr preset export my-preset --description "我的 OpenAI 配置" --author "您的名字" --tags "openai,生产环境"
|
|
243
|
+
|
|
244
|
+
# 从本地目录安装预设
|
|
245
|
+
ccr preset install /path/to/preset
|
|
246
|
+
|
|
247
|
+
# 列出所有已安装的预设
|
|
248
|
+
ccr preset list
|
|
249
|
+
|
|
250
|
+
# 显示预设信息
|
|
251
|
+
ccr preset info my-preset
|
|
252
|
+
|
|
253
|
+
# 删除预设
|
|
254
|
+
ccr preset delete my-preset
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**预设功能:**
|
|
258
|
+
- **导出**:将当前配置保存为预设目录(包含 manifest.json)
|
|
259
|
+
- **安装**:从本地目录安装预设
|
|
260
|
+
- **敏感数据处理**:导出期间自动清理 API 密钥和其他敏感数据(标记为 `{{field}}` 占位符)
|
|
261
|
+
- **动态配置**:预设可以包含输入架构,用于在安装期间收集所需信息
|
|
262
|
+
- **版本控制**:每个预设包含版本元数据,用于跟踪更新
|
|
263
|
+
|
|
264
|
+
**预设文件结构:**
|
|
265
|
+
```
|
|
266
|
+
~/.claude-code-router/presets/
|
|
267
|
+
├── my-preset/
|
|
268
|
+
│ └── manifest.json # 包含配置和元数据
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### 7. Activate 命令(环境变量设置)
|
|
209
272
|
|
|
210
273
|
`activate` 命令允许您在 shell 中全局设置环境变量,使您能够直接使用 `claude` 命令或将 Claude Code Router 与使用 Agent SDK 构建的应用程序集成。
|
|
211
274
|
|
|
@@ -625,6 +688,10 @@ jobs:
|
|
|
625
688
|
- \*勤
|
|
626
689
|
- \*\*锟
|
|
627
690
|
- \*涛
|
|
691
|
+
- \*\*明
|
|
692
|
+
- \*知
|
|
693
|
+
- \*语
|
|
694
|
+
- \*瓜
|
|
628
695
|
|
|
629
696
|
(如果您的名字被屏蔽,请通过我的主页电子邮件与我联系,以便使用您的 GitHub 用户名进行更新。)
|
|
630
697
|
|