@halilertekin/claude-code-router-config 2.0.7 → 2.0.8
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/CHANGELOG.md +4 -0
- package/NPM_README.md +9 -3
- package/README.md +5 -4
- package/cli/ccc.zsh +42 -3
- package/docs/HOMEBREW_SETUP.md +7 -3
- package/docs/README_EN.md +5 -0
- package/install.js +4 -2
- package/package.json +1 -1
- package/setup-glm.sh +74 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.8
|
|
4
|
+
- GLM setup now installs direct z.ai `glm` wrapper by default and keeps `glm-ccr` for router usage.
|
|
5
|
+
- Safer `.env` loading in `ccc` (ignores comments/invalid lines) and updated setup docs.
|
|
6
|
+
|
|
3
7
|
## 2.0.7
|
|
4
8
|
- Security: qs arrayLimit bypass fix (force qs 6.14.1).
|
|
5
9
|
|
package/NPM_README.md
CHANGED
|
@@ -26,13 +26,17 @@ CCR_CONFIG_OVERWRITE=1 ccr-setup
|
|
|
26
26
|
ccr-setup --overwrite
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
### One-shot GLM setup (
|
|
29
|
+
### One-shot GLM setup (z.ai GLM API)
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npx -y -p @halilertekin/claude-code-router-config ccr-glm-setup --key "YOUR_GLM_API_KEY"
|
|
33
33
|
source ~/.zshrc
|
|
34
34
|
glm
|
|
35
35
|
```
|
|
36
|
+
Direct z.ai is the default. If you want the router version:
|
|
37
|
+
```bash
|
|
38
|
+
glm-ccr
|
|
39
|
+
```
|
|
36
40
|
|
|
37
41
|
## Features
|
|
38
42
|
|
|
@@ -82,8 +86,10 @@ After installation:
|
|
|
82
86
|
|
|
83
87
|
2. **Add to shell** (`~/.zshrc` or `~/.bashrc`):
|
|
84
88
|
```bash
|
|
85
|
-
# Load .env variables
|
|
86
|
-
|
|
89
|
+
# Load .env variables (safe with comments)
|
|
90
|
+
set -a
|
|
91
|
+
source ~/.env
|
|
92
|
+
set +a
|
|
87
93
|
|
|
88
94
|
# Router connection
|
|
89
95
|
export ANTHROPIC_BASE_URL="http://127.0.0.1:3456"
|
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# Claude Code Router Config - Advanced Multi-Provider Setup
|
|
2
2
|
|
|
3
|
-
🚀 **v2.0.
|
|
3
|
+
🚀 **v2.0.8** - 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 v2.0.
|
|
7
|
+
## ✨ New in v2.0.8
|
|
8
8
|
- UI üzerinden `.env` anahtarları ekleme/güncelleme (TR/NL).
|
|
9
9
|
- `~/.env` otomatik yükleme ile API anahtarlarının bulunması (CLI + health monitor).
|
|
10
10
|
- **z.ai Support**: Native integration for GLM-4.7 via z.ai (PPInfra).
|
|
11
11
|
- **Lightweight Mode**: New `ccc` function for zero-dependency routing.
|
|
12
|
-
- **Direct GLM Alias**:
|
|
12
|
+
- **Direct GLM Alias**: `glm` now launches GLM-4.7 directly via z.ai; `glm-ccr` keeps router mode.
|
|
13
13
|
- **Non-interactive install**: CI-friendly installer flags and env controls.
|
|
14
14
|
- **Unified router**: Built-in router service, no external dependency required.
|
|
15
15
|
- **UI refresh**: Daha sade ve responsive tasarım, TR/NL dil desteği.
|
|
@@ -40,7 +40,8 @@ If you just want to use the `ccc` command (Claude Code Commander) and `glm` alia
|
|
|
40
40
|
4. **Reload & Run:**
|
|
41
41
|
```bash
|
|
42
42
|
source ~/.zshrc
|
|
43
|
-
glm # Launches GLM-4.7 via z.ai
|
|
43
|
+
glm # Launches GLM-4.7 via z.ai (direct)
|
|
44
|
+
glm-ccr # Launches GLM-4.7 via local router
|
|
44
45
|
ccc ds # Launches DeepSeek
|
|
45
46
|
ccc claude # Launches Official Claude (Pro)
|
|
46
47
|
```
|
package/cli/ccc.zsh
CHANGED
|
@@ -8,9 +8,41 @@ ccc() {
|
|
|
8
8
|
shift 1 2>/dev/null
|
|
9
9
|
local extra_args=("$@")
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
load_env_file() {
|
|
12
|
+
local env_file="$1"
|
|
13
|
+
[[ -f "$env_file" ]] || return 0
|
|
14
|
+
local line key val
|
|
15
|
+
while IFS= read -r line || [[ -n "$line" ]]; do
|
|
16
|
+
line="${line%$'\r'}"
|
|
17
|
+
line="${line%%#*}"
|
|
18
|
+
line="${line#"${line%%[![:space:]]*}"}"
|
|
19
|
+
line="${line%"${line##*[![:space:]]}"}"
|
|
20
|
+
[[ -z "$line" ]] && continue
|
|
21
|
+
line="${line#export }"
|
|
22
|
+
[[ "$line" == *"="* ]] || continue
|
|
23
|
+
key="${line%%=*}"
|
|
24
|
+
val="${line#*=}"
|
|
25
|
+
key="${key#"${key%%[![:space:]]*}"}"
|
|
26
|
+
key="${key%"${key##*[![:space:]]}"}"
|
|
27
|
+
val="${val#"${val%%[![:space:]]*}"}"
|
|
28
|
+
val="${val%"${val##*[![:space:]]}"}"
|
|
29
|
+
if [[ ${#val} -ge 2 ]]; then
|
|
30
|
+
if [[ "$val" == \"*\" && "$val" == *\" ]]; then
|
|
31
|
+
val="${val:1:-1}"
|
|
32
|
+
elif [[ "$val" == \'*\' && "$val" == *\' ]]; then
|
|
33
|
+
val="${val:1:-1}"
|
|
34
|
+
fi
|
|
35
|
+
fi
|
|
36
|
+
if [[ "$key" == [A-Za-z_][A-Za-z0-9_]* ]]; then
|
|
37
|
+
export "$key=$val"
|
|
38
|
+
fi
|
|
39
|
+
done < "$env_file"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Load keys from multiple sources for redundancy (safe parser)
|
|
43
|
+
load_env_file "$HOME/.ccm_config"
|
|
44
|
+
load_env_file "$HOME/.env"
|
|
45
|
+
load_env_file "$HOME/.claude-code-router/keys.env"
|
|
14
46
|
|
|
15
47
|
# 1. CLEANUP: Remove all env vars that might interfere with Claude Pro
|
|
16
48
|
unset ANTHROPIC_BASE_URL ANTHROPIC_API_KEY ANTHROPIC_MODEL ANTHROPIC_AUTH_TOKEN API_TIMEOUT_MS
|
|
@@ -31,6 +63,13 @@ ccc() {
|
|
|
31
63
|
export ANTHROPIC_DEFAULT_SONNET_MODEL="glm-4.7"
|
|
32
64
|
export ANTHROPIC_DEFAULT_OPUS_MODEL="glm-4.7"
|
|
33
65
|
export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-4.5-air"
|
|
66
|
+
export ANTHROPIC_SMALL_FAST_MODEL="glm-4.5-air"
|
|
67
|
+
export CLAUDE_CODE_SUBAGENT_MODEL="glm-4.7"
|
|
68
|
+
|
|
69
|
+
if [[ -z "$ANTHROPIC_API_KEY" ]]; then
|
|
70
|
+
echo "GLM_API_KEY not set. Add it to ~/.env or ~/.claude-code-router/keys.env" >&2
|
|
71
|
+
return 1
|
|
72
|
+
fi
|
|
34
73
|
|
|
35
74
|
echo "🔄 Provider: z.ai (GLM 4.7)"
|
|
36
75
|
;;
|
package/docs/HOMEBREW_SETUP.md
CHANGED
|
@@ -57,8 +57,10 @@ The installer automatically creates configuration files and an `.env.example` fi
|
|
|
57
57
|
|
|
58
58
|
3. **Add to shell configuration:**
|
|
59
59
|
```bash
|
|
60
|
-
# Add to ~/.zshrc or ~/.bashrc
|
|
61
|
-
|
|
60
|
+
# Add to ~/.zshrc or ~/.bashrc (safe .env load)
|
|
61
|
+
set -a
|
|
62
|
+
source ~/.env
|
|
63
|
+
set +a
|
|
62
64
|
export ANTHROPIC_BASE_URL="http://127.0.0.1:3456"
|
|
63
65
|
export NO_PROXY="127.0.0.1"
|
|
64
66
|
```
|
|
@@ -139,7 +141,9 @@ The router automatically routes requests to the most appropriate provider based
|
|
|
139
141
|
ls -la ~/.env
|
|
140
142
|
|
|
141
143
|
# Manually source environment
|
|
142
|
-
|
|
144
|
+
set -a
|
|
145
|
+
source ~/.env
|
|
146
|
+
set +a
|
|
143
147
|
```
|
|
144
148
|
|
|
145
149
|
4. **Router Fails to Start**
|
package/docs/README_EN.md
CHANGED
package/install.js
CHANGED
|
@@ -113,8 +113,10 @@ async function showNextSteps() {
|
|
|
113
113
|
|
|
114
114
|
console.log('\n2. Add environment variables to your shell (~/.zshrc or ~/.bashrc):');
|
|
115
115
|
console.log(chalk.cyan(`
|
|
116
|
-
# Claude Code Router
|
|
117
|
-
|
|
116
|
+
# Claude Code Router (safe .env load)
|
|
117
|
+
set -a
|
|
118
|
+
source ~/.env
|
|
119
|
+
set +a
|
|
118
120
|
export ANTHROPIC_BASE_URL="http://127.0.0.1:3456"
|
|
119
121
|
export NO_PROXY="127.0.0.1"
|
|
120
122
|
`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@halilertekin/claude-code-router-config",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Multi-provider configuration for Claude Code Router with intent-based routing, advanced CLI tools, analytics, and smart routing. Setup OpenAI, Anthropic, Gemini, Qwen, GLM, OpenRouter, and GitHub Copilot with intelligent routing.",
|
|
5
5
|
"main": "install.js",
|
|
6
6
|
"bin": {
|
package/setup-glm.sh
CHANGED
|
@@ -20,8 +20,8 @@ usage() {
|
|
|
20
20
|
Usage: ./setup-glm.sh [--key <GLM_API_KEY>] [--skip-install] [--non-interactive]
|
|
21
21
|
|
|
22
22
|
Installs/updates CCR (if missing), writes GLM-only config,
|
|
23
|
-
creates ~/.claude-code-router/keys.env, and installs
|
|
24
|
-
|
|
23
|
+
creates ~/.claude-code-router/keys.env, and installs commands:
|
|
24
|
+
glm (direct z.ai) + glm-ccr (router) + aliases ccc and claude-glm.
|
|
25
25
|
|
|
26
26
|
Options:
|
|
27
27
|
--key <GLM_API_KEY> Provide GLM key non-interactively
|
|
@@ -221,10 +221,76 @@ fi
|
|
|
221
221
|
|
|
222
222
|
"$CLAUDE_BIN" "$@"
|
|
223
223
|
EOS
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
224
|
+
cat > "$BIN_DIR/glm-zai" <<'EOS'
|
|
225
|
+
#!/usr/bin/env bash
|
|
226
|
+
set -euo pipefail
|
|
227
|
+
|
|
228
|
+
ROUTER_DIR="$HOME/.claude-code-router"
|
|
229
|
+
KEYS_FILE="$ROUTER_DIR/keys.env"
|
|
230
|
+
|
|
231
|
+
load_keys() {
|
|
232
|
+
if [[ -f "$KEYS_FILE" ]]; then
|
|
233
|
+
while IFS= read -r line || [[ -n "$line" ]]; do
|
|
234
|
+
line="${line%$'\r'}"
|
|
235
|
+
line="${line%%#*}"
|
|
236
|
+
line="$(echo "$line" | sed -E 's/^[[:space:]]*//; s/[[:space:]]*$//')"
|
|
237
|
+
[[ -z "$line" ]] && continue
|
|
238
|
+
if [[ "$line" =~ ^(export[[:space:]]+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$ ]]; then
|
|
239
|
+
key="${BASH_REMATCH[2]}"
|
|
240
|
+
val="${BASH_REMATCH[3]}"
|
|
241
|
+
val="$(echo "$val" | sed -E 's/^[[:space:]]*//; s/[[:space:]]*$//')"
|
|
242
|
+
if [[ ${#val} -ge 2 ]]; then
|
|
243
|
+
if [[ "${val:0:1}" == "\"" && "${val: -1}" == "\"" ]]; then
|
|
244
|
+
val="${val:1:-1}"
|
|
245
|
+
elif [[ "${val:0:1}" == "'" && "${val: -1}" == "'" ]]; then
|
|
246
|
+
val="${val:1:-1}"
|
|
247
|
+
fi
|
|
248
|
+
fi
|
|
249
|
+
val="${val%$'\r'}"
|
|
250
|
+
if [[ -n "$val" ]]; then
|
|
251
|
+
export "$key=$val"
|
|
252
|
+
fi
|
|
253
|
+
fi
|
|
254
|
+
done < "$KEYS_FILE"
|
|
255
|
+
fi
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
load_keys
|
|
259
|
+
|
|
260
|
+
if [[ -z "${GLM_API_KEY:-}" ]]; then
|
|
261
|
+
echo "GLM_API_KEY not set. Add it to ~/.claude-code-router/keys.env" >&2
|
|
262
|
+
exit 1
|
|
263
|
+
fi
|
|
264
|
+
|
|
265
|
+
# Direct z.ai (Anthropic-compatible) - no router required.
|
|
266
|
+
export ANTHROPIC_AUTH_TOKEN="${GLM_API_KEY}"
|
|
267
|
+
export ANTHROPIC_API_KEY="${GLM_API_KEY}"
|
|
268
|
+
export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
|
|
269
|
+
export API_TIMEOUT_MS="${API_TIMEOUT_MS:-3000000}"
|
|
270
|
+
|
|
271
|
+
export ANTHROPIC_MODEL="${ANTHROPIC_MODEL:-glm-4.7}"
|
|
272
|
+
export ANTHROPIC_DEFAULT_OPUS_MODEL="${ANTHROPIC_DEFAULT_OPUS_MODEL:-glm-4.7}"
|
|
273
|
+
export ANTHROPIC_DEFAULT_SONNET_MODEL="${ANTHROPIC_DEFAULT_SONNET_MODEL:-glm-4.7}"
|
|
274
|
+
export ANTHROPIC_DEFAULT_HAIKU_MODEL="${ANTHROPIC_DEFAULT_HAIKU_MODEL:-glm-4.5-air}"
|
|
275
|
+
export ANTHROPIC_SMALL_FAST_MODEL="${ANTHROPIC_SMALL_FAST_MODEL:-glm-4.5-air}"
|
|
276
|
+
export CLAUDE_CODE_SUBAGENT_MODEL="${CLAUDE_CODE_SUBAGENT_MODEL:-glm-4.7}"
|
|
277
|
+
|
|
278
|
+
CLAUDE_BIN="$HOME/.claude/local/claude"
|
|
279
|
+
if [[ ! -x "$CLAUDE_BIN" ]]; then
|
|
280
|
+
CLAUDE_BIN="$(command -v claude || true)"
|
|
281
|
+
fi
|
|
282
|
+
if [[ -z "${CLAUDE_BIN:-}" ]]; then
|
|
283
|
+
echo "claude binary not found. Install Claude Code first." >&2
|
|
284
|
+
exit 1
|
|
285
|
+
fi
|
|
286
|
+
|
|
287
|
+
"$CLAUDE_BIN" "$@"
|
|
288
|
+
EOS
|
|
289
|
+
chmod +x "$BIN_DIR/ccr-glm" "$BIN_DIR/glm-zai"
|
|
290
|
+
ln -sf "$BIN_DIR/glm-zai" "$BIN_DIR/glm"
|
|
291
|
+
ln -sf "$BIN_DIR/glm-zai" "$BIN_DIR/ccc"
|
|
292
|
+
ln -sf "$BIN_DIR/glm-zai" "$BIN_DIR/claude-glm"
|
|
293
|
+
ln -sf "$BIN_DIR/ccr-glm" "$BIN_DIR/glm-ccr"
|
|
228
294
|
}
|
|
229
295
|
|
|
230
296
|
ensure_path() {
|
|
@@ -266,4 +332,5 @@ ensure_path
|
|
|
266
332
|
echo ""
|
|
267
333
|
echo "GLM setup complete."
|
|
268
334
|
echo "Run: source ~/.zshrc"
|
|
269
|
-
echo "Then: glm"
|
|
335
|
+
echo "Then: glm # direct z.ai (recommended)"
|
|
336
|
+
echo "Or: glm-ccr # via local router"
|