ai-account-switch 1.1.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/.claude/settings.local.json +19 -0
- package/NPM_PUBLISH.md +334 -0
- package/README.md +378 -0
- package/bin/ais.js +3 -0
- package/package.json +60 -0
- package/src/commands.js +309 -0
- package/src/config.js +258 -0
- package/src/index.js +124 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(node:*)",
|
|
5
|
+
"Bash(npm --version)",
|
|
6
|
+
"Bash(chmod:*)",
|
|
7
|
+
"Bash(npm install)",
|
|
8
|
+
"Bash(npm link)",
|
|
9
|
+
"Bash(ais:*)",
|
|
10
|
+
"WebSearch",
|
|
11
|
+
"WebFetch(domain:www.vibesparking.com)",
|
|
12
|
+
"Read(//Users/deanwang/.claude/**)",
|
|
13
|
+
"Read(//Users/deanwang/IdeaProjects/githubProject/team-nav/**)",
|
|
14
|
+
"Bash(cat:*)"
|
|
15
|
+
],
|
|
16
|
+
"deny": [],
|
|
17
|
+
"ask": []
|
|
18
|
+
}
|
|
19
|
+
}
|
package/NPM_PUBLISH.md
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
# NPM Publishing Guide
|
|
2
|
+
|
|
3
|
+
This guide explains how to publish `ai-account-switch` to npm registry.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
### 1. Create npm Account
|
|
8
|
+
|
|
9
|
+
If you don't have an npm account:
|
|
10
|
+
|
|
11
|
+
1. Go to https://www.npmjs.com/signup
|
|
12
|
+
2. Create your account
|
|
13
|
+
3. Verify your email
|
|
14
|
+
|
|
15
|
+
### 2. Login to npm
|
|
16
|
+
|
|
17
|
+
Login via command line:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm login
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Enter your:
|
|
24
|
+
- Username
|
|
25
|
+
- Password
|
|
26
|
+
- Email
|
|
27
|
+
- One-time password (if 2FA is enabled)
|
|
28
|
+
|
|
29
|
+
Verify you're logged in:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm whoami
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Before Publishing
|
|
36
|
+
|
|
37
|
+
### 1. Update Package Information
|
|
38
|
+
|
|
39
|
+
Edit `package.json`:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"name": "ai-account-switch",
|
|
44
|
+
"version": "1.1.0",
|
|
45
|
+
"author": "Your Name <your.email@example.com>",
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/yourusername/ai-agent-user-swith.git"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. Check Package Name Availability
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm view ai-account-switch
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If it returns an error, the name is available. If not, choose a different name like:
|
|
60
|
+
- `@yourusername/ai-account-switch` (scoped package)
|
|
61
|
+
- `ais-cli`
|
|
62
|
+
- `claude-account-switch`
|
|
63
|
+
|
|
64
|
+
### 3. Test Package Locally
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Install dependencies
|
|
68
|
+
npm install
|
|
69
|
+
|
|
70
|
+
# Test the CLI works
|
|
71
|
+
npm link
|
|
72
|
+
ais --version
|
|
73
|
+
ais --help
|
|
74
|
+
|
|
75
|
+
# Clean up
|
|
76
|
+
npm unlink
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 4. Dry Run
|
|
80
|
+
|
|
81
|
+
Test what will be published:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm pack --dry-run
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Or create a tarball to inspect:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm pack
|
|
91
|
+
tar -xzf ai-account-switch-1.1.0.tgz
|
|
92
|
+
ls package/
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Publishing
|
|
96
|
+
|
|
97
|
+
### First Time Publication
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Make sure you're on the main branch
|
|
101
|
+
git checkout main
|
|
102
|
+
|
|
103
|
+
# Make sure everything is committed
|
|
104
|
+
git status
|
|
105
|
+
|
|
106
|
+
# Publish to npm
|
|
107
|
+
npm publish
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
For scoped packages:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm publish --access public
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Updating a Published Package
|
|
117
|
+
|
|
118
|
+
1. **Update version number** in `package.json`:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Patch version (1.1.0 -> 1.1.1)
|
|
122
|
+
npm version patch
|
|
123
|
+
|
|
124
|
+
# Minor version (1.1.0 -> 1.2.0)
|
|
125
|
+
npm version minor
|
|
126
|
+
|
|
127
|
+
# Major version (1.1.0 -> 2.0.0)
|
|
128
|
+
npm version major
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
This command will:
|
|
132
|
+
- Update `package.json`
|
|
133
|
+
- Create a git commit
|
|
134
|
+
- Create a git tag
|
|
135
|
+
|
|
136
|
+
2. **Push changes and tags**:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
git push
|
|
140
|
+
git push --tags
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
3. **Publish to npm**:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npm publish
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## After Publishing
|
|
150
|
+
|
|
151
|
+
### 1. Verify Publication
|
|
152
|
+
|
|
153
|
+
Check on npm website:
|
|
154
|
+
```
|
|
155
|
+
https://www.npmjs.com/package/ai-account-switch
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Or via CLI:
|
|
159
|
+
```bash
|
|
160
|
+
npm view ai-account-switch
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 2. Test Installation
|
|
164
|
+
|
|
165
|
+
Test in a clean environment:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
# Install globally
|
|
169
|
+
npm install -g ai-account-switch
|
|
170
|
+
|
|
171
|
+
# Test it works
|
|
172
|
+
ais --version
|
|
173
|
+
ais --help
|
|
174
|
+
|
|
175
|
+
# Uninstall
|
|
176
|
+
npm uninstall -g ai-account-switch
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### 3. Update README
|
|
180
|
+
|
|
181
|
+
Update installation instructions to reflect the published package:
|
|
182
|
+
|
|
183
|
+
```markdown
|
|
184
|
+
### Option 3: Global npm Installation
|
|
185
|
+
|
|
186
|
+
\`\`\`bash
|
|
187
|
+
npm install -g ai-account-switch
|
|
188
|
+
\`\`\`
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Automation with GitHub Actions
|
|
192
|
+
|
|
193
|
+
### Option 1: Automatic NPM Publish on Release
|
|
194
|
+
|
|
195
|
+
Create `.github/workflows/npm-publish.yml`:
|
|
196
|
+
|
|
197
|
+
```yaml
|
|
198
|
+
name: Publish to NPM
|
|
199
|
+
|
|
200
|
+
on:
|
|
201
|
+
release:
|
|
202
|
+
types: [published]
|
|
203
|
+
|
|
204
|
+
jobs:
|
|
205
|
+
publish:
|
|
206
|
+
runs-on: ubuntu-latest
|
|
207
|
+
steps:
|
|
208
|
+
- uses: actions/checkout@v4
|
|
209
|
+
|
|
210
|
+
- uses: actions/setup-node@v4
|
|
211
|
+
with:
|
|
212
|
+
node-version: '18'
|
|
213
|
+
registry-url: 'https://registry.npmjs.org'
|
|
214
|
+
|
|
215
|
+
- run: npm ci
|
|
216
|
+
|
|
217
|
+
- run: npm publish
|
|
218
|
+
env:
|
|
219
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Setup NPM Token in GitHub:
|
|
223
|
+
|
|
224
|
+
1. Generate NPM token:
|
|
225
|
+
```bash
|
|
226
|
+
npm token create
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
2. Add to GitHub:
|
|
230
|
+
- Go to your repository on GitHub
|
|
231
|
+
- Settings → Secrets and variables → Actions
|
|
232
|
+
- New repository secret
|
|
233
|
+
- Name: `NPM_TOKEN`
|
|
234
|
+
- Value: (paste your npm token)
|
|
235
|
+
|
|
236
|
+
## Troubleshooting
|
|
237
|
+
|
|
238
|
+
### Package Name Already Taken
|
|
239
|
+
|
|
240
|
+
Use a scoped package:
|
|
241
|
+
|
|
242
|
+
```json
|
|
243
|
+
{
|
|
244
|
+
"name": "@yourusername/ai-account-switch"
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Permission Denied
|
|
249
|
+
|
|
250
|
+
Make sure you're logged in:
|
|
251
|
+
```bash
|
|
252
|
+
npm whoami
|
|
253
|
+
npm login
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### 2FA Required
|
|
257
|
+
|
|
258
|
+
If you have 2FA enabled, you need to:
|
|
259
|
+
|
|
260
|
+
1. Generate an automation token on npmjs.com
|
|
261
|
+
2. Use it for CI/CD publishing
|
|
262
|
+
|
|
263
|
+
### Version Already Published
|
|
264
|
+
|
|
265
|
+
You cannot republish the same version. Update version:
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
npm version patch
|
|
269
|
+
npm publish
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Best Practices
|
|
273
|
+
|
|
274
|
+
1. **Semantic Versioning**: Follow semver (MAJOR.MINOR.PATCH)
|
|
275
|
+
2. **Test Before Publishing**: Always test locally first
|
|
276
|
+
3. **Keep README Updated**: Ensure documentation is current
|
|
277
|
+
4. **Changelog**: Maintain a changelog in README.md
|
|
278
|
+
5. **Clean Package**: Use `.npmignore` to exclude unnecessary files
|
|
279
|
+
6. **License**: Include appropriate license (MIT)
|
|
280
|
+
|
|
281
|
+
## Unpublishing (Emergency Only)
|
|
282
|
+
|
|
283
|
+
**Warning**: Only unpublish in emergency situations (security issues, etc.)
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
# Unpublish specific version
|
|
287
|
+
npm unpublish ai-account-switch@1.1.0
|
|
288
|
+
|
|
289
|
+
# Unpublish all versions (within 72 hours of publish)
|
|
290
|
+
npm unpublish ai-account-switch --force
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
After 72 hours, you cannot unpublish. Instead, publish a new version.
|
|
294
|
+
|
|
295
|
+
## Package Maintenance
|
|
296
|
+
|
|
297
|
+
### Deprecate a Version
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
npm deprecate ai-account-switch@1.0.0 "Please upgrade to 1.1.0"
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Add Collaborators
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
npm owner add username ai-account-switch
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### View Package Stats
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
npm view ai-account-switch
|
|
313
|
+
|
|
314
|
+
# Download stats
|
|
315
|
+
npm view ai-account-switch time
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Checklist Before Publishing
|
|
319
|
+
|
|
320
|
+
- [ ] All tests pass
|
|
321
|
+
- [ ] Version number updated
|
|
322
|
+
- [ ] README.md is current
|
|
323
|
+
- [ ] CHANGELOG updated
|
|
324
|
+
- [ ] `.npmignore` configured
|
|
325
|
+
- [ ] `package.json` has correct info
|
|
326
|
+
- [ ] Tested with `npm pack`
|
|
327
|
+
- [ ] Logged into npm
|
|
328
|
+
- [ ] Git committed and pushed
|
|
329
|
+
|
|
330
|
+
## Resources
|
|
331
|
+
|
|
332
|
+
- [npm Documentation](https://docs.npmjs.com/)
|
|
333
|
+
- [Semantic Versioning](https://semver.org/)
|
|
334
|
+
- [npm Publishing Guide](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry)
|
package/README.md
ADDED
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
# AI Account Switch (ais)
|
|
2
|
+
|
|
3
|
+
A cross-platform CLI tool to manage and switch between Claude/Codex account configurations for different projects.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Cross-Platform**: Works seamlessly on macOS, Linux, and Windows
|
|
8
|
+
- **Multiple Accounts**: Store and manage multiple AI service accounts
|
|
9
|
+
- **Project-Specific**: Each project can use a different account
|
|
10
|
+
- **Smart Directory Detection**: Works in any subdirectory of your project (like git)
|
|
11
|
+
- **Claude Code Integration**: Automatically generates `.claude/settings.local.json` for Claude Code CLI
|
|
12
|
+
- **Secure Storage**: Account credentials stored locally in your home directory
|
|
13
|
+
- **Interactive CLI**: Easy-to-use interactive prompts for all operations
|
|
14
|
+
- **Account Types**: Support for Claude, Codex, and other AI services
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
### Option 1: Download Pre-built Binary (Recommended)
|
|
19
|
+
|
|
20
|
+
Download the latest release for your platform from the [Releases page](https://github.com/yourusername/ai-agent-user-swith/releases):
|
|
21
|
+
|
|
22
|
+
**macOS:**
|
|
23
|
+
```bash
|
|
24
|
+
# Download and install
|
|
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
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Linux:**
|
|
30
|
+
```bash
|
|
31
|
+
# Download and install
|
|
32
|
+
curl -L https://github.com/yourusername/ai-agent-user-swith/releases/latest/download/ais-linux -o /usr/local/bin/ais
|
|
33
|
+
chmod +x /usr/local/bin/ais
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Windows:**
|
|
37
|
+
Download `ais-win.exe` from the releases page and add it to your PATH.
|
|
38
|
+
|
|
39
|
+
### Option 2: Install from Source
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Clone the repository
|
|
43
|
+
git clone https://github.com/yourusername/ai-agent-user-swith.git
|
|
44
|
+
cd ai-agent-user-swith
|
|
45
|
+
|
|
46
|
+
# Install dependencies
|
|
47
|
+
npm install
|
|
48
|
+
|
|
49
|
+
# Link the CLI tool globally
|
|
50
|
+
npm link
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Option 3: Global npm Installation
|
|
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.
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
### Commands Overview
|
|
66
|
+
|
|
67
|
+
| Command | Alias | Description |
|
|
68
|
+
|---------|-------|-------------|
|
|
69
|
+
| `ais add [name]` | - | Add a new account configuration |
|
|
70
|
+
| `ais list` | `ls` | List all available accounts |
|
|
71
|
+
| `ais use [name]` | - | Set account for current project |
|
|
72
|
+
| `ais info` | - | Show current project's account info |
|
|
73
|
+
| `ais current` | - | Show current account name |
|
|
74
|
+
| `ais remove [name]` | `rm` | Remove an account |
|
|
75
|
+
| `ais paths` | - | Show configuration file paths |
|
|
76
|
+
| `ais export <name>` | - | Export account as JSON |
|
|
77
|
+
| `ais help` | - | Display help information |
|
|
78
|
+
| `ais --version` | - | Show version number |
|
|
79
|
+
|
|
80
|
+
### Quick Start
|
|
81
|
+
|
|
82
|
+
#### 1. Add an Account
|
|
83
|
+
|
|
84
|
+
Add your first account interactively:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
ais add
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Or specify a name directly:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
ais add my-claude-account
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
You'll be prompted to enter:
|
|
97
|
+
- Account type (Claude, Codex, Other)
|
|
98
|
+
- API Key
|
|
99
|
+
- API URL (optional)
|
|
100
|
+
- Organization ID (optional)
|
|
101
|
+
- Email (optional)
|
|
102
|
+
- Description (optional)
|
|
103
|
+
|
|
104
|
+
#### 2. List All Accounts
|
|
105
|
+
|
|
106
|
+
View all your configured accounts:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
ais list
|
|
110
|
+
# or
|
|
111
|
+
ais ls
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The active account for the current project will be marked with a green dot.
|
|
115
|
+
|
|
116
|
+
#### 3. Switch Account for Current Project
|
|
117
|
+
|
|
118
|
+
Set which account to use in your current project:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
ais use my-claude-account
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Or select interactively:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
ais use
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Note:** This command automatically generates `.claude/settings.local.json` for Claude Code CLI integration.
|
|
131
|
+
You can run this command from any subdirectory within your project - it will automatically find the project root.
|
|
132
|
+
|
|
133
|
+
#### 4. Check Current Project Info
|
|
134
|
+
|
|
135
|
+
See which account is active for your current project:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
ais info
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Or just show the account name:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
ais current
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Note:** These commands work from any subdirectory within your project, similar to how git commands work.
|
|
148
|
+
|
|
149
|
+
#### 5. Remove an Account
|
|
150
|
+
|
|
151
|
+
Remove an account you no longer need:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
ais remove old-account
|
|
155
|
+
# or
|
|
156
|
+
ais rm
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Advanced Usage
|
|
160
|
+
|
|
161
|
+
#### Show Configuration Paths
|
|
162
|
+
|
|
163
|
+
See where your configurations are stored:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
ais paths
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### Export Account Configuration
|
|
170
|
+
|
|
171
|
+
Export an account's configuration as JSON:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
ais export my-claude-account
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Configuration
|
|
178
|
+
|
|
179
|
+
### Global Configuration
|
|
180
|
+
|
|
181
|
+
All accounts are stored globally in your home directory:
|
|
182
|
+
|
|
183
|
+
- **macOS/Linux**: `~/.ai-account-switch/config.json`
|
|
184
|
+
- **Windows**: `%USERPROFILE%\.ai-account-switch\config.json`
|
|
185
|
+
|
|
186
|
+
### Project Configuration
|
|
187
|
+
|
|
188
|
+
Each project stores its active account reference in:
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
./.ais-project-config
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
This file is created automatically when you run `ais use` and should be added to `.gitignore`.
|
|
195
|
+
|
|
196
|
+
### Claude Code Integration
|
|
197
|
+
|
|
198
|
+
When you run `ais use`, the tool automatically creates `.claude/settings.local.json` with the following structure:
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
{
|
|
202
|
+
"env": {
|
|
203
|
+
"ANTHROPIC_AUTH_TOKEN": "your-api-key",
|
|
204
|
+
"ANTHROPIC_BASE_URL": "your-api-url",
|
|
205
|
+
"ANTHROPIC_ORGANIZATION_ID": "your-org-id"
|
|
206
|
+
},
|
|
207
|
+
"permissions": {
|
|
208
|
+
"allow": [],
|
|
209
|
+
"deny": [],
|
|
210
|
+
"ask": []
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
This ensures Claude Code CLI automatically uses the correct account for your project.
|
|
216
|
+
|
|
217
|
+
## Examples
|
|
218
|
+
|
|
219
|
+
### Example 1: Setting Up Multiple Accounts
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Add your personal Claude account
|
|
223
|
+
ais add personal-claude
|
|
224
|
+
|
|
225
|
+
# Add your work Claude account
|
|
226
|
+
ais add work-claude
|
|
227
|
+
|
|
228
|
+
# Add a Codex account
|
|
229
|
+
ais add codex-dev
|
|
230
|
+
|
|
231
|
+
# List all accounts
|
|
232
|
+
ais list
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Example 2: Using Different Accounts for Different Projects
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# In your personal project
|
|
239
|
+
cd ~/my-personal-project
|
|
240
|
+
ais use personal-claude
|
|
241
|
+
|
|
242
|
+
# In your work project
|
|
243
|
+
cd ~/work/company-project
|
|
244
|
+
ais use work-claude
|
|
245
|
+
|
|
246
|
+
# Check what's active
|
|
247
|
+
ais info
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Example 3: Managing Accounts
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# View all accounts
|
|
254
|
+
ais list
|
|
255
|
+
|
|
256
|
+
# Check current account
|
|
257
|
+
ais current
|
|
258
|
+
|
|
259
|
+
# Export an account config
|
|
260
|
+
ais export personal-claude
|
|
261
|
+
|
|
262
|
+
# Remove old accounts
|
|
263
|
+
ais remove old-account
|
|
264
|
+
|
|
265
|
+
# View config locations
|
|
266
|
+
ais paths
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Security Notes
|
|
270
|
+
|
|
271
|
+
- API keys are stored locally on your machine only
|
|
272
|
+
- The global configuration file contains sensitive credentials
|
|
273
|
+
- Always add `.ais-project-config` to your `.gitignore`
|
|
274
|
+
- Never commit account credentials to version control
|
|
275
|
+
- API keys are masked when displayed (shows first and last 4 characters only)
|
|
276
|
+
|
|
277
|
+
## Platform Compatibility
|
|
278
|
+
|
|
279
|
+
| Platform | Status | Notes |
|
|
280
|
+
|----------|--------|-------|
|
|
281
|
+
| macOS | ✅ Fully Supported | Tested on macOS 10.15+ |
|
|
282
|
+
| Linux | ✅ Fully Supported | Tested on Ubuntu 20.04+ |
|
|
283
|
+
| Windows | ✅ Fully Supported | Tested on Windows 10+ |
|
|
284
|
+
|
|
285
|
+
## Requirements
|
|
286
|
+
|
|
287
|
+
- Node.js >= 14.0.0
|
|
288
|
+
- npm >= 6.0.0
|
|
289
|
+
|
|
290
|
+
## Project Structure
|
|
291
|
+
|
|
292
|
+
```
|
|
293
|
+
ai-agent-user-swith/
|
|
294
|
+
├── bin/
|
|
295
|
+
│ └── ais.js # Executable entry point
|
|
296
|
+
├── src/
|
|
297
|
+
│ ├── index.js # Main CLI program
|
|
298
|
+
│ ├── commands.js # Command implementations
|
|
299
|
+
│ └── config.js # Configuration manager
|
|
300
|
+
├── package.json
|
|
301
|
+
├── .gitignore
|
|
302
|
+
└── README.md
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Troubleshooting
|
|
306
|
+
|
|
307
|
+
### Command not found: ais
|
|
308
|
+
|
|
309
|
+
If you get this error after installation, make sure you've linked the package:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
npm link
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Permission denied
|
|
316
|
+
|
|
317
|
+
On Unix systems, ensure the bin file is executable:
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
chmod +x bin/ais.js
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### No accounts found
|
|
324
|
+
|
|
325
|
+
Make sure you've added at least one account:
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
ais add
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Contributing
|
|
332
|
+
|
|
333
|
+
Contributions are welcome! Feel free to:
|
|
334
|
+
- Report bugs
|
|
335
|
+
- Suggest new features
|
|
336
|
+
- Submit pull requests
|
|
337
|
+
|
|
338
|
+
## License
|
|
339
|
+
|
|
340
|
+
MIT License - feel free to use this tool in your projects!
|
|
341
|
+
|
|
342
|
+
## Changelog
|
|
343
|
+
|
|
344
|
+
### v1.1.0
|
|
345
|
+
- Added smart directory detection (works in any subdirectory)
|
|
346
|
+
- Automatic Claude Code `.claude/settings.local.json` generation
|
|
347
|
+
- Project root display in `ais info` command
|
|
348
|
+
- Improved cross-platform compatibility
|
|
349
|
+
|
|
350
|
+
### v1.0.0
|
|
351
|
+
- Initial release
|
|
352
|
+
- Basic account management (add, list, remove)
|
|
353
|
+
- Project-specific account switching
|
|
354
|
+
- Cross-platform support
|
|
355
|
+
- Interactive CLI prompts
|
|
356
|
+
- Account export functionality
|
|
357
|
+
|
|
358
|
+
## Future Enhancements
|
|
359
|
+
|
|
360
|
+
Potential features for future versions:
|
|
361
|
+
- Account validation
|
|
362
|
+
- Bulk import/export
|
|
363
|
+
- Account templates
|
|
364
|
+
- Environment variable export
|
|
365
|
+
- Account sharing (encrypted)
|
|
366
|
+
- Cloud sync support
|
|
367
|
+
- Account usage statistics
|
|
368
|
+
|
|
369
|
+
## Support
|
|
370
|
+
|
|
371
|
+
If you encounter any issues or have questions:
|
|
372
|
+
1. Check the troubleshooting section
|
|
373
|
+
2. Review existing issues
|
|
374
|
+
3. Create a new issue with detailed information
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
**Happy coding with your AI assistants!** 🤖
|
package/bin/ais.js
ADDED