claude-code-router-config 1.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/.env.example +27 -0
- package/LICENSE +30 -0
- package/README.md +148 -0
- package/config/config.json +67 -0
- package/config/intent-router.js +108 -0
- package/docs/FULL_DOCUMENTATION.md +489 -0
- package/docs/FULL_DOCUMENTATION_EN.md +505 -0
- package/docs/README_EN.md +146 -0
- package/docs/SETUP_PROMPT.md +299 -0
- package/docs/SETUP_PROMPT_EN.md +317 -0
- package/install.js +160 -0
- package/install.sh +73 -0
- package/package.json +59 -0
package/install.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Claude Code Router Config - Interactive Installer
|
|
5
|
+
* For use with @musistudio/claude-code-router
|
|
6
|
+
*
|
|
7
|
+
* Original project: https://github.com/musistudio/claude-code-router
|
|
8
|
+
* Configuration by Halil Ertekin
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const fs = require('fs-extra');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const chalk = require('chalk');
|
|
14
|
+
const inquirer = require('inquirer');
|
|
15
|
+
const dotenv = require('dotenv');
|
|
16
|
+
const { execSync } = require('child_process');
|
|
17
|
+
|
|
18
|
+
const configDir = path.join(process.env.HOME || process.env.USERPROFILE, '.claude-code-router');
|
|
19
|
+
const packageDir = __dirname;
|
|
20
|
+
|
|
21
|
+
async function checkRequirements() {
|
|
22
|
+
console.log(chalk.blue('π Checking requirements...'));
|
|
23
|
+
|
|
24
|
+
// Check Node version
|
|
25
|
+
const nodeVersion = process.version;
|
|
26
|
+
const majorVersion = parseInt(nodeVersion.slice(1).split('.')[0]);
|
|
27
|
+
|
|
28
|
+
if (majorVersion < 16) {
|
|
29
|
+
console.error(chalk.red(`β Node.js ${majorVersion} detected. Node.js 16+ required.`));
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
console.log(chalk.green(`β
Node.js ${nodeVersion}`));
|
|
33
|
+
|
|
34
|
+
// Check for pnpm
|
|
35
|
+
try {
|
|
36
|
+
execSync('pnpm --version', { stdio: 'ignore' });
|
|
37
|
+
console.log(chalk.green('β
pnpm found'));
|
|
38
|
+
return 'pnpm';
|
|
39
|
+
} catch {
|
|
40
|
+
try {
|
|
41
|
+
execSync('npm --version', { stdio: 'ignore' });
|
|
42
|
+
console.log(chalk.yellow('β οΈ pnpm not found, using npm'));
|
|
43
|
+
return 'npm';
|
|
44
|
+
} catch {
|
|
45
|
+
console.error(chalk.red('β Neither pnpm nor npm found'));
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function installRouter(packageManager) {
|
|
52
|
+
console.log(chalk.blue('π¦ Installing claude-code-router...'));
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
const command = `${packageManager} add -g @musistudio/claude-code-router`;
|
|
56
|
+
console.log(chalk.gray(`Running: ${command}`));
|
|
57
|
+
execSync(command, { stdio: 'inherit' });
|
|
58
|
+
console.log(chalk.green('β
claude-code-router installed'));
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error(chalk.red('β Failed to install claude-code-router'));
|
|
61
|
+
console.error(error.message);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function setupConfig() {
|
|
67
|
+
console.log(chalk.blue('βοΈ Setting up configuration...'));
|
|
68
|
+
|
|
69
|
+
// Ensure config directory exists
|
|
70
|
+
await fs.ensureDir(configDir);
|
|
71
|
+
|
|
72
|
+
// Copy config files
|
|
73
|
+
const configFiles = ['config.json', 'intent-router.js'];
|
|
74
|
+
for (const file of configFiles) {
|
|
75
|
+
const src = path.join(packageDir, 'config', file);
|
|
76
|
+
const dest = path.join(configDir, file);
|
|
77
|
+
|
|
78
|
+
if (await fs.pathExists(dest)) {
|
|
79
|
+
const { overwrite } = await inquirer.prompt([
|
|
80
|
+
{
|
|
81
|
+
type: 'confirm',
|
|
82
|
+
name: 'overwrite',
|
|
83
|
+
message: `File ${file} exists. Overwrite?`,
|
|
84
|
+
default: false
|
|
85
|
+
}
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
if (!overwrite) {
|
|
89
|
+
console.log(chalk.yellow(`β οΈ Skipping ${file}`));
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
await fs.copy(src, dest);
|
|
95
|
+
console.log(chalk.green(`β
${file} copied`));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Copy .env.example if .env doesn't exist
|
|
99
|
+
const envFile = path.join(process.env.HOME || process.env.USERPROFILE, '.env');
|
|
100
|
+
const envExample = path.join(packageDir, '.env.example');
|
|
101
|
+
|
|
102
|
+
if (!(await fs.pathExists(envFile))) {
|
|
103
|
+
await fs.copy(envExample, envFile);
|
|
104
|
+
console.log(chalk.green('β
.env file created from example'));
|
|
105
|
+
} else {
|
|
106
|
+
console.log(chalk.yellow('β οΈ .env file already exists'));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function showNextSteps() {
|
|
111
|
+
console.log(chalk.green('\nπ Installation complete!'));
|
|
112
|
+
console.log(chalk.blue('\nπ Next steps:'));
|
|
113
|
+
console.log('\n1. Edit your API keys in ~/.env file:');
|
|
114
|
+
console.log(chalk.gray(' nano ~/.env'));
|
|
115
|
+
|
|
116
|
+
console.log('\n2. Add environment variables to your shell (~/.zshrc or ~/.bashrc):');
|
|
117
|
+
console.log(chalk.cyan(`
|
|
118
|
+
# Claude Code Router
|
|
119
|
+
export $(cat ~/.env | xargs)
|
|
120
|
+
export ANTHROPIC_BASE_URL="http://127.0.0.1:3456"
|
|
121
|
+
export NO_PROXY="127.0.0.1"
|
|
122
|
+
`));
|
|
123
|
+
|
|
124
|
+
console.log('\n3. Reload your shell:');
|
|
125
|
+
console.log(chalk.gray(' source ~/.zshrc'));
|
|
126
|
+
|
|
127
|
+
console.log('\n4. Start the router:');
|
|
128
|
+
console.log(chalk.gray(' ccr code'));
|
|
129
|
+
|
|
130
|
+
console.log(chalk.blue('\nπ Documentation:'));
|
|
131
|
+
console.log(chalk.gray(' https://github.com/halilertekin/claude-code-router-config'));
|
|
132
|
+
|
|
133
|
+
console.log(chalk.blue('\nπ Get API keys:'));
|
|
134
|
+
console.log(chalk.gray(' OpenAI: https://platform.openai.com/api-keys'));
|
|
135
|
+
console.log(chalk.gray(' Anthropic: https://console.anthropic.com/settings/keys'));
|
|
136
|
+
console.log(chalk.gray(' Gemini: https://aistudio.google.com/apikey'));
|
|
137
|
+
console.log(chalk.gray(' Qwen: https://dashscope.console.aliyun.com/apiKey'));
|
|
138
|
+
console.log(chalk.gray(' GLM: https://open.bigmodel.cn/usercenter/apikeys'));
|
|
139
|
+
console.log(chalk.gray(' OpenRouter: https://openrouter.ai/keys'));
|
|
140
|
+
console.log(chalk.gray(' Copilot: https://github.com/settings/tokens'));
|
|
141
|
+
|
|
142
|
+
console.log(chalk.yellow('\nβ Attribution:'));
|
|
143
|
+
console.log(chalk.gray(' This config is for @musistudio/claude-code-router'));
|
|
144
|
+
console.log(chalk.gray(' Original: https://github.com/musistudio/claude-code-router'));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function main() {
|
|
148
|
+
console.log(chalk.cyan.bold('\nπ Claude Code Router Config Installer\n'));
|
|
149
|
+
|
|
150
|
+
const packageManager = await checkRequirements();
|
|
151
|
+
await installRouter(packageManager);
|
|
152
|
+
await setupConfig();
|
|
153
|
+
await showNextSteps();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (require.main === module) {
|
|
157
|
+
main().catch(console.error);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
module.exports = { checkRequirements, installRouter, setupConfig };
|
package/install.sh
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Claude Code Router - Install Script
|
|
4
|
+
# Usage: ./install.sh
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
echo "=========================================="
|
|
9
|
+
echo " Claude Code Router - Kurulum"
|
|
10
|
+
echo "=========================================="
|
|
11
|
+
echo ""
|
|
12
|
+
|
|
13
|
+
# Colors
|
|
14
|
+
RED='\033[0;31m'
|
|
15
|
+
GREEN='\033[0;32m'
|
|
16
|
+
YELLOW='\033[1;33m'
|
|
17
|
+
NC='\033[0m' # No Color
|
|
18
|
+
|
|
19
|
+
# Check for pnpm
|
|
20
|
+
if ! command -v pnpm &> /dev/null; then
|
|
21
|
+
echo -e "${YELLOW}pnpm bulunamadΔ±. Kuruluyor...${NC}"
|
|
22
|
+
npm install -g pnpm
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
# Install claude-code-router
|
|
26
|
+
echo -e "${GREEN}[1/3] Claude Code Router kuruluyor...${NC}"
|
|
27
|
+
pnpm add -g @musistudio/claude-code-router
|
|
28
|
+
|
|
29
|
+
# Create config directory
|
|
30
|
+
echo -e "${GREEN}[2/3] Config dizini oluΕturuluyor...${NC}"
|
|
31
|
+
mkdir -p ~/.claude-code-router
|
|
32
|
+
|
|
33
|
+
# Copy config files
|
|
34
|
+
echo -e "${GREEN}[3/3] Config dosyalarΔ± kopyalanΔ±yor...${NC}"
|
|
35
|
+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
36
|
+
cp "$SCRIPT_DIR/config/config.json" ~/.claude-code-router/
|
|
37
|
+
cp "$SCRIPT_DIR/config/intent-router.js" ~/.claude-code-router/
|
|
38
|
+
|
|
39
|
+
echo ""
|
|
40
|
+
echo -e "${GREEN}=========================================="
|
|
41
|
+
echo " Kurulum TamamlandΔ±!"
|
|
42
|
+
echo "==========================================${NC}"
|
|
43
|
+
echo ""
|
|
44
|
+
echo -e "${YELLOW}SON ADIM: ~/.zshrc dosyanΔ±za aΕaΔΔ±daki satΔ±rlarΔ± ekleyin:${NC}"
|
|
45
|
+
echo ""
|
|
46
|
+
cat << 'EOF'
|
|
47
|
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
48
|
+
# Claude Code Router - API Keys
|
|
49
|
+
# βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
50
|
+
export OPENAI_API_KEY="sk-..."
|
|
51
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
52
|
+
export GEMINI_API_KEY="AIza..."
|
|
53
|
+
export QWEN_API_KEY="sk-..."
|
|
54
|
+
export GLM_API_KEY="..."
|
|
55
|
+
export OPENROUTER_API_KEY="sk-or-..."
|
|
56
|
+
|
|
57
|
+
# Router Connection
|
|
58
|
+
export ANTHROPIC_BASE_URL="http://127.0.0.1:3456"
|
|
59
|
+
export NO_PROXY="127.0.0.1"
|
|
60
|
+
EOF
|
|
61
|
+
|
|
62
|
+
echo ""
|
|
63
|
+
echo -e "${GREEN}Sonra:${NC}"
|
|
64
|
+
echo " source ~/.zshrc"
|
|
65
|
+
echo " ccr code"
|
|
66
|
+
echo ""
|
|
67
|
+
echo -e "${YELLOW}API Key Alma Linkleri:${NC}"
|
|
68
|
+
echo " OpenAI: https://platform.openai.com/api-keys"
|
|
69
|
+
echo " Anthropic: https://console.anthropic.com/settings/keys"
|
|
70
|
+
echo " Gemini: https://aistudio.google.com/apikey"
|
|
71
|
+
echo " Qwen: https://dashscope.console.aliyun.com/apiKey"
|
|
72
|
+
echo " GLM: https://open.bigmodel.cn/usercenter/apikeys"
|
|
73
|
+
echo " OpenRouter: https://openrouter.ai/keys"
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claude-code-router-config",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Configuration package for @musistudio/claude-code-router with multi-provider intent-based routing",
|
|
5
|
+
"main": "install.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"ccr-setup": "install.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"install": "node install.js",
|
|
11
|
+
"setup": "chmod +x install.sh && ./install.sh",
|
|
12
|
+
"postinstall": "node postinstall.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"config/",
|
|
16
|
+
"install.sh",
|
|
17
|
+
".env.example",
|
|
18
|
+
"docs/"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"claude",
|
|
22
|
+
"ai",
|
|
23
|
+
"routing",
|
|
24
|
+
"multi-provider",
|
|
25
|
+
"openai",
|
|
26
|
+
"anthropic",
|
|
27
|
+
"gemini",
|
|
28
|
+
"qwen",
|
|
29
|
+
"glm",
|
|
30
|
+
"copilot",
|
|
31
|
+
"claude-code",
|
|
32
|
+
"cli",
|
|
33
|
+
"automation",
|
|
34
|
+
"configuration"
|
|
35
|
+
],
|
|
36
|
+
"author": {
|
|
37
|
+
"name": "Halil Ertekin",
|
|
38
|
+
"email": "halil@ertekin.me",
|
|
39
|
+
"url": "https://github.com/halilertekin"
|
|
40
|
+
},
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/halilertekin/claude-code-router-config.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/halilertekin/claude-code-router-config/issues"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/halilertekin/claude-code-router-config#readme",
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=16.0.0"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"inquirer": "^9.2.0",
|
|
55
|
+
"chalk": "^5.3.0",
|
|
56
|
+
"fs-extra": "^11.1.1",
|
|
57
|
+
"dotenv": "^16.3.1"
|
|
58
|
+
}
|
|
59
|
+
}
|