@peterwangze/claude-trigger-router 1.3.0 → 1.4.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.
package/README.md CHANGED
@@ -11,17 +11,17 @@ Claude Trigger Router 是给 Claude Code 用的本地路由代理。
11
11
  - 想在 Claude Code 外层增加配置校验、健康检查、治理观测和 UI 工作台
12
12
  - 想从 `claude-code-router` 迁移到更清晰的 `Models + Router` 配置心智
13
13
 
14
- ## v1.3.0 发布定位
14
+ ## v1.4.0 发布定位
15
15
 
16
- `v1.3.0` 是基础路由常用体验版。它把用户每天最常用的 `Router.default` / `think` / `longContext` / `background` / `webSearch` 五个槽位收口到可复制模板、README 使用说明、`ctr doctor` 诊断、`/ui` 路由解释和 packaged smoke 验收里。
16
+ `v1.4.0` SmartRouter 常用体验版。它把 CTR 的智能路由从“有能力但需要理解内部机制”推进到“能复制模板、能配置候选、能看懂为什么选模、能发现切换割裂,并能按配置路径调优”。
17
17
 
18
- 这个版本的目标是让新用户能完成基础分流配置,并能看懂当前请求为什么选中某个模型;它不把 SmartRouter 完整模板、benchmark 历史看板、托管级一键部署或更复杂模型池策略纳入发布承诺。完整发布边界见 [docs/release-notes-v1.3.0.md](docs/release-notes-v1.3.0.md)。
18
+ 这个版本的目标是让用户能把规则和候选模型稳定用于高频任务:`config/trigger.smart-router.yaml` 提供可复制起步模板,`/ui` 展示 SmartRouter 规则、候选、route decision 和 switch continuity summary,health routing tuning 会把慢路由、错路由、上下文窗口和切换割裂转成 `configSuggestions`。它不把 benchmark 历史看板、完整 server/cloud 托管平台或更复杂模型池策略纳入发布承诺。完整发布边界见 [docs/release-notes-v1.4.0.md](docs/release-notes-v1.4.0.md)。
19
19
 
20
- ## 后续路线
20
+ ## 版本路线
21
21
 
22
- 从用户使用频率看,后续演进会优先回到最常用的基础路由和 SmartRouter 体验:
22
+ 从用户使用频率看,版本演进会优先回到最常用的基础路由和 SmartRouter 体验:
23
23
 
24
- - `v1.4.0`:SmartRouter 常用体验,重点收口规则模板、候选模型配置、路由决策解释、sticky/alignment 切换体感和调优建议。
24
+ - `v1.3.0`:基础路由常用体验,已收口 `Router.default` / `think` / `longContext` / `background` / `webSearch` 五槽位、doctor 诊断、UI 路由解释和 packaged smoke。
25
25
  - `v1.5.0`:多模型收益运营化,继续补 benchmark 历史看板、人工校准表单和评测/真实 trace 的统一解释。
26
26
  - `v1.6.0`:服务化与模型池安全体验,继续补服务端安全默认值、密钥轮换手册、主动 pool health、成本/速率元数据和更多调度策略。
27
27
 
@@ -298,6 +298,8 @@ SmartRouter:
298
298
 
299
299
  规则命中时优先使用规则指定模型;没命中时回到 `Router.default`。
300
300
 
301
+ 可复制的 SmartRouter 常用模板见 `config/trigger.smart-router.yaml`。它已经把 `coding`、`review`、`architecture`、`long_context` 和 `fast_reply` 五类高频任务写成规则,并保留 `router_model + candidates` 作为规则未命中时的智能兜底起点。
302
+
301
303
  ## 智能模型选择
302
304
 
303
305
  如果任务边界比较模糊,可以让 SmartRouter 用一个路由模型从候选模型中选择:
@@ -559,6 +561,7 @@ setup 会自动探测旧配置,并优先提供迁移选项。迁移后的配
559
561
 
560
562
  - 最小示例:`config/trigger.example.yaml`
561
563
  - 基础路由五槽位示例:`config/trigger.routing.yaml`
564
+ - SmartRouter 常用规则示例:`config/trigger.smart-router.yaml`
562
565
  - 高级示例:`config/trigger.advanced.yaml`
563
566
  - 配置细节:`docs/configuration-guide.md`
564
567
  - Models 迁移:`docs/models-migration-guide.md`
@@ -0,0 +1,213 @@
1
+ # Claude Trigger Router SmartRouter rule template
2
+ # 复制到 ~/.claude-trigger-router/config.yaml 后,先替换 API Key、模型名和本地模型地址。
3
+ # 这个模板面向 v1.4.0 的高频智能路由场景:
4
+ # coding / review / architecture / long context / fast reply。
5
+
6
+ HOST: "127.0.0.1"
7
+ PORT: 5678
8
+
9
+ LOG: true
10
+ LOG_LEVEL: "debug"
11
+
12
+ Models:
13
+ - id: sonnet
14
+ api: "https://openrouter.ai/api/v1/chat/completions"
15
+ key: "sk-xxx"
16
+ interface: "openai"
17
+ model: "anthropic/claude-sonnet-4"
18
+ thinking: "auto"
19
+ metadata:
20
+ context_window_tokens: 200000
21
+ safe_input_tokens: 180000
22
+
23
+ - id: reviewer
24
+ api: "https://openrouter.ai/api/v1/chat/completions"
25
+ key: "sk-xxx"
26
+ interface: "openai"
27
+ model: "anthropic/claude-sonnet-4"
28
+ thinking: "auto"
29
+ metadata:
30
+ context_window_tokens: 200000
31
+ safe_input_tokens: 180000
32
+
33
+ - id: architect
34
+ api: "https://openrouter.ai/api/v1/chat/completions"
35
+ key: "sk-xxx"
36
+ interface: "openai"
37
+ model: "anthropic/claude-opus-4"
38
+ thinking: "high"
39
+ metadata:
40
+ context_window_tokens: 200000
41
+ safe_input_tokens: 180000
42
+
43
+ - id: long_context
44
+ api: "https://openrouter.ai/api/v1/chat/completions"
45
+ key: "sk-xxx"
46
+ interface: "openai"
47
+ model: "google/gemini-2.5-pro"
48
+ thinking: "auto"
49
+ metadata:
50
+ context_window_tokens: 1000000
51
+ safe_input_tokens: 900000
52
+
53
+ - id: fast_background
54
+ api: "http://localhost:11434/v1/chat/completions"
55
+ key: "ollama"
56
+ interface: "openai"
57
+ model: "qwen2.5-coder:latest"
58
+ thinking: "off"
59
+ metadata:
60
+ context_window_tokens: 32000
61
+ safe_input_tokens: 24000
62
+
63
+ Router:
64
+ default: "sonnet"
65
+ think: "architect"
66
+ longContext: "long_context"
67
+ longContextThreshold: 60000
68
+ background: "fast_background"
69
+ webSearch: "sonnet"
70
+
71
+ SmartRouter:
72
+ enabled: true
73
+ analysis_scope: "last_message"
74
+ rules:
75
+ - name: "long_context"
76
+ priority: 95
77
+ enabled: true
78
+ description: "长文档、长上下文、全文总结或需要大窗口承载的请求"
79
+ patterns:
80
+ - type: exact
81
+ keywords:
82
+ - "长上下文"
83
+ - "长文档"
84
+ - "全文总结"
85
+ - "large context"
86
+ - "long context"
87
+ - type: regex
88
+ pattern: "(长上下文|长文档|全文总结|long context|large context)"
89
+ model: "long_context"
90
+ semantic_profile:
91
+ prototype: "长文档 长上下文 全文 总结 大窗口 large context long document"
92
+
93
+ - name: "architecture"
94
+ priority: 90
95
+ enabled: true
96
+ description: "架构设计、系统设计、技术方案和模块拆分"
97
+ patterns:
98
+ - type: exact
99
+ keywords:
100
+ - "架构设计"
101
+ - "系统设计"
102
+ - "技术方案"
103
+ - "模块拆分"
104
+ - "architecture"
105
+ - "system design"
106
+ - type: regex
107
+ pattern: "(架构|系统设计|技术方案|模块拆分|architecture|system design)"
108
+ model: "architect"
109
+ semantic_profile:
110
+ prototype: "架构 系统设计 技术方案 模块边界 演进路线 architecture system design"
111
+
112
+ - name: "review"
113
+ priority: 80
114
+ enabled: true
115
+ description: "代码审查、风险检查、安全检查和回归风险评估"
116
+ patterns:
117
+ - type: exact
118
+ keywords:
119
+ - "代码审查"
120
+ - "code review"
121
+ - "review code"
122
+ - "检查代码"
123
+ - "安全风险"
124
+ - "回归风险"
125
+ - type: regex
126
+ pattern: "(代码|code).{0,8}(审查|review|检查|审核)"
127
+ model: "reviewer"
128
+ semantic_profile:
129
+ prototype: "代码审查 风险 安全 回归 regression review bug finding"
130
+
131
+ - name: "coding"
132
+ priority: 70
133
+ enabled: true
134
+ description: "实现功能、修复 bug、重构代码和补测试"
135
+ patterns:
136
+ - type: exact
137
+ keywords:
138
+ - "实现"
139
+ - "写代码"
140
+ - "修复 bug"
141
+ - "补测试"
142
+ - "implement"
143
+ - "refactor"
144
+ - "feature"
145
+ - type: regex
146
+ pattern: "(实现|编写|修复|重构|补测试|implement|refactor|feature|bug)"
147
+ model: "sonnet"
148
+ semantic_profile:
149
+ prototype: "实现 功能 修复 bug 重构 单元测试 编程 coding implementation"
150
+
151
+ - name: "fast_reply"
152
+ priority: 10
153
+ enabled: true
154
+ description: "简单问题、快速答复、短答案和低成本后台任务"
155
+ patterns:
156
+ - type: exact
157
+ keywords:
158
+ - "快速回答"
159
+ - "简单回答"
160
+ - "不用详细"
161
+ - "quick"
162
+ - "short answer"
163
+ - "simple"
164
+ - type: regex
165
+ pattern: "(快速回答|简单回答|不用详细|quick|short answer|simple)"
166
+ model: "fast_background"
167
+ semantic_profile:
168
+ prototype: "快速 简单 短答案 低成本 fast quick short answer simple"
169
+
170
+ router_model: "sonnet"
171
+ candidates:
172
+ - model: "sonnet"
173
+ description: "通用 coding、日常调试、多轮任务和默认 Claude Code 体验"
174
+ - model: "reviewer"
175
+ description: "代码审查、风险识别、安全检查和回归影响判断"
176
+ - model: "architect"
177
+ description: "架构设计、系统方案、复杂权衡和高质量长推理"
178
+ - model: "long_context"
179
+ description: "长文档、超长上下文、全文总结和大规格输入"
180
+ - model: "fast_background"
181
+ description: "快速短答、低成本后台任务和简单重复问题"
182
+ cache_ttl: 600000
183
+ max_tokens: 256
184
+ fallback: "default"
185
+ router_hint:
186
+ include_task_summary: true
187
+ include_top_route_candidates: true
188
+
189
+ sticky:
190
+ enabled: true
191
+ session_ttl_ms: 3600000
192
+ fingerprint_similarity_threshold: 0.82
193
+ break_on_explicit_route: true
194
+ # Claude Code 的请求本身会携带会话上下文。
195
+ # 只有明确需要跨模型交接摘要,并接受额外 summarizer 调用时,再开启 alignment。
196
+ alignment:
197
+ enabled: false
198
+ summarizer_model: "sonnet"
199
+ max_summary_tokens: 256
200
+
201
+ semantic:
202
+ enabled: true
203
+ mode: "embedding"
204
+ threshold: 0.2
205
+ prototypes:
206
+ coding: "实现 功能 修复 bug 重构 单元测试 编程 coding implementation"
207
+ review: "代码审查 风险 安全 回归 regression review bug finding"
208
+ architecture: "架构 系统设计 技术方案 模块边界 演进路线 architecture system design"
209
+ long_context: "长文档 长上下文 全文 总结 大窗口 large context long document"
210
+ fast_reply: "快速 简单 短答案 低成本 fast quick short answer simple"
211
+
212
+ Governance:
213
+ enabled: true