ccman 2.1.2 β†’ 2.1.4

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.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +308 -258
  3. package/README_en.md +444 -0
  4. package/dist/cli.js +213 -33
  5. package/dist/cli.js.map +1 -1
  6. package/dist/config/default-providers.d.ts +34 -0
  7. package/dist/config/default-providers.d.ts.map +1 -0
  8. package/dist/config/default-providers.js +96 -0
  9. package/dist/config/default-providers.js.map +1 -0
  10. package/dist/config/static-env.d.ts +1 -1
  11. package/dist/config/static-env.js +1 -1
  12. package/dist/core/ClaudeConfigManager.d.ts +5 -1
  13. package/dist/core/ClaudeConfigManager.d.ts.map +1 -1
  14. package/dist/core/ClaudeConfigManager.js +19 -3
  15. package/dist/core/ClaudeConfigManager.js.map +1 -1
  16. package/dist/providers/ProviderManager.d.ts.map +1 -1
  17. package/dist/providers/ProviderManager.js +7 -8
  18. package/dist/providers/ProviderManager.js.map +1 -1
  19. package/dist/types/index.d.ts +1 -0
  20. package/dist/types/index.d.ts.map +1 -1
  21. package/package.json +24 -3
  22. package/.editorconfig +0 -15
  23. package/.env.development +0 -3
  24. package/.env.production +0 -3
  25. package/.eslintrc.js +0 -28
  26. package/.github/workflows/release.yml +0 -99
  27. package/.prettierrc +0 -10
  28. package/CLAUDE.md +0 -276
  29. package/README_zh.md +0 -394
  30. package/dev-test.sh +0 -40
  31. package/docs/npm-publish-guide.md +0 -71
  32. package/docs/release-guide.md +0 -144
  33. package/docs/scripts-guide.md +0 -221
  34. package/docs/version-management.md +0 -64
  35. package/jest.config.js +0 -22
  36. package/release-temp/README.md +0 -394
  37. package/release-temp/package.json +0 -61
  38. package/scripts/build-env.js +0 -75
  39. package/scripts/modules/check-uncommitted.sh +0 -109
  40. package/scripts/modules/create-tag.sh +0 -279
  41. package/scripts/modules/monitor-release.sh +0 -296
  42. package/scripts/modules/version-bump.sh +0 -262
  43. package/scripts/publish-local.sh +0 -91
  44. package/scripts/quick-release.sh +0 -100
  45. package/scripts/release.sh +0 -430
  46. package/scripts/smart-release-v3.sh +0 -283
  47. package/scripts/smart-release.sh +0 -322
  48. package/src/cli.ts +0 -598
  49. package/src/commands/lang.ts +0 -105
  50. package/src/core/CCMConfigManager.ts +0 -259
  51. package/src/core/ClaudeConfigManager.ts +0 -123
  52. package/src/i18n/LanguageManager.ts +0 -169
  53. package/src/i18n/messages.ts +0 -233
  54. package/src/index.ts +0 -4
  55. package/src/providers/ProviderManager.ts +0 -414
  56. package/src/types/index.ts +0 -100
  57. package/src/utils/env-config.ts +0 -53
  58. package/src/utils/version.ts +0 -16
  59. package/tsconfig.json +0 -25
package/README_en.md ADDED
@@ -0,0 +1,444 @@
1
+ # CCM - Claude Code Manager
2
+
3
+ <div align="center">
4
+
5
+ [![npm version](https://img.shields.io/npm/v/ccman.svg)](https://www.npmjs.com/package/ccman)
6
+ [![npm downloads](https://img.shields.io/npm/dm/ccman.svg)](https://www.npmjs.com/package/ccman)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+ [![Node.js Version](https://img.shields.io/node/v/ccman.svg)](https://nodejs.org)
9
+
10
+ **Intelligent TypeScript CLI Tool for Managing Claude Code API Configurations**
11
+
12
+ 🌍 Multilingual Support Β· πŸ”§ Direct Configuration Integration Β· πŸ“ Multi-Provider Management Β· ⚑ Zero-Config Experience
13
+
14
+ [δΈ­ζ–‡ζ–‡ζ‘£](./README.md) | **English Documentation**
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ ## ✨ Key Features
21
+
22
+ - **🌍 Intelligent Language Support** - Auto-detects system language with seamless Chinese/English switching
23
+ - **πŸ”§ Direct Configuration Integration** - Modifies `~/.claude/settings.json` directly without shell integration
24
+ - **πŸ“ Multi-Provider Management** - Quick switching between API providers (Official Anthropic, third-party, etc.)
25
+ - **🎯 Interactive Menu System** - User-friendly command-line interface with continuous operation support
26
+ - **⚑ Zero-Config Experience** - Works out of the box with intelligent defaults
27
+ - **πŸ”’ Secure & Reliable** - Automatic backups, selective configuration updates, and user data protection
28
+
29
+ ## πŸš€ Quick Start
30
+
31
+ ### Installation
32
+
33
+ ```bash
34
+ npm install -g ccman
35
+ ```
36
+
37
+ ### First Run
38
+
39
+ ```bash
40
+ ccman
41
+ ```
42
+
43
+ On first run, you'll be guided through:
44
+ 1. Choose interface language (Chinese/English/Auto-detect)
45
+ 2. Create your first provider configuration
46
+ 3. Automatically apply to Claude Code
47
+
48
+ ## πŸ“– Command Reference
49
+
50
+ ### Core Commands
51
+
52
+ ```bash
53
+ ccman # Interactive main menu (recommended entry point)
54
+ ccman ls # List all providers and system status
55
+ ccman ls --current # Show current provider details
56
+ ccman ls --brief # Brief list mode
57
+ ccman add <id> <name> <url> [key] # Add new provider
58
+ ccman use <id> # Switch to specified provider
59
+ ccman rm <id> # Remove provider
60
+ ccman clear # Clear all configurations (requires confirmation)
61
+ ```
62
+
63
+ ### Language Management
64
+
65
+ ```bash
66
+ ccman lang # Show current language setting
67
+ ccman lang set zh # Set to Chinese
68
+ ccman lang set en # Set to English
69
+ ccman lang set auto # Auto-detect system language
70
+ ccman lang reset # Reset to first-run state
71
+ ```
72
+
73
+ ## πŸ’‘ Usage Examples
74
+
75
+ ### Adding and Switching Providers
76
+
77
+ ```bash
78
+ # Add official Anthropic configuration
79
+ ccman add anthropic "Anthropic Official" https://api.anthropic.com sk-ant-xxx
80
+
81
+ # Add third-party provider
82
+ ccman add custom "My Custom API" https://api.custom.com
83
+
84
+ # Switch to custom provider
85
+ ccman use custom
86
+
87
+ # List all providers
88
+ ccman ls
89
+ ```
90
+
91
+ ### Interactive Menu Operations
92
+
93
+ ```bash
94
+ $ ccman
95
+
96
+ ? What would you like to do?
97
+ ❯ Switch provider
98
+ Add new provider
99
+ Update provider
100
+ Remove provider
101
+ Show detailed status
102
+ Exit
103
+
104
+ # Follow prompts after selecting an operation
105
+ # Choose to continue or exit after each operation
106
+ ```
107
+
108
+ ## πŸ”§ How It Works
109
+
110
+ CCM directly manages the `~/.claude/settings.json` file with these safety measures:
111
+
112
+ ### 1. Selective Updates
113
+
114
+ Only modifies CCM-managed configuration items:
115
+ - `env.ANTHROPIC_AUTH_TOKEN`
116
+ - `env.ANTHROPIC_BASE_URL`
117
+ - `env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`
118
+ - `env.CLAUDE_CODE_MAX_OUTPUT_TOKENS`
119
+ - `permissions.allow` / `permissions.deny`
120
+
121
+ ### 2. Configuration Protection
122
+
123
+ Preserves all other user configuration items:
124
+ - βœ… Preserves: `mcpServers`, `model`, `customUserConfig`, etc.
125
+ - πŸ”„ Updates: Only the CCM-managed configuration items listed above
126
+
127
+ ### 3. Automatic Backups
128
+
129
+ Automatically backs up current configuration to `~/.ccman/backups/` before each switch
130
+
131
+ ## πŸ“‚ Configuration Structure
132
+
133
+ ```
134
+ ~/.ccman/
135
+ β”œβ”€β”€ config.json # Main CCM configuration
136
+ β”œβ”€β”€ providers/ # Provider configuration directory
137
+ β”‚ β”œβ”€β”€ anthropic.json # Official Anthropic
138
+ β”‚ β”œβ”€β”€ custom.json # Custom providers
139
+ β”‚ └── ...
140
+ └── backups/ # Configuration backup directory (auto-created)
141
+ ```
142
+
143
+ ### Provider Configuration File Structure
144
+
145
+ ```json
146
+ {
147
+ "name": "Anthropic Official",
148
+ "description": "Official Anthropic API Configuration",
149
+ "config": {
150
+ "env": {
151
+ "ANTHROPIC_AUTH_TOKEN": "your-token",
152
+ "ANTHROPIC_BASE_URL": "https://api.anthropic.com",
153
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1,
154
+ "CLAUDE_CODE_MAX_OUTPUT_TOKENS": 32000
155
+ },
156
+ "permissions": {
157
+ "allow": [],
158
+ "deny": []
159
+ }
160
+ },
161
+ "metadata": {
162
+ "createdAt": "2025-01-15T10:30:00.000Z",
163
+ "updatedAt": "2025-01-15T10:30:00.000Z",
164
+ "usageCount": 5
165
+ }
166
+ }
167
+ ```
168
+
169
+ ### Main CCM Configuration File Structure
170
+
171
+ ```json
172
+ {
173
+ "currentProvider": "anthropic",
174
+ "claudeConfigPath": "/Users/user/.claude/settings.json",
175
+ "providers": {
176
+ "anthropic": {
177
+ "name": "Anthropic Official",
178
+ "configFile": "anthropic.json",
179
+ "lastUsed": "2025-01-15T10:30:00.000Z"
180
+ }
181
+ },
182
+ "settings": {
183
+ "language": "zh",
184
+ "firstRun": false
185
+ },
186
+ "metadata": {
187
+ "version": "2.1.3",
188
+ "createdAt": "2025-01-15T10:00:00.000Z",
189
+ "updatedAt": "2025-01-15T10:30:00.000Z"
190
+ }
191
+ }
192
+ ```
193
+
194
+ ## 🌐 Language Support
195
+
196
+ ### Supported Languages
197
+
198
+ - **Chinese (zh)** - Complete Chinese interface
199
+ - **English (en)** - Complete English interface
200
+ - **Auto-detect (auto)** - Automatically selects based on system `LANG` environment variable
201
+
202
+ ### Language Detection Logic
203
+
204
+ - English environments (`en-*`) β†’ Automatically uses English interface
205
+ - Other environments (including `zh-*`, unset, etc.) β†’ Automatically uses Chinese interface
206
+ - Users can manually override language settings at any time
207
+
208
+ ### First-Run Experience
209
+
210
+ ```bash
211
+ $ ccman
212
+
213
+ 🌍 Welcome to CCM! / ζ¬’θΏŽδ½Ώη”¨ CCM!
214
+
215
+ This is your first time running CCM.
216
+ θΏ™ζ˜―ζ‚¨ι¦–ζ¬‘θΏθ‘Œ CCM。
217
+
218
+ ? Please choose your preferred language:
219
+ ? 请选择您偏ε₯½ηš„θ―­θ¨€οΌš
220
+ ❯ πŸ‡¨πŸ‡³ δΈ­ζ–‡ (Chinese)
221
+ πŸ‡ΊπŸ‡Έ English
222
+ 🌐 Auto-detect based on system
223
+
224
+ βœ“ Language set to English
225
+ βœ“ You can change this later with: ccman lang set <zh|en|auto>
226
+ ```
227
+
228
+ ## πŸ› οΈ Development
229
+
230
+ ### Environment Setup
231
+
232
+ ```bash
233
+ # Clone repository
234
+ git clone https://github.com/2ue/ccman.git
235
+ cd ccman
236
+
237
+ # Install dependencies
238
+ pnpm install
239
+ ```
240
+
241
+ ### Development Commands
242
+
243
+ ```bash
244
+ pnpm run dev # Development mode (using tsx)
245
+ pnpm run build # TypeScript compilation
246
+ pnpm run start # Run compiled CLI
247
+ pnpm run clean # Clean dist/ directory
248
+ pnpm run lint # ESLint code check
249
+ pnpm test # Run tests
250
+ ```
251
+
252
+ ### Development Environment Isolation
253
+
254
+ CCM supports development environment configuration isolation to avoid affecting production configurations:
255
+
256
+ ```bash
257
+ # Set development environment configuration paths
258
+ export CCM_CONFIG_DIR=".ccman-dev"
259
+ export CLAUDE_CONFIG_PATH="$HOME/.claude/settings-dev.json"
260
+
261
+ # Run in isolated environment
262
+ pnpm run dev
263
+ ```
264
+
265
+ ### Project Structure
266
+
267
+ ```
268
+ src/
269
+ β”œβ”€β”€ types/ # TypeScript type definitions
270
+ β”‚ └── index.ts # Core type interfaces
271
+ β”œβ”€β”€ core/ # Core modules
272
+ β”‚ β”œβ”€β”€ CCMConfigManager.ts # CCM configuration manager
273
+ β”‚ └── ClaudeConfigManager.ts # Claude configuration manager
274
+ β”œβ”€β”€ providers/ # Provider management
275
+ β”‚ └── ProviderManager.ts # Provider business logic
276
+ β”œβ”€β”€ commands/ # Command handling
277
+ β”‚ └── lang.ts # Language command processing
278
+ β”œβ”€β”€ i18n/ # Internationalization
279
+ β”‚ β”œβ”€β”€ LanguageManager.ts # Language manager
280
+ β”‚ └── messages.ts # Multi-language messages
281
+ β”œβ”€β”€ utils/ # Utility functions
282
+ β”‚ β”œβ”€β”€ env-config.ts # Environment configuration
283
+ β”‚ └── version.ts # Version information
284
+ β”œβ”€β”€ config/ # Configuration files
285
+ β”‚ └── static-env.ts # Static environment configuration
286
+ β”œβ”€β”€ cli.ts # CLI entry point
287
+ └── index.ts # Module exports
288
+ ```
289
+
290
+ ## πŸ“‹ System Requirements
291
+
292
+ - **Node.js** >= 16.0.0
293
+ - **Claude Code** installed with settings.json support
294
+ - **Operating Systems**: Linux, macOS, Windows (WSL)
295
+ - **Package Managers**: npm, pnpm, yarn (pnpm recommended)
296
+
297
+ ## πŸ” Troubleshooting
298
+
299
+ ### Provider Configuration Not Applied
300
+
301
+ ```bash
302
+ # 1. Check current provider information
303
+ ccman ls --current
304
+
305
+ # 2. Re-apply configuration
306
+ ccman use <provider-id>
307
+
308
+ # 3. Check Claude configuration file
309
+ cat ~/.claude/settings.json | grep ANTHROPIC
310
+
311
+ # 4. View complete configuration
312
+ cat ~/.claude/settings.json | jq .
313
+ ```
314
+
315
+ ### Language Switching Issues
316
+
317
+ ```bash
318
+ # View current language setting
319
+ ccman lang
320
+
321
+ # Force set to Chinese
322
+ ccman lang set zh
323
+
324
+ # Force set to English
325
+ ccman lang set en
326
+
327
+ # Reset to first-run state (re-select language)
328
+ ccman lang reset
329
+ ccman
330
+ ```
331
+
332
+ ### Corrupted Configuration Files
333
+
334
+ ```bash
335
+ # Delete all configurations (requires confirmation)
336
+ ccman clear
337
+
338
+ # Start fresh configuration
339
+ ccman
340
+ ```
341
+
342
+ ### Development Environment Issues
343
+
344
+ ```bash
345
+ # Use isolated development environment
346
+ export CCM_CONFIG_DIR=".ccman-dev"
347
+ pnpm run dev
348
+
349
+ # Clean and rebuild
350
+ pnpm run clean
351
+ pnpm run build
352
+ ```
353
+
354
+ ## πŸ“ Changelog
355
+
356
+ ### v2.1.3 (2025-09-24)
357
+ - ✨ Added `CLAUDE_CODE_MAX_OUTPUT_TOKENS` configuration support
358
+ - πŸ› Fixed TypeScript compilation errors, completely removed apiKeyHelper configuration
359
+ - 🎨 Optimized interactive menu experience
360
+ - πŸ“¦ Updated dependency package versions
361
+
362
+ ### v2.1.2
363
+ - 🎨 Simplified provider configuration, removed manual ID setting
364
+ - ✨ Optimized first-run experience
365
+
366
+ ### v2.0.0
367
+ - πŸŽ‰ New architecture: Direct configuration integration without shell integration
368
+ - 🌍 Intelligent multilingual support (Chinese/English/Auto-detect)
369
+ - 🎯 Interactive menu system
370
+ - πŸ“ Multi-provider management
371
+ - πŸ”’ Automatic backups and configuration protection
372
+
373
+ ### v1.x
374
+ - Legacy architecture: Based on shell environment variable integration (deprecated)
375
+
376
+ ## πŸš€ Migration from v1.x
377
+
378
+ CCM v2.0 uses a completely different architecture and is incompatible with v1.x:
379
+
380
+ ### v1.x (Deprecated)
381
+ - ❌ Modified shell configuration files (.bashrc, .zshrc, etc.)
382
+ - ❌ Used environment variables
383
+ - ❌ Complex shell integration and reloading
384
+
385
+ ### v2.x (Current Version)
386
+ - βœ… Directly modifies `~/.claude/settings.json`
387
+ - βœ… Provider-based configuration management
388
+ - βœ… Intelligent language support
389
+ - βœ… Simplified, secure implementation
390
+
391
+ **Migration Steps**:
392
+
393
+ 1. Uninstall v1.x version
394
+ 2. Clean up related content from shell configuration files
395
+ 3. Install v2.x version: `npm install -g ccman`
396
+ 4. Run `ccman` to reconfigure
397
+
398
+ ## 🀝 Contributing
399
+
400
+ We welcome all forms of contributions!
401
+
402
+ ### How to Contribute
403
+
404
+ 1. Fork this repository
405
+ 2. Create a feature branch (`git checkout -b feature/AmazingFeature`)
406
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
407
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
408
+ 5. Submit a Pull Request
409
+
410
+ ### Reporting Issues
411
+
412
+ If you find bugs or have feature suggestions, please submit them in [GitHub Issues](https://github.com/2ue/ccman/issues).
413
+
414
+ ## πŸ“„ License
415
+
416
+ This project is licensed under the [MIT License](LICENSE).
417
+
418
+ ## πŸ‘€ Author
419
+
420
+ **2ue**
421
+ - πŸ“§ Email: jie746635835@163.com
422
+ - πŸ™ GitHub: [@2ue](https://github.com/2ue)
423
+
424
+ ## πŸ™ Acknowledgments
425
+
426
+ Thanks to all developers who have contributed to this project!
427
+
428
+ Special thanks to these open source projects:
429
+ - [TypeScript](https://www.typescriptlang.org/)
430
+ - [Commander.js](https://github.com/tj/commander.js)
431
+ - [Inquirer.js](https://github.com/SBoudrias/Inquirer.js)
432
+ - [Chalk](https://github.com/chalk/chalk)
433
+
434
+ ---
435
+
436
+ <div align="center">
437
+
438
+ **CCM v2.x - Intelligent, Multilingual, Seamless Claude Code Provider Management**
439
+
440
+ Made with ❀️ by [2ue](https://github.com/2ue)
441
+
442
+ [⬆ Back to Top](#ccm---claude-code-manager)
443
+
444
+ </div>