@supertiny99/cc-switch 1.0.1 → 1.0.3
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.en.md +342 -0
- package/README.md +2 -0
- package/dist/index.js +353 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/config/creator.d.ts +25 -0
- package/dist/lib/config/creator.js +115 -0
- package/dist/lib/config/creator.js.map +1 -0
- package/dist/lib/config/loader.js +7 -1
- package/dist/lib/config/loader.js.map +1 -1
- package/dist/lib/config/writer.d.ts +2 -0
- package/dist/lib/config/writer.js +18 -0
- package/dist/lib/config/writer.js.map +1 -1
- package/package.json +8 -2
package/README.en.md
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# cc-switch
|
|
2
|
+
|
|
3
|
+
[English](README.en.md) | [中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
> A TUI tool for quickly switching Claude Code API providers
|
|
6
|
+
|
|
7
|
+
When your token quota is exhausted, you can quickly switch to another provider/token.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- 🔄 **Quick Switch** - Complete provider switch in 1-2 seconds
|
|
12
|
+
- 🎨 **Interactive Selection** - Friendly interface with fuzzy search support
|
|
13
|
+
- 🔒 **Auto Backup** - Automatically backs up config before each switch
|
|
14
|
+
- 📦 **Extensible** - Reserved interfaces for MCP, skills, and plugin switching
|
|
15
|
+
- 🌍 **Multi-provider** - Supports any Anthropic API-compatible provider
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
### Global Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g @supertiny99/cc-switch
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Local Development
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone <repo-url>
|
|
29
|
+
cd cc-switch
|
|
30
|
+
npm install
|
|
31
|
+
npm link # Link to local environment
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
### 1. Check Current Configuration
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
cc-switch current
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Output:
|
|
43
|
+
```
|
|
44
|
+
Current Configuration:
|
|
45
|
+
Provider: zhipu
|
|
46
|
+
Base URL: https://open.bigmodel.cn/api/anthropic
|
|
47
|
+
Haiku Model: GLM-4.5-Air
|
|
48
|
+
Sonnet Model: GLM-4.7
|
|
49
|
+
Opus Model: GLM-4.7
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. List All Providers
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
cc-switch list
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 3. Interactive Switch
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
cc-switch
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Type `zh` to quickly locate "Zhipu AI", then press Enter to confirm.
|
|
65
|
+
|
|
66
|
+
### 4. Direct Switch
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cc-switch use anthropic
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Configuration Files
|
|
73
|
+
|
|
74
|
+
Provider profiles are located in `~/.claude/profiles/`:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
~/.claude/
|
|
78
|
+
├── settings.json # Current Claude Code configuration
|
|
79
|
+
├── profiles/ # Provider configuration directory
|
|
80
|
+
│ ├── zhipu.json # Zhipu AI (GLM)
|
|
81
|
+
│ ├── anthropic.json # Anthropic Official
|
|
82
|
+
│ └── custom.json # Custom provider
|
|
83
|
+
└── cc-switch-backups/ # Auto backup directory
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Creating a Custom Provider
|
|
87
|
+
|
|
88
|
+
Create a JSON file in `~/.claude/profiles/`:
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"id": "my-provider",
|
|
93
|
+
"name": "My Provider",
|
|
94
|
+
"description": "Custom API provider",
|
|
95
|
+
"icon": "🚀",
|
|
96
|
+
"config": {
|
|
97
|
+
"env": {
|
|
98
|
+
"ANTHROPIC_AUTH_TOKEN": "your_token_here",
|
|
99
|
+
"ANTHROPIC_BASE_URL": "https://your-api-endpoint.com",
|
|
100
|
+
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "model-name",
|
|
101
|
+
"ANTHROPIC_DEFAULT_OPUS_MODEL": "model-name",
|
|
102
|
+
"ANTHROPIC_DEFAULT_SONNET_MODEL": "model-name"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Command Reference
|
|
109
|
+
|
|
110
|
+
| Command | Description |
|
|
111
|
+
|---------|-------------|
|
|
112
|
+
| `cc-switch` | Interactive provider selection |
|
|
113
|
+
| `cc-switch use <id>` | Switch directly to specified provider |
|
|
114
|
+
| `cc-switch list` | List all available providers |
|
|
115
|
+
| `cc-switch current` | Display current configuration |
|
|
116
|
+
| `cc-switch history` | View backup history |
|
|
117
|
+
| `cc-switch restore <file>` | Restore from backup |
|
|
118
|
+
|
|
119
|
+
## Development
|
|
120
|
+
|
|
121
|
+
### Project Structure
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
cc-switch/
|
|
125
|
+
├── src/
|
|
126
|
+
│ ├── index.ts # CLI entry point
|
|
127
|
+
│ ├── lib/
|
|
128
|
+
│ │ └── config/
|
|
129
|
+
│ │ ├── schema.ts # Type definitions
|
|
130
|
+
│ │ ├── loader.ts # Config reading
|
|
131
|
+
│ │ └── writer.ts # Config writing (with backup)
|
|
132
|
+
│ └── ui/
|
|
133
|
+
│ └── quick-select.ts # Interactive selection
|
|
134
|
+
├── package.json
|
|
135
|
+
├── tsconfig.json
|
|
136
|
+
└── README.md
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Development Commands
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Install dependencies
|
|
143
|
+
npm install
|
|
144
|
+
|
|
145
|
+
# Development mode (hot reload)
|
|
146
|
+
npm run dev list
|
|
147
|
+
|
|
148
|
+
# Build
|
|
149
|
+
npm run build
|
|
150
|
+
|
|
151
|
+
# Local testing
|
|
152
|
+
npm link
|
|
153
|
+
cc-switch list
|
|
154
|
+
|
|
155
|
+
# Run tests
|
|
156
|
+
npm test
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Adding New Features
|
|
160
|
+
|
|
161
|
+
1. **Add CLI Command** - Add in `src/index.ts`:
|
|
162
|
+
```typescript
|
|
163
|
+
program
|
|
164
|
+
.command('my-command')
|
|
165
|
+
.description('My command')
|
|
166
|
+
.action(async () => {
|
|
167
|
+
// Your logic
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
2. **Add Config Items** - Extend types in `src/lib/config/schema.ts`
|
|
172
|
+
|
|
173
|
+
3. **Add UI Components** - Create new files in `src/ui/`
|
|
174
|
+
|
|
175
|
+
## Testing
|
|
176
|
+
|
|
177
|
+
### Manual Testing Checklist
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# 1. Test listing providers
|
|
181
|
+
cc-switch list
|
|
182
|
+
|
|
183
|
+
# 2. Test displaying current config
|
|
184
|
+
cc-switch current
|
|
185
|
+
|
|
186
|
+
# 3. Test switching providers
|
|
187
|
+
cc-switch use anthropic
|
|
188
|
+
cc-switch current # Verify switch
|
|
189
|
+
|
|
190
|
+
# 4. Test backup function
|
|
191
|
+
cc-switch history
|
|
192
|
+
|
|
193
|
+
# 5. Test restoring backup
|
|
194
|
+
cc-switch restore settings-2025-01-29T14-30-22-123Z.json
|
|
195
|
+
|
|
196
|
+
# 6. Test interactive selection
|
|
197
|
+
cc-switch # Press Ctrl+C to cancel
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Unit Tests (To Be Implemented)
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
npm test
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Publishing to npm
|
|
207
|
+
|
|
208
|
+
### 1. Prepare for Release
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
# Ensure build is complete
|
|
212
|
+
npm run build
|
|
213
|
+
|
|
214
|
+
# Check package.json configuration
|
|
215
|
+
cat package.json
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 2. npm Account Setup
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Login to npm (first time only)
|
|
222
|
+
npm login
|
|
223
|
+
|
|
224
|
+
# Or login using token
|
|
225
|
+
npm token create
|
|
226
|
+
npm logout
|
|
227
|
+
npm login --registry=https://registry.npmjs.org --auth-only
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### 3. Check Package Name Availability
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
npm search @supertiny99/cc-switch
|
|
234
|
+
# Or visit https://www.npmjs.com/package/@supertiny99/cc-switch
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### 4. Release Process
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# 1. Update version number
|
|
241
|
+
npm version patch # 1.0.0 -> 1.0.1
|
|
242
|
+
npm version minor # 1.0.0 -> 1.1.0
|
|
243
|
+
npm version major # 1.0.0 -> 2.0.0
|
|
244
|
+
|
|
245
|
+
# 2. Publish to npm
|
|
246
|
+
npm publish
|
|
247
|
+
|
|
248
|
+
# 3. Verify release
|
|
249
|
+
npm view @supertiny99/cc-switch
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### 5. Release Options
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# Public release (default)
|
|
256
|
+
npm publish
|
|
257
|
+
|
|
258
|
+
# Publish as scoped package (@scope/package-name)
|
|
259
|
+
npm publish --access public
|
|
260
|
+
|
|
261
|
+
# Dry run (don't actually publish)
|
|
262
|
+
npm publish --dry-run
|
|
263
|
+
|
|
264
|
+
# Publish with specific tag
|
|
265
|
+
npm publish --tag beta
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### 6. Post-Release Verification
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
# Global installation test
|
|
272
|
+
npm install -g @supertiny99/cc-switch
|
|
273
|
+
|
|
274
|
+
# Or run directly with npx
|
|
275
|
+
npx @supertiny99/cc-switch list
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Release Checklist
|
|
279
|
+
|
|
280
|
+
- [ ] Update package.json version number
|
|
281
|
+
- [ ] Run `npm run build` to ensure successful build
|
|
282
|
+
- [ ] Update README.md documentation
|
|
283
|
+
- [ ] Add LICENSE file
|
|
284
|
+
- [ ] Test all commands work properly
|
|
285
|
+
- [ ] Confirm package name is not taken
|
|
286
|
+
- [ ] Check .npmignore excludes unnecessary files
|
|
287
|
+
|
|
288
|
+
## Troubleshooting
|
|
289
|
+
|
|
290
|
+
### Command Not Found
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
# Re-link
|
|
294
|
+
npm link
|
|
295
|
+
|
|
296
|
+
# Or check global path
|
|
297
|
+
which cc-switch
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Configuration File Error
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
# View backups
|
|
304
|
+
cc-switch history
|
|
305
|
+
|
|
306
|
+
# Restore backup
|
|
307
|
+
cc-switch restore <backup-file>
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Permission Issues
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
# macOS/Linux may need sudo
|
|
314
|
+
sudo npm link
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## Compatibility
|
|
318
|
+
|
|
319
|
+
- Node.js >= 16.0.0
|
|
320
|
+
- macOS, Linux, Windows
|
|
321
|
+
|
|
322
|
+
## License
|
|
323
|
+
|
|
324
|
+
MIT
|
|
325
|
+
|
|
326
|
+
## Contributing
|
|
327
|
+
|
|
328
|
+
Issues and Pull Requests are welcome!
|
|
329
|
+
|
|
330
|
+
## Roadmap
|
|
331
|
+
|
|
332
|
+
- [ ] MCP server switching
|
|
333
|
+
- [ ] Skill enable/disable
|
|
334
|
+
- [ ] Plugin management
|
|
335
|
+
- [ ] Full TUI interface (using Ink)
|
|
336
|
+
- [ ] Configuration validation
|
|
337
|
+
- [ ] Unit tests
|
|
338
|
+
|
|
339
|
+
## Related Links
|
|
340
|
+
|
|
341
|
+
- [Claude Code](https://github.com/anthropics/claude-code)
|
|
342
|
+
- [Anthropic API](https://docs.anthropic.com/)
|
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,7 +8,9 @@ const commander_1 = require("commander");
|
|
|
8
8
|
const quick_select_1 = require("./ui/quick-select");
|
|
9
9
|
const loader_1 = require("./lib/config/loader");
|
|
10
10
|
const writer_1 = require("./lib/config/writer");
|
|
11
|
+
const creator_1 = require("./lib/config/creator");
|
|
11
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
12
14
|
const program = new commander_1.Command();
|
|
13
15
|
program
|
|
14
16
|
.name('cc-switch')
|
|
@@ -19,15 +21,56 @@ program
|
|
|
19
21
|
await (0, quick_select_1.quickSelect)();
|
|
20
22
|
});
|
|
21
23
|
program
|
|
22
|
-
.command('use
|
|
24
|
+
.command('use')
|
|
23
25
|
.description('Switch to a provider profile')
|
|
24
|
-
.action(async (
|
|
26
|
+
.action(async () => {
|
|
25
27
|
try {
|
|
28
|
+
const profiles = await (0, loader_1.listProfiles)();
|
|
29
|
+
if (profiles.length === 0) {
|
|
30
|
+
console.log(chalk_1.default.yellow('No profiles found. Run: cc-switch add'));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const settings = await (0, loader_1.loadSettings)();
|
|
34
|
+
const current = (0, loader_1.getCurrentProvider)(settings);
|
|
35
|
+
const { profileId } = await (0, prompts_1.default)({
|
|
36
|
+
type: 'select',
|
|
37
|
+
name: 'profileId',
|
|
38
|
+
message: 'Select profile:',
|
|
39
|
+
choices: profiles.map(p => ({
|
|
40
|
+
title: `${p.id === current ? '✓ ' : ''}${p.icon} ${p.name}`,
|
|
41
|
+
description: p.description || p.id,
|
|
42
|
+
value: p.id
|
|
43
|
+
}))
|
|
44
|
+
});
|
|
45
|
+
if (!profileId) {
|
|
46
|
+
console.log(chalk_1.default.yellow('Cancelled'));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
26
49
|
const profile = await (0, loader_1.loadProfile)(profileId);
|
|
27
50
|
await (0, writer_1.applyProfile)(profile);
|
|
28
|
-
|
|
51
|
+
// Build detailed output
|
|
52
|
+
const baseUrl = profile.config.env.ANTHROPIC_BASE_URL;
|
|
53
|
+
const haikuModel = profile.config.env.ANTHROPIC_DEFAULT_HAIKU_MODEL;
|
|
54
|
+
const sonnetModel = profile.config.env.ANTHROPIC_DEFAULT_SONNET_MODEL;
|
|
55
|
+
const opusModel = profile.config.env.ANTHROPIC_DEFAULT_OPUS_MODEL;
|
|
56
|
+
console.log('');
|
|
57
|
+
console.log(chalk_1.default.green(` ${profile.icon || '📦'} Switched to ${profile.name}`));
|
|
58
|
+
console.log(chalk_1.default.gray(' ──────────────────────────────────────'));
|
|
59
|
+
if (baseUrl)
|
|
60
|
+
console.log(chalk_1.default.gray(` Base URL: ${baseUrl}`));
|
|
61
|
+
if (haikuModel)
|
|
62
|
+
console.log(chalk_1.default.gray(` Haiku: ${haikuModel}`));
|
|
63
|
+
if (sonnetModel)
|
|
64
|
+
console.log(chalk_1.default.gray(` Sonnet: ${sonnetModel}`));
|
|
65
|
+
if (opusModel)
|
|
66
|
+
console.log(chalk_1.default.gray(` Opus: ${opusModel}`));
|
|
67
|
+
console.log('');
|
|
29
68
|
}
|
|
30
69
|
catch (err) {
|
|
70
|
+
if (err.message === 'User cancelled') {
|
|
71
|
+
console.log(chalk_1.default.yellow('Cancelled'));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
31
74
|
console.error(chalk_1.default.red(`Error: ${err.message}`));
|
|
32
75
|
process.exit(1);
|
|
33
76
|
}
|
|
@@ -70,6 +113,12 @@ program
|
|
|
70
113
|
console.log(` Haiku Model: ${chalk_1.default.gray(settings.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL || 'default')}`);
|
|
71
114
|
console.log(` Sonnet Model: ${chalk_1.default.gray(settings.env?.ANTHROPIC_DEFAULT_SONNET_MODEL || 'default')}`);
|
|
72
115
|
console.log(` Opus Model: ${chalk_1.default.gray(settings.env?.ANTHROPIC_DEFAULT_OPUS_MODEL || 'default')}`);
|
|
116
|
+
// Try to find and display the profile description
|
|
117
|
+
const profiles = await (0, loader_1.listProfiles)();
|
|
118
|
+
const currentProfile = profiles.find(p => p.id === current);
|
|
119
|
+
if (currentProfile?.description) {
|
|
120
|
+
console.log(` Description: ${chalk_1.default.gray(currentProfile.description)}`);
|
|
121
|
+
}
|
|
73
122
|
}
|
|
74
123
|
catch (err) {
|
|
75
124
|
console.error(chalk_1.default.red(`Error: ${err.message}`));
|
|
@@ -107,5 +156,306 @@ program
|
|
|
107
156
|
process.exit(1);
|
|
108
157
|
}
|
|
109
158
|
});
|
|
159
|
+
program
|
|
160
|
+
.command('add')
|
|
161
|
+
.description('Add a new provider profile')
|
|
162
|
+
.action(async () => {
|
|
163
|
+
try {
|
|
164
|
+
console.log(chalk_1.default.bold('\n📝 Add a new provider profile\n'));
|
|
165
|
+
const { preset } = await (0, prompts_1.default)({
|
|
166
|
+
type: 'select',
|
|
167
|
+
name: 'preset',
|
|
168
|
+
message: 'Select provider type:',
|
|
169
|
+
choices: creator_1.PROVIDER_PRESETS.map(p => ({
|
|
170
|
+
title: `${p.icon} ${p.name}`,
|
|
171
|
+
description: p.description,
|
|
172
|
+
value: p.id
|
|
173
|
+
}))
|
|
174
|
+
});
|
|
175
|
+
if (!preset)
|
|
176
|
+
return;
|
|
177
|
+
const selectedPreset = creator_1.PROVIDER_PRESETS.find(p => p.id === preset);
|
|
178
|
+
// Ask for token
|
|
179
|
+
const { token } = await (0, prompts_1.default)({
|
|
180
|
+
type: 'password',
|
|
181
|
+
name: 'token',
|
|
182
|
+
message: 'Enter API token:',
|
|
183
|
+
validate: (val) => val.trim().length > 0 || 'Token is required'
|
|
184
|
+
});
|
|
185
|
+
if (!token)
|
|
186
|
+
return;
|
|
187
|
+
// Custom profile requires base URL
|
|
188
|
+
let customBaseUrl = selectedPreset.baseUrl;
|
|
189
|
+
if (preset === 'custom') {
|
|
190
|
+
const { baseUrl } = await (0, prompts_1.default)({
|
|
191
|
+
type: 'text',
|
|
192
|
+
name: 'baseUrl',
|
|
193
|
+
message: 'Enter base API URL:',
|
|
194
|
+
validate: (val) => val.trim().length > 0 || 'Base URL is required'
|
|
195
|
+
});
|
|
196
|
+
if (!baseUrl)
|
|
197
|
+
return;
|
|
198
|
+
customBaseUrl = baseUrl;
|
|
199
|
+
}
|
|
200
|
+
// Ask for custom name
|
|
201
|
+
const { useCustomName } = await (0, prompts_1.default)({
|
|
202
|
+
type: 'confirm',
|
|
203
|
+
name: 'useCustomName',
|
|
204
|
+
message: 'Use custom profile name?',
|
|
205
|
+
initial: false
|
|
206
|
+
});
|
|
207
|
+
let customName = '';
|
|
208
|
+
if (useCustomName) {
|
|
209
|
+
const { name } = await (0, prompts_1.default)({
|
|
210
|
+
type: 'text',
|
|
211
|
+
name: 'name',
|
|
212
|
+
message: 'Enter profile name:',
|
|
213
|
+
validate: (val) => val.trim().length > 0 || 'Name is required'
|
|
214
|
+
});
|
|
215
|
+
if (!name)
|
|
216
|
+
return;
|
|
217
|
+
customName = name;
|
|
218
|
+
}
|
|
219
|
+
// Check for existing profile
|
|
220
|
+
const profileId = (0, creator_1.sanitizeId)(customName || selectedPreset.id);
|
|
221
|
+
if (await (0, creator_1.profileExists)(profileId)) {
|
|
222
|
+
const { overwrite } = await (0, prompts_1.default)({
|
|
223
|
+
type: 'confirm',
|
|
224
|
+
name: 'overwrite',
|
|
225
|
+
message: `Profile "${profileId}" already exists. Overwrite?`,
|
|
226
|
+
initial: false
|
|
227
|
+
});
|
|
228
|
+
if (!overwrite) {
|
|
229
|
+
console.log(chalk_1.default.yellow('Cancelled'));
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Optional: Custom models
|
|
234
|
+
const { customizeModels } = await (0, prompts_1.default)({
|
|
235
|
+
type: 'confirm',
|
|
236
|
+
name: 'customizeModels',
|
|
237
|
+
message: 'Customize model names?',
|
|
238
|
+
initial: false
|
|
239
|
+
});
|
|
240
|
+
let customHaiku;
|
|
241
|
+
let customSonnet;
|
|
242
|
+
let customOpus;
|
|
243
|
+
if (customizeModels) {
|
|
244
|
+
const models = await (0, prompts_1.default)([
|
|
245
|
+
{
|
|
246
|
+
type: 'text',
|
|
247
|
+
name: 'haiku',
|
|
248
|
+
message: 'Haiku model name:',
|
|
249
|
+
initial: selectedPreset.defaultModels?.haiku
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
type: 'text',
|
|
253
|
+
name: 'sonnet',
|
|
254
|
+
message: 'Sonnet model name:',
|
|
255
|
+
initial: selectedPreset.defaultModels?.sonnet
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
type: 'text',
|
|
259
|
+
name: 'opus',
|
|
260
|
+
message: 'Opus model name:',
|
|
261
|
+
initial: selectedPreset.defaultModels?.opus
|
|
262
|
+
}
|
|
263
|
+
]);
|
|
264
|
+
customHaiku = models.haiku;
|
|
265
|
+
customSonnet = models.sonnet;
|
|
266
|
+
customOpus = models.opus;
|
|
267
|
+
}
|
|
268
|
+
// Create profile
|
|
269
|
+
const profile = (0, creator_1.createProfileFromPreset)(selectedPreset, token, {
|
|
270
|
+
customName: customName || undefined,
|
|
271
|
+
customBaseUrl,
|
|
272
|
+
customHaiku,
|
|
273
|
+
customSonnet,
|
|
274
|
+
customOpus
|
|
275
|
+
});
|
|
276
|
+
// Save profile
|
|
277
|
+
await (0, creator_1.saveProfile)(profile);
|
|
278
|
+
console.log(chalk_1.default.green(`\n✓ Profile "${profile.name}" (${profile.id}) created successfully!`));
|
|
279
|
+
console.log(chalk_1.default.gray(` Run: cc-switch use ${profile.id}`));
|
|
280
|
+
}
|
|
281
|
+
catch (err) {
|
|
282
|
+
if (err.message === 'User cancelled') {
|
|
283
|
+
console.log(chalk_1.default.yellow('\nCancelled'));
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
console.error(chalk_1.default.red(`Error: ${err.message}`));
|
|
287
|
+
process.exit(1);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
program
|
|
291
|
+
.command('delete')
|
|
292
|
+
.alias('rm')
|
|
293
|
+
.description('Delete a provider profile')
|
|
294
|
+
.action(async () => {
|
|
295
|
+
try {
|
|
296
|
+
const profiles = await (0, loader_1.listProfiles)();
|
|
297
|
+
if (profiles.length === 0) {
|
|
298
|
+
console.log(chalk_1.default.yellow('No profiles found.'));
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const { profileId } = await (0, prompts_1.default)({
|
|
302
|
+
type: 'select',
|
|
303
|
+
name: 'profileId',
|
|
304
|
+
message: 'Select profile to delete:',
|
|
305
|
+
choices: profiles.map(p => ({
|
|
306
|
+
title: `${p.icon} ${p.name}`,
|
|
307
|
+
description: `${p.id}${p.description ? ' - ' + p.description : ''}`,
|
|
308
|
+
value: p.id
|
|
309
|
+
}))
|
|
310
|
+
});
|
|
311
|
+
if (!profileId) {
|
|
312
|
+
console.log(chalk_1.default.yellow('Cancelled'));
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const profile = profiles.find(p => p.id === profileId);
|
|
316
|
+
// Confirm deletion
|
|
317
|
+
const { confirm } = await (0, prompts_1.default)({
|
|
318
|
+
type: 'confirm',
|
|
319
|
+
name: 'confirm',
|
|
320
|
+
message: `Delete profile "${profile.icon} ${profile.name}" (${profile.id})?`,
|
|
321
|
+
initial: false
|
|
322
|
+
});
|
|
323
|
+
if (!confirm) {
|
|
324
|
+
console.log(chalk_1.default.yellow('Cancelled'));
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
await (0, writer_1.deleteProfile)(profileId);
|
|
328
|
+
console.log(chalk_1.default.green(`✓ Deleted profile "${profile.name}" (${profileId})`));
|
|
329
|
+
}
|
|
330
|
+
catch (err) {
|
|
331
|
+
if (err.message === 'User cancelled') {
|
|
332
|
+
console.log(chalk_1.default.yellow('Cancelled'));
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
console.error(chalk_1.default.red(`Error: ${err.message}`));
|
|
336
|
+
process.exit(1);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
program
|
|
340
|
+
.command('edit')
|
|
341
|
+
.alias('modify')
|
|
342
|
+
.description('Edit an existing provider profile')
|
|
343
|
+
.action(async () => {
|
|
344
|
+
try {
|
|
345
|
+
const profiles = await (0, loader_1.listProfiles)();
|
|
346
|
+
if (profiles.length === 0) {
|
|
347
|
+
console.log(chalk_1.default.yellow('No profiles found.'));
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
const { profileId } = await (0, prompts_1.default)({
|
|
351
|
+
type: 'select',
|
|
352
|
+
name: 'profileId',
|
|
353
|
+
message: 'Select profile to edit:',
|
|
354
|
+
choices: profiles.map(p => ({
|
|
355
|
+
title: `${p.icon} ${p.name}`,
|
|
356
|
+
description: `${p.id}${p.description ? ' - ' + p.description : ''}`,
|
|
357
|
+
value: p.id
|
|
358
|
+
}))
|
|
359
|
+
});
|
|
360
|
+
if (!profileId) {
|
|
361
|
+
console.log(chalk_1.default.yellow('Cancelled'));
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
const profile = await (0, loader_1.loadProfile)(profileId);
|
|
365
|
+
const currentEnv = profile.config.env;
|
|
366
|
+
console.log(chalk_1.default.bold(`\nEditing: ${profile.icon} ${profile.name} (${profile.id})\n`));
|
|
367
|
+
// Prompt for editable fields with current values as defaults
|
|
368
|
+
const answers = await (0, prompts_1.default)([
|
|
369
|
+
{
|
|
370
|
+
type: 'text',
|
|
371
|
+
name: 'name',
|
|
372
|
+
message: 'Profile name:',
|
|
373
|
+
initial: profile.name
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
type: 'text',
|
|
377
|
+
name: 'description',
|
|
378
|
+
message: 'Description:',
|
|
379
|
+
initial: profile.description || ''
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
type: 'password',
|
|
383
|
+
name: 'token',
|
|
384
|
+
message: 'API token (leave empty to keep current):',
|
|
385
|
+
initial: ''
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
type: 'text',
|
|
389
|
+
name: 'baseUrl',
|
|
390
|
+
message: 'Base URL (leave empty to keep current):',
|
|
391
|
+
initial: currentEnv.ANTHROPIC_BASE_URL || ''
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
type: 'text',
|
|
395
|
+
name: 'haikuModel',
|
|
396
|
+
message: 'Haiku model (leave empty to keep current):',
|
|
397
|
+
initial: currentEnv.ANTHROPIC_DEFAULT_HAIKU_MODEL || ''
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
type: 'text',
|
|
401
|
+
name: 'sonnetModel',
|
|
402
|
+
message: 'Sonnet model (leave empty to keep current):',
|
|
403
|
+
initial: currentEnv.ANTHROPIC_DEFAULT_SONNET_MODEL || ''
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
type: 'text',
|
|
407
|
+
name: 'opusModel',
|
|
408
|
+
message: 'Opus model (leave empty to keep current):',
|
|
409
|
+
initial: currentEnv.ANTHROPIC_DEFAULT_OPUS_MODEL || ''
|
|
410
|
+
}
|
|
411
|
+
]);
|
|
412
|
+
// Build updated profile
|
|
413
|
+
const updatedProfile = {
|
|
414
|
+
...profile,
|
|
415
|
+
name: answers.name || profile.name,
|
|
416
|
+
description: answers.description || profile.description,
|
|
417
|
+
config: {
|
|
418
|
+
env: {
|
|
419
|
+
ANTHROPIC_AUTH_TOKEN: answers.token || currentEnv.ANTHROPIC_AUTH_TOKEN
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
// Add optional fields only if provided
|
|
424
|
+
if (answers.baseUrl) {
|
|
425
|
+
updatedProfile.config.env.ANTHROPIC_BASE_URL = answers.baseUrl;
|
|
426
|
+
}
|
|
427
|
+
else if (currentEnv.ANTHROPIC_BASE_URL) {
|
|
428
|
+
updatedProfile.config.env.ANTHROPIC_BASE_URL = currentEnv.ANTHROPIC_BASE_URL;
|
|
429
|
+
}
|
|
430
|
+
if (answers.haikuModel) {
|
|
431
|
+
updatedProfile.config.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = answers.haikuModel;
|
|
432
|
+
}
|
|
433
|
+
else if (currentEnv.ANTHROPIC_DEFAULT_HAIKU_MODEL) {
|
|
434
|
+
updatedProfile.config.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = currentEnv.ANTHROPIC_DEFAULT_HAIKU_MODEL;
|
|
435
|
+
}
|
|
436
|
+
if (answers.sonnetModel) {
|
|
437
|
+
updatedProfile.config.env.ANTHROPIC_DEFAULT_SONNET_MODEL = answers.sonnetModel;
|
|
438
|
+
}
|
|
439
|
+
else if (currentEnv.ANTHROPIC_DEFAULT_SONNET_MODEL) {
|
|
440
|
+
updatedProfile.config.env.ANTHROPIC_DEFAULT_SONNET_MODEL = currentEnv.ANTHROPIC_DEFAULT_SONNET_MODEL;
|
|
441
|
+
}
|
|
442
|
+
if (answers.opusModel) {
|
|
443
|
+
updatedProfile.config.env.ANTHROPIC_DEFAULT_OPUS_MODEL = answers.opusModel;
|
|
444
|
+
}
|
|
445
|
+
else if (currentEnv.ANTHROPIC_DEFAULT_OPUS_MODEL) {
|
|
446
|
+
updatedProfile.config.env.ANTHROPIC_DEFAULT_OPUS_MODEL = currentEnv.ANTHROPIC_DEFAULT_OPUS_MODEL;
|
|
447
|
+
}
|
|
448
|
+
await (0, writer_1.updateProfile)(updatedProfile);
|
|
449
|
+
console.log(chalk_1.default.green(`\n✓ Profile "${updatedProfile.name}" updated successfully!`));
|
|
450
|
+
}
|
|
451
|
+
catch (err) {
|
|
452
|
+
if (err.message === 'User cancelled') {
|
|
453
|
+
console.log(chalk_1.default.yellow('\nCancelled'));
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
console.error(chalk_1.default.red(`Error: ${err.message}`));
|
|
457
|
+
process.exit(1);
|
|
458
|
+
}
|
|
459
|
+
});
|
|
110
460
|
program.parse();
|
|
111
461
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,yCAAoC;AACpC,oDAAgD;AAChD,gDAAkG;AAClG,gDAA+E;AAC/E,kDAA0B;AAE1B,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,WAAW,CAAC;KACjB,WAAW,CAAC,0CAA0C,CAAC;KACvD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,IAAA,0BAAW,GAAE,CAAC;AACtB,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,kBAAkB,CAAC;KAC3B,WAAW,CAAC,8BAA8B,CAAC;KAC3C,MAAM,CAAC,KAAK,EAAE,SAAiB,EAAE,EAAE;IAClC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,IAAA,oBAAW,EAAC,SAAS,CAAC,CAAC;QAC7C,MAAM,IAAA,qBAAY,EAAC,OAAO,CAAC,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,iBAAiB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC5D,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,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,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ProviderProfile } from './schema';
|
|
2
|
+
export interface ProviderPreset {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
defaultModels?: {
|
|
9
|
+
haiku?: string;
|
|
10
|
+
sonnet?: string;
|
|
11
|
+
opus?: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare const PROVIDER_PRESETS: ProviderPreset[];
|
|
15
|
+
export declare function saveProfile(profile: ProviderProfile): Promise<void>;
|
|
16
|
+
export declare function sanitizeId(input: string): string;
|
|
17
|
+
export declare function createProfileFromPreset(preset: ProviderPreset, token: string, options?: {
|
|
18
|
+
customName?: string;
|
|
19
|
+
customDescription?: string;
|
|
20
|
+
customBaseUrl?: string;
|
|
21
|
+
customHaiku?: string;
|
|
22
|
+
customSonnet?: string;
|
|
23
|
+
customOpus?: string;
|
|
24
|
+
}): ProviderProfile;
|
|
25
|
+
export declare function profileExists(id: string): Promise<boolean>;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PROVIDER_PRESETS = void 0;
|
|
7
|
+
exports.saveProfile = saveProfile;
|
|
8
|
+
exports.sanitizeId = sanitizeId;
|
|
9
|
+
exports.createProfileFromPreset = createProfileFromPreset;
|
|
10
|
+
exports.profileExists = profileExists;
|
|
11
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const os_1 = __importDefault(require("os"));
|
|
14
|
+
const CLAUDE_DIR = path_1.default.join(os_1.default.homedir(), '.claude');
|
|
15
|
+
const PROFILES_DIR = path_1.default.join(CLAUDE_DIR, 'profiles');
|
|
16
|
+
exports.PROVIDER_PRESETS = [
|
|
17
|
+
{
|
|
18
|
+
id: 'anthropic',
|
|
19
|
+
name: 'Anthropic (Official)',
|
|
20
|
+
description: 'Official Anthropic API',
|
|
21
|
+
icon: '🔷',
|
|
22
|
+
defaultModels: {
|
|
23
|
+
haiku: 'claude-3-5-haiku-20241022',
|
|
24
|
+
sonnet: 'claude-3-5-sonnet-20241022',
|
|
25
|
+
opus: 'claude-3-5-opus-20241022'
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 'zhipu-coding',
|
|
30
|
+
name: 'Zhipu GLM Coding Plan',
|
|
31
|
+
description: 'GLM Coding Plan (编程套餐)',
|
|
32
|
+
icon: '💻',
|
|
33
|
+
baseUrl: 'https://open.bigmodel.cn/api/anthropic',
|
|
34
|
+
defaultModels: {
|
|
35
|
+
haiku: 'glm-4.5-air',
|
|
36
|
+
sonnet: 'glm-4.7',
|
|
37
|
+
opus: 'glm-4.7'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'openrouter',
|
|
42
|
+
name: 'OpenRouter',
|
|
43
|
+
description: 'OpenRouter AI (200+ models)',
|
|
44
|
+
icon: '🔀',
|
|
45
|
+
baseUrl: 'https://openrouter.ai/api/v1',
|
|
46
|
+
defaultModels: {
|
|
47
|
+
haiku: 'anthropic/claude-3.5-haiku',
|
|
48
|
+
sonnet: 'anthropic/claude-3.5-sonnet',
|
|
49
|
+
opus: 'anthropic/claude-3.5-opus'
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 'cloudflare-worker',
|
|
54
|
+
name: 'Cloudflare Worker Proxy',
|
|
55
|
+
description: 'Cloudflare Worker Claude Proxy',
|
|
56
|
+
icon: '☁️',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'custom',
|
|
60
|
+
name: 'Custom Provider',
|
|
61
|
+
description: 'Custom API endpoint',
|
|
62
|
+
icon: '🔌',
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
async function saveProfile(profile) {
|
|
66
|
+
await fs_extra_1.default.ensureDir(PROFILES_DIR);
|
|
67
|
+
const profilePath = path_1.default.join(PROFILES_DIR, `${profile.id}.json`);
|
|
68
|
+
if (await fs_extra_1.default.pathExists(profilePath)) {
|
|
69
|
+
throw new Error(`Profile ${profile.id} already exists`);
|
|
70
|
+
}
|
|
71
|
+
await fs_extra_1.default.writeJSON(profilePath, profile, { spaces: 2 });
|
|
72
|
+
}
|
|
73
|
+
function sanitizeId(input) {
|
|
74
|
+
return input.toLowerCase()
|
|
75
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
76
|
+
.replace(/^-|-$/g, '');
|
|
77
|
+
}
|
|
78
|
+
function createProfileFromPreset(preset, token, options = {}) {
|
|
79
|
+
const name = options.customName || preset.name;
|
|
80
|
+
const id = sanitizeId(options.customName || preset.id);
|
|
81
|
+
const description = options.customDescription || preset.description;
|
|
82
|
+
const baseUrl = options.customBaseUrl || preset.baseUrl;
|
|
83
|
+
const profile = {
|
|
84
|
+
id,
|
|
85
|
+
name,
|
|
86
|
+
description,
|
|
87
|
+
icon: preset.icon,
|
|
88
|
+
config: {
|
|
89
|
+
env: {
|
|
90
|
+
ANTHROPIC_AUTH_TOKEN: token,
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
if (baseUrl) {
|
|
95
|
+
profile.config.env.ANTHROPIC_BASE_URL = baseUrl;
|
|
96
|
+
}
|
|
97
|
+
const haikuModel = options.customHaiku || preset.defaultModels?.haiku;
|
|
98
|
+
if (haikuModel) {
|
|
99
|
+
profile.config.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = haikuModel;
|
|
100
|
+
}
|
|
101
|
+
const sonnetModel = options.customSonnet || preset.defaultModels?.sonnet;
|
|
102
|
+
if (sonnetModel) {
|
|
103
|
+
profile.config.env.ANTHROPIC_DEFAULT_SONNET_MODEL = sonnetModel;
|
|
104
|
+
}
|
|
105
|
+
const opusModel = options.customOpus || preset.defaultModels?.opus;
|
|
106
|
+
if (opusModel) {
|
|
107
|
+
profile.config.env.ANTHROPIC_DEFAULT_OPUS_MODEL = opusModel;
|
|
108
|
+
}
|
|
109
|
+
return profile;
|
|
110
|
+
}
|
|
111
|
+
async function profileExists(id) {
|
|
112
|
+
const profilePath = path_1.default.join(PROFILES_DIR, `${id}.json`);
|
|
113
|
+
return fs_extra_1.default.pathExists(profilePath);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=creator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"creator.js","sourceRoot":"","sources":["../../../src/lib/config/creator.ts"],"names":[],"mappings":";;;;;;AAuEA,kCAOC;AAED,gCAIC;AAED,0DAiDC;AAED,sCAGC;AA5ID,wDAA0B;AAC1B,gDAAwB;AACxB,4CAAoB;AAGpB,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AACtD,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAe1C,QAAA,gBAAgB,GAAqB;IAChD;QACE,EAAE,EAAE,WAAW;QACf,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE,wBAAwB;QACrC,IAAI,EAAE,IAAI;QACV,aAAa,EAAE;YACb,KAAK,EAAE,2BAA2B;YAClC,MAAM,EAAE,4BAA4B;YACpC,IAAI,EAAE,0BAA0B;SACjC;KACF;IACD;QACE,EAAE,EAAE,cAAc;QAClB,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,wBAAwB;QACrC,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,wCAAwC;QACjD,aAAa,EAAE;YACb,KAAK,EAAE,aAAa;YACpB,MAAM,EAAE,SA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AC5C,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1D,OAAO,kBAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -45,10 +45,16 @@ function getCurrentProvider(settings) {
|
|
|
45
45
|
const baseUrl = settings.env?.ANTHROPIC_BASE_URL;
|
|
46
46
|
if (!baseUrl)
|
|
47
47
|
return 'anthropic';
|
|
48
|
+
if (baseUrl.includes('open.bigmodel.cn/api/anthropic'))
|
|
49
|
+
return 'zhipu-coding';
|
|
48
50
|
if (baseUrl.includes('bigmodel.cn'))
|
|
49
|
-
return 'zhipu';
|
|
51
|
+
return 'zhipu-coding';
|
|
52
|
+
if (baseUrl.includes('openrouter.ai'))
|
|
53
|
+
return 'openrouter';
|
|
50
54
|
if (baseUrl.includes('api.anthropic.com'))
|
|
51
55
|
return 'anthropic';
|
|
56
|
+
if (baseUrl.includes('workers.dev'))
|
|
57
|
+
return 'cloudflare-worker';
|
|
52
58
|
return 'custom';
|
|
53
59
|
}
|
|
54
60
|
//# sourceMappingURL=loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/lib/config/loader.ts"],"names":[],"mappings":";;;;;AASA,oCAKC;AAED,kCAMC;AAED,oCAcC;AAED,
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/lib/config/loader.ts"],"names":[],"mappings":";;;;;AASA,oCAKC;AAED,kCAMC;AAED,oCAcC;AAED,gDASC;AAjDD,wDAA0B;AAC1B,gDAAwB;AACxB,4CAAoB;AAGpB,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AACtD,MAAM,aAAa,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AAC7D,MAAM,Y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,OAAO,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,kBAAkB,CAAC,QAAkB;IACnD,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC;IACjD,IAAI,CAAC,OAAO;QAAE,OAAO,WAAW,CAAC;IACjC,IAAI,OAAO,CAAC,QAAQ,CAAC,gCAAgC,CAAC;QAAE,OAAO,cAAc,CAAC;IAC9E,IAAI,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;QAAE,OAAO,cAAc,CAAC;IAC3D,IAAI,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC;QAAE,OAAO,YAAY,CAAC;IAC3D,IAAI,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QAAE,OAAO,WAAW,CAAC;IAC9D,IAAI,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;QAAE,OAAO,mBAAmB,CAAC;IAChE,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -3,3 +3,5 @@ export declare function backupSettings(): Promise<string>;
|
|
|
3
3
|
export declare function applyProfile(profile: ProviderProfile): Promise<void>;
|
|
4
4
|
export declare function listBackups(): Promise<string[]>;
|
|
5
5
|
export declare function restoreBackup(backupFile: string): Promise<void>;
|
|
6
|
+
export declare function deleteProfile(profileId: string): Promise<void>;
|
|
7
|
+
export declare function updateProfile(profile: ProviderProfile): Promise<void>;
|
|
@@ -7,12 +7,15 @@ exports.backupSettings = backupSettings;
|
|
|
7
7
|
exports.applyProfile = applyProfile;
|
|
8
8
|
exports.listBackups = listBackups;
|
|
9
9
|
exports.restoreBackup = restoreBackup;
|
|
10
|
+
exports.deleteProfile = deleteProfile;
|
|
11
|
+
exports.updateProfile = updateProfile;
|
|
10
12
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
11
13
|
const path_1 = __importDefault(require("path"));
|
|
12
14
|
const os_1 = __importDefault(require("os"));
|
|
13
15
|
const CLAUDE_DIR = path_1.default.join(os_1.default.homedir(), '.claude');
|
|
14
16
|
const SETTINGS_FILE = path_1.default.join(CLAUDE_DIR, 'settings.json');
|
|
15
17
|
const BACKUP_DIR = path_1.default.join(CLAUDE_DIR, 'cc-switch-backups');
|
|
18
|
+
const PROFILES_DIR = path_1.default.join(CLAUDE_DIR, 'profiles');
|
|
16
19
|
async function backupSettings() {
|
|
17
20
|
await fs_extra_1.default.ensureDir(BACKUP_DIR);
|
|
18
21
|
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
@@ -45,4 +48,19 @@ async function restoreBackup(backupFile) {
|
|
|
45
48
|
}
|
|
46
49
|
await fs_extra_1.default.copy(backupPath, SETTINGS_FILE);
|
|
47
50
|
}
|
|
51
|
+
async function deleteProfile(profileId) {
|
|
52
|
+
const profilePath = path_1.default.join(PROFILES_DIR, `${profileId}.json`);
|
|
53
|
+
if (!(await fs_extra_1.default.pathExists(profilePath))) {
|
|
54
|
+
throw new Error(`Profile not found: ${profileId}`);
|
|
55
|
+
}
|
|
56
|
+
await fs_extra_1.default.remove(profilePath);
|
|
57
|
+
}
|
|
58
|
+
async function updateProfile(profile) {
|
|
59
|
+
await fs_extra_1.default.ensureDir(PROFILES_DIR);
|
|
60
|
+
const profilePath = path_1.default.join(PROFILES_DIR, `${profile.id}.json`);
|
|
61
|
+
if (!(await fs_extra_1.default.pathExists(profilePath))) {
|
|
62
|
+
throw new Error(`Profile not found: ${profile.id}`);
|
|
63
|
+
}
|
|
64
|
+
await fs_extra_1.default.writeJSON(profilePath, profile, { spaces: 2 });
|
|
65
|
+
}
|
|
48
66
|
//# sourceMappingURL=writer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../../../src/lib/config/writer.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../../../src/lib/config/writer.ts"],"names":[],"mappings":";;;;;AAUA,wCA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CAAC;IACD,MAAM,kBAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC;AAEM,KAAK,UAAU,aAAa,CAAC,OAAwB;IAC1D,MAAM,kBAAE,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACjC,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAClE,IAAI,CAAC,CAAC,MAAM,kBAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,sBAAsB,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,kBAAE,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AAC1D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supertiny99/cc-switch",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Quick TUI for switching Claude Code API providers - fast provider/token switching when quota is exhausted",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -15,11 +15,17 @@
|
|
|
15
15
|
"build": "tsc",
|
|
16
16
|
"dev": "ts-node src/index.ts",
|
|
17
17
|
"link": "npm link",
|
|
18
|
+
"link:global": "npm run build && npm link -g cc-switch",
|
|
18
19
|
"prepublishOnly": "npm run build",
|
|
19
20
|
"pretest": "npm run build",
|
|
20
21
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
21
22
|
"version": "git add .",
|
|
22
|
-
"postversion": "git push && git push --tags"
|
|
23
|
+
"postversion": "git push && git push --tags",
|
|
24
|
+
"push": "git push && git push --tags",
|
|
25
|
+
"release": "npm run build && npm run push",
|
|
26
|
+
"release:patch": "npm version patch && npm run push",
|
|
27
|
+
"release:minor": "npm version minor && npm run push",
|
|
28
|
+
"release:major": "npm version major && npm run push"
|
|
23
29
|
},
|
|
24
30
|
"keywords": [
|
|
25
31
|
"claude",
|