ai-account-switch 1.5.7 → 1.6.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 +197 -4
- package/README_ZH.md +188 -4
- package/package.json +2 -2
- package/src/commands/README.md +124 -0
- package/src/commands/account.js +997 -0
- package/src/commands/helpers.js +35 -0
- package/src/commands/index.js +53 -0
- package/src/commands/model.js +383 -0
- package/src/commands/utility.js +326 -0
- package/src/config.js +114 -0
- package/src/index.js +55 -55
- package/src/ui-server.js +312 -7
- package/src/commands.js +0 -1290
package/README.md
CHANGED
|
@@ -13,7 +13,8 @@ A cross-platform CLI tool to manage and switch between Claude/Codex/Droids accou
|
|
|
13
13
|
- **Claude Code Integration**: Automatically generates `.claude/settings.local.json` for Claude Code CLI
|
|
14
14
|
- **Secure Storage**: Account credentials stored locally in your home directory
|
|
15
15
|
- **Interactive CLI**: Easy-to-use interactive prompts for all operations
|
|
16
|
-
- **Account Types**: Support for Claude, Codex, Droids, and other AI services
|
|
16
|
+
- **Account Types**: Support for Claude, Codex, CCR (Claude Code Router), Droids, and other AI services
|
|
17
|
+
- **Web UI**: Modern web interface with account status checking and management
|
|
17
18
|
|
|
18
19
|
## Installation
|
|
19
20
|
|
|
@@ -92,7 +93,7 @@ ais add my-claude-account
|
|
|
92
93
|
```
|
|
93
94
|
|
|
94
95
|
You'll be prompted to enter:
|
|
95
|
-
- Account type (Claude, Codex, Other)
|
|
96
|
+
- Account type (Claude, Codex, CCR, Droids, Other)
|
|
96
97
|
- API Key
|
|
97
98
|
- API URL (optional)
|
|
98
99
|
- Organization ID (optional)
|
|
@@ -329,6 +330,163 @@ grep -A 10 "$(cat .codex-profile)" ~/.codex/config.toml
|
|
|
329
330
|
ais doctor
|
|
330
331
|
```
|
|
331
332
|
|
|
333
|
+
### CCR (Claude Code Router) Integration
|
|
334
|
+
|
|
335
|
+
[Claude Code Router](https://github.com/musistudio/claude-code-router) is a powerful routing layer for Claude Code that allows you to use multiple AI providers and models seamlessly.
|
|
336
|
+
|
|
337
|
+
When you add a **CCR** type account and run `ais use`, the tool automatically:
|
|
338
|
+
1. Updates `~/.claude-code-router/config.json` with Provider and Router configuration
|
|
339
|
+
2. Generates `.claude/settings.local.json` pointing to the local CCR Router
|
|
340
|
+
3. Automatically restarts CCR Router to apply changes
|
|
341
|
+
|
|
342
|
+
**Prerequisites:**
|
|
343
|
+
- Install Claude Code Router: `npm install -g @musistudio/claude-code-router`
|
|
344
|
+
- Start CCR Router: `ccr start`
|
|
345
|
+
|
|
346
|
+
#### Adding a CCR Account
|
|
347
|
+
|
|
348
|
+
When adding a CCR account, you'll see helpful configuration tips:
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
ais add my-ccr-account
|
|
352
|
+
|
|
353
|
+
? Select account type: CCR
|
|
354
|
+
|
|
355
|
+
📝 CCR Configuration Tips:
|
|
356
|
+
• CCR configuration will be stored in ~/.claude-code-router/config.json
|
|
357
|
+
• You need to provide Provider name and models
|
|
358
|
+
• Router configuration will be automatically updated
|
|
359
|
+
|
|
360
|
+
? Enter API Key: sk-xxx...
|
|
361
|
+
? Enter API URL: http://localhost:3000/v1/chat/completions
|
|
362
|
+
? Enter Provider name: Local-new-api
|
|
363
|
+
? Enter default model: gemini-2.5-flash
|
|
364
|
+
? Enter background model: gemini-2.5-flash
|
|
365
|
+
? Enter think model: gemini-2.5-pro
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
**Important Notes:**
|
|
369
|
+
- Default API URL is `http://localhost:3000/v1/chat/completions`
|
|
370
|
+
- You need to specify three models: default, background, and think
|
|
371
|
+
- Models are automatically deduplicated in the Provider configuration
|
|
372
|
+
|
|
373
|
+
#### Using CCR with Your Project
|
|
374
|
+
|
|
375
|
+
After running `ais use` with a CCR account:
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
cd ~/my-project
|
|
379
|
+
ais use my-ccr-account
|
|
380
|
+
|
|
381
|
+
# Output:
|
|
382
|
+
# ✓ Switched to account 'my-ccr-account' for current project.
|
|
383
|
+
# 🔄 Restarting CCR Router...
|
|
384
|
+
# ✓ CCR Router restarted successfully
|
|
385
|
+
# ✓ CCR configuration updated at: ~/.claude-code-router/config.json
|
|
386
|
+
# ✓ Claude configuration generated at: .claude/settings.local.json
|
|
387
|
+
#
|
|
388
|
+
# 📖 Next Steps:
|
|
389
|
+
# Start interactive session: claude
|
|
390
|
+
# This will enter project-level interactive mode
|
|
391
|
+
# Claude Code will use CCR Router to route requests
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
The tool:
|
|
395
|
+
1. **Updates CCR Config**: Adds/updates Provider in `~/.claude-code-router/config.json`
|
|
396
|
+
2. **Updates Router**: Sets default, background, and think models
|
|
397
|
+
3. **Generates Claude Config**: Creates `.claude/settings.local.json` with `ANTHROPIC_BASE_URL` pointing to CCR Router
|
|
398
|
+
4. **Restarts CCR**: Automatically runs `ccr restart` to apply changes
|
|
399
|
+
|
|
400
|
+
#### Running Claude with CCR
|
|
401
|
+
|
|
402
|
+
Start Claude interactive session:
|
|
403
|
+
|
|
404
|
+
```bash
|
|
405
|
+
# In your project directory
|
|
406
|
+
claude
|
|
407
|
+
|
|
408
|
+
# Claude Code will automatically use CCR Router
|
|
409
|
+
# Requests are routed based on your CCR configuration
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
#### CCR Configuration Structure
|
|
413
|
+
|
|
414
|
+
The generated configuration in `~/.claude-code-router/config.json`:
|
|
415
|
+
|
|
416
|
+
```json
|
|
417
|
+
{
|
|
418
|
+
"PORT": 3456,
|
|
419
|
+
"Providers": [
|
|
420
|
+
{
|
|
421
|
+
"api_base_url": "http://localhost:3000/v1/chat/completions",
|
|
422
|
+
"api_key": "sk-xxx...",
|
|
423
|
+
"models": ["gemini-2.5-flash", "gemini-2.5-pro"],
|
|
424
|
+
"name": "Local-new-api"
|
|
425
|
+
}
|
|
426
|
+
],
|
|
427
|
+
"Router": {
|
|
428
|
+
"default": "Local-new-api,gemini-2.5-flash",
|
|
429
|
+
"background": "Local-new-api,gemini-2.5-flash",
|
|
430
|
+
"think": "Local-new-api,gemini-2.5-pro"
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
The generated configuration in `.claude/settings.local.json`:
|
|
436
|
+
|
|
437
|
+
```json
|
|
438
|
+
{
|
|
439
|
+
"env": {
|
|
440
|
+
"ANTHROPIC_AUTH_TOKEN": "your-api-key",
|
|
441
|
+
"ANTHROPIC_BASE_URL": "http://127.0.0.1:3456"
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
#### Switching Between Projects
|
|
447
|
+
|
|
448
|
+
Each project can use a different CCR configuration:
|
|
449
|
+
|
|
450
|
+
```bash
|
|
451
|
+
# Project A
|
|
452
|
+
cd ~/project-a
|
|
453
|
+
ais use ccr-account-1
|
|
454
|
+
claude
|
|
455
|
+
|
|
456
|
+
# Project B
|
|
457
|
+
cd ~/project-b
|
|
458
|
+
ais use ccr-account-2
|
|
459
|
+
claude
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
#### Troubleshooting CCR
|
|
463
|
+
|
|
464
|
+
**Check CCR Configuration**
|
|
465
|
+
```bash
|
|
466
|
+
# View your CCR configuration
|
|
467
|
+
cat ~/.claude-code-router/config.json
|
|
468
|
+
|
|
469
|
+
# View Claude configuration
|
|
470
|
+
cat .claude/settings.local.json
|
|
471
|
+
|
|
472
|
+
# Or use the doctor command
|
|
473
|
+
ais doctor
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
**CCR Router not installed**
|
|
477
|
+
- Install from npm: `npm install -g @musistudio/claude-code-router`
|
|
478
|
+
- Visit the project page: https://github.com/musistudio/claude-code-router
|
|
479
|
+
|
|
480
|
+
**CCR Router not restarting**
|
|
481
|
+
- Make sure CCR CLI is installed and available in your PATH
|
|
482
|
+
- Run `ccr restart` manually if automatic restart fails
|
|
483
|
+
- Check if CCR Router is running: `ccr status`
|
|
484
|
+
|
|
485
|
+
**Claude not using CCR Router**
|
|
486
|
+
- Verify `ANTHROPIC_BASE_URL` in `.claude/settings.local.json` points to correct port
|
|
487
|
+
- Check CCR Router is running on the configured port
|
|
488
|
+
- Restart Claude Code after configuration changes
|
|
489
|
+
|
|
332
490
|
### Droids Integration
|
|
333
491
|
|
|
334
492
|
When you add a **Droids** type account and run `ais use`, the tool automatically creates a configuration file at `.droids/config.json` in your project directory.
|
|
@@ -531,8 +689,16 @@ ais paths
|
|
|
531
689
|
|
|
532
690
|
## Requirements
|
|
533
691
|
|
|
534
|
-
- Node.js >=
|
|
535
|
-
- npm >=
|
|
692
|
+
- **Node.js**: >= 16.0.0
|
|
693
|
+
- **npm**: >= 7.0.0
|
|
694
|
+
|
|
695
|
+
**Note**: This tool requires Node.js version 16 or higher (due to commander@11.x dependency). You can check your current version with:
|
|
696
|
+
```bash
|
|
697
|
+
node --version
|
|
698
|
+
npm --version
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
If you need to upgrade Node.js, visit [nodejs.org](https://nodejs.org/) or use a version manager like [nvm](https://github.com/nvm-sh/nvm).
|
|
536
702
|
|
|
537
703
|
## Project Structure
|
|
538
704
|
|
|
@@ -622,6 +788,33 @@ MIT License - feel free to use this tool in your projects!
|
|
|
622
788
|
|
|
623
789
|
## Changelog
|
|
624
790
|
|
|
791
|
+
### v1.6.0
|
|
792
|
+
- **CCR (Claude Code Router) Integration**:
|
|
793
|
+
- Added full support for Claude Code Router
|
|
794
|
+
- Automatic generation of `~/.claude-code-router/config.json` configuration
|
|
795
|
+
- Provider and Router configuration management
|
|
796
|
+
- Automatic CCR Router restart after configuration changes
|
|
797
|
+
- Claude Code integration with local CCR Router endpoint
|
|
798
|
+
- Support for default, background, and think model routing
|
|
799
|
+
- **Web UI Enhancements**:
|
|
800
|
+
- Added account status checking with color-coded indicators (green: available, orange: unstable, red: unavailable)
|
|
801
|
+
- Status results are saved and displayed on page load
|
|
802
|
+
- Real-time status checking with "状态检查" button
|
|
803
|
+
- Improved account card layout with status in top-right corner
|
|
804
|
+
- Enhanced visual feedback during status checks
|
|
805
|
+
- **Configuration Improvements**:
|
|
806
|
+
- CCR accounts automatically generate both CCR and Claude configurations
|
|
807
|
+
- Dynamic port reading from CCR config for Claude integration
|
|
808
|
+
- Better error handling and user feedback
|
|
809
|
+
|
|
810
|
+
### v1.5.8
|
|
811
|
+
- **Bilingual Support (双语支持)**:
|
|
812
|
+
- All CLI commands now display both English and Chinese text (所有 CLI 命令现在同时显示中英文)
|
|
813
|
+
- Help messages, prompts, and output messages are bilingual (帮助信息、提示和输出消息都支持双语)
|
|
814
|
+
- Better user experience for Chinese-speaking users (为中文用户提供更好的使用体验)
|
|
815
|
+
- No configuration needed - works out of the box (无需配置 - 开箱即用)
|
|
816
|
+
- Uses parentheses format for better clarity: `English text (中文)` (使用括号格式更清晰)
|
|
817
|
+
|
|
625
818
|
### v1.5.7
|
|
626
819
|
- **Droids Integration**:
|
|
627
820
|
- Added full support for Droids AI assistant
|
package/README_ZH.md
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
- 🎯 主题自动跟随系统设置
|
|
22
22
|
- **安全存储**:账户凭证仅存储在本地
|
|
23
23
|
- **交互式命令行**:所有操作都有易用的交互式提示
|
|
24
|
-
- **多种账户类型**:支持 Claude、Codex、Droids 和其他 AI 服务
|
|
24
|
+
- **多种账户类型**:支持 Claude、Codex、CCR (Claude Code Router)、Droids 和其他 AI 服务
|
|
25
25
|
|
|
26
26
|
## 安装
|
|
27
27
|
|
|
@@ -100,7 +100,7 @@ ais add my-claude-account
|
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
系统将提示你输入:
|
|
103
|
-
- 账户类型(Claude、Codex、其他)
|
|
103
|
+
- 账户类型(Claude、Codex、CCR、Droids、其他)
|
|
104
104
|
- API Key
|
|
105
105
|
- API URL(可选)
|
|
106
106
|
- Email(可选)
|
|
@@ -384,6 +384,163 @@ grep -A 10 "$(cat .codex-profile)" ~/.codex/config.toml
|
|
|
384
384
|
ais doctor
|
|
385
385
|
```
|
|
386
386
|
|
|
387
|
+
### CCR (Claude Code Router) 集成
|
|
388
|
+
|
|
389
|
+
[Claude Code Router](https://github.com/musistudio/claude-code-router) 是一个强大的 Claude Code 路由层,允许你无缝使用多个 AI 提供商和模型。
|
|
390
|
+
|
|
391
|
+
当你添加 **CCR** 类型账户并运行 `ais use` 时,工具会自动:
|
|
392
|
+
1. 更新 `~/.claude-code-router/config.json` 中的 Provider 和 Router 配置
|
|
393
|
+
2. 生成指向本地 CCR Router 的 `.claude/settings.local.json`
|
|
394
|
+
3. 自动重启 CCR Router 以应用更改
|
|
395
|
+
|
|
396
|
+
**前提条件:**
|
|
397
|
+
- 安装 Claude Code Router:`npm install -g @musistudio/claude-code-router`
|
|
398
|
+
- 启动 CCR Router:`ccr start`
|
|
399
|
+
|
|
400
|
+
#### 添加 CCR 账户
|
|
401
|
+
|
|
402
|
+
添加 CCR 账户时,你会看到有用的配置提示:
|
|
403
|
+
|
|
404
|
+
```bash
|
|
405
|
+
ais add my-ccr-account
|
|
406
|
+
|
|
407
|
+
? Select account type: CCR
|
|
408
|
+
|
|
409
|
+
📝 CCR Configuration Tips:
|
|
410
|
+
• CCR configuration will be stored in ~/.claude-code-router/config.json
|
|
411
|
+
• You need to provide Provider name and models
|
|
412
|
+
• Router configuration will be automatically updated
|
|
413
|
+
|
|
414
|
+
? Enter API Key: sk-xxx...
|
|
415
|
+
? Enter API URL: http://localhost:3000/v1/chat/completions
|
|
416
|
+
? Enter Provider name: Local-new-api
|
|
417
|
+
? Enter default model: gemini-2.5-flash
|
|
418
|
+
? Enter background model: gemini-2.5-flash
|
|
419
|
+
? Enter think model: gemini-2.5-pro
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
**重要说明:**
|
|
423
|
+
- 默认 API URL 是 `http://localhost:3000/v1/chat/completions`
|
|
424
|
+
- 你需要指定三个模型:default、background 和 think
|
|
425
|
+
- 模型会在 Provider 配置中自动去重
|
|
426
|
+
|
|
427
|
+
#### 在项目中使用 CCR
|
|
428
|
+
|
|
429
|
+
使用 CCR 账户运行 `ais use` 后:
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
cd ~/my-project
|
|
433
|
+
ais use my-ccr-account
|
|
434
|
+
|
|
435
|
+
# 输出:
|
|
436
|
+
# ✓ Switched to account 'my-ccr-account' for current project.
|
|
437
|
+
# 🔄 Restarting CCR Router...
|
|
438
|
+
# ✓ CCR Router restarted successfully
|
|
439
|
+
# ✓ CCR configuration updated at: ~/.claude-code-router/config.json
|
|
440
|
+
# ✓ Claude configuration generated at: .claude/settings.local.json
|
|
441
|
+
#
|
|
442
|
+
# 📖 Next Steps:
|
|
443
|
+
# Start interactive session: claude
|
|
444
|
+
# This will enter project-level interactive mode
|
|
445
|
+
# Claude Code will use CCR Router to route requests
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
工具会:
|
|
449
|
+
1. **更新 CCR 配置**:在 `~/.claude-code-router/config.json` 中添加/更新 Provider
|
|
450
|
+
2. **更新 Router**:设置 default、background 和 think 模型
|
|
451
|
+
3. **生成 Claude 配置**:创建 `.claude/settings.local.json`,`ANTHROPIC_BASE_URL` 指向 CCR Router
|
|
452
|
+
4. **重启 CCR**:自动运行 `ccr restart` 以应用更改
|
|
453
|
+
|
|
454
|
+
#### 使用 CCR 运行 Claude
|
|
455
|
+
|
|
456
|
+
启动 Claude 交互会话:
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
# 在项目目录中
|
|
460
|
+
claude
|
|
461
|
+
|
|
462
|
+
# Claude Code 会自动使用 CCR Router
|
|
463
|
+
# 请求会根据你的 CCR 配置进行路由
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
#### CCR 配置结构
|
|
467
|
+
|
|
468
|
+
在 `~/.claude-code-router/config.json` 中生成的配置:
|
|
469
|
+
|
|
470
|
+
```json
|
|
471
|
+
{
|
|
472
|
+
"PORT": 3456,
|
|
473
|
+
"Providers": [
|
|
474
|
+
{
|
|
475
|
+
"api_base_url": "http://localhost:3000/v1/chat/completions",
|
|
476
|
+
"api_key": "sk-xxx...",
|
|
477
|
+
"models": ["gemini-2.5-flash", "gemini-2.5-pro"],
|
|
478
|
+
"name": "Local-new-api"
|
|
479
|
+
}
|
|
480
|
+
],
|
|
481
|
+
"Router": {
|
|
482
|
+
"default": "Local-new-api,gemini-2.5-flash",
|
|
483
|
+
"background": "Local-new-api,gemini-2.5-flash",
|
|
484
|
+
"think": "Local-new-api,gemini-2.5-pro"
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
在 `.claude/settings.local.json` 中生成的配置:
|
|
490
|
+
|
|
491
|
+
```json
|
|
492
|
+
{
|
|
493
|
+
"env": {
|
|
494
|
+
"ANTHROPIC_AUTH_TOKEN": "your-api-key",
|
|
495
|
+
"ANTHROPIC_BASE_URL": "http://127.0.0.1:3456"
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
#### 在不同项目间切换
|
|
501
|
+
|
|
502
|
+
每个项目可以使用不同的 CCR 配置:
|
|
503
|
+
|
|
504
|
+
```bash
|
|
505
|
+
# 项目 A
|
|
506
|
+
cd ~/project-a
|
|
507
|
+
ais use ccr-account-1
|
|
508
|
+
claude
|
|
509
|
+
|
|
510
|
+
# 项目 B
|
|
511
|
+
cd ~/project-b
|
|
512
|
+
ais use ccr-account-2
|
|
513
|
+
claude
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
#### CCR 故障排除
|
|
517
|
+
|
|
518
|
+
**检查 CCR 配置**
|
|
519
|
+
```bash
|
|
520
|
+
# 查看你的 CCR 配置
|
|
521
|
+
cat ~/.claude-code-router/config.json
|
|
522
|
+
|
|
523
|
+
# 查看 Claude 配置
|
|
524
|
+
cat .claude/settings.local.json
|
|
525
|
+
|
|
526
|
+
# 或使用 doctor 命令
|
|
527
|
+
ais doctor
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
**CCR Router 未安装**
|
|
531
|
+
- 从 npm 安装:`npm install -g @musistudio/claude-code-router`
|
|
532
|
+
- 访问项目页面:https://github.com/musistudio/claude-code-router
|
|
533
|
+
|
|
534
|
+
**CCR Router 未重启**
|
|
535
|
+
- 确保 CCR CLI 已安装并在 PATH 中可用
|
|
536
|
+
- 如果自动重启失败,手动运行 `ccr restart`
|
|
537
|
+
- 检查 CCR Router 是否运行:`ccr status`
|
|
538
|
+
|
|
539
|
+
**Claude 未使用 CCR Router**
|
|
540
|
+
- 验证 `.claude/settings.local.json` 中的 `ANTHROPIC_BASE_URL` 指向正确的端口
|
|
541
|
+
- 检查 CCR Router 是否在配置的端口上运行
|
|
542
|
+
- 配置更改后重启 Claude Code
|
|
543
|
+
|
|
387
544
|
### Droids 集成
|
|
388
545
|
|
|
389
546
|
当你添加 **Droids** 类型账户并运行 `ais use` 时,工具会自动在项目目录中创建 `.droids/config.json` 配置文件。
|
|
@@ -601,8 +758,16 @@ ais use correct-account
|
|
|
601
758
|
|
|
602
759
|
## 系统要求
|
|
603
760
|
|
|
604
|
-
- Node.js >=
|
|
605
|
-
- npm >=
|
|
761
|
+
- **Node.js**: >= 16.0.0
|
|
762
|
+
- **npm**: >= 7.0.0
|
|
763
|
+
|
|
764
|
+
**注意**: 此工具需要 Node.js 16 或更高版本(因为 commander@11.x 依赖要求)。你可以使用以下命令检查当前版本:
|
|
765
|
+
```bash
|
|
766
|
+
node --version
|
|
767
|
+
npm --version
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
如果需要升级 Node.js,请访问 [nodejs.org](https://nodejs.org/) 或使用版本管理器如 [nvm](https://github.com/nvm-sh/nvm)。
|
|
606
771
|
|
|
607
772
|
## 项目结构
|
|
608
773
|
|
|
@@ -699,6 +864,25 @@ MIT License - 欢迎在你的项目中使用此工具!
|
|
|
699
864
|
|
|
700
865
|
## 更新日志
|
|
701
866
|
|
|
867
|
+
### v1.6.0
|
|
868
|
+
- **CCR (Claude Code Router) 集成**:
|
|
869
|
+
- 完整支持 Claude Code Router
|
|
870
|
+
- 自动生成 `~/.claude-code-router/config.json` 配置
|
|
871
|
+
- Provider 和 Router 配置管理
|
|
872
|
+
- 配置更改后自动重启 CCR Router
|
|
873
|
+
- Claude Code 与本地 CCR Router 端点集成
|
|
874
|
+
- 支持 default、background 和 think 模型路由
|
|
875
|
+
- **Web UI 增强**:
|
|
876
|
+
- 添加账户状态检查,带颜色指示器(绿色:可用,橙色:不稳定,红色:不可用)
|
|
877
|
+
- 状态结果会保存并在页面加载时显示
|
|
878
|
+
- 实时状态检查,带"状态检查"按钮
|
|
879
|
+
- 改进账户卡片布局,状态显示在右上角
|
|
880
|
+
- 状态检查期间增强视觉反馈
|
|
881
|
+
- **配置改进**:
|
|
882
|
+
- CCR 账户自动生成 CCR 和 Claude 两种配置
|
|
883
|
+
- 从 CCR 配置动态读取端口用于 Claude 集成
|
|
884
|
+
- 更好的错误处理和用户反馈
|
|
885
|
+
|
|
702
886
|
### v1.5.7
|
|
703
887
|
- **Droids 集成**:
|
|
704
888
|
- 完整支持 Droids AI 助手
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-account-switch",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "A cross-platform CLI tool to manage and switch Claude/Codex/Droids account configurations",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"inquirer": "^8.2.5"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
|
-
"node": ">=
|
|
36
|
+
"node": ">=16.0.0"
|
|
37
37
|
},
|
|
38
38
|
"repository": {
|
|
39
39
|
"type": "git",
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Commands 模块说明
|
|
2
|
+
|
|
3
|
+
## 目录结构
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
commands/
|
|
7
|
+
├── README.md # 本文件 - 模块说明
|
|
8
|
+
├── helpers.js # ✅ 辅助函数 (maskApiKey, validateAccount)
|
|
9
|
+
├── account.js # ⏳ 账号管理命令
|
|
10
|
+
├── model.js # ⏳ 模型组管理命令
|
|
11
|
+
├── utility.js # ⏳ 工具类命令
|
|
12
|
+
└── index.js # ⏳ 统一导出接口
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 模块职责
|
|
16
|
+
|
|
17
|
+
### helpers.js ✅
|
|
18
|
+
**辅助函数** - 所有模块共用的工具函数
|
|
19
|
+
|
|
20
|
+
- `maskApiKey(apiKey)` - API密钥遮罩显示
|
|
21
|
+
- `validateAccount(apiKey, apiUrl)` - 验证账号有效性
|
|
22
|
+
|
|
23
|
+
### account.js
|
|
24
|
+
**账号管理** - 处理账号的 CRUD 操作
|
|
25
|
+
|
|
26
|
+
- `addAccount(name, options)` - 添加新账号
|
|
27
|
+
- `listAccounts()` - 列出所有账号
|
|
28
|
+
- `useAccount(name)` - 切换到指定账号
|
|
29
|
+
- `showInfo()` - 显示当前项目账号信息
|
|
30
|
+
- `removeAccount(name)` - 删除账号
|
|
31
|
+
- `showCurrent()` - 显示当前账号名称
|
|
32
|
+
- `exportAccount(name)` - 导出账号配置
|
|
33
|
+
- `promptForModelGroup()` - 模型组配置提示(内部使用)
|
|
34
|
+
|
|
35
|
+
### model.js
|
|
36
|
+
**模型组管理** - 管理 Claude 账号的模型组配置
|
|
37
|
+
|
|
38
|
+
- `listModelGroups()` - 列出模型组
|
|
39
|
+
- `addModelGroup(name)` - 添加模型组
|
|
40
|
+
- `useModelGroup(name)` - 切换模型组
|
|
41
|
+
- `removeModelGroup(name)` - 删除模型组
|
|
42
|
+
- `showModelGroup(name)` - 显示模型组详情
|
|
43
|
+
|
|
44
|
+
### utility.js
|
|
45
|
+
**工具类命令** - 诊断和辅助功能
|
|
46
|
+
|
|
47
|
+
- `showPaths()` - 显示配置文件路径
|
|
48
|
+
- `doctor()` - 诊断配置问题
|
|
49
|
+
- `startUI()` - 启动 Web UI 管理界面
|
|
50
|
+
|
|
51
|
+
### index.js
|
|
52
|
+
**统一导出** - 导出所有命令供主程序使用
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
module.exports = {
|
|
56
|
+
// Account commands
|
|
57
|
+
addAccount,
|
|
58
|
+
listAccounts,
|
|
59
|
+
useAccount,
|
|
60
|
+
showInfo,
|
|
61
|
+
removeAccount,
|
|
62
|
+
showCurrent,
|
|
63
|
+
exportAccount,
|
|
64
|
+
|
|
65
|
+
// Model commands
|
|
66
|
+
listModelGroups,
|
|
67
|
+
addModelGroup,
|
|
68
|
+
useModelGroup,
|
|
69
|
+
removeModelGroup,
|
|
70
|
+
showModelGroup,
|
|
71
|
+
|
|
72
|
+
// Utility commands
|
|
73
|
+
showPaths,
|
|
74
|
+
doctor,
|
|
75
|
+
startUI
|
|
76
|
+
};
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 依赖关系
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
index.js (主入口)
|
|
83
|
+
↓
|
|
84
|
+
commands/index.js (命令导出)
|
|
85
|
+
↓
|
|
86
|
+
├─ account.js → helpers.js
|
|
87
|
+
├─ model.js → helpers.js
|
|
88
|
+
└─ utility.js → helpers.js
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## 迁移状态
|
|
92
|
+
|
|
93
|
+
✅ **重构已完成!** (2025-10-24)
|
|
94
|
+
|
|
95
|
+
- [x] helpers.js - 辅助函数模块
|
|
96
|
+
- [x] account.js - 账号管理模块
|
|
97
|
+
- [x] model.js - 模型组管理模块
|
|
98
|
+
- [x] utility.js - 工具类模块
|
|
99
|
+
- [x] index.js - 统一导出
|
|
100
|
+
- [x] 更新 src/index.js 引用 (已兼容)
|
|
101
|
+
- [x] 测试所有命令功能
|
|
102
|
+
- [x] 备份原文件 (src/commands.js → src/commands.js.bak)
|
|
103
|
+
|
|
104
|
+
## 优势
|
|
105
|
+
|
|
106
|
+
1. **模块化** - 每个文件职责单一,代码清晰
|
|
107
|
+
2. **可维护** - 修改某个功能只需关注对应模块
|
|
108
|
+
3. **可测试** - 独立模块易于编写单元测试
|
|
109
|
+
4. **可扩展** - 新增功能只需添加新模块或扩展现有模块
|
|
110
|
+
|
|
111
|
+
## 使用方式
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
// 旧方式 (src/commands.js)
|
|
115
|
+
const { addAccount, listAccounts } = require('./commands');
|
|
116
|
+
|
|
117
|
+
// 新方式 (src/commands/index.js)
|
|
118
|
+
const { addAccount, listAccounts } = require('./commands');
|
|
119
|
+
// 或
|
|
120
|
+
const commands = require('./commands');
|
|
121
|
+
commands.addAccount();
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
接口保持不变,只是内部实现变成模块化。
|