ai-account-switch 1.2.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 +167 -15
- package/README_ZH.md +167 -15
- package/install.bat +103 -0
- package/install.ps1 +128 -0
- package/package.json +1 -1
- package/src/commands.js +52 -14
|
@@ -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
|
@@ -41,22 +41,147 @@ export PATH="$PATH:$(npm config get prefix)/bin"
|
|
|
41
41
|
|
|
42
42
|
Download the latest release for your platform from the [Releases page](https://github.com/yourusername/ai-agent-user-swith/releases):
|
|
43
43
|
|
|
44
|
-
**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
49
52
|
```
|
|
50
53
|
|
|
51
|
-
**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
|
56
68
|
```
|
|
57
69
|
|
|
58
|
-
**Windows:**
|
|
59
|
-
|
|
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
|
|
175
|
+
|
|
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
|
+
```
|
|
60
185
|
|
|
61
186
|
### Option 3: Install from Source
|
|
62
187
|
|
|
@@ -114,7 +239,10 @@ You'll be prompted to enter:
|
|
|
114
239
|
- Organization ID (optional)
|
|
115
240
|
- Email (optional)
|
|
116
241
|
- Description (optional)
|
|
117
|
-
- Custom environment variables (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
|
|
118
246
|
|
|
119
247
|
#### 2. List All Accounts
|
|
120
248
|
|
|
@@ -232,14 +360,30 @@ This ensures Claude Code CLI automatically uses the correct account for your pro
|
|
|
232
360
|
|
|
233
361
|
#### Custom Environment Variables
|
|
234
362
|
|
|
235
|
-
You can add custom environment variables when creating an account.
|
|
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
|
|
236
372
|
|
|
373
|
+
? Add another environment variable? (y/N)
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
**Common Examples:**
|
|
237
377
|
- `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1` - Disable non-essential network traffic
|
|
238
378
|
- `HTTP_PROXY=http://proxy.example.com:8080` - Set HTTP proxy
|
|
239
379
|
- `HTTPS_PROXY=https://proxy.example.com:8080` - Set HTTPS proxy
|
|
240
380
|
- Any other environment variables needed for your setup
|
|
241
381
|
|
|
242
|
-
|
|
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`
|
|
243
387
|
|
|
244
388
|
## Examples
|
|
245
389
|
|
|
@@ -402,6 +546,14 @@ MIT License - feel free to use this tool in your projects!
|
|
|
402
546
|
|
|
403
547
|
## Changelog
|
|
404
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
|
+
|
|
405
557
|
### v1.2.0
|
|
406
558
|
- Added custom environment variables support for accounts
|
|
407
559
|
- Added `ais doctor` command for configuration diagnostics
|
package/README_ZH.md
CHANGED
|
@@ -41,22 +41,147 @@ export PATH="$PATH:$(npm config get prefix)/bin"
|
|
|
41
41
|
|
|
42
42
|
从 [Releases 页面](https://github.com/yourusername/ai-agent-user-swith/releases) 下载适合你平台的最新版本:
|
|
43
43
|
|
|
44
|
-
**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
**Windows(自动安装 - 推荐):**
|
|
45
|
+
|
|
46
|
+
使用自动安装程序,它会下载最新版本并自动添加到 PATH:
|
|
47
|
+
|
|
48
|
+
**方法 1:PowerShell(推荐)**
|
|
49
|
+
```powershell
|
|
50
|
+
# 在 PowerShell 中运行(建议使用管理员权限进行系统级安装)
|
|
51
|
+
irm https://github.com/yourusername/ai-agent-user-swith/releases/latest/download/install.ps1 | iex
|
|
49
52
|
```
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
**方法 2:下载并运行安装脚本**
|
|
55
|
+
1. 从 [Releases 页面](https://github.com/yourusername/ai-agent-user-swith/releases) 下载 `install.ps1` 或 `install.bat`
|
|
56
|
+
2. 右键点击 `install.ps1` 并选择"使用 PowerShell 运行"
|
|
57
|
+
- 或双击运行 `install.bat`
|
|
58
|
+
|
|
59
|
+
安装程序将:
|
|
60
|
+
- 下载最新的 `ais-win.exe`
|
|
61
|
+
- 安装到 `%LOCALAPPDATA%\ais`(用户安装)或 `C:\Program Files\ais`(系统安装)
|
|
62
|
+
- 自动添加到 PATH
|
|
63
|
+
- 验证安装
|
|
64
|
+
|
|
65
|
+
安装完成后,打开**新的终端**并验证:
|
|
66
|
+
```cmd
|
|
67
|
+
ais --version
|
|
56
68
|
```
|
|
57
69
|
|
|
58
|
-
**Windows
|
|
59
|
-
|
|
70
|
+
**Windows(手动安装):**
|
|
71
|
+
|
|
72
|
+
如果你更喜欢手动安装:
|
|
73
|
+
|
|
74
|
+
1. 从 [Releases 页面](https://github.com/yourusername/ai-agent-user-swith/releases) 下载 `ais-win.exe`
|
|
75
|
+
|
|
76
|
+
2. 选择安装位置(推荐:`C:\Program Files\ais\`)
|
|
77
|
+
```cmd
|
|
78
|
+
mkdir "C:\Program Files\ais"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
3. 将下载的文件移动到安装目录并重命名:
|
|
82
|
+
```cmd
|
|
83
|
+
move "%USERPROFILE%\Downloads\ais-win.exe" "C:\Program Files\ais\ais.exe"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
4. 添加到 PATH:
|
|
87
|
+
|
|
88
|
+
**方法 1:使用系统设置(推荐)**
|
|
89
|
+
- 打开开始菜单,搜索"环境变量"
|
|
90
|
+
- 点击"编辑系统环境变量"
|
|
91
|
+
- 点击"环境变量..."按钮
|
|
92
|
+
- 在"系统变量"(或"用户变量",仅对当前用户有效)下,找到并选择"Path"
|
|
93
|
+
- 点击"编辑..."
|
|
94
|
+
- 点击"新建"
|
|
95
|
+
- 添加 `C:\Program Files\ais`
|
|
96
|
+
- 在所有对话框上点击"确定"
|
|
97
|
+
- **重启终端**使更改生效
|
|
98
|
+
|
|
99
|
+
**方法 2:使用 PowerShell(管理员权限)**
|
|
100
|
+
```powershell
|
|
101
|
+
# 添加到用户 PATH
|
|
102
|
+
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\ais", "User")
|
|
103
|
+
|
|
104
|
+
# 或添加到系统 PATH(需要管理员权限)
|
|
105
|
+
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\ais", "Machine")
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**方法 3:使用命令提示符(管理员权限)**
|
|
109
|
+
```cmd
|
|
110
|
+
setx PATH "%PATH%;C:\Program Files\ais"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
5. 验证安装:
|
|
114
|
+
```cmd
|
|
115
|
+
# 打开新的终端窗口
|
|
116
|
+
ais --version
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**注意**:如果你希望安装到用户目录而不需要管理员权限,可以使用 `%LOCALAPPDATA%\ais`:
|
|
120
|
+
```cmd
|
|
121
|
+
mkdir "%LOCALAPPDATA%\ais"
|
|
122
|
+
move "%USERPROFILE%\Downloads\ais-win.exe" "%LOCALAPPDATA%\ais\ais.exe"
|
|
123
|
+
# 然后将 %LOCALAPPDATA%\ais 添加到你的用户 PATH
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**macOS:**
|
|
127
|
+
|
|
128
|
+
1. 下载并安装到 `/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. 如果你没有 `/usr/local/bin` 的写入权限,使用 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. 或者,安装到用户目录(无需 sudo):
|
|
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
|
+
# 如果还未添加到 PATH,请添加
|
|
147
|
+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
|
|
148
|
+
source ~/.zshrc
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
4. 验证安装:
|
|
152
|
+
```bash
|
|
153
|
+
ais --version
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Linux:**
|
|
157
|
+
|
|
158
|
+
1. 下载并安装到 `/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. 如果你没有 `/usr/local/bin` 的写入权限,使用 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. 或者,安装到用户目录(无需 sudo):
|
|
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
|
|
175
|
+
|
|
176
|
+
# 如果还未添加到 PATH,请添加
|
|
177
|
+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
|
|
178
|
+
source ~/.bashrc
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
4. 验证安装:
|
|
182
|
+
```bash
|
|
183
|
+
ais --version
|
|
184
|
+
```
|
|
60
185
|
|
|
61
186
|
### 方式 3:从源码安装
|
|
62
187
|
|
|
@@ -115,7 +240,10 @@ ais add my-claude-account
|
|
|
115
240
|
- Organization ID(可选)
|
|
116
241
|
- Email(可选)
|
|
117
242
|
- 描述(可选)
|
|
118
|
-
-
|
|
243
|
+
- 自定义环境变量(可选)
|
|
244
|
+
- 使用 `KEY=VALUE` 格式输入(例如:`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`)
|
|
245
|
+
- 工具会在完成前显示所有已添加的变量
|
|
246
|
+
- 直接按回车(不输入)即可完成添加
|
|
119
247
|
|
|
120
248
|
#### 2. 列出所有账户
|
|
121
249
|
|
|
@@ -248,14 +376,30 @@ ais export my-claude-account
|
|
|
248
376
|
|
|
249
377
|
#### 自定义环境变量
|
|
250
378
|
|
|
251
|
-
|
|
379
|
+
在创建账户时可以添加自定义环境变量。在提示时,使用 `KEY=VALUE` 格式输入:
|
|
252
380
|
|
|
381
|
+
**输入格式:**
|
|
382
|
+
```
|
|
383
|
+
? Environment variable (KEY=VALUE format): CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
|
|
384
|
+
✓ Added: CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
|
|
385
|
+
|
|
386
|
+
📋 Current environment variables:
|
|
387
|
+
• CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
|
|
388
|
+
|
|
389
|
+
? Add another environment variable? (y/N)
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
**常见示例:**
|
|
253
393
|
- `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1` - 禁用非必要网络流量
|
|
254
394
|
- `HTTP_PROXY=http://proxy.example.com:8080` - 设置 HTTP 代理
|
|
255
395
|
- `HTTPS_PROXY=https://proxy.example.com:8080` - 设置 HTTPS 代理
|
|
256
396
|
- 其他你需要的环境变量
|
|
257
397
|
|
|
258
|
-
|
|
398
|
+
**功能特性:**
|
|
399
|
+
- 单行输入格式(`KEY=VALUE`)
|
|
400
|
+
- 实时显示已添加的变量
|
|
401
|
+
- 直接按回车即可完成
|
|
402
|
+
- 变量会自动包含在 `.claude/settings.local.json` 文件中
|
|
259
403
|
|
|
260
404
|
## 使用示例
|
|
261
405
|
|
|
@@ -437,6 +581,14 @@ MIT License - 欢迎在你的项目中使用此工具!
|
|
|
437
581
|
|
|
438
582
|
## 更新日志
|
|
439
583
|
|
|
584
|
+
### v1.3.0
|
|
585
|
+
- **改进自定义环境变量输入**:
|
|
586
|
+
- 支持单行 `KEY=VALUE` 格式输入(例如:`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`)
|
|
587
|
+
- 配置过程中实时显示已添加的变量
|
|
588
|
+
- 直接按回车即可完成变量添加
|
|
589
|
+
- 更清晰的错误提示和用户指引
|
|
590
|
+
- 增强文档,添加详细的示例和使用说明
|
|
591
|
+
|
|
440
592
|
### v1.2.0
|
|
441
593
|
- 添加账户自定义环境变量支持
|
|
442
594
|
- 添加 `ais doctor` 命令用于配置诊断
|
package/install.bat
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
REM AI Account Switch (ais) - Windows Installer (Batch)
|
|
3
|
+
REM This script downloads and installs ais, automatically adding it to PATH
|
|
4
|
+
|
|
5
|
+
setlocal enabledelayedexpansion
|
|
6
|
+
|
|
7
|
+
echo ==========================================
|
|
8
|
+
echo AI Account Switch (ais) Installer
|
|
9
|
+
echo ==========================================
|
|
10
|
+
echo.
|
|
11
|
+
|
|
12
|
+
REM Determine installation directory (user-local by default)
|
|
13
|
+
set "INSTALL_DIR=%LOCALAPPDATA%\ais"
|
|
14
|
+
set "PATH_SCOPE=User"
|
|
15
|
+
|
|
16
|
+
echo Installing for current user
|
|
17
|
+
echo Installation directory: %INSTALL_DIR%
|
|
18
|
+
echo.
|
|
19
|
+
|
|
20
|
+
REM Create installation directory
|
|
21
|
+
if not exist "%INSTALL_DIR%" (
|
|
22
|
+
echo Creating installation directory...
|
|
23
|
+
mkdir "%INSTALL_DIR%"
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
REM Download using PowerShell (available on all modern Windows)
|
|
27
|
+
set "EXE_PATH=%INSTALL_DIR%\ais.exe"
|
|
28
|
+
set "DOWNLOAD_URL=https://github.com/yourusername/ai-agent-user-swith/releases/latest/download/ais-win.exe"
|
|
29
|
+
|
|
30
|
+
echo Downloading latest release...
|
|
31
|
+
echo From: %DOWNLOAD_URL%
|
|
32
|
+
echo.
|
|
33
|
+
|
|
34
|
+
powershell -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%DOWNLOAD_URL%' -OutFile '%EXE_PATH%'}"
|
|
35
|
+
|
|
36
|
+
if %errorlevel% neq 0 (
|
|
37
|
+
echo [ERROR] Failed to download ais-win.exe
|
|
38
|
+
echo Please check your internet connection and try again.
|
|
39
|
+
pause
|
|
40
|
+
exit /b 1
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
echo [OK] Downloaded successfully
|
|
44
|
+
echo.
|
|
45
|
+
|
|
46
|
+
REM Add to PATH
|
|
47
|
+
echo Adding to PATH...
|
|
48
|
+
|
|
49
|
+
REM Check if already in PATH
|
|
50
|
+
echo %PATH% | findstr /C:"%INSTALL_DIR%" >nul
|
|
51
|
+
if %errorlevel% equ 0 (
|
|
52
|
+
echo [OK] Already in PATH
|
|
53
|
+
) else (
|
|
54
|
+
REM Use PowerShell to update PATH permanently
|
|
55
|
+
powershell -Command "& {$path = [Environment]::GetEnvironmentVariable('Path', 'User'); if ($path -notlike '*%INSTALL_DIR%*') { [Environment]::SetEnvironmentVariable('Path', $path + ';%INSTALL_DIR%', 'User') }}"
|
|
56
|
+
|
|
57
|
+
if !errorlevel! equ 0 (
|
|
58
|
+
echo [OK] Added to PATH
|
|
59
|
+
REM Update current session PATH
|
|
60
|
+
set "PATH=%PATH%;%INSTALL_DIR%"
|
|
61
|
+
) else (
|
|
62
|
+
echo [WARNING] Could not add to PATH automatically
|
|
63
|
+
echo Please add the following to your PATH manually:
|
|
64
|
+
echo %INSTALL_DIR%
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
echo.
|
|
69
|
+
echo Verifying installation...
|
|
70
|
+
|
|
71
|
+
REM Test the executable
|
|
72
|
+
"%EXE_PATH%" --version >nul 2>&1
|
|
73
|
+
if %errorlevel% equ 0 (
|
|
74
|
+
echo [OK] Installation successful!
|
|
75
|
+
echo.
|
|
76
|
+
echo ==========================================
|
|
77
|
+
echo Installation Complete!
|
|
78
|
+
echo ==========================================
|
|
79
|
+
echo.
|
|
80
|
+
|
|
81
|
+
REM Display version
|
|
82
|
+
"%EXE_PATH%" --version
|
|
83
|
+
|
|
84
|
+
echo.
|
|
85
|
+
echo Installed to: %EXE_PATH%
|
|
86
|
+
echo.
|
|
87
|
+
echo You can now use 'ais' command in a new terminal window.
|
|
88
|
+
echo.
|
|
89
|
+
echo Quick start:
|
|
90
|
+
echo ais add - Add a new account
|
|
91
|
+
echo ais list - List all accounts
|
|
92
|
+
echo ais use - Set account for current project
|
|
93
|
+
echo ais help - Show all commands
|
|
94
|
+
echo.
|
|
95
|
+
echo [NOTE] Please restart your terminal or open a new one for PATH changes to take effect.
|
|
96
|
+
) else (
|
|
97
|
+
echo [WARNING] Installation may have issues
|
|
98
|
+
echo Installed to: %EXE_PATH%
|
|
99
|
+
echo Please verify manually by running: "%EXE_PATH%" --version
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
echo.
|
|
103
|
+
pause
|
package/install.ps1
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# AI Account Switch (ais) - Windows Installer
|
|
2
|
+
# This script downloads and installs ais, automatically adding it to PATH
|
|
3
|
+
|
|
4
|
+
param(
|
|
5
|
+
[string]$InstallDir = "$env:LOCALAPPDATA\ais",
|
|
6
|
+
[switch]$SystemWide = $false
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
$ErrorActionPreference = "Stop"
|
|
10
|
+
|
|
11
|
+
# Colors
|
|
12
|
+
function Write-ColorOutput($ForegroundColor) {
|
|
13
|
+
$fc = $host.UI.RawUI.ForegroundColor
|
|
14
|
+
$host.UI.RawUI.ForegroundColor = $ForegroundColor
|
|
15
|
+
if ($args) {
|
|
16
|
+
Write-Output $args
|
|
17
|
+
}
|
|
18
|
+
$host.UI.RawUI.ForegroundColor = $fc
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Write-ColorOutput Green "=========================================="
|
|
22
|
+
Write-ColorOutput Green " AI Account Switch (ais) Installer"
|
|
23
|
+
Write-ColorOutput Green "=========================================="
|
|
24
|
+
Write-Output ""
|
|
25
|
+
|
|
26
|
+
# Determine installation directory
|
|
27
|
+
if ($SystemWide) {
|
|
28
|
+
$InstallDir = "$env:ProgramFiles\ais"
|
|
29
|
+
$PathScope = "Machine"
|
|
30
|
+
Write-Output "Installing system-wide (requires administrator privileges)"
|
|
31
|
+
} else {
|
|
32
|
+
$InstallDir = "$env:LOCALAPPDATA\ais"
|
|
33
|
+
$PathScope = "User"
|
|
34
|
+
Write-Output "Installing for current user"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Write-Output "Installation directory: $InstallDir"
|
|
38
|
+
Write-Output ""
|
|
39
|
+
|
|
40
|
+
# Create installation directory
|
|
41
|
+
if (!(Test-Path $InstallDir)) {
|
|
42
|
+
Write-Output "Creating installation directory..."
|
|
43
|
+
New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# Download the latest release
|
|
47
|
+
$LatestReleaseUrl = "https://api.github.com/repos/yourusername/ai-agent-user-swith/releases/latest"
|
|
48
|
+
$ExePath = Join-Path $InstallDir "ais.exe"
|
|
49
|
+
|
|
50
|
+
Write-Output "Downloading latest release..."
|
|
51
|
+
try {
|
|
52
|
+
$release = Invoke-RestMethod -Uri $LatestReleaseUrl
|
|
53
|
+
$asset = $release.assets | Where-Object { $_.name -eq "ais-win.exe" }
|
|
54
|
+
|
|
55
|
+
if (!$asset) {
|
|
56
|
+
throw "Could not find ais-win.exe in the latest release"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
$downloadUrl = $asset.browser_download_url
|
|
60
|
+
Write-Output "Downloading from: $downloadUrl"
|
|
61
|
+
|
|
62
|
+
# Download with progress
|
|
63
|
+
$ProgressPreference = 'SilentlyContinue'
|
|
64
|
+
Invoke-WebRequest -Uri $downloadUrl -OutFile $ExePath
|
|
65
|
+
$ProgressPreference = 'Continue'
|
|
66
|
+
|
|
67
|
+
Write-ColorOutput Green "✓ Downloaded successfully"
|
|
68
|
+
} catch {
|
|
69
|
+
Write-ColorOutput Red "Failed to download: $_"
|
|
70
|
+
exit 1
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# Add to PATH if not already there
|
|
74
|
+
Write-Output ""
|
|
75
|
+
Write-Output "Adding to PATH..."
|
|
76
|
+
|
|
77
|
+
$currentPath = [Environment]::GetEnvironmentVariable("Path", $PathScope)
|
|
78
|
+
|
|
79
|
+
if ($currentPath -notlike "*$InstallDir*") {
|
|
80
|
+
try {
|
|
81
|
+
$newPath = $currentPath + ";$InstallDir"
|
|
82
|
+
[Environment]::SetEnvironmentVariable("Path", $newPath, $PathScope)
|
|
83
|
+
Write-ColorOutput Green "✓ Added to PATH"
|
|
84
|
+
|
|
85
|
+
# Update current session PATH
|
|
86
|
+
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
|
87
|
+
|
|
88
|
+
} catch {
|
|
89
|
+
Write-ColorOutput Yellow "! Could not add to PATH automatically"
|
|
90
|
+
Write-Output "Please add the following to your PATH manually:"
|
|
91
|
+
Write-Output " $InstallDir"
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
Write-ColorOutput Green "✓ Already in PATH"
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
# Verify installation
|
|
98
|
+
Write-Output ""
|
|
99
|
+
Write-Output "Verifying installation..."
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
$version = & $ExePath --version 2>&1
|
|
103
|
+
Write-ColorOutput Green "✓ Installation successful!"
|
|
104
|
+
Write-Output ""
|
|
105
|
+
Write-ColorOutput Green "=========================================="
|
|
106
|
+
Write-ColorOutput Green " Installation Complete!"
|
|
107
|
+
Write-ColorOutput Green "=========================================="
|
|
108
|
+
Write-Output ""
|
|
109
|
+
Write-Output "Version: $version"
|
|
110
|
+
Write-Output "Installed to: $ExePath"
|
|
111
|
+
Write-Output ""
|
|
112
|
+
Write-Output "You can now use 'ais' command in a new terminal window."
|
|
113
|
+
Write-Output ""
|
|
114
|
+
Write-Output "Quick start:"
|
|
115
|
+
Write-Output " ais add - Add a new account"
|
|
116
|
+
Write-Output " ais list - List all accounts"
|
|
117
|
+
Write-Output " ais use - Set account for current project"
|
|
118
|
+
Write-Output " ais help - Show all commands"
|
|
119
|
+
Write-Output ""
|
|
120
|
+
Write-ColorOutput Yellow "Note: Please restart your terminal or open a new one for PATH changes to take effect."
|
|
121
|
+
|
|
122
|
+
} catch {
|
|
123
|
+
Write-ColorOutput Red "Installation may have issues. Error: $_"
|
|
124
|
+
Write-Output ""
|
|
125
|
+
Write-Output "Installed to: $ExePath"
|
|
126
|
+
Write-Output "Please verify manually by running: $ExePath --version"
|
|
127
|
+
exit 1
|
|
128
|
+
}
|
package/package.json
CHANGED
package/src/commands.js
CHANGED
|
@@ -90,31 +90,65 @@ async function addAccount(name, options) {
|
|
|
90
90
|
accountData.customEnv = {};
|
|
91
91
|
let addMore = true;
|
|
92
92
|
|
|
93
|
-
console.log(chalk.cyan('\n💡
|
|
93
|
+
console.log(chalk.cyan('\n💡 Tip: Enter in format KEY=VALUE (e.g., CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1)'));
|
|
94
|
+
console.log(chalk.gray(' Or leave empty to finish\n'));
|
|
94
95
|
|
|
95
96
|
while (addMore) {
|
|
96
97
|
const envInput = await inquirer.prompt([
|
|
97
98
|
{
|
|
98
99
|
type: 'input',
|
|
99
|
-
name: '
|
|
100
|
-
message: 'Environment variable
|
|
100
|
+
name: 'envVar',
|
|
101
|
+
message: 'Environment variable (KEY=VALUE format):',
|
|
101
102
|
validate: (input) => {
|
|
102
|
-
|
|
103
|
-
if (
|
|
104
|
-
|
|
103
|
+
// Allow empty input to skip
|
|
104
|
+
if (!input.trim()) return true;
|
|
105
|
+
|
|
106
|
+
// Check if input contains '='
|
|
107
|
+
if (!input.includes('=')) {
|
|
108
|
+
return 'Invalid format. Use KEY=VALUE format (e.g., MY_VAR=value)';
|
|
105
109
|
}
|
|
110
|
+
|
|
111
|
+
const [key, ...valueParts] = input.split('=');
|
|
112
|
+
const value = valueParts.join('='); // In case value contains '='
|
|
113
|
+
|
|
114
|
+
if (!key.trim()) {
|
|
115
|
+
return 'Variable name cannot be empty';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!/^[A-Z_][A-Z0-9_]*$/.test(key.trim())) {
|
|
119
|
+
return 'Invalid variable name. Use uppercase letters, numbers, and underscores (e.g., MY_VAR)';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!value.trim()) {
|
|
123
|
+
return 'Variable value cannot be empty';
|
|
124
|
+
}
|
|
125
|
+
|
|
106
126
|
return true;
|
|
107
127
|
}
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
type: 'input',
|
|
111
|
-
name: 'value',
|
|
112
|
-
message: 'Environment variable value:',
|
|
113
|
-
validate: (input) => input.trim() !== '' || 'Value is required'
|
|
114
128
|
}
|
|
115
129
|
]);
|
|
116
130
|
|
|
117
|
-
|
|
131
|
+
// If user left input empty, skip adding more
|
|
132
|
+
if (!envInput.envVar.trim()) {
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Parse KEY=VALUE
|
|
137
|
+
const [key, ...valueParts] = envInput.envVar.split('=');
|
|
138
|
+
const value = valueParts.join('='); // In case value contains '='
|
|
139
|
+
|
|
140
|
+
accountData.customEnv[key.trim()] = value.trim();
|
|
141
|
+
|
|
142
|
+
// Display currently added variables
|
|
143
|
+
console.log(chalk.green('\n✓ Added:'), chalk.cyan(`${key.trim()}=${value.trim()}`));
|
|
144
|
+
|
|
145
|
+
if (Object.keys(accountData.customEnv).length > 0) {
|
|
146
|
+
console.log(chalk.bold('\n📋 Current environment variables:'));
|
|
147
|
+
Object.entries(accountData.customEnv).forEach(([k, v]) => {
|
|
148
|
+
console.log(chalk.gray(' •'), chalk.cyan(`${k}=${v}`));
|
|
149
|
+
});
|
|
150
|
+
console.log('');
|
|
151
|
+
}
|
|
118
152
|
|
|
119
153
|
const { continueAdding } = await inquirer.prompt([
|
|
120
154
|
{
|
|
@@ -128,7 +162,11 @@ async function addAccount(name, options) {
|
|
|
128
162
|
addMore = continueAdding;
|
|
129
163
|
}
|
|
130
164
|
|
|
131
|
-
|
|
165
|
+
if (Object.keys(accountData.customEnv).length > 0) {
|
|
166
|
+
console.log(chalk.green(`\n✓ Total: ${Object.keys(accountData.customEnv).length} custom environment variable(s) added\n`));
|
|
167
|
+
} else {
|
|
168
|
+
console.log(chalk.yellow('\n⚠ No custom environment variables added\n'));
|
|
169
|
+
}
|
|
132
170
|
}
|
|
133
171
|
|
|
134
172
|
// Remove the addCustomEnv flag before saving
|