@dedenlabs/claude-code-router-cli 2.0.1 → 2.0.3
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/README.md +63 -36
- package/dist/cli.js +10027 -182
- package/examples/configs/fixed-router-config.json +3 -4
- package/examples/configs/unified-router-example.json +165 -171
- package/package.json +15 -3
package/README.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
[](https://github.com/dedenlabs/claude-code-router-cli)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](https://nodejs.org/)
|
|
8
8
|
[](https://www.typescriptlang.org/)
|
|
9
9
|
|
|
10
10
|
**基于 [@musistudio/claude-code-router](https://github.com/musistudio/claude-code-router) 的增强版命令行路由工具**
|
|
11
11
|
|
|
12
|
-
[✨ 新功能概览](#-新功能) • [🚀 快速开始](#-快速开始) • [📖 完整文档](./docs/UNIFIED_ROUTER_GUIDE.md) • [🔧 示例配置](./examples/) • [📚 官方教程](https://code.claude.com/docs/en/quickstart)
|
|
12
|
+
[✨ 新功能概览](#-新功能) • [🚀 快速开始](#-快速开始) • [📖 完整文档](./docs/UNIFIED_ROUTER_GUIDE.md) • [📋 路由规则](./docs/UNIFIED_ROUTER_RULES.md) • [🔧 示例配置](./examples/) • [📚 官方教程](https://code.claude.com/docs/en/quickstart)
|
|
13
13
|
|
|
14
14
|
</div>
|
|
15
15
|
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
🚀 ──────────────────────────────────────
|
|
30
30
|
📝 用户请求开始 [2025/12/07 00:35:46] 🎯 目标模型: opus
|
|
31
31
|
🔗 请求ID: b8fdsc4f-ba72-4e2c-967d-2be41577f820
|
|
32
|
-
✨ 规则触发:
|
|
32
|
+
✨ 规则触发: 代号映射规则
|
|
33
33
|
📍 路由决策: opus → opus/glm-4.6
|
|
34
34
|
📝 请求文本: <system-reminder>...
|
|
35
35
|
As you answer the user's questions, you can use the following context:...
|
|
@@ -51,14 +51,14 @@ As you answer the user's questions, you can use the following context:...
|
|
|
51
51
|
🔍 [DEBUG] 条件: 自定义函数: modelContainsComma
|
|
52
52
|
🔍 [DEBUG] 结果: ❌ 不匹配
|
|
53
53
|
🔍 [DEBUG] 评估条件 {"conditionType":"custom","condition":{"type":"custom","customFunction":"directModelMapping"},"requestedModel":"haiku"}
|
|
54
|
-
🔍 [DEBUG] 规则 "
|
|
54
|
+
🔍 [DEBUG] 规则 "代号映射规则" (优先级: 190)
|
|
55
55
|
🔍 [DEBUG] 条件: 自定义函数: directModelMapping
|
|
56
56
|
🔍 [DEBUG] 结果: ✅ 匹配
|
|
57
|
-
🔍 [DEBUG] 🎯 规则 "
|
|
58
|
-
🔍 [DEBUG]
|
|
59
|
-
🔍 [DEBUG]
|
|
57
|
+
🔍 [DEBUG] 🎯 规则 "代号映射规则" 匹配成功,停止后续评估
|
|
58
|
+
🔍 [DEBUG] 尝试代号模型映射 {"modelName":"haiku","providersCount":3}
|
|
59
|
+
🔍 [DEBUG] 未找到代号模型映射,尝试通过 provider 名称匹配 {"modelName":"haiku"}
|
|
60
60
|
🔍 [DEBUG] 🔄 变量替换完成 {"原始路由":"${mappedModel}","最终路由":"haiku,glm-4.5-air"}
|
|
61
|
-
✨ 规则触发:
|
|
61
|
+
✨ 规则触发: 代号映射规则
|
|
62
62
|
📍 路由决策: haiku → haiku/glm-4.5-air
|
|
63
63
|
📝 请求文本:
|
|
64
64
|
Please write a 5-10 word title for the following conversation:...
|
|
@@ -93,7 +93,11 @@ npm install @dedenlabs/claude-code-router-cli
|
|
|
93
93
|
|
|
94
94
|
**启动路由服务:**
|
|
95
95
|
```bash
|
|
96
|
+
# 前台运行
|
|
96
97
|
ccr start
|
|
98
|
+
# 或
|
|
99
|
+
# 后台运行
|
|
100
|
+
ccr start -b
|
|
97
101
|
```
|
|
98
102
|
|
|
99
103
|
**配置 Claude 环境变量:**
|
|
@@ -183,8 +187,8 @@ ccr stop # 停止服务
|
|
|
183
187
|
```javascript
|
|
184
188
|
// external-rules/user-preference.js
|
|
185
189
|
const userPreferences = {
|
|
186
|
-
'premium@company.com': { provider: 'opus
|
|
187
|
-
'standard@company.com': { provider: 'sonnet
|
|
190
|
+
'premium@company.com': { provider: 'opus', model: 'glm-4.6' },
|
|
191
|
+
'standard@company.com': { provider: 'sonnet', model: 'glm-4.5-air' }
|
|
188
192
|
};
|
|
189
193
|
|
|
190
194
|
function checkUserPreference(context) {
|
|
@@ -275,7 +279,7 @@ module.exports = { checkUserPreference };
|
|
|
275
279
|
}
|
|
276
280
|
},
|
|
277
281
|
{
|
|
278
|
-
"name": "
|
|
282
|
+
"name": "代号映射规则",
|
|
279
283
|
"priority": 190,
|
|
280
284
|
"enabled": true,
|
|
281
285
|
"condition": {
|
|
@@ -284,7 +288,7 @@ module.exports = { checkUserPreference };
|
|
|
284
288
|
},
|
|
285
289
|
"action": {
|
|
286
290
|
"route": "${mappedModel}",
|
|
287
|
-
"description": "
|
|
291
|
+
"description": "将provider作为代号,映射到对应的model模型"
|
|
288
292
|
}
|
|
289
293
|
},
|
|
290
294
|
{
|
|
@@ -444,6 +448,8 @@ lsof -i :3456
|
|
|
444
448
|
|
|
445
449
|
# 更换端口
|
|
446
450
|
ccr start --port 3457
|
|
451
|
+
# 后台运行
|
|
452
|
+
ccr start -b
|
|
447
453
|
```
|
|
448
454
|
|
|
449
455
|
**Q: 路由不生效,模型没有切换**
|
|
@@ -510,10 +516,7 @@ npm install
|
|
|
510
516
|
|
|
511
517
|
# 构建项目
|
|
512
518
|
npm run build
|
|
513
|
-
|
|
514
|
-
# 运行测试
|
|
515
|
-
npm test
|
|
516
|
-
|
|
519
|
+
|
|
517
520
|
# 开发模式
|
|
518
521
|
npm run dev
|
|
519
522
|
```
|
|
@@ -562,21 +565,49 @@ export class MyTransformer extends BaseTransformer {
|
|
|
562
565
|
- 将最常用的规则放在前面(高优先级)
|
|
563
566
|
- 避免复杂的条件判断
|
|
564
567
|
- 合理设置缓存TTL
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
## 📈 版本历史
|
|
565
571
|
|
|
566
|
-
### 3
|
|
572
|
+
### v2.0.3 (2025-12-16)
|
|
567
573
|
|
|
568
|
-
|
|
569
|
-
# 查看性能统计
|
|
570
|
-
ccr stats
|
|
574
|
+
**🔧 核心问题修复**
|
|
571
575
|
|
|
572
|
-
|
|
573
|
-
|
|
576
|
+
**✅ 字段兼容性问题修复**
|
|
577
|
+
- 修复 `${subagent}` 变量替换失败问题
|
|
578
|
+
- 实现智能字段兼容机制,自动兼容 `content` 和 `text` 字段
|
|
579
|
+
- 确保老用户配置无需修改,完全向后兼容
|
|
580
|
+
- 优化 `getFieldValue` 方法,支持 `system.1.text` 路径自动获取 `content` 字段
|
|
574
581
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
582
|
+
**📚 文档完善**
|
|
583
|
+
- 新增《统一路由引擎规则文档》(UNIFIED_ROUTER_RULES.md)
|
|
584
|
+
- 提供完整的技术规则说明和 Mermaid 流程图
|
|
585
|
+
- 修复文档中的 Mermaid 图表解析错误
|
|
586
|
+
- 标准化术语为"代号模型映射规则"
|
|
587
|
+
- 在 README.md 中添加路由规则文档引用
|
|
578
588
|
|
|
579
|
-
|
|
589
|
+
**🧪 测试增强**
|
|
590
|
+
- 新增字段兼容性的单元测试
|
|
591
|
+
- 验证所有路由规则的正确性 (8/8 测试用例通过)
|
|
592
|
+
- 确保变量替换机制正常工作
|
|
593
|
+
|
|
594
|
+
### v2.0.2 (2025-12-14)
|
|
595
|
+
|
|
596
|
+
**📚 文档修复**
|
|
597
|
+
|
|
598
|
+
**✅ README文档更新**
|
|
599
|
+
- 修复版本徽章显示错误(从2.0.0更新为2.0.2)
|
|
600
|
+
- 更新版本历史记录,添加v2.0.1和v2.0.2的详细说明
|
|
601
|
+
- 完善命令行使用示例和文档描述
|
|
602
|
+
|
|
603
|
+
### v2.0.1 (2025-12-14)
|
|
604
|
+
|
|
605
|
+
**🎯 用户体验优化**
|
|
606
|
+
|
|
607
|
+
**✅ 前台模式默认运行**
|
|
608
|
+
- `ccr start` 默认在前台运行,显示详细运行信息
|
|
609
|
+
- 可通过 `--background` / `-b` 参数切换到后台模式
|
|
610
|
+
- 更新命令行帮助文档和使用示例
|
|
580
611
|
|
|
581
612
|
### v2.0.0 (2025-12-14)
|
|
582
613
|
|
|
@@ -612,7 +643,7 @@ ccr stats --rules
|
|
|
612
643
|
- 确保路由决策的准确性和稳定性
|
|
613
644
|
- 提供模拟测试和性能监控工具
|
|
614
645
|
|
|
615
|
-
### v1.x (
|
|
646
|
+
### v1.x (原版本)
|
|
616
647
|
- 基础路由功能
|
|
617
648
|
- 固定规则配置
|
|
618
649
|
|
|
@@ -625,8 +656,7 @@ ccr stats --rules
|
|
|
625
656
|
| **日志系统** | 基础输出 | ✅ 可视化智能日志 |
|
|
626
657
|
| **配置迁移** | 手动 | ✅ 自动迁移工具 |
|
|
627
658
|
| **思考模式** | 无 | ✅ GLM思考转换器 |
|
|
628
|
-
| **包名** | @musistudio/... | @dedenlabs/... |
|
|
629
|
-
| **文档** | 基础 | ✅ 完整示例和指南 |
|
|
659
|
+
| **包名** | @musistudio/... | @dedenlabs/... |
|
|
630
660
|
|
|
631
661
|
## 📄 许可证
|
|
632
662
|
|
|
@@ -634,18 +664,15 @@ MIT License - 与原版保持一致
|
|
|
634
664
|
|
|
635
665
|
## 🙏 致谢
|
|
636
666
|
|
|
637
|
-
- **musistudio** - 原版项目作者
|
|
638
|
-
- **社区贡献者** - 测试和反馈
|
|
639
|
-
- **GLM团队** - 提供优质模型支持
|
|
667
|
+
- **musistudio** - 原版项目作者
|
|
640
668
|
|
|
641
669
|
---
|
|
642
670
|
|
|
643
671
|
<div align="center">
|
|
644
|
-
|
|
645
|
-
**[⬆ 回到顶部](#claude-code-router-cli-v20)**
|
|
646
|
-
|
|
672
|
+
|
|
647
673
|
[🐛 报告问题](https://github.com/dedenlabs/claude-code-router-cli/issues) •
|
|
648
674
|
[💡 功能建议](https://github.com/dedenlabs/claude-code-router-cli/issues) •
|
|
649
|
-
[📖 完整文档](./docs/UNIFIED_ROUTER_GUIDE.md)
|
|
675
|
+
[📖 完整文档](./docs/UNIFIED_ROUTER_GUIDE.md) •
|
|
676
|
+
[📋 路由规则](./docs/UNIFIED_ROUTER_RULES.md)
|
|
650
677
|
|
|
651
678
|
</div>
|