release v1.0.26

This commit is contained in:
jinhui.li
2025-07-23 12:20:52 +08:00
parent b9d556ff1b
commit c6969fdd90
6 changed files with 142 additions and 14 deletions

View File

@@ -1,12 +1,43 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.You need use English to write text.
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Key Development Commands
- Build: `npm run build`
- Start: `npm start`
## Commands
- **Build the project**:
```bash
npm run build
```
- **Start the router server**:
```bash
ccr start
```
- **Stop the router server**:
```bash
ccr stop
```
- **Check the server status**:
```bash
ccr status
```
- **Run Claude Code through the router**:
```bash
ccr code "<your prompt>"
```
- **Release a new version**:
```bash
npm run release
```
## Architecture
- Uses `express` for routing (see `src/server.ts`)
- Bundles with `esbuild` for CLI distribution
- Plugins are loaded from `$HOME/.claude-code-router/plugins`
This project is a TypeScript-based router for Claude Code requests. It allows routing requests to different large language models (LLMs) from various providers based on custom rules.
- **Entry Point**: The main command-line interface logic is in `src/cli.ts`. It handles parsing commands like `start`, `stop`, and `code`.
- **Server**: The `ccr start` command launches a server that listens for requests from Claude Code. The server logic is initiated from `src/index.ts`.
- **Configuration**: The router is configured via a JSON file located at `~/.claude-code-router/config.json`. This file defines API providers, routing rules, and custom transformers. An example can be found in `config.example.json`.
- **Routing**: The core routing logic determines which LLM provider and model to use for a given request. It supports default routes for different scenarios (`default`, `background`, `think`, `longContext`, `webSearch`) and can be extended with a custom JavaScript router file. The router logic is likely in `src/utils/router.ts`.
- **Providers and Transformers**: The application supports multiple LLM providers. Transformers adapt the request and response formats for different provider APIs.
- **Claude Code Integration**: When a user runs `ccr code`, the command is forwarded to the running router service. The service then processes the request, applies routing rules, and sends it to the configured LLM. If the service isn't running, `ccr code` will attempt to start it automatically.
- **Dependencies**: The project is built with `esbuild`. It has a key local dependency `@musistudio/llms`, which probably contains the core logic for interacting with different LLM APIs.
- `@musistudio/llms` is implemented based on `fastify` and exposes `fastify`'s hook and middleware interfaces, allowing direct use of `server.addHook`.

View File

@@ -101,6 +101,38 @@ Here is a comprehensive example:
"transformer": {
"use": ["deepseek"]
}
},
{
"name": "modelscope",
"api_base_url": "https://api-inference.modelscope.cn/v1/chat/completions",
"api_key": "",
"models": ["Qwen/Qwen3-Coder-480B-A35B-Instruct"],
"transformer": {
"use": [
[
"maxtoken",
{
"max_tokens": 8192
}
]
]
}
},
{
"name": "dashscope",
"api_base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
"api_key": "",
"models": ["qwen3-coder-plus"],
"transformer": {
"use": [
[
"maxtoken",
{
"max_tokens": 8192
}
]
]
}
}
],
"Router": {
@@ -380,5 +412,6 @@ A huge thank you to all our sponsors for their generous support!
- @*琢
- @*成
- @Z*o
- @*琨
(If your name is masked, please contact me via my homepage email to update it with your GitHub username.)

View File

@@ -98,6 +98,38 @@ npm install -g @musistudio/claude-code-router
"transformer": {
"use": ["deepseek"]
}
},
{
"name": "modelscope",
"api_base_url": "https://api-inference.modelscope.cn/v1/chat/completions",
"api_key": "",
"models": ["Qwen/Qwen3-Coder-480B-A35B-Instruct"],
"transformer": {
"use": [
[
"maxtoken",
{
"max_tokens": 8192
}
]
]
}
},
{
"name": "dashscope",
"api_base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
"api_key": "",
"models": ["qwen3-coder-plus"],
"transformer": {
"use": [
[
"maxtoken",
{
"max_tokens": 8192
}
]
]
}
}
],
"Router": {

View File

@@ -65,6 +65,38 @@
]
]
}
},
{
"name": "modelscope",
"api_base_url": "https://api-inference.modelscope.cn/v1/chat/completions",
"api_key": "",
"models": ["Qwen/Qwen3-Coder-480B-A35B-Instruct"],
"transformer": {
"use": [
[
"maxtoken",
{
"max_tokens": 8192
}
]
]
}
},
{
"name": "dashscope",
"api_base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
"api_key": "",
"models": ["qwen3-coder-plus"],
"transformer": {
"use": [
[
"maxtoken",
{
"max_tokens": 8192
}
]
]
}
}
],
"Router": {

View File

@@ -1,6 +1,6 @@
{
"name": "@musistudio/claude-code-router",
"version": "1.0.25",
"version": "1.0.26",
"description": "Use Claude Code without an Anthropics account and route it to another LLM provider",
"bin": {
"ccr": "./dist/cli.js"
@@ -19,7 +19,7 @@
"author": "musistudio",
"license": "MIT",
"dependencies": {
"@musistudio/llms": "^1.0.11",
"@musistudio/llms": "^1.0.12",
"dotenv": "^16.4.7",
"tiktoken": "^1.0.21",
"uuid": "^11.1.0"

10
pnpm-lock.yaml generated
View File

@@ -9,8 +9,8 @@ importers:
.:
dependencies:
'@musistudio/llms':
specifier: ^1.0.11
version: 1.0.11(ws@8.18.3)(zod@3.25.67)
specifier: ^1.0.12
version: 1.0.12(ws@8.18.3)(zod@3.25.67)
dotenv:
specifier: ^16.4.7
version: 16.6.1
@@ -223,8 +223,8 @@ packages:
'@modelcontextprotocol/sdk':
optional: true
'@musistudio/llms@1.0.11':
resolution: {integrity: sha512-qydLNzZDeURK8fsYJFspM04x/4mlqmKAN2Ie7MLvWuYjYT+fOtDm5BaEzQKhNLOqA5pcB2bCU0L0VFRnoeOpBg==}
'@musistudio/llms@1.0.12':
resolution: {integrity: sha512-5sRIrt8UgXDLqim1xZrnMxugUW2m6zopXMQ+wF5Px20hH06aLO0zdT3Gyq78IKJZ+Xupkj+h1FooCAtWl+6bLw==}
'@nodelib/fs.scandir@2.1.5':
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
@@ -824,7 +824,7 @@ snapshots:
- supports-color
- utf-8-validate
'@musistudio/llms@1.0.11(ws@8.18.3)(zod@3.25.67)':
'@musistudio/llms@1.0.12(ws@8.18.3)(zod@3.25.67)':
dependencies:
'@anthropic-ai/sdk': 0.54.0
'@fastify/cors': 11.0.1