@halilertekin/claude-code-router-config 1.3.8 โ 2.0.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/LICENSE +1 -4
- package/NPM_README.md +15 -8
- package/README.md +22 -18
- package/cli/commands.js +257 -145
- package/config/config.json +4 -3
- package/config/glm-only.json +1 -1
- package/config/intent-router.js +1 -2
- package/docs/AGENTSKILLS_INTEGRATION.md +3 -4
- package/docs/AGENTSKILLS_SETUP.md +7 -11
- package/docs/AGENTSKILLS_SETUP_TR.md +7 -11
- package/docs/FULL_DOCUMENTATION.md +7 -12
- package/docs/FULL_DOCUMENTATION_EN.md +7 -12
- package/docs/HOMEBREW_SETUP.md +4 -7
- package/docs/README_EN.md +4 -3
- package/docs/SETUP_PROMPT.md +9 -9
- package/docs/SETUP_PROMPT_EN.md +9 -9
- package/docs/v1.1.0-FEATURES.md +2 -3
- package/install.js +45 -48
- package/install.sh +3 -6
- package/package.json +4 -4
- package/setup-glm.sh +13 -2
- package/templates/balanced.json +1 -1
- package/templates/cost-optimized.json +1 -1
- package/templates/development.json +1 -1
- package/templates/performance-optimized.json +1 -1
- package/templates/quality-focused.json +1 -1
package/LICENSE
CHANGED
|
@@ -24,7 +24,4 @@ SOFTWARE.
|
|
|
24
24
|
|
|
25
25
|
## Attribution
|
|
26
26
|
|
|
27
|
-
This package provides configuration for
|
|
28
|
-
Original project: https://github.com/musistudio/claude-code-router
|
|
29
|
-
|
|
30
|
-
The configuration files and intent-based routing logic in this package are designed to work with the original Claude Code Router created by musistudio.
|
|
27
|
+
This package provides a unified router and configuration for Claude Code workflows.
|
package/NPM_README.md
CHANGED
|
@@ -12,6 +12,20 @@ npm install -g @halilertekin/claude-code-router-config
|
|
|
12
12
|
ccr-setup
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
### Non-interactive install (CI)
|
|
16
|
+
|
|
17
|
+
If you run in CI or without a TTY, the installer skips existing config files by default.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Skip prompts (CI-friendly)
|
|
21
|
+
CCR_CONFIG_NO_PROMPT=1 ccr-setup
|
|
22
|
+
|
|
23
|
+
# Force overwrite existing config files
|
|
24
|
+
CCR_CONFIG_OVERWRITE=1 ccr-setup
|
|
25
|
+
# or
|
|
26
|
+
ccr-setup --overwrite
|
|
27
|
+
```
|
|
28
|
+
|
|
15
29
|
### One-shot GLM setup (Claude login + GLM API)
|
|
16
30
|
|
|
17
31
|
```bash
|
|
@@ -83,6 +97,7 @@ After installation:
|
|
|
83
97
|
|
|
84
98
|
4. **Start router**:
|
|
85
99
|
```bash
|
|
100
|
+
ccr start
|
|
86
101
|
ccr code
|
|
87
102
|
```
|
|
88
103
|
|
|
@@ -164,16 +179,8 @@ The installer creates:
|
|
|
164
179
|
- [Complete Documentation](https://github.com/halilertekin/claude-code-router-config/docs/FULL_DOCUMENTATION_EN.md)
|
|
165
180
|
- [GitHub Repository](https://github.com/halilertekin/claude-code-router-config)
|
|
166
181
|
|
|
167
|
-
## Attribution
|
|
168
|
-
|
|
169
|
-
This package provides configuration for [@musistudio/claude-code-router](https://github.com/musistudio/claude-code-router), the original tool that enables Claude Code functionality with multiple AI providers.
|
|
170
|
-
|
|
171
|
-
The original Claude Code Router project is developed and maintained by musistudio. This package contains pre-configured routing logic and provider configurations.
|
|
172
|
-
|
|
173
182
|
## License
|
|
174
183
|
|
|
175
184
|
MIT ยฉ [Halil Ertekin](https://github.com/halilertekin)
|
|
176
185
|
|
|
177
186
|
---
|
|
178
|
-
|
|
179
|
-
**Note**: This is a configuration package. Requires the original [@musistudio/claude-code-router](https://github.com/musistudio/claude-code-router) to function.
|
package/README.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# Claude Code Router Config - Advanced Multi-Provider Setup
|
|
2
2
|
|
|
3
|
-
๐ **
|
|
3
|
+
๐ **v2.0.0** - Unified router + config package with z.ai (GLM 4.7) support, advanced CLI tools, analytics, smart routing, and configuration templates!
|
|
4
4
|
|
|
5
5
|
Use Claude Code as a single interface to access multiple AI providers with intelligent routing for optimal performance, cost, and quality.
|
|
6
6
|
|
|
7
|
-
## โจ New in
|
|
7
|
+
## โจ New in v2.0.0
|
|
8
8
|
- **z.ai Support**: Native integration for GLM-4.7 via z.ai (PPInfra).
|
|
9
9
|
- **Lightweight Mode**: New `ccc` function for zero-dependency routing.
|
|
10
10
|
- **Direct GLM Alias**: Type `glm` to launch Claude Code with GLM-4.7 immediately.
|
|
11
|
+
- **Non-interactive install**: CI-friendly installer flags and env controls.
|
|
12
|
+
- **Unified router**: Built-in router service, no external dependency required.
|
|
11
13
|
|
|
12
14
|
## ๐ Setup on Another Machine (Fastest Way)
|
|
13
15
|
|
|
@@ -76,23 +78,33 @@ pnpm add -g @halilertekin/claude-code-router-config
|
|
|
76
78
|
# System is ready! Run: ccr --help
|
|
77
79
|
```
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
Then run the installer to copy config files:
|
|
80
82
|
|
|
81
|
-
|
|
83
|
+
```bash
|
|
84
|
+
ccr-setup
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Non-interactive usage (CI):
|
|
82
88
|
|
|
83
89
|
```bash
|
|
84
|
-
|
|
90
|
+
CCR_CONFIG_NO_PROMPT=1 ccr-setup
|
|
91
|
+
CCR_CONFIG_OVERWRITE=1 ccr-setup
|
|
92
|
+
# or
|
|
93
|
+
ccr-setup --overwrite
|
|
85
94
|
```
|
|
86
95
|
|
|
87
|
-
|
|
96
|
+
### Option 2: Manual Setup
|
|
97
|
+
|
|
98
|
+
#### 1. Copy Configuration Files
|
|
88
99
|
|
|
89
100
|
```bash
|
|
90
101
|
mkdir -p ~/.claude-code-router
|
|
91
102
|
cp config/config.json ~/.claude-code-router/
|
|
92
103
|
cp config/intent-router.js ~/.claude-code-router/
|
|
104
|
+
cp config/smart-intent-router.js ~/.claude-code-router/
|
|
93
105
|
```
|
|
94
106
|
|
|
95
|
-
####
|
|
107
|
+
#### 2. Set Up Environment Variables
|
|
96
108
|
|
|
97
109
|
Create `.env` file:
|
|
98
110
|
|
|
@@ -101,11 +113,11 @@ cp .env.example ~/.env
|
|
|
101
113
|
# Edit ~/.env with your API keys
|
|
102
114
|
```
|
|
103
115
|
|
|
104
|
-
####
|
|
116
|
+
#### 3. Start Router
|
|
105
117
|
|
|
106
118
|
```bash
|
|
107
119
|
source ~/.zshrc
|
|
108
|
-
|
|
120
|
+
node router/server.js
|
|
109
121
|
```
|
|
110
122
|
|
|
111
123
|
## API Key Setup
|
|
@@ -163,20 +175,12 @@ Metrics tracked:
|
|
|
163
175
|
- [Setup Prompt (TR)](docs/SETUP_PROMPT.md)
|
|
164
176
|
- [Configuration Templates Guide](templates/README.md)
|
|
165
177
|
|
|
166
|
-
## Attribution
|
|
167
|
-
|
|
168
|
-
This package provides configuration for [@musistudio/claude-code-router](https://github.com/musistudio/claude-code-router), an excellent tool that enables Claude Code functionality with multiple AI providers.
|
|
169
|
-
|
|
170
|
-
The original Claude Code Router project is developed and maintained by musistudio. This package contains pre-configured routing logic, advanced CLI tools, and provider configurations to help users get started quickly and optimize their AI workflows.
|
|
171
|
-
|
|
172
178
|
## License
|
|
173
179
|
|
|
174
180
|
MIT ยฉ [Halil Ertekin](https://github.com/halilertekin)
|
|
175
181
|
|
|
176
182
|
---
|
|
177
183
|
|
|
178
|
-
**Note**: This is an enhanced configuration package. To use it, you need to install the original [@musistudio/claude-code-router](https://github.com/musistudio/claude-code-router) package.
|
|
179
|
-
|
|
180
184
|
## ๐ Show Your Support
|
|
181
185
|
|
|
182
|
-
If you find this useful, please give it a โญ on [GitHub](https://github.com/halilertekin/CC-RouterMultiProvider)!
|
|
186
|
+
If you find this useful, please give it a โญ on [GitHub](https://github.com/halilertekin/CC-RouterMultiProvider)!
|
package/cli/commands.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
4
5
|
const path = require('path');
|
|
5
6
|
const { spawn } = require('child_process');
|
|
6
7
|
const chalk = require('./chalk-safe');
|
|
7
|
-
const configPath = path.join(
|
|
8
|
+
const configPath = path.join(os.homedir(), '.claude-code-router');
|
|
9
|
+
const pidFile = path.join(configPath, 'router.pid');
|
|
10
|
+
const serverScript = path.join(__dirname, '..', 'router', 'server.js');
|
|
8
11
|
|
|
9
12
|
// Load config
|
|
10
13
|
function loadConfig() {
|
|
@@ -16,6 +19,102 @@ function loadConfig() {
|
|
|
16
19
|
}
|
|
17
20
|
}
|
|
18
21
|
|
|
22
|
+
function readPid() {
|
|
23
|
+
if (!fs.existsSync(pidFile)) return null;
|
|
24
|
+
const pid = parseInt(fs.readFileSync(pidFile, 'utf8'), 10);
|
|
25
|
+
return Number.isNaN(pid) ? null : pid;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function isProcessRunning(pid) {
|
|
29
|
+
if (!pid) return false;
|
|
30
|
+
try {
|
|
31
|
+
process.kill(pid, 0);
|
|
32
|
+
return true;
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function startRouter() {
|
|
39
|
+
const existingPid = readPid();
|
|
40
|
+
if (existingPid && isProcessRunning(existingPid)) {
|
|
41
|
+
console.log(chalk.yellow(`โ ๏ธ Router already running (PID ${existingPid})`));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const child = spawn(process.execPath, [serverScript], {
|
|
46
|
+
detached: true,
|
|
47
|
+
stdio: 'ignore',
|
|
48
|
+
env: process.env
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
fs.mkdirSync(configPath, { recursive: true });
|
|
52
|
+
fs.writeFileSync(pidFile, `${child.pid}`);
|
|
53
|
+
child.unref();
|
|
54
|
+
|
|
55
|
+
console.log(chalk.green(`โ
Router started (PID ${child.pid})`));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function stopRouter() {
|
|
59
|
+
const pid = readPid();
|
|
60
|
+
if (!pid) {
|
|
61
|
+
console.log(chalk.yellow('โ ๏ธ Router is not running'));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!isProcessRunning(pid)) {
|
|
66
|
+
fs.unlinkSync(pidFile);
|
|
67
|
+
console.log(chalk.yellow('โ ๏ธ Router process not found (stale PID cleaned)'));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
process.kill(pid);
|
|
73
|
+
fs.unlinkSync(pidFile);
|
|
74
|
+
console.log(chalk.green(`โ
Router stopped (PID ${pid})`));
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error(chalk.red(`โ Failed to stop router: ${error.message}`));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function restartRouter() {
|
|
81
|
+
stopRouter();
|
|
82
|
+
startRouter();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function showStatus() {
|
|
86
|
+
const pid = readPid();
|
|
87
|
+
const running = isProcessRunning(pid);
|
|
88
|
+
const config = loadConfig();
|
|
89
|
+
const host = config.HOST || '127.0.0.1';
|
|
90
|
+
const port = config.PORT || 3456;
|
|
91
|
+
|
|
92
|
+
console.log(chalk.blue('๐ Router Status'));
|
|
93
|
+
console.log(chalk.gray('โ'.repeat(40)));
|
|
94
|
+
console.log(` Running: ${running ? '๐ข Yes' : '๐ด No'}`);
|
|
95
|
+
console.log(` PID: ${pid || '-'}`);
|
|
96
|
+
console.log(` Endpoint: http://${host}:${port}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function openUi(portOverride) {
|
|
100
|
+
const config = loadConfig();
|
|
101
|
+
const port = portOverride || config.PORT || 3456;
|
|
102
|
+
const url = `http://127.0.0.1:${port}/ui`;
|
|
103
|
+
|
|
104
|
+
const opener = process.platform === 'darwin'
|
|
105
|
+
? 'open'
|
|
106
|
+
: process.platform === 'win32'
|
|
107
|
+
? 'start'
|
|
108
|
+
: 'xdg-open';
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
spawn(opener, [url], { detached: true, stdio: 'ignore' }).unref();
|
|
112
|
+
console.log(chalk.green(`โ
Opened dashboard: ${url}`));
|
|
113
|
+
} catch {
|
|
114
|
+
console.log(chalk.yellow(`Dashboard URL: ${url}`));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
19
118
|
// Test provider connectivity
|
|
20
119
|
async function testProvider(provider, model) {
|
|
21
120
|
const config = loadConfig();
|
|
@@ -219,157 +318,170 @@ function backupConfig() {
|
|
|
219
318
|
}
|
|
220
319
|
}
|
|
221
320
|
|
|
222
|
-
// Helper to find original ccr binary
|
|
223
|
-
function getOriginalCcrPath() {
|
|
224
|
-
try {
|
|
225
|
-
// Try to find it in dependencies
|
|
226
|
-
return require.resolve('@musistudio/claude-code-router/dist/cli.js');
|
|
227
|
-
} catch (e) {
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Proxy command to original router
|
|
233
|
-
function proxyToOriginal(args) {
|
|
234
|
-
const originalPath = getOriginalCcrPath();
|
|
235
|
-
if (!originalPath) {
|
|
236
|
-
console.error(chalk.red('โ Original @musistudio/claude-code-router not found.'));
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const child = spawn('node', [originalPath, ...args], {
|
|
241
|
-
stdio: 'inherit',
|
|
242
|
-
env: process.env
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
child.on('exit', (code) => {
|
|
246
|
-
if (code !== 0) {
|
|
247
|
-
process.exit(code || 1);
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
|
|
252
321
|
// CLI command handler
|
|
253
322
|
async function main() {
|
|
254
323
|
const [command, ...args] = process.argv.slice(2);
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
stdio: 'inherit',
|
|
266
|
-
env: process.env
|
|
267
|
-
});
|
|
268
|
-
updateProcess.on('exit', (code) => {
|
|
269
|
-
if (code === 0) {
|
|
270
|
-
console.log(chalk.green('โ
Successfully updated to the latest version!'));
|
|
271
|
-
} else {
|
|
272
|
-
console.error(chalk.red(`โ Update failed with code ${code}. Please try running manually: pnpm add -g @halilertekin/claude-code-router-config@latest`));
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
break;
|
|
276
|
-
|
|
277
|
-
case 'version':
|
|
278
|
-
case '-v':
|
|
279
|
-
case '--version':
|
|
280
|
-
const packageJson = require('../package.json');
|
|
281
|
-
console.log(chalk.blue(`v${packageJson.version}`));
|
|
282
|
-
break;
|
|
283
|
-
|
|
284
|
-
case 'test':
|
|
285
|
-
const provider = args[0];
|
|
286
|
-
const model = args[1];
|
|
287
|
-
if (provider) {
|
|
288
|
-
await testProvider(provider, model);
|
|
324
|
+
switch (command) {
|
|
325
|
+
case 'update': {
|
|
326
|
+
console.log(chalk.blue('๐ Checking for updates and updating...'));
|
|
327
|
+
const updateProcess = spawn('pnpm', ['add', '-g', '@halilertekin/claude-code-router-config@latest'], {
|
|
328
|
+
stdio: 'inherit',
|
|
329
|
+
env: process.env
|
|
330
|
+
});
|
|
331
|
+
updateProcess.on('exit', (code) => {
|
|
332
|
+
if (code === 0) {
|
|
333
|
+
console.log(chalk.green('โ
Successfully updated to the latest version!'));
|
|
289
334
|
} else {
|
|
290
|
-
console.error(chalk.red(
|
|
335
|
+
console.error(chalk.red(`โ Update failed with code ${code}. Please try running manually: pnpm add -g @halilertekin/claude-code-router-config@latest`));
|
|
291
336
|
}
|
|
292
|
-
|
|
337
|
+
});
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
case 'version':
|
|
342
|
+
case '-v':
|
|
343
|
+
case '--version': {
|
|
344
|
+
const packageJson = require('../package.json');
|
|
345
|
+
console.log(chalk.blue(`v${packageJson.version}`));
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
293
348
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
349
|
+
case 'start':
|
|
350
|
+
startRouter();
|
|
351
|
+
break;
|
|
352
|
+
|
|
353
|
+
case 'stop':
|
|
354
|
+
stopRouter();
|
|
355
|
+
break;
|
|
356
|
+
|
|
357
|
+
case 'restart':
|
|
358
|
+
restartRouter();
|
|
359
|
+
break;
|
|
360
|
+
|
|
361
|
+
case 'status':
|
|
362
|
+
if (args.includes('--detailed')) {
|
|
363
|
+
const statusOptions = {
|
|
364
|
+
detailed: true,
|
|
365
|
+
showCosts: args.includes('--show-costs')
|
|
298
366
|
};
|
|
299
|
-
await
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
console.
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
console.log(chalk.yellow('\n๐ฆ Core Router Commands (Proxy):'));
|
|
358
|
-
console.log(' start - Start router server (Backend only)');
|
|
359
|
-
console.log(' stop - Stop router server');
|
|
360
|
-
console.log(' restart - Restart router server');
|
|
361
|
-
console.log(' status - Show server status');
|
|
362
|
-
console.log(' code - Start Router + Claude Code (Recommended)');
|
|
363
|
-
console.log(' model - Switch models at runtime');
|
|
364
|
-
console.log(' activate - Export env variables');
|
|
365
|
-
|
|
366
|
-
console.log(chalk.yellow('\n๐ก Tip:'));
|
|
367
|
-
console.log(' To start everything at once, run: ' + chalk.cyan('ccr code'));
|
|
368
|
-
console.log(' To only start the background server, run: ' + chalk.cyan('ccr start'));
|
|
367
|
+
await showDetailedStatus(statusOptions);
|
|
368
|
+
} else {
|
|
369
|
+
showStatus();
|
|
370
|
+
}
|
|
371
|
+
break;
|
|
372
|
+
|
|
373
|
+
case 'code': {
|
|
374
|
+
startRouter();
|
|
375
|
+
const config = loadConfig();
|
|
376
|
+
const port = config.PORT || 3456;
|
|
377
|
+
const claudePath = config.CLAUDE_PATH || process.env.CLAUDE_PATH || 'claude';
|
|
378
|
+
const env = {
|
|
379
|
+
...process.env,
|
|
380
|
+
ANTHROPIC_BASE_URL: `http://127.0.0.1:${port}`,
|
|
381
|
+
NO_PROXY: '127.0.0.1'
|
|
382
|
+
};
|
|
383
|
+
const child = spawn(claudePath, ['code', ...args], { stdio: 'inherit', env });
|
|
384
|
+
child.on('error', (error) => {
|
|
385
|
+
console.error(chalk.red(`โ Failed to start claude command: ${error.message}`));
|
|
386
|
+
console.log(chalk.yellow('Make sure Claude Code is installed: npm install -g @anthropic-ai/claude-code'));
|
|
387
|
+
});
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
case 'activate': {
|
|
392
|
+
const config = loadConfig();
|
|
393
|
+
const port = config.PORT || 3456;
|
|
394
|
+
console.log('export $(cat ~/.env | xargs)');
|
|
395
|
+
console.log(`export ANTHROPIC_BASE_URL="http://127.0.0.1:${port}"`);
|
|
396
|
+
console.log('export NO_PROXY="127.0.0.1"');
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
case 'ui': {
|
|
401
|
+
const portIndex = args.findIndex((arg) => arg === '--port' || arg === '-p');
|
|
402
|
+
const port = portIndex >= 0 ? parseInt(args[portIndex + 1], 10) : null;
|
|
403
|
+
openUi(Number.isNaN(port) ? null : port);
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
case 'test': {
|
|
408
|
+
const provider = args[0];
|
|
409
|
+
const model = args[1];
|
|
410
|
+
if (provider) {
|
|
411
|
+
await testProvider(provider, model);
|
|
412
|
+
} else {
|
|
413
|
+
console.error(chalk.red('โ Please specify a provider: ccr test <provider> [model]'));
|
|
414
|
+
}
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
case 'benchmark': {
|
|
419
|
+
const options = {
|
|
420
|
+
allProviders: args.includes('--all'),
|
|
421
|
+
compareSpeed: args.includes('--compare-speed')
|
|
422
|
+
};
|
|
423
|
+
await benchmarkProviders(options);
|
|
424
|
+
break;
|
|
369
425
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
426
|
+
|
|
427
|
+
case 'analytics': {
|
|
428
|
+
const analyticsPath = path.join(__dirname, 'analytics.js');
|
|
429
|
+
spawn('node', [analyticsPath, ...args], { stdio: 'inherit' });
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
case 'health': {
|
|
434
|
+
const healthPath = path.join(__dirname, '../logging/health-monitor.js');
|
|
435
|
+
spawn('node', [healthPath, ...args], { stdio: 'inherit' });
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
case 'config': {
|
|
440
|
+
const configCommand = args[0];
|
|
441
|
+
switch (configCommand) {
|
|
442
|
+
case 'validate':
|
|
443
|
+
validateConfig();
|
|
444
|
+
break;
|
|
445
|
+
case 'backup':
|
|
446
|
+
backupConfig();
|
|
447
|
+
break;
|
|
448
|
+
default:
|
|
449
|
+
console.log(chalk.yellow('Available config commands:'));
|
|
450
|
+
console.log(' validate - Check configuration validity');
|
|
451
|
+
console.log(' backup - Backup current configuration');
|
|
452
|
+
}
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
case 'help':
|
|
457
|
+
case '--help':
|
|
458
|
+
case '-h':
|
|
459
|
+
default:
|
|
460
|
+
console.log(chalk.blue('Claude Code Router - Unified CLI'));
|
|
461
|
+
console.log(chalk.gray('โ'.repeat(45)));
|
|
462
|
+
|
|
463
|
+
console.log(chalk.yellow('๐ Core Router Commands:'));
|
|
464
|
+
console.log(' start - Start router server');
|
|
465
|
+
console.log(' stop - Stop router server');
|
|
466
|
+
console.log(' restart - Restart router server');
|
|
467
|
+
console.log(' status - Show server status');
|
|
468
|
+
console.log(' code - Start Router + Claude Code');
|
|
469
|
+
console.log(' activate - Print env exports');
|
|
470
|
+
console.log(' ui [--port N] - Open dashboard');
|
|
471
|
+
|
|
472
|
+
console.log(chalk.yellow('\n๐งช Diagnostics:'));
|
|
473
|
+
console.log(' test <provider> [model] - Test provider connection');
|
|
474
|
+
console.log(' benchmark [--all] [--compare-speed] - Benchmark providers');
|
|
475
|
+
console.log(' analytics [period] - View usage statistics');
|
|
476
|
+
console.log(' status --detailed [--show-costs] - Show detailed router status');
|
|
477
|
+
console.log(' config validate - Validate configuration');
|
|
478
|
+
console.log(' config backup - Backup configuration');
|
|
479
|
+
console.log(' health [--all-providers] - Check provider health');
|
|
480
|
+
console.log(' update - Update to the latest version');
|
|
481
|
+
|
|
482
|
+
console.log(chalk.yellow('\n๐ก Tip:'));
|
|
483
|
+
console.log(' To start everything at once, run: ' + chalk.cyan('ccr code'));
|
|
484
|
+
console.log(' To only start the background server, run: ' + chalk.cyan('ccr start'));
|
|
373
485
|
}
|
|
374
486
|
}
|
|
375
487
|
|
|
@@ -383,4 +495,4 @@ module.exports = {
|
|
|
383
495
|
showDetailedStatus,
|
|
384
496
|
validateConfig,
|
|
385
497
|
backupConfig
|
|
386
|
-
};
|
|
498
|
+
};
|
package/config/config.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_comment": "Claude Code Router Configuration -
|
|
3
|
-
"_attribution": "Original project: https://github.com/musistudio/claude-code-router",
|
|
2
|
+
"_comment": "Claude Code Router Configuration - Unified router + config",
|
|
4
3
|
"_author": "Configuration by Halil Ertekin",
|
|
4
|
+
"HOST": "127.0.0.1",
|
|
5
|
+
"PORT": 3456,
|
|
5
6
|
"LOG": true,
|
|
6
7
|
"LOG_LEVEL": "info",
|
|
7
8
|
"API_TIMEOUT_MS": 300000,
|
|
8
|
-
"CUSTOM_ROUTER_PATH": "$HOME/.claude-code-router/intent-router.js",
|
|
9
|
+
"CUSTOM_ROUTER_PATH": "$HOME/.claude-code-router/smart-intent-router.js",
|
|
9
10
|
|
|
10
11
|
"Providers": [
|
|
11
12
|
{
|
package/config/glm-only.json
CHANGED
package/config/intent-router.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Multi-Provider Intent Router
|
|
3
3
|
* Routes requests based on task type to optimal provider
|
|
4
4
|
*
|
|
5
|
-
* This router is designed for
|
|
6
|
-
* Original project: https://github.com/musistudio/claude-code-router
|
|
5
|
+
* This router is designed for the built-in unified router
|
|
7
6
|
*
|
|
8
7
|
* Configuration by Halil Ertekin
|
|
9
8
|
*/
|
|
@@ -375,7 +375,7 @@ This skill provides comprehensive business analysis capabilities including:
|
|
|
375
375
|
1. **Backup Configuration**
|
|
376
376
|
```bash
|
|
377
377
|
cp ~/.claude-code-router/config.json ~/.claude-code-router/config.json.backup
|
|
378
|
-
cp ~/.claude-code-router/intent-router.js ~/.claude-code-router/intent-router.js.backup
|
|
378
|
+
cp ~/.claude-code-router/smart-intent-router.js ~/.claude-code-router/smart-intent-router.js.backup
|
|
379
379
|
```
|
|
380
380
|
|
|
381
381
|
2. **Add AgentSkills Provider**
|
|
@@ -399,7 +399,7 @@ This skill provides comprehensive business analysis capabilities including:
|
|
|
399
399
|
```bash
|
|
400
400
|
# Test skill detection
|
|
401
401
|
node -e "
|
|
402
|
-
const { detectRequiredSkills } = require('./intent-router.js');
|
|
402
|
+
const { detectRequiredSkills } = require('./smart-intent-router.js');
|
|
403
403
|
console.log(detectRequiredSkills('/sc:business-panel analyze market'));
|
|
404
404
|
"
|
|
405
405
|
```
|
|
@@ -495,6 +495,5 @@ const LOG_CONFIG = {
|
|
|
495
495
|
## Attribution
|
|
496
496
|
|
|
497
497
|
This integration guide is for the [claude-code-router-config](https://github.com/halilertekin/CC-RouterMultiProvider) project.
|
|
498
|
-
Original project: https://github.com/musistudio/claude-code-router
|
|
499
498
|
AgentSkills: https://github.com/agentskills/agentskills
|
|
500
|
-
Configuration by Halil Ertekin
|
|
499
|
+
Configuration by Halil Ertekin
|