ai-account-switch 1.5.6 → 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 +325 -5
- package/README_ZH.md +316 -5
- package/package.json +6 -4
- 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 +158 -7
- package/src/index.js +55 -55
- package/src/ui-server.js +494 -47
- package/src/commands.js +0 -1182
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
English | [简体中文](README_ZH.md)
|
|
4
4
|
|
|
5
|
-
A cross-platform CLI tool to manage and switch between Claude/Codex account configurations for different projects.
|
|
5
|
+
A cross-platform CLI tool to manage and switch between Claude/Codex/Droids account configurations for different projects.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -13,7 +13,8 @@ A cross-platform CLI tool to manage and switch between Claude/Codex account conf
|
|
|
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, 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,265 @@ 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
|
+
|
|
490
|
+
### Droids Integration
|
|
491
|
+
|
|
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.
|
|
493
|
+
|
|
494
|
+
#### Adding a Droids Account
|
|
495
|
+
|
|
496
|
+
When adding a Droids account, you'll see helpful configuration tips:
|
|
497
|
+
|
|
498
|
+
```bash
|
|
499
|
+
ais add my-droids-account
|
|
500
|
+
|
|
501
|
+
? Select account type: Droids
|
|
502
|
+
|
|
503
|
+
📝 Droids Configuration Tips:
|
|
504
|
+
• Droids configuration will be stored in .droids/config.json
|
|
505
|
+
• API URL is optional (defaults to Droids default endpoint)
|
|
506
|
+
• You can configure custom models and settings
|
|
507
|
+
|
|
508
|
+
? Enter API Key: sk-xxx...
|
|
509
|
+
? Enter API URL (optional): https://api.example.com
|
|
510
|
+
? Do you want to specify a model? (Optional) Yes
|
|
511
|
+
? Enter model name: droids-model-v1
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
#### Using Droids with Your Project
|
|
515
|
+
|
|
516
|
+
After running `ais use` with a Droids account:
|
|
517
|
+
|
|
518
|
+
```bash
|
|
519
|
+
cd ~/my-project
|
|
520
|
+
ais use my-droids-account
|
|
521
|
+
|
|
522
|
+
# Output:
|
|
523
|
+
# ✓ Switched to account 'my-droids-account' for current project.
|
|
524
|
+
# ✓ Droids configuration generated at: .droids/config.json
|
|
525
|
+
#
|
|
526
|
+
# 📖 Next Steps:
|
|
527
|
+
# Start interactive session: droid
|
|
528
|
+
# This will enter project-level interactive mode
|
|
529
|
+
# Droids will automatically use the configuration from .droids/config.json
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
The tool creates:
|
|
533
|
+
- **Project Configuration**: `.droids/config.json` with your account settings
|
|
534
|
+
|
|
535
|
+
#### Running Droids
|
|
536
|
+
|
|
537
|
+
Start Droids interactive session:
|
|
538
|
+
|
|
539
|
+
```bash
|
|
540
|
+
# In your project directory
|
|
541
|
+
droid
|
|
542
|
+
|
|
543
|
+
# Droids will automatically load configuration from .droids/config.json
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
#### Droids Configuration Structure
|
|
547
|
+
|
|
548
|
+
The generated configuration in `.droids/config.json`:
|
|
549
|
+
|
|
550
|
+
```json
|
|
551
|
+
{
|
|
552
|
+
"apiKey": "your-api-key",
|
|
553
|
+
"baseUrl": "https://api.example.com",
|
|
554
|
+
"model": "droids-model-v1",
|
|
555
|
+
"customSettings": {
|
|
556
|
+
"CUSTOM_VAR": "value"
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
#### Switching Between Projects
|
|
562
|
+
|
|
563
|
+
Each project can use a different Droids account:
|
|
564
|
+
|
|
565
|
+
```bash
|
|
566
|
+
# Project A
|
|
567
|
+
cd ~/project-a
|
|
568
|
+
ais use droids-account-1
|
|
569
|
+
droid
|
|
570
|
+
|
|
571
|
+
# Project B
|
|
572
|
+
cd ~/project-b
|
|
573
|
+
ais use droids-account-2
|
|
574
|
+
droid
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
#### Troubleshooting Droids
|
|
578
|
+
|
|
579
|
+
**Check Droids Configuration**
|
|
580
|
+
```bash
|
|
581
|
+
# View your Droids configuration
|
|
582
|
+
cat .droids/config.json
|
|
583
|
+
|
|
584
|
+
# Or use the doctor command
|
|
585
|
+
ais doctor
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
**Droids CLI not found**
|
|
589
|
+
- Make sure Droids CLI is installed and available in your PATH
|
|
590
|
+
- Run `droid --version` to verify installation
|
|
591
|
+
|
|
332
592
|
#### Custom Environment Variables
|
|
333
593
|
|
|
334
594
|
You can add custom environment variables when creating an account. When prompted, enter them in `KEY=VALUE` format:
|
|
@@ -370,6 +630,9 @@ ais add work-claude
|
|
|
370
630
|
# Add a Codex account
|
|
371
631
|
ais add codex-dev
|
|
372
632
|
|
|
633
|
+
# Add a Droids account
|
|
634
|
+
ais add droids-dev
|
|
635
|
+
|
|
373
636
|
# List all accounts
|
|
374
637
|
ais list
|
|
375
638
|
```
|
|
@@ -426,8 +689,16 @@ ais paths
|
|
|
426
689
|
|
|
427
690
|
## Requirements
|
|
428
691
|
|
|
429
|
-
- Node.js >=
|
|
430
|
-
- 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).
|
|
431
702
|
|
|
432
703
|
## Project Structure
|
|
433
704
|
|
|
@@ -517,6 +788,55 @@ MIT License - feel free to use this tool in your projects!
|
|
|
517
788
|
|
|
518
789
|
## Changelog
|
|
519
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
|
+
|
|
818
|
+
### v1.5.7
|
|
819
|
+
- **Droids Integration**:
|
|
820
|
+
- Added full support for Droids AI assistant
|
|
821
|
+
- Automatic generation of `.droids/config.json` configuration
|
|
822
|
+
- Simple model configuration for Droids accounts
|
|
823
|
+
- Interactive session command: `droid`
|
|
824
|
+
- Enhanced `ais doctor` command with Droids configuration detection
|
|
825
|
+
- **UI Enhancements**:
|
|
826
|
+
- Added type filter dropdown for quick account filtering
|
|
827
|
+
- Color-coded account cards by type (Claude: blue, Codex: purple, Droids: green, Other: orange)
|
|
828
|
+
- Left border color indicators on account cards
|
|
829
|
+
- Improved visual hierarchy and user experience
|
|
830
|
+
- **Model Configuration Improvements**:
|
|
831
|
+
- Separated model configuration for different account types
|
|
832
|
+
- Claude: Complex model groups with multiple model settings
|
|
833
|
+
- Codex/Droids: Simple model field for straightforward configuration
|
|
834
|
+
- All model settings moved to collapsible "Advanced Configuration" section
|
|
835
|
+
- **Better User Guidance**:
|
|
836
|
+
- Enhanced `ais use` command with clear next-step instructions
|
|
837
|
+
- Type-specific usage examples for each AI assistant
|
|
838
|
+
- Interactive mode prompts instead of one-time command examples
|
|
839
|
+
|
|
520
840
|
### v1.5.1
|
|
521
841
|
- **Codex Integration Enhancements**:
|
|
522
842
|
- Added full support for Codex CLI with profile-based configuration
|