ccman 1.0.1 → 2.0.1

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 (91) hide show
  1. package/.env.development +3 -0
  2. package/.env.production +3 -0
  3. package/.github/workflows/release.yml +5 -5
  4. package/CLAUDE.md +246 -185
  5. package/README.md +282 -249
  6. package/README_zh.md +283 -250
  7. package/dev-test.sh +40 -0
  8. package/dist/cli.js +425 -369
  9. package/dist/cli.js.map +1 -1
  10. package/dist/commands/lang.d.ts +3 -0
  11. package/dist/commands/lang.d.ts.map +1 -0
  12. package/dist/commands/lang.js +99 -0
  13. package/dist/commands/lang.js.map +1 -0
  14. package/dist/config/static-env.d.ts +14 -0
  15. package/dist/config/static-env.d.ts.map +1 -0
  16. package/dist/config/static-env.js +17 -0
  17. package/dist/config/static-env.js.map +1 -0
  18. package/dist/core/CCMConfigManager.d.ts +52 -0
  19. package/dist/core/CCMConfigManager.d.ts.map +1 -0
  20. package/dist/core/CCMConfigManager.js +203 -0
  21. package/dist/core/CCMConfigManager.js.map +1 -0
  22. package/dist/core/ClaudeConfigManager.d.ts +35 -0
  23. package/dist/core/ClaudeConfigManager.d.ts.map +1 -0
  24. package/dist/core/ClaudeConfigManager.js +149 -0
  25. package/dist/core/ClaudeConfigManager.js.map +1 -0
  26. package/dist/i18n/LanguageManager.d.ts +43 -0
  27. package/dist/i18n/LanguageManager.d.ts.map +1 -0
  28. package/dist/i18n/LanguageManager.js +157 -0
  29. package/dist/i18n/LanguageManager.js.map +1 -0
  30. package/dist/i18n/messages.d.ts +65 -0
  31. package/dist/i18n/messages.d.ts.map +1 -0
  32. package/dist/i18n/messages.js +144 -0
  33. package/dist/i18n/messages.js.map +1 -0
  34. package/dist/index.d.ts +3 -3
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +3 -8
  37. package/dist/index.js.map +1 -1
  38. package/dist/providers/ProviderManager.d.ts +58 -0
  39. package/dist/providers/ProviderManager.d.ts.map +1 -0
  40. package/dist/providers/ProviderManager.js +335 -0
  41. package/dist/providers/ProviderManager.js.map +1 -0
  42. package/dist/types/index.d.ts +78 -38
  43. package/dist/types/index.d.ts.map +1 -1
  44. package/dist/types/index.js +1 -0
  45. package/dist/types/index.js.map +1 -1
  46. package/dist/utils/env-config.d.ts +27 -0
  47. package/dist/utils/env-config.d.ts.map +1 -0
  48. package/dist/{config/constants.js → utils/env-config.js} +36 -50
  49. package/dist/utils/env-config.js.map +1 -0
  50. package/dist/utils/version.d.ts +2 -64
  51. package/dist/utils/version.d.ts.map +1 -1
  52. package/dist/utils/version.js +12 -158
  53. package/dist/utils/version.js.map +1 -1
  54. package/package.json +17 -16
  55. package/release-temp/README.md +282 -249
  56. package/release-temp/package.json +17 -16
  57. package/scripts/build-env.js +75 -0
  58. package/scripts/modules/create-tag.sh +53 -10
  59. package/scripts/modules/monitor-release.sh +40 -12
  60. package/scripts/modules/version-bump.sh +14 -17
  61. package/scripts/smart-release-v3.sh +20 -26
  62. package/src/cli.ts +462 -394
  63. package/src/commands/lang.ts +105 -0
  64. package/src/core/CCMConfigManager.ts +185 -0
  65. package/src/core/ClaudeConfigManager.ts +125 -0
  66. package/src/i18n/LanguageManager.ts +169 -0
  67. package/src/i18n/messages.ts +233 -0
  68. package/src/index.ts +4 -5
  69. package/src/providers/ProviderManager.ts +393 -0
  70. package/src/types/index.ts +80 -39
  71. package/src/utils/env-config.ts +53 -0
  72. package/src/utils/version.ts +11 -184
  73. package/dist/config/ConfigManager.d.ts +0 -67
  74. package/dist/config/ConfigManager.d.ts.map +0 -1
  75. package/dist/config/ConfigManager.js +0 -226
  76. package/dist/config/ConfigManager.js.map +0 -1
  77. package/dist/config/EnvironmentManager.d.ts +0 -83
  78. package/dist/config/EnvironmentManager.d.ts.map +0 -1
  79. package/dist/config/EnvironmentManager.js +0 -280
  80. package/dist/config/EnvironmentManager.js.map +0 -1
  81. package/dist/config/constants.d.ts +0 -40
  82. package/dist/config/constants.d.ts.map +0 -1
  83. package/dist/config/constants.js.map +0 -1
  84. package/dist/shell/ShellManager.d.ts +0 -81
  85. package/dist/shell/ShellManager.d.ts.map +0 -1
  86. package/dist/shell/ShellManager.js +0 -490
  87. package/dist/shell/ShellManager.js.map +0 -1
  88. package/src/config/ConfigManager.ts +0 -227
  89. package/src/config/EnvironmentManager.ts +0 -327
  90. package/src/config/constants.ts +0 -64
  91. package/src/shell/ShellManager.ts +0 -526
@@ -0,0 +1,3 @@
1
+ # 开发环境配置
2
+ CCM_CONFIG_DIR=~/.ccman-dev
3
+ CLAUDE_CONFIG_PATH=~/.claude/settings-dev.json
@@ -0,0 +1,3 @@
1
+ # 生产环境配置 - 默认值,可不设置
2
+ CCM_CONFIG_DIR=~/.ccman
3
+ CLAUDE_CONFIG_PATH=~/.claude/settings.json
@@ -10,7 +10,7 @@ jobs:
10
10
  release:
11
11
  name: Build, Test and Release
12
12
  runs-on: ubuntu-latest
13
-
13
+
14
14
  permissions:
15
15
  contents: write # 创建 release
16
16
  id-token: write # NPM 发布
@@ -26,7 +26,7 @@ jobs:
26
26
  - name: Setup pnpm
27
27
  uses: pnpm/action-setup@v4
28
28
  with:
29
- version: 8.15.1
29
+ version: 7.33.7
30
30
 
31
31
  # 3. 设置 Node.js
32
32
  - name: Setup Node.js
@@ -39,7 +39,7 @@ jobs:
39
39
  # 4. 安装依赖和构建
40
40
  - name: Install and Build
41
41
  run: |
42
- pnpm install
42
+ pnpm install --no-frozen-lockfile
43
43
  pnpm run lint
44
44
  pnpm run build
45
45
 
@@ -66,7 +66,7 @@ jobs:
66
66
  token: ${{ secrets.NPM_TOKEN }}
67
67
  access: public
68
68
 
69
- # 8. 创建 GitHub Release
69
+ # 8. 创建 GitHub Release
70
70
  - name: Create GitHub Release
71
71
  uses: softprops/action-gh-release@v2
72
72
  with:
@@ -96,4 +96,4 @@ jobs:
96
96
  draft: false
97
97
  prerelease: ${{ contains(github.ref, '-beta') || contains(github.ref, '-alpha') || contains(github.ref, '-rc') }}
98
98
  env:
99
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package/CLAUDE.md CHANGED
@@ -4,212 +4,273 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
 
5
5
  ## Project Overview
6
6
 
7
- CCM (Claude Code Manager) is a TypeScript-based command-line tool for managing Claude Code API configurations. It provides structured, modular environment management with **safe shell integration** through independent configuration files.
7
+ CCM (Claude Code Manager) 是一个 TypeScript 命令行工具,用于管理 Claude Code API 配置。新架构直接修改 `~/.claude/settings.json` 文件实现配置切换,无需 shell 集成。
8
8
 
9
- ## Architecture
9
+ ## 新架构设计 (v2.0.0)
10
10
 
11
- ### Core Modules
12
- - **src/types/index.ts**: TypeScript type definitions for all interfaces
13
- - **src/config/ConfigManager.ts**: Core configuration management with JSON storage
14
- - **src/config/EnvironmentManager.ts**: High-level environment group operations
15
- - **src/shell/ShellManager.ts**: Safe shell configuration file management using ..ccmanrc approach
16
- - **src/cli.ts**: Command-line interface with Commander.js and unified interaction logic
11
+ ### 核心理念
12
+ - **直接配置修改**: 直接修改 `~/.claude/settings.json` 实现配置切换
13
+ - **多供应商支持**: `~/.ccman/providers/` 目录存储多个供应商配置
14
+ - **零 shell 依赖**: 无需修改 shell 配置文件,立即生效
15
+ - **安全备份**: 每次切换前自动备份当前配置
17
16
 
18
- ### Project Structure
17
+ ### 目录结构
19
18
  ```
20
- src/
21
- ├── types/ # TypeScript type definitions
22
- ├── config/ # Configuration management modules
23
- ├── shell/ # Shell integration modules
24
- ├── utils/ # Utility functions (future)
25
- ├── cli.ts # CLI entry point with performUseEnvironment() shared function
26
- └── index.ts # Module exports
19
+ ~/.ccman/
20
+ ├── config.json # CCM 主配置文件
21
+ ├── providers/ # 供应商配置目录
22
+ ├── anthropic.json # Anthropic 官方配置
23
+ ├── packycode.json # Packycode 配置
24
+ │ └── custom.json # 其他自定义配置
25
+ └── backups/ # 配置备份目录(未来功能)
27
26
  ```
28
27
 
29
- ## Key Features Implemented
30
-
31
- ### 1. Safe Shell Integration Architecture
32
- - **Independent .ccmanrc file**: `~/.ccman/.ccmanrc` contains all environment variables
33
- - **Minimal shell reference**: Single line added to `.bashrc`/`.zshrc` to source .ccmanrc
34
- - **Non-invasive approach**: User's shell config remains largely untouched
35
- - **Easy cleanup**: Remove reference line and delete .ccmanrc file
36
-
37
- ### 2. Interactive Source Control
38
- - After environment switching, user chooses source method:
39
- - **Manual**: User manually sources or restarts terminal (recommended)
40
- - **Auto-source**: Tool attempts automatic sourcing with risk warnings
41
-
42
- ### 3. Unified Use Logic
43
- - `performUseEnvironment()` function provides consistent behavior across:
44
- - `add` command's "set as current" flow
45
- - Standalone `use` command
46
- - `config` command's switch environment option
47
-
48
- ### 4. Complete Interactive Workflows
49
- - **config command**: Full menu-driven interface for all operations
50
- - **add command**: Interactive API key input + use confirmation + source choice
51
- - **Consistent interactions**: All use operations have identical user experience
52
-
53
- ## Current Environment Variables
28
+ ### 项目结构
29
+ ```
30
+ src/
31
+ ├── types/ # TypeScript 类型定义
32
+ ├── core/ # 核心模块
33
+ │ ├── CCMConfigManager.ts # CCM 配置管理
34
+ │ └── ClaudeConfigManager.ts # Claude 配置管理
35
+ ├── providers/ # 供应商管理
36
+ │ └── ProviderManager.ts # 供应商业务逻辑
37
+ ├── cli.ts # CLI 入口点
38
+ └── index.ts # 模块导出
39
+ ```
54
40
 
55
- The tool manages these Claude Code environment variables:
56
- - `ANTHROPIC_BASE_URL`: API base URL
57
- - `ANTHROPIC_AUTH_TOKEN`: API authentication token
41
+ ## 配置文件结构
42
+
43
+ ### CCM 主配置 (~/.ccman/config.json)
44
+ ```json
45
+ {
46
+ "currentProvider": "anthropic",
47
+ "claudeConfigPath": "~/.claude/settings.json",
48
+ "providers": {
49
+ "anthropic": {
50
+ "name": "Anthropic Official",
51
+ "configFile": "anthropic.json",
52
+ "lastUsed": "2025-01-15T10:30:00.000Z"
53
+ }
54
+ },
55
+ "metadata": {
56
+ "version": "2.0.0",
57
+ "createdAt": "2025-01-10T08:00:00.000Z",
58
+ "updatedAt": "2025-01-15T10:30:00.000Z"
59
+ }
60
+ }
61
+ ```
58
62
 
59
- *Note: Updated from previous CLAUDE_API_BASE_URL and ANTHROPIC_API_KEY*
63
+ ### 供应商配置 (~/.ccman/providers/anthropic.json)
64
+ ```json
65
+ {
66
+ "name": "Anthropic Official",
67
+ "description": "Official Anthropic API",
68
+ "config": {
69
+ "env": {
70
+ "ANTHROPIC_AUTH_TOKEN": "sk-xxx",
71
+ "ANTHROPIC_BASE_URL": "https://api.anthropic.com",
72
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1
73
+ },
74
+ "permissions": {
75
+ "allow": [],
76
+ "deny": []
77
+ },
78
+ "apiKeyHelper": "echo 'sk-xxx'"
79
+ },
80
+ "metadata": {
81
+ "createdAt": "2025-01-10T08:00:00.000Z",
82
+ "updatedAt": "2025-01-15T10:30:00.000Z",
83
+ "usageCount": 25
84
+ }
85
+ }
86
+ ```
60
87
 
61
- ## Common Commands
88
+ ## 命令使用
62
89
 
63
- ### Development
90
+ ### 开发命令
64
91
  ```bash
65
- npm run build # Compile TypeScript to dist/
66
- npm run dev # Run CLI in development mode with tsx
67
- npm start # Run compiled CLI
68
- npm run clean # Remove dist/ directory
69
- npm run lint # Run ESLint on TypeScript files (requires config)
92
+ npm run build # 编译 TypeScript
93
+ npm run dev # 开发模式运行
94
+ npm start # 运行编译后的程序
95
+ npm run clean # 清理构建文件
96
+ npm run lint # 代码检查
70
97
  ```
71
98
 
72
- ### Basic Usage
99
+ ### 基础使用(精简版)
73
100
  ```bash
74
- ccman ls # List all environment groups (* = current)
75
- ccman add <name> <url> # Add environment group with interactive flow
76
- ccman use <name> # Switch environment with source interaction
77
- ccman remove <name> # Delete environment group
78
- ccman current # Show current environment
79
- ccman status # Show CCM statistics
80
- ccman config # Interactive configuration menu
81
- ccman clear # Clear all environments and shell integration (DESTRUCTIVE)
101
+ # 核心命令(6个)
102
+ ccman # 交互式菜单(默认入口)
103
+ ccman ls # 智能列表显示(合并原status信息)
104
+ ccman ls --current # 显示当前供应商详情(替代原current)
105
+ ccman ls --brief # 简洁模式显示
106
+ ccman add <id> <name> <url> [key] # 添加供应商配置
107
+ ccman use <id> # 切换到指定供应商
108
+ ccman rm <id> # 删除供应商配置(别名:remove)
109
+ ccman clear # 清除所有配置(别名:reset)
82
110
  ```
83
111
 
84
- ### Advanced Features
112
+ ### 命令详解
85
113
  ```bash
86
- ccman env # Generate shell script for manual sourcing
87
- ccman test [name] # Test environment configuration
88
- ccman add <name> <url> --no-auto-write # Add without shell integration
89
- ccman use <name> --no-auto-write # Switch without shell integration
90
- ccman use <name> --auto-source # Force auto-source with risk warning
114
+ # 默认交互模式 - 最直观的入口
115
+ ccman # 进入菜单,包含所有操作(添加/切换/更新/删除/状态)
116
+
117
+ # 智能列表命令 - 整合了多种信息显示
118
+ ccman ls # 显示所有供应商 + 系统状态信息
119
+ ccman ls --current # 仅显示当前供应商的详细信息
120
+ ccman ls --brief # 简洁模式,仅显示供应商名称和ID
121
+
122
+ # 快速操作命令 - 适合脚本和熟练用户
123
+ ccman add <id> <name> <url> [key] -d "description" # 添加时指定描述
124
+ ccman use <id> # 快速切换
125
+ ccman rm <id> # 快速删除
126
+ ccman clear # 重置所有配置
91
127
  ```
92
128
 
93
- ## Implementation Details
94
-
95
- ### 1. Environment Group Management
96
- - Add/remove/switch between environment groups
97
- - Each group contains: name, baseUrl, apiKey, timestamps
98
- - Automatic validation of URLs and required fields
99
- - Interactive API key input if not provided
100
-
101
- ### 2. Shell Integration Process
102
- 1. **Write .ccmanrc**: Environment variables written to `~/.ccman/.ccmanrc`
103
- 2. **Add reference**: Shell config updated to source .ccmanrc if not already present
104
- 3. **User choice**: Interactive prompt for sourcing method
105
- 4. **Auto-source**: Optional automatic sourcing with error handling
106
-
107
- ### 3. Type Safety Implementation
108
- - Full TypeScript implementation with strict typing
109
- - Interfaces for all data structures and operations:
110
- - `ClaudeEnv`: Environment configuration
111
- - `ShellEnvVars`: Environment variables with correct naming
112
- - `AddEnvOptions`: Add operation parameters
113
- - `ShellWriteResult`: Shell operation results
114
- - Compile-time error checking
115
-
116
- ### 4. Interactive CLI Features
117
- - Inquirer.js for consistent prompts
118
- - Colored output with chalk
119
- - Confirmation prompts for destructive operations
120
- - Menu-driven configuration interface
121
- - Progress feedback and error handling
122
-
123
- ## Configuration Storage
124
-
125
- - Config directory: `~/.ccman/`
126
- - Main config: `~/.ccman/config.json`
127
- - Environment variables: `~/.ccman/.ccmanrc`
128
- - Structure includes environments, current selection, and global settings
129
-
130
- ## Shell Integration Technical Details
131
-
132
- ### File Locations
133
- - **Configuration**: `~/.ccman/.ccmanrc` - Contains current environment variables
134
- - **Shell reference**: Added to `.bashrc`, `.zshrc`, or `config.fish`
135
- - **Detection order**: zsh → bash → fish → fallback
136
-
137
- ### Shell Reference Format
138
- ```bash
139
- # CCM (Claude Code Manager) - Auto Generated Reference
140
- # This line sources CCM environment variables from /home/user/.ccman/.ccmanrc
141
- [ -f "/home/user/.ccman/.ccmanrc" ] && source "/home/user/.ccman/.ccmanrc"
142
- # End CCM Reference
129
+ ## 核心类型定义
130
+
131
+ ### ClaudeSettings
132
+ Claude settings.json 的标准结构
133
+ ```typescript
134
+ interface ClaudeSettings {
135
+ env: {
136
+ ANTHROPIC_AUTH_TOKEN: string;
137
+ ANTHROPIC_BASE_URL: string;
138
+ CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC?: number;
139
+ };
140
+ permissions: { allow: string[]; deny: string[]; };
141
+ apiKeyHelper: string;
142
+ }
143
143
  ```
144
144
 
145
- ### .ccmanrc File Format
145
+ ### ProviderConfig
146
+ 供应商配置结构
147
+ ```typescript
148
+ interface ProviderConfig {
149
+ name: string;
150
+ description: string;
151
+ config: ClaudeSettings;
152
+ metadata: {
153
+ createdAt: string;
154
+ updatedAt: string;
155
+ usageCount: number;
156
+ };
157
+ }
158
+ ```
159
+
160
+ ## 关键特性
161
+
162
+ ### 1. 直接配置修改
163
+ - 直接读写 `~/.claude/settings.json`
164
+ - **选择性覆盖**: 只修改CCM管理的key,保留用户其他配置
165
+ - 无需重启终端或 source 任何文件
166
+ - 配置切换立即生效
167
+
168
+ #### CCM管理的配置项
169
+ ```json
170
+ {
171
+ "env": {
172
+ "ANTHROPIC_AUTH_TOKEN": "...", // ✅ CCM管理
173
+ "ANTHROPIC_BASE_URL": "...", // ✅ CCM管理
174
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1 // ✅ CCM管理
175
+ },
176
+ "permissions": {
177
+ "allow": [], // ✅ CCM管理
178
+ "deny": [] // ✅ CCM管理
179
+ },
180
+ "apiKeyHelper": "..." // ✅ CCM管理
181
+ }
182
+ ```
183
+
184
+ #### 用户配置保护
185
+ - 保留所有其他用户自定义配置项
186
+ - 保留 `env` 中其他环境变量
187
+ - 保留 `permissions` 中其他权限设置
188
+ - 保留所有非CCM管理的顶级配置项
189
+
190
+ ### 2. 自动备份机制
191
+ - 每次切换前自动备份当前配置
192
+ - 备份文件带时间戳,便于恢复
193
+ - 防止配置丢失和冲突
194
+
195
+ ### 3. 交互式界面
196
+ - 使用 inquirer.js 提供友好的交互体验
197
+ - 彩色输出和进度反馈
198
+ - 确认提示防止误操作
199
+
200
+ ### 4. 类型安全
201
+ - 完整的 TypeScript 类型定义
202
+ - 编译时错误检查
203
+ - 严格的接口约束
204
+
205
+ ## 安全注意事项
206
+
207
+ ### 🚨 开发时的重要限制
208
+
209
+ **绝对禁止修改以下文件(会导致系统不可用):**
210
+ - `~/.ccman/config.json` - 现有历史配置文件
211
+ - `~/.claude/settings.json` - Claude Code 配置文件
212
+
213
+ **开发时的安全做法:**
214
+ 1. **使用测试目录**: 开发时使用 `~/.ccman-dev/` 或其他测试目录
215
+ 2. **配置隔离**: 通过环境变量指定不同的配置路径
216
+ 3. **备份验证**: 修改前确保备份机制正常工作
217
+ 4. **分步测试**: 先测试读取,再测试写入功能
218
+
219
+ ### 开发环境配置
146
220
  ```bash
147
- # CCM (Claude Code Manager) Environment Variables - Auto Generated
148
- # Generated at: 2025-08-06 11:45:30
149
- # Environment: production
150
- export ANTHROPIC_BASE_URL="https://api.anthropic.com"
151
- export ANTHROPIC_AUTH_TOKEN="your-api-key"
152
- # End CCM Environment Variables
221
+ # 设置开发环境配置路径
222
+ export CCM_CONFIG_DIR="~/.ccman-dev"
223
+ export CLAUDE_CONFIG_PATH="~/.claude/settings-dev.json"
224
+
225
+ # 或在代码中使用环境变量
226
+ const configDir = process.env.CCM_CONFIG_DIR || path.join(os.homedir(), '.ccman');
153
227
  ```
154
228
 
155
- ## Build Process
156
-
157
- 1. TypeScript compilation targets ES2020 with CommonJS modules
158
- 2. Output goes to `dist/` directory with source maps
159
- 3. CLI entry point is `dist/cli.js` with proper shebang
160
- 4. Supports both development (`tsx`) and production (`node`) execution
161
-
162
- ## Code Organization
163
-
164
- ### CLI Structure (`src/cli.ts`)
165
- - **performUseEnvironment()**: Shared function for consistent use behavior across commands
166
- - **Command definitions**: Using Commander.js with proper option handling
167
- - **Interactive prompts**: Inquirer.js integration for user input
168
- - **Error handling**: Consistent error reporting and process exit codes
169
-
170
- ### Shell Manager (`src/shell/ShellManager.ts`)
171
- - **.ccmanrc management**: Independent file creation and updates
172
- - **Shell reference management**: Minimal invasive approach
173
- - **Auto-source capability**: Subprocess execution with error handling
174
- - **Multi-shell support**: bash, zsh, fish detection and handling
175
-
176
- ### Environment Manager (`src/config/EnvironmentManager.ts`)
177
- - **High-level operations**: Add, remove, update, switch environments
178
- - **Shell integration coordination**: Works with ShellManager for safe updates
179
- - **Validation**: URL validation, environment name checking
180
- - **Statistics**: Usage tracking and reporting
181
-
182
- ## Recent Major Changes
183
-
184
- 1. **Shell Architecture Redesign**: From direct modification to .ccmanrc + reference approach
185
- 2. **Environment Variable Renaming**: Updated to ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN
186
- 3. **Interactive Source Control**: Added user choice for manual vs automatic sourcing
187
- 4. **Unified Use Logic**: Single function for consistent behavior across all use scenarios
188
- 5. **Time Format Improvement**: Human-readable timestamps instead of ISO format
189
- 6. **Enhanced config Command**: Complete menu-driven interface for all operations
190
- 7. **Clear All Functionality**: Added clearAll command for complete CCM reset with confirmation
191
-
192
- ## Testing Approach
193
-
194
- - Manual testing of CLI interactions
195
- - Verification of file system operations
196
- - Shell integration testing across different shells
197
- - Error condition handling validation
198
- - User experience flow testing
199
-
200
- ## Important Notes for Development
201
-
202
- - **Always test shell integration**: Verify .ccmanrc creation and shell reference addition
203
- - **Test interactive flows**: Ensure prompts work correctly in different scenarios
204
- - **Validate file operations**: Check permissions and error handling
205
- - **Cross-shell compatibility**: Test with bash, zsh, and fish when possible
206
- - **User experience focus**: Prioritize clear messaging and helpful guidance
207
-
208
- ## Future Enhancement Areas
209
-
210
- - Configuration validation and migration
211
- - Backup and restore functionality
212
- - Environment templates or presets
213
- - Integration with external credential stores
214
- - Enhanced error reporting and diagnostics
215
- - Network connectivity testing for environments
229
+ ## 构建和部署
230
+
231
+ ### TypeScript 编译
232
+ - 目标: ES2020, CommonJS 模块
233
+ - 输出: `dist/` 目录,包含源映射
234
+ - CLI 入口: `dist/cli.js` 带正确的 shebang
235
+
236
+ ### 依赖管理
237
+ - 使用 pnpm 管理依赖
238
+ - 包含所有必要的类型声明
239
+ - 严格的版本控制
240
+
241
+ ## 测试方法
242
+
243
+ ### 功能测试
244
+ - CLI 命令交互测试
245
+ - 文件系统操作验证
246
+ - 配置切换流程测试
247
+ - 错误处理验证
248
+
249
+ ### 安全测试
250
+ - 备份机制验证
251
+ - 权限检查
252
+ - 配置文件完整性
253
+ - 回滚功能测试
254
+
255
+ ## 未来改进
256
+
257
+ ### 计划功能
258
+ - 配置模板和预设
259
+ - 批量配置管理
260
+ - 网络连接测试
261
+ - 配置迁移工具
262
+ - 增强的错误诊断
263
+
264
+ ### 架构优化
265
+ - 插件化供应商支持
266
+ - 配置验证和修复
267
+ - 更好的备份策略
268
+ - 性能优化
269
+
270
+ ## 开发注意事项
271
+
272
+ - **测试优先**: 修改任何配置管理逻辑前先测试
273
+ - **备份验证**: 确保每次操作都有可靠的备份
274
+ - **用户体验**: 提供清晰的反馈和错误信息
275
+ - **向后兼容**: 考虑现有用户的配置迁移
276
+ - **安全第一**: 绝不能破坏用户的现有配置