ai-account-switch 1.1.0 → 1.3.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/INSTALL_WINDOWS.md +109 -0
- package/README.md +245 -24
- package/README_ZH.md +634 -0
- package/install.bat +103 -0
- package/install.ps1 +128 -0
- package/package.json +1 -1
- package/src/commands.js +240 -4
- package/src/config.js +7 -0
- package/src/index.js +20 -3
- package/.claude/settings.local.json +0 -19
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Windows Installation Guide
|
|
2
|
+
|
|
3
|
+
This guide provides detailed instructions for installing AI Account Switch (ais) on Windows.
|
|
4
|
+
|
|
5
|
+
## Quick Install (Recommended)
|
|
6
|
+
|
|
7
|
+
### Method 1: One-Line PowerShell Install
|
|
8
|
+
|
|
9
|
+
Open PowerShell and run:
|
|
10
|
+
|
|
11
|
+
```powershell
|
|
12
|
+
irm https://github.com/yourusername/ai-agent-user-swith/releases/latest/download/install.ps1 | iex
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This will:
|
|
16
|
+
- Download the latest version
|
|
17
|
+
- Install to `%LOCALAPPDATA%\ais` (no admin rights required)
|
|
18
|
+
- Automatically add to your PATH
|
|
19
|
+
- Verify the installation
|
|
20
|
+
|
|
21
|
+
### Method 2: Download and Run Installer
|
|
22
|
+
|
|
23
|
+
1. Download `install.ps1` or `install.bat` from the [Releases page](https://github.com/yourusername/ai-agent-user-swith/releases)
|
|
24
|
+
2. Right-click `install.ps1` → "Run with PowerShell"
|
|
25
|
+
- Or double-click `install.bat`
|
|
26
|
+
|
|
27
|
+
### System-Wide Installation
|
|
28
|
+
|
|
29
|
+
If you want to install for all users (requires Administrator):
|
|
30
|
+
|
|
31
|
+
```powershell
|
|
32
|
+
# Run PowerShell as Administrator
|
|
33
|
+
irm https://github.com/yourusername/ai-agent-user-swith/releases/latest/download/install.ps1 | iex -SystemWide
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or run the downloaded `install.ps1` with the `-SystemWide` parameter:
|
|
37
|
+
|
|
38
|
+
```powershell
|
|
39
|
+
.\install.ps1 -SystemWide
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This installs to `C:\Program Files\ais` instead of the user directory.
|
|
43
|
+
|
|
44
|
+
## Manual Installation
|
|
45
|
+
|
|
46
|
+
If you prefer to install manually, see the main [README.md](README.md) for detailed instructions.
|
|
47
|
+
|
|
48
|
+
## Verify Installation
|
|
49
|
+
|
|
50
|
+
After installation, open a **new terminal window** and run:
|
|
51
|
+
|
|
52
|
+
```cmd
|
|
53
|
+
ais --version
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
You should see the version number displayed.
|
|
57
|
+
|
|
58
|
+
## Troubleshooting
|
|
59
|
+
|
|
60
|
+
### Command not found
|
|
61
|
+
|
|
62
|
+
If `ais` command is not found after installation:
|
|
63
|
+
|
|
64
|
+
1. Close and reopen your terminal (PATH changes require a new session)
|
|
65
|
+
2. Verify the installation directory is in your PATH:
|
|
66
|
+
```cmd
|
|
67
|
+
echo %PATH%
|
|
68
|
+
```
|
|
69
|
+
3. Re-run the installer
|
|
70
|
+
|
|
71
|
+
### Permission Denied
|
|
72
|
+
|
|
73
|
+
If you get permission errors:
|
|
74
|
+
|
|
75
|
+
1. Run PowerShell as Administrator
|
|
76
|
+
2. Or use the user-local installation (default, no admin required)
|
|
77
|
+
|
|
78
|
+
### Antivirus Blocking
|
|
79
|
+
|
|
80
|
+
Some antivirus software may flag the executable. This is a false positive. You can:
|
|
81
|
+
|
|
82
|
+
1. Add an exception in your antivirus software
|
|
83
|
+
2. Download and verify the file manually from GitHub Releases
|
|
84
|
+
3. Install from npm instead: `npm install -g ai-account-switch`
|
|
85
|
+
|
|
86
|
+
## Uninstallation
|
|
87
|
+
|
|
88
|
+
To uninstall ais:
|
|
89
|
+
|
|
90
|
+
1. Remove the installation directory:
|
|
91
|
+
```cmd
|
|
92
|
+
rmdir /s "%LOCALAPPDATA%\ais"
|
|
93
|
+
```
|
|
94
|
+
Or for system-wide installation:
|
|
95
|
+
```cmd
|
|
96
|
+
rmdir /s "C:\Program Files\ais"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
2. Remove from PATH:
|
|
100
|
+
- Open "Edit the system environment variables"
|
|
101
|
+
- Click "Environment Variables"
|
|
102
|
+
- Find "Path" and remove the ais directory entry
|
|
103
|
+
|
|
104
|
+
## Alternative Installation Methods
|
|
105
|
+
|
|
106
|
+
- **npm**: `npm install -g ai-account-switch` (requires Node.js)
|
|
107
|
+
- **From source**: Clone the repository and run `npm link`
|
|
108
|
+
|
|
109
|
+
See [README.md](README.md) for more details.
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# AI Account Switch (ais)
|
|
2
2
|
|
|
3
|
+
English | [简体中文](README_ZH.md)
|
|
4
|
+
|
|
3
5
|
A cross-platform CLI tool to manage and switch between Claude/Codex account configurations for different projects.
|
|
4
6
|
|
|
5
7
|
## Features
|
|
@@ -15,28 +17,173 @@ A cross-platform CLI tool to manage and switch between Claude/Codex account conf
|
|
|
15
17
|
|
|
16
18
|
## Installation
|
|
17
19
|
|
|
18
|
-
### Option 1:
|
|
19
|
-
|
|
20
|
-
Download the latest release for your platform from the [Releases page](https://github.com/yourusername/ai-agent-user-swith/releases):
|
|
20
|
+
### Option 1: Global npm Installation (Recommended)
|
|
21
21
|
|
|
22
|
-
**macOS:**
|
|
23
22
|
```bash
|
|
24
|
-
|
|
25
|
-
curl -L https://github.com/yourusername/ai-agent-user-swith/releases/latest/download/ais-macos -o /usr/local/bin/ais
|
|
26
|
-
chmod +x /usr/local/bin/ais
|
|
23
|
+
npm install -g ai-account-switch
|
|
27
24
|
```
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
After installation, the `ais` command will be available globally.
|
|
27
|
+
|
|
28
|
+
**Note**: If you encounter "command not found" after installation, you may need to add npm's global bin directory to your PATH:
|
|
29
|
+
|
|
30
30
|
```bash
|
|
31
|
-
#
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
# Check npm global bin path
|
|
32
|
+
npm config get prefix
|
|
33
|
+
|
|
34
|
+
# Add to PATH (Linux/macOS)
|
|
35
|
+
export PATH="$PATH:$(npm config get prefix)/bin"
|
|
36
|
+
|
|
37
|
+
# On Windows, add to system PATH: %APPDATA%\npm
|
|
34
38
|
```
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
### Option 2: Download Pre-built Binary
|
|
41
|
+
|
|
42
|
+
Download the latest release for your platform from the [Releases page](https://github.com/yourusername/ai-agent-user-swith/releases):
|
|
43
|
+
|
|
44
|
+
**Windows (Automatic Installation - Recommended):**
|
|
45
|
+
|
|
46
|
+
Use the automated installer that downloads the latest version and adds it to PATH automatically:
|
|
47
|
+
|
|
48
|
+
**Method 1: PowerShell (Recommended)**
|
|
49
|
+
```powershell
|
|
50
|
+
# Run in PowerShell (Administrator recommended for system-wide install)
|
|
51
|
+
irm https://github.com/yourusername/ai-agent-user-swith/releases/latest/download/install.ps1 | iex
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Method 2: Download and Run Installer Script**
|
|
55
|
+
1. Download `install.ps1` or `install.bat` from the [Releases page](https://github.com/yourusername/ai-agent-user-swith/releases)
|
|
56
|
+
2. Right-click on `install.ps1` and select "Run with PowerShell"
|
|
57
|
+
- Or run `install.bat` by double-clicking it
|
|
58
|
+
|
|
59
|
+
The installer will:
|
|
60
|
+
- Download the latest `ais-win.exe`
|
|
61
|
+
- Install to `%LOCALAPPDATA%\ais` (user install) or `C:\Program Files\ais` (system install)
|
|
62
|
+
- Automatically add to PATH
|
|
63
|
+
- Verify the installation
|
|
64
|
+
|
|
65
|
+
After installation, open a **new terminal** and verify:
|
|
66
|
+
```cmd
|
|
67
|
+
ais --version
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Windows (Manual Installation):**
|
|
71
|
+
|
|
72
|
+
If you prefer manual installation:
|
|
73
|
+
|
|
74
|
+
1. Download `ais-win.exe` from the [Releases page](https://github.com/yourusername/ai-agent-user-swith/releases)
|
|
75
|
+
|
|
76
|
+
2. Choose an installation location (recommended: `C:\Program Files\ais\`)
|
|
77
|
+
```cmd
|
|
78
|
+
mkdir "C:\Program Files\ais"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
3. Move the downloaded file to the installation directory and rename it:
|
|
82
|
+
```cmd
|
|
83
|
+
move "%USERPROFILE%\Downloads\ais-win.exe" "C:\Program Files\ais\ais.exe"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
4. Add to PATH:
|
|
87
|
+
|
|
88
|
+
**Method 1: Using System Settings (Recommended)**
|
|
89
|
+
- Open Start Menu and search for "Environment Variables"
|
|
90
|
+
- Click "Edit the system environment variables"
|
|
91
|
+
- Click "Environment Variables..." button
|
|
92
|
+
- Under "System variables" (or "User variables" for current user only), find and select "Path"
|
|
93
|
+
- Click "Edit..."
|
|
94
|
+
- Click "New"
|
|
95
|
+
- Add `C:\Program Files\ais`
|
|
96
|
+
- Click "OK" on all dialogs
|
|
97
|
+
- **Restart your terminal** for changes to take effect
|
|
98
|
+
|
|
99
|
+
**Method 2: Using PowerShell (Administrator)**
|
|
100
|
+
```powershell
|
|
101
|
+
# Add to User PATH
|
|
102
|
+
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\ais", "User")
|
|
103
|
+
|
|
104
|
+
# Or add to System PATH (requires admin)
|
|
105
|
+
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\ais", "Machine")
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Method 3: Using Command Prompt (Administrator)**
|
|
109
|
+
```cmd
|
|
110
|
+
setx PATH "%PATH%;C:\Program Files\ais"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
5. Verify installation:
|
|
114
|
+
```cmd
|
|
115
|
+
# Open a NEW terminal window
|
|
116
|
+
ais --version
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Note**: If you prefer a user-local installation without admin rights, use `%LOCALAPPDATA%\ais` instead:
|
|
120
|
+
```cmd
|
|
121
|
+
mkdir "%LOCALAPPDATA%\ais"
|
|
122
|
+
move "%USERPROFILE%\Downloads\ais-win.exe" "%LOCALAPPDATA%\ais\ais.exe"
|
|
123
|
+
# Then add %LOCALAPPDATA%\ais to your User PATH
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**macOS:**
|
|
127
|
+
|
|
128
|
+
1. Download and install to `/usr/local/bin`:
|
|
129
|
+
```bash
|
|
130
|
+
curl -L https://github.com/yourusername/ai-agent-user-swith/releases/latest/download/ais-macos -o /usr/local/bin/ais
|
|
131
|
+
chmod +x /usr/local/bin/ais
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
2. If you don't have write permissions for `/usr/local/bin`, use sudo:
|
|
135
|
+
```bash
|
|
136
|
+
sudo curl -L https://github.com/yourusername/ai-agent-user-swith/releases/latest/download/ais-macos -o /usr/local/bin/ais
|
|
137
|
+
sudo chmod +x /usr/local/bin/ais
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
3. Alternatively, install to your user directory (no sudo required):
|
|
141
|
+
```bash
|
|
142
|
+
mkdir -p ~/.local/bin
|
|
143
|
+
curl -L https://github.com/yourusername/ai-agent-user-swith/releases/latest/download/ais-macos -o ~/.local/bin/ais
|
|
144
|
+
chmod +x ~/.local/bin/ais
|
|
145
|
+
|
|
146
|
+
# Add to PATH if not already there
|
|
147
|
+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
|
|
148
|
+
source ~/.zshrc
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
4. Verify installation:
|
|
152
|
+
```bash
|
|
153
|
+
ais --version
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Linux:**
|
|
157
|
+
|
|
158
|
+
1. Download and install to `/usr/local/bin`:
|
|
159
|
+
```bash
|
|
160
|
+
curl -L https://github.com/yourusername/ai-agent-user-swith/releases/latest/download/ais-linux -o /usr/local/bin/ais
|
|
161
|
+
chmod +x /usr/local/bin/ais
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
2. If you don't have write permissions for `/usr/local/bin`, use sudo:
|
|
165
|
+
```bash
|
|
166
|
+
sudo curl -L https://github.com/yourusername/ai-agent-user-swith/releases/latest/download/ais-linux -o /usr/local/bin/ais
|
|
167
|
+
sudo chmod +x /usr/local/bin/ais
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
3. Alternatively, install to your user directory (no sudo required):
|
|
171
|
+
```bash
|
|
172
|
+
mkdir -p ~/.local/bin
|
|
173
|
+
curl -L https://github.com/yourusername/ai-agent-user-swith/releases/latest/download/ais-linux -o ~/.local/bin/ais
|
|
174
|
+
chmod +x ~/.local/bin/ais
|
|
38
175
|
|
|
39
|
-
|
|
176
|
+
# Add to PATH if not already there
|
|
177
|
+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
|
|
178
|
+
source ~/.bashrc
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
4. Verify installation:
|
|
182
|
+
```bash
|
|
183
|
+
ais --version
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Option 3: Install from Source
|
|
40
187
|
|
|
41
188
|
```bash
|
|
42
189
|
# Clone the repository
|
|
@@ -50,15 +197,7 @@ npm install
|
|
|
50
197
|
npm link
|
|
51
198
|
```
|
|
52
199
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
npm install -g ai-account-switch
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
After installation, the `ais` command will be available globally.
|
|
60
|
-
|
|
61
|
-
**Note**: See [NPM_PUBLISH.md](NPM_PUBLISH.md) for publishing instructions if you're a maintainer.
|
|
200
|
+
**For Maintainers**: See [NPM_PUBLISH.md](NPM_PUBLISH.md) for publishing instructions.
|
|
62
201
|
|
|
63
202
|
## Usage
|
|
64
203
|
|
|
@@ -100,6 +239,10 @@ You'll be prompted to enter:
|
|
|
100
239
|
- Organization ID (optional)
|
|
101
240
|
- Email (optional)
|
|
102
241
|
- Description (optional)
|
|
242
|
+
- Custom environment variables (optional)
|
|
243
|
+
- Enter in `KEY=VALUE` format (e.g., `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`)
|
|
244
|
+
- The tool will display all added variables before completion
|
|
245
|
+
- Press Enter without input to finish adding variables
|
|
103
246
|
|
|
104
247
|
#### 2. List All Accounts
|
|
105
248
|
|
|
@@ -202,7 +345,8 @@ When you run `ais use`, the tool automatically creates `.claude/settings.local.j
|
|
|
202
345
|
"env": {
|
|
203
346
|
"ANTHROPIC_AUTH_TOKEN": "your-api-key",
|
|
204
347
|
"ANTHROPIC_BASE_URL": "your-api-url",
|
|
205
|
-
"ANTHROPIC_ORGANIZATION_ID": "your-org-id"
|
|
348
|
+
"ANTHROPIC_ORGANIZATION_ID": "your-org-id",
|
|
349
|
+
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
|
|
206
350
|
},
|
|
207
351
|
"permissions": {
|
|
208
352
|
"allow": [],
|
|
@@ -214,6 +358,33 @@ When you run `ais use`, the tool automatically creates `.claude/settings.local.j
|
|
|
214
358
|
|
|
215
359
|
This ensures Claude Code CLI automatically uses the correct account for your project.
|
|
216
360
|
|
|
361
|
+
#### Custom Environment Variables
|
|
362
|
+
|
|
363
|
+
You can add custom environment variables when creating an account. When prompted, enter them in `KEY=VALUE` format:
|
|
364
|
+
|
|
365
|
+
**Input Format:**
|
|
366
|
+
```
|
|
367
|
+
? Environment variable (KEY=VALUE format): CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
|
|
368
|
+
✓ Added: CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
|
|
369
|
+
|
|
370
|
+
📋 Current environment variables:
|
|
371
|
+
• CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
|
|
372
|
+
|
|
373
|
+
? Add another environment variable? (y/N)
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
**Common Examples:**
|
|
377
|
+
- `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1` - Disable non-essential network traffic
|
|
378
|
+
- `HTTP_PROXY=http://proxy.example.com:8080` - Set HTTP proxy
|
|
379
|
+
- `HTTPS_PROXY=https://proxy.example.com:8080` - Set HTTPS proxy
|
|
380
|
+
- Any other environment variables needed for your setup
|
|
381
|
+
|
|
382
|
+
**Features:**
|
|
383
|
+
- One-line input format (`KEY=VALUE`)
|
|
384
|
+
- Real-time display of added variables
|
|
385
|
+
- Press Enter without input to finish
|
|
386
|
+
- Variables are automatically included in `.claude/settings.local.json`
|
|
387
|
+
|
|
217
388
|
## Examples
|
|
218
389
|
|
|
219
390
|
### Example 1: Setting Up Multiple Accounts
|
|
@@ -328,6 +499,40 @@ Make sure you've added at least one account:
|
|
|
328
499
|
ais add
|
|
329
500
|
```
|
|
330
501
|
|
|
502
|
+
### Claude Code uses wrong account
|
|
503
|
+
|
|
504
|
+
If Claude Code is using a different account than expected:
|
|
505
|
+
|
|
506
|
+
1. Run diagnostics:
|
|
507
|
+
```bash
|
|
508
|
+
ais doctor
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
2. Check if global Claude config is overriding project config:
|
|
512
|
+
- If `~/.claude/settings.json` contains `env.ANTHROPIC_AUTH_TOKEN`, it may conflict
|
|
513
|
+
- **Solution**: Remove the `env` section from global config, or only keep `permissions`
|
|
514
|
+
|
|
515
|
+
3. Ensure you're starting Claude Code from your project directory or subdirectory
|
|
516
|
+
|
|
517
|
+
4. Regenerate project config:
|
|
518
|
+
```bash
|
|
519
|
+
ais use <your-account-name>
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Project config not found in subdirectory
|
|
523
|
+
|
|
524
|
+
The tool should work in any subdirectory. If it doesn't:
|
|
525
|
+
|
|
526
|
+
```bash
|
|
527
|
+
# Make sure you're within a configured project
|
|
528
|
+
cd /path/to/your/project
|
|
529
|
+
ais use <account>
|
|
530
|
+
|
|
531
|
+
# Then try from subdirectory
|
|
532
|
+
cd src/
|
|
533
|
+
ais current # Should show your account
|
|
534
|
+
```
|
|
535
|
+
|
|
331
536
|
## Contributing
|
|
332
537
|
|
|
333
538
|
Contributions are welcome! Feel free to:
|
|
@@ -341,6 +546,22 @@ MIT License - feel free to use this tool in your projects!
|
|
|
341
546
|
|
|
342
547
|
## Changelog
|
|
343
548
|
|
|
549
|
+
### v1.3.0
|
|
550
|
+
- **Improved custom environment variables input**:
|
|
551
|
+
- One-line `KEY=VALUE` format input (e.g., `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`)
|
|
552
|
+
- Real-time display of added variables during configuration
|
|
553
|
+
- Press Enter without input to finish adding variables
|
|
554
|
+
- Better error messages and user guidance
|
|
555
|
+
- Enhanced documentation with detailed examples and usage instructions
|
|
556
|
+
|
|
557
|
+
### v1.2.0
|
|
558
|
+
- Added custom environment variables support for accounts
|
|
559
|
+
- Added `ais doctor` command for configuration diagnostics
|
|
560
|
+
- Enhanced `ais help` with all new features
|
|
561
|
+
- Updated installation documentation (npm as recommended method)
|
|
562
|
+
- Improved PATH configuration instructions
|
|
563
|
+
- Display custom env variables in `ais list` and `ais info`
|
|
564
|
+
|
|
344
565
|
### v1.1.0
|
|
345
566
|
- Added smart directory detection (works in any subdirectory)
|
|
346
567
|
- Automatic Claude Code `.claude/settings.local.json` generation
|