@peterwangze/claude-trigger-router 1.0.3 → 1.0.5
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 +360 -296
- package/config/trigger.advanced.yaml +210 -0
- package/config/trigger.example.yaml +4 -191
- package/dist/cli.js +1494 -363
- package/dist/cli.js.map +4 -4
- package/package.json +9 -1
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Claude Trigger Router 完整配置示例
|
|
2
|
+
# 这是偏进阶的参考模板,不是新用户的最小起步配置。
|
|
3
|
+
# 如果你是首次使用,优先运行 `ctr setup`,或先参考 README 中的最小配置。
|
|
4
|
+
# 复制到 ~/.claude-trigger-router/config.yaml 后,先替换 API Key 和模型名。
|
|
5
|
+
#
|
|
6
|
+
# 常见 provider preset(与 `ctr setup` 保持一致):
|
|
7
|
+
# - openrouter: https://openrouter.ai/api/v1/chat/completions
|
|
8
|
+
# - deepseek: https://api.deepseek.com/chat/completions
|
|
9
|
+
# - openai-compatible: https://api.openai.com/v1/chat/completions
|
|
10
|
+
# - anthropic: https://api.anthropic.com/v1/messages
|
|
11
|
+
# - siliconflow: https://api.siliconflow.cn/v1/chat/completions
|
|
12
|
+
# - custom/local: 自定义兼容地址,例如 Ollama / vLLM / one-api
|
|
13
|
+
|
|
14
|
+
HOST: "127.0.0.1"
|
|
15
|
+
PORT: 5678
|
|
16
|
+
|
|
17
|
+
LOG: true
|
|
18
|
+
LOG_LEVEL: "debug"
|
|
19
|
+
|
|
20
|
+
# 1) Models:主入口。每个模型直接配置成一个可引用的接入项
|
|
21
|
+
Models:
|
|
22
|
+
- id: sonnet
|
|
23
|
+
api: "https://openrouter.ai/api/v1/chat/completions"
|
|
24
|
+
key: "sk-xxx"
|
|
25
|
+
interface: "openai"
|
|
26
|
+
model: "anthropic/claude-sonnet-4"
|
|
27
|
+
thinking: "auto"
|
|
28
|
+
|
|
29
|
+
- id: opus
|
|
30
|
+
api: "https://openrouter.ai/api/v1/chat/completions"
|
|
31
|
+
key: "sk-xxx"
|
|
32
|
+
interface: "openai"
|
|
33
|
+
model: "anthropic/claude-opus-4"
|
|
34
|
+
|
|
35
|
+
- id: deepseek_reasoner
|
|
36
|
+
api: "https://api.deepseek.com/chat/completions"
|
|
37
|
+
key: "sk-xxx"
|
|
38
|
+
interface: "openai"
|
|
39
|
+
model: "deepseek-reasoner"
|
|
40
|
+
thinking: "high"
|
|
41
|
+
|
|
42
|
+
- id: ollama_qwen
|
|
43
|
+
api: "http://localhost:11434/v1/chat/completions"
|
|
44
|
+
key: "ollama"
|
|
45
|
+
interface: "openai"
|
|
46
|
+
model: "qwen2.5-coder:latest"
|
|
47
|
+
thinking: "off"
|
|
48
|
+
|
|
49
|
+
# 2) Router:基础路由,统一直接引用 model id
|
|
50
|
+
Router:
|
|
51
|
+
default: "sonnet"
|
|
52
|
+
background: "ollama_qwen"
|
|
53
|
+
think: "deepseek_reasoner"
|
|
54
|
+
longContext: "opus"
|
|
55
|
+
longContextThreshold: 60000
|
|
56
|
+
webSearch: "sonnet"
|
|
57
|
+
|
|
58
|
+
# 3) TriggerRouter:高确定性任务优先走规则路由
|
|
59
|
+
TriggerRouter:
|
|
60
|
+
enabled: true
|
|
61
|
+
analysis_scope: "last_message"
|
|
62
|
+
llm_intent_recognition: false
|
|
63
|
+
rules:
|
|
64
|
+
- name: "architecture"
|
|
65
|
+
priority: 90
|
|
66
|
+
enabled: true
|
|
67
|
+
description: "架构设计与系统方案任务"
|
|
68
|
+
patterns:
|
|
69
|
+
- type: exact
|
|
70
|
+
keywords:
|
|
71
|
+
- "架构设计"
|
|
72
|
+
- "系统设计"
|
|
73
|
+
- "技术方案"
|
|
74
|
+
- "architecture"
|
|
75
|
+
- "system design"
|
|
76
|
+
- type: regex
|
|
77
|
+
pattern: "(架构|系统设计|技术方案)"
|
|
78
|
+
model: "opus"
|
|
79
|
+
|
|
80
|
+
- name: "code_review"
|
|
81
|
+
priority: 80
|
|
82
|
+
enabled: true
|
|
83
|
+
description: "代码审查与风险评估任务"
|
|
84
|
+
patterns:
|
|
85
|
+
- type: exact
|
|
86
|
+
keywords:
|
|
87
|
+
- "代码审查"
|
|
88
|
+
- "code review"
|
|
89
|
+
- "review code"
|
|
90
|
+
- "检查代码"
|
|
91
|
+
- type: regex
|
|
92
|
+
pattern: "(代码|code).{0,5}(审查|review|检查|审核)"
|
|
93
|
+
model: "sonnet"
|
|
94
|
+
|
|
95
|
+
- name: "complex_reasoning"
|
|
96
|
+
priority: 70
|
|
97
|
+
enabled: true
|
|
98
|
+
description: "复杂推理与严谨分析任务"
|
|
99
|
+
patterns:
|
|
100
|
+
- type: exact
|
|
101
|
+
keywords:
|
|
102
|
+
- "深入分析"
|
|
103
|
+
- "复杂推理"
|
|
104
|
+
- "逻辑推理"
|
|
105
|
+
- "deep analysis"
|
|
106
|
+
- "reasoning"
|
|
107
|
+
- type: regex
|
|
108
|
+
pattern: "(深入|复杂|详细).{0,5}(分析|推理|解析)"
|
|
109
|
+
model: "deepseek_reasoner"
|
|
110
|
+
|
|
111
|
+
- name: "simple_task"
|
|
112
|
+
priority: 10
|
|
113
|
+
enabled: true
|
|
114
|
+
description: "快速简单任务"
|
|
115
|
+
patterns:
|
|
116
|
+
- type: exact
|
|
117
|
+
keywords:
|
|
118
|
+
- "快速"
|
|
119
|
+
- "简单"
|
|
120
|
+
- "quick"
|
|
121
|
+
- "simple"
|
|
122
|
+
model: "ollama_qwen"
|
|
123
|
+
|
|
124
|
+
# 4) SmartRouter:规则没命中时,从候选模型中自动挑选
|
|
125
|
+
SmartRouter:
|
|
126
|
+
enabled: true
|
|
127
|
+
router_model: "sonnet"
|
|
128
|
+
candidates:
|
|
129
|
+
- model: "sonnet"
|
|
130
|
+
description: "通用编程、代码生成、日常调试、多轮对话"
|
|
131
|
+
|
|
132
|
+
- model: "deepseek_reasoner"
|
|
133
|
+
description: "复杂推理、逻辑分析、需要严谨思考的任务"
|
|
134
|
+
|
|
135
|
+
- model: "opus"
|
|
136
|
+
description: "架构设计、系统规划、长文档与复杂评审任务"
|
|
137
|
+
|
|
138
|
+
cache_ttl: 600000
|
|
139
|
+
max_tokens: 256
|
|
140
|
+
fallback: "default"
|
|
141
|
+
|
|
142
|
+
# 5) Governance:治理模块也直接引用 model id
|
|
143
|
+
Governance:
|
|
144
|
+
enabled: true
|
|
145
|
+
|
|
146
|
+
sticky:
|
|
147
|
+
enabled: true
|
|
148
|
+
session_ttl_ms: 3600000
|
|
149
|
+
fingerprint_similarity_threshold: 0.82
|
|
150
|
+
break_on_explicit_route: true
|
|
151
|
+
alignment:
|
|
152
|
+
enabled: true
|
|
153
|
+
summarizer_model: "sonnet"
|
|
154
|
+
max_summary_tokens: 256
|
|
155
|
+
|
|
156
|
+
cascade:
|
|
157
|
+
enabled: true
|
|
158
|
+
max_attempts: 2
|
|
159
|
+
triggers:
|
|
160
|
+
compile_failure: true
|
|
161
|
+
test_failure: true
|
|
162
|
+
placeholder_patterns:
|
|
163
|
+
- "TODO"
|
|
164
|
+
- "...rest of code"
|
|
165
|
+
- "placeholder"
|
|
166
|
+
levels:
|
|
167
|
+
- from: "sonnet"
|
|
168
|
+
to: "opus"
|
|
169
|
+
reasoning: "high"
|
|
170
|
+
|
|
171
|
+
semantic:
|
|
172
|
+
enabled: true
|
|
173
|
+
mode: "embedding"
|
|
174
|
+
threshold: 0.2
|
|
175
|
+
prototypes:
|
|
176
|
+
architecture: "重构 系统 结构 模块 拆分 架构 设计"
|
|
177
|
+
code_review: "代码 审查 风险 评审 review"
|
|
178
|
+
complex_reasoning: "复杂 推理 分析 严谨 逻辑 reasoning"
|
|
179
|
+
|
|
180
|
+
shadow:
|
|
181
|
+
enabled: true
|
|
182
|
+
mode: "async_audit"
|
|
183
|
+
verifier_model: "sonnet"
|
|
184
|
+
sample_rate: 0.2
|
|
185
|
+
checks:
|
|
186
|
+
placeholder_patterns: true
|
|
187
|
+
length_anomaly: true
|
|
188
|
+
missing_code_block: true
|
|
189
|
+
|
|
190
|
+
observability:
|
|
191
|
+
anomaly_thresholds:
|
|
192
|
+
min_sample_size: 3
|
|
193
|
+
cascade_warn_rate: 0.4
|
|
194
|
+
cascade_critical_rate: 0.6
|
|
195
|
+
shadow_warn_rate: 0.5
|
|
196
|
+
shadow_critical_rate: 0.7
|
|
197
|
+
latency_warn_ms: 1500
|
|
198
|
+
latency_critical_ms: 3000
|
|
199
|
+
spike_warn_rate: 0.5
|
|
200
|
+
spike_delta_rate: 0.3
|
|
201
|
+
|
|
202
|
+
# 6) Legacy 兼容:旧 `Providers` 仅作为兼容层保留,不建议新配置继续扩展
|
|
203
|
+
# Providers:
|
|
204
|
+
# - name: openrouter
|
|
205
|
+
# api_base_url: "https://openrouter.ai/api/v1/chat/completions"
|
|
206
|
+
# api_key: "sk-xxx"
|
|
207
|
+
# models:
|
|
208
|
+
# - "anthropic/claude-sonnet-4"
|
|
209
|
+
# transformer:
|
|
210
|
+
# use: ["openrouter"]
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
# Claude Trigger Router
|
|
1
|
+
# Claude Trigger Router 最小配置示例
|
|
2
|
+
# `ctr init --force` 默认生成的就是这一类最小模板。
|
|
3
|
+
# 如果你是首次使用,也可以直接运行 `ctr setup`。
|
|
2
4
|
# 复制到 ~/.claude-trigger-router/config.yaml 后,先替换 API Key 和模型名。
|
|
3
|
-
#
|
|
4
|
-
# 常见 provider preset(与 `ctr setup`、`/ui` Provider template 保持一致):
|
|
5
|
-
# - openrouter: https://openrouter.ai/api/v1/chat/completions
|
|
6
|
-
# - deepseek: https://api.deepseek.com/chat/completions
|
|
7
|
-
# - openai-compatible: https://api.openai.com/v1/chat/completions
|
|
8
|
-
# - anthropic: https://api.anthropic.com/v1/messages
|
|
9
|
-
# - siliconflow: https://api.siliconflow.cn/v1/chat/completions
|
|
10
|
-
# - custom/local: 自定义兼容地址,例如 Ollama / vLLM / one-api
|
|
11
5
|
|
|
12
6
|
HOST: "127.0.0.1"
|
|
13
|
-
PORT:
|
|
7
|
+
PORT: 5678
|
|
14
8
|
|
|
15
9
|
LOG: true
|
|
16
10
|
LOG_LEVEL: "debug"
|
|
17
11
|
|
|
18
|
-
# 1) Models:推荐优先使用的简化模型接入配置
|
|
19
12
|
Models:
|
|
20
13
|
- id: sonnet
|
|
21
14
|
api: "https://openrouter.ai/api/v1/chat/completions"
|
|
@@ -24,185 +17,5 @@ Models:
|
|
|
24
17
|
model: "anthropic/claude-sonnet-4"
|
|
25
18
|
thinking: "auto"
|
|
26
19
|
|
|
27
|
-
- id: opus
|
|
28
|
-
api: "https://openrouter.ai/api/v1/chat/completions"
|
|
29
|
-
key: "sk-xxx"
|
|
30
|
-
interface: "openai"
|
|
31
|
-
model: "anthropic/claude-opus-4"
|
|
32
|
-
|
|
33
|
-
- id: deepseek_reasoner
|
|
34
|
-
api: "https://api.deepseek.com/chat/completions"
|
|
35
|
-
key: "sk-xxx"
|
|
36
|
-
interface: "openai"
|
|
37
|
-
model: "deepseek-reasoner"
|
|
38
|
-
thinking: "high"
|
|
39
|
-
|
|
40
|
-
- id: ollama_qwen
|
|
41
|
-
api: "http://localhost:11434/v1/chat/completions"
|
|
42
|
-
key: "ollama"
|
|
43
|
-
interface: "openai"
|
|
44
|
-
model: "qwen2.5-coder:latest"
|
|
45
|
-
thinking: "off"
|
|
46
|
-
|
|
47
|
-
# 2) Router:推荐直接引用 model id
|
|
48
20
|
Router:
|
|
49
21
|
default: "sonnet"
|
|
50
|
-
background: "ollama_qwen"
|
|
51
|
-
think: "deepseek_reasoner"
|
|
52
|
-
longContext: "opus"
|
|
53
|
-
longContextThreshold: 60000
|
|
54
|
-
webSearch: "sonnet"
|
|
55
|
-
|
|
56
|
-
# 3) TriggerRouter:高确定性任务优先走规则路由
|
|
57
|
-
TriggerRouter:
|
|
58
|
-
enabled: true
|
|
59
|
-
analysis_scope: "last_message"
|
|
60
|
-
llm_intent_recognition: false
|
|
61
|
-
rules:
|
|
62
|
-
- name: "architecture"
|
|
63
|
-
priority: 90
|
|
64
|
-
enabled: true
|
|
65
|
-
description: "架构设计与系统方案任务"
|
|
66
|
-
patterns:
|
|
67
|
-
- type: exact
|
|
68
|
-
keywords:
|
|
69
|
-
- "架构设计"
|
|
70
|
-
- "系统设计"
|
|
71
|
-
- "技术方案"
|
|
72
|
-
- "architecture"
|
|
73
|
-
- "system design"
|
|
74
|
-
- type: regex
|
|
75
|
-
pattern: "(架构|系统设计|技术方案)"
|
|
76
|
-
model: "opus"
|
|
77
|
-
|
|
78
|
-
- name: "code_review"
|
|
79
|
-
priority: 80
|
|
80
|
-
enabled: true
|
|
81
|
-
description: "代码审查与风险评估任务"
|
|
82
|
-
patterns:
|
|
83
|
-
- type: exact
|
|
84
|
-
keywords:
|
|
85
|
-
- "代码审查"
|
|
86
|
-
- "code review"
|
|
87
|
-
- "review code"
|
|
88
|
-
- "检查代码"
|
|
89
|
-
- type: regex
|
|
90
|
-
pattern: "(代码|code).{0,5}(审查|review|检查|审核)"
|
|
91
|
-
model: "sonnet"
|
|
92
|
-
|
|
93
|
-
- name: "complex_reasoning"
|
|
94
|
-
priority: 70
|
|
95
|
-
enabled: true
|
|
96
|
-
description: "复杂推理与严谨分析任务"
|
|
97
|
-
patterns:
|
|
98
|
-
- type: exact
|
|
99
|
-
keywords:
|
|
100
|
-
- "深入分析"
|
|
101
|
-
- "复杂推理"
|
|
102
|
-
- "逻辑推理"
|
|
103
|
-
- "deep analysis"
|
|
104
|
-
- "reasoning"
|
|
105
|
-
- type: regex
|
|
106
|
-
pattern: "(深入|复杂|详细).{0,5}(分析|推理|解析)"
|
|
107
|
-
model: "deepseek_reasoner"
|
|
108
|
-
|
|
109
|
-
- name: "simple_task"
|
|
110
|
-
priority: 10
|
|
111
|
-
enabled: true
|
|
112
|
-
description: "快速简单任务"
|
|
113
|
-
patterns:
|
|
114
|
-
- type: exact
|
|
115
|
-
keywords:
|
|
116
|
-
- "快速"
|
|
117
|
-
- "简单"
|
|
118
|
-
- "quick"
|
|
119
|
-
- "simple"
|
|
120
|
-
model: "ollama_qwen"
|
|
121
|
-
|
|
122
|
-
# 4) SmartRouter:规则没命中时,让路由模型从候选模型中挑选
|
|
123
|
-
SmartRouter:
|
|
124
|
-
enabled: true
|
|
125
|
-
router_model: "sonnet"
|
|
126
|
-
candidates:
|
|
127
|
-
- model: "sonnet"
|
|
128
|
-
description: "通用编程、代码生成、日常调试、多轮对话"
|
|
129
|
-
|
|
130
|
-
- model: "deepseek_reasoner"
|
|
131
|
-
description: "复杂推理、逻辑分析、需要严谨思考的任务"
|
|
132
|
-
|
|
133
|
-
- model: "opus"
|
|
134
|
-
description: "架构设计、系统规划、长文档与复杂评审任务"
|
|
135
|
-
|
|
136
|
-
cache_ttl: 600000
|
|
137
|
-
max_tokens: 256
|
|
138
|
-
fallback: "default"
|
|
139
|
-
|
|
140
|
-
# 5) Governance:治理配置也推荐直接引用 model id
|
|
141
|
-
Governance:
|
|
142
|
-
enabled: true
|
|
143
|
-
|
|
144
|
-
sticky:
|
|
145
|
-
enabled: true
|
|
146
|
-
session_ttl_ms: 3600000
|
|
147
|
-
fingerprint_similarity_threshold: 0.82
|
|
148
|
-
break_on_explicit_route: true
|
|
149
|
-
alignment:
|
|
150
|
-
enabled: true
|
|
151
|
-
summarizer_model: "sonnet"
|
|
152
|
-
max_summary_tokens: 256
|
|
153
|
-
|
|
154
|
-
cascade:
|
|
155
|
-
enabled: true
|
|
156
|
-
max_attempts: 2
|
|
157
|
-
triggers:
|
|
158
|
-
compile_failure: true
|
|
159
|
-
test_failure: true
|
|
160
|
-
placeholder_patterns:
|
|
161
|
-
- "TODO"
|
|
162
|
-
- "...rest of code"
|
|
163
|
-
- "placeholder"
|
|
164
|
-
levels:
|
|
165
|
-
- from: "sonnet"
|
|
166
|
-
to: "opus"
|
|
167
|
-
reasoning: "high"
|
|
168
|
-
|
|
169
|
-
semantic:
|
|
170
|
-
enabled: true
|
|
171
|
-
mode: "embedding"
|
|
172
|
-
threshold: 0.2
|
|
173
|
-
prototypes:
|
|
174
|
-
architecture: "重构 系统 结构 模块 拆分 架构 设计"
|
|
175
|
-
code_review: "代码 审查 风险 评审 review"
|
|
176
|
-
complex_reasoning: "复杂 推理 分析 严谨 逻辑 reasoning"
|
|
177
|
-
|
|
178
|
-
shadow:
|
|
179
|
-
enabled: true
|
|
180
|
-
mode: "async_audit"
|
|
181
|
-
verifier_model: "sonnet"
|
|
182
|
-
sample_rate: 0.2
|
|
183
|
-
checks:
|
|
184
|
-
placeholder_patterns: true
|
|
185
|
-
length_anomaly: true
|
|
186
|
-
missing_code_block: true
|
|
187
|
-
|
|
188
|
-
observability:
|
|
189
|
-
anomaly_thresholds:
|
|
190
|
-
min_sample_size: 3
|
|
191
|
-
cascade_warn_rate: 0.4
|
|
192
|
-
cascade_critical_rate: 0.6
|
|
193
|
-
shadow_warn_rate: 0.5
|
|
194
|
-
shadow_critical_rate: 0.7
|
|
195
|
-
latency_warn_ms: 1500
|
|
196
|
-
latency_critical_ms: 3000
|
|
197
|
-
spike_warn_rate: 0.5
|
|
198
|
-
spike_delta_rate: 0.3
|
|
199
|
-
|
|
200
|
-
# 6) Legacy 兼容:如果你仍在使用旧配置,可继续保留 Providers
|
|
201
|
-
# Providers:
|
|
202
|
-
# - name: openrouter
|
|
203
|
-
# api_base_url: "https://openrouter.ai/api/v1/chat/completions"
|
|
204
|
-
# api_key: "sk-xxx"
|
|
205
|
-
# models:
|
|
206
|
-
# - "anthropic/claude-sonnet-4"
|
|
207
|
-
# transformer:
|
|
208
|
-
# use: ["openrouter"]
|