ccconfig 1.4.1 → 1.4.2

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.md CHANGED
@@ -38,7 +38,7 @@ ccconfig use personal --permanent # or use -p for short
38
38
  npm install -g ccconfig
39
39
  ```
40
40
 
41
- ### Method 1: Direct Start Mode (Recommended 🚀)
41
+ ### Method 1: Direct Start Mode (Recommended)
42
42
 
43
43
  The easiest way to use ccconfig - directly start Claude Code with a specific profile:
44
44
 
@@ -64,21 +64,21 @@ ccconfig safe-start work # Safe mode (requires confirmation for each com
64
64
  - **`ccconfig start`** - Auto-approve mode
65
65
  - Automatically adds `--dangerously-skip-permissions` flag
66
66
  - Commands execute without confirmation prompts
67
- - ⚠️ **Only use with profiles you trust**
67
+ - **Only use with profiles you trust**
68
68
  - Perfect for: personal projects, trusted company profiles, rapid development
69
69
 
70
70
  - **`ccconfig safe-start`** - Safe mode
71
71
  - Does NOT add `--dangerously-skip-permissions`
72
72
  - Requires manual confirmation before executing each command
73
- - **Recommended for production or untrusted environments**
73
+ - **Recommended for production or untrusted environments**
74
74
  - Perfect for: production systems, new profiles, sensitive data
75
75
 
76
76
  **Advantages:**
77
- - No shell configuration needed
78
- - No manual switching required
79
- - Environment variables automatically injected
80
- - Works across all shells
81
- - Pass additional arguments: `ccconfig start work /path/to/project --verbose`
77
+ - No shell configuration needed
78
+ - No manual switching required
79
+ - Environment variables automatically injected
80
+ - Works across all shells
81
+ - Pass additional arguments: `ccconfig start work /path/to/project --verbose`
82
82
 
83
83
  ### Method 2: Manual Switch Mode
84
84
 
@@ -269,11 +269,11 @@ Do you want to set ANTHROPIC_SMALL_FAST_MODEL? (y/N) [n]:
269
269
  ccconfig supports shell completion for commands, profile names, and options. This makes it easier to discover and use commands.
270
270
 
271
271
  **Features:**
272
- - Command completion (list, add, update, use, remove, etc.)
273
- - Profile name completion (dynamically reads from your configurations)
274
- - Option completion (--permanent, --show-secret, etc.)
275
- - Mode completion (settings, env)
276
- - Format completion (bash, zsh, fish, etc.)
272
+ - Command completion (list, add, update, use, remove, etc.)
273
+ - Profile name completion (dynamically reads from your configurations)
274
+ - Option completion (--permanent, --show-secret, etc.)
275
+ - Mode completion (settings, env)
276
+ - Format completion (bash, zsh, fish, etc.)
277
277
 
278
278
  **Installation:**
279
279
 
package/README_zh.md CHANGED
@@ -38,7 +38,7 @@ ccconfig use personal --permanent # 或使用 -p 简写
38
38
  npm install -g ccconfig
39
39
  ```
40
40
 
41
- ### 方式 1:直接启动模式(推荐 🚀)
41
+ ### 方式 1:直接启动模式(推荐)
42
42
 
43
43
  最简单的使用方式 - 直接使用指定配置启动 Claude Code:
44
44
 
@@ -64,21 +64,21 @@ ccconfig safe-start work # 安全模式(每个命令需要确认)
64
64
  - **`ccconfig start`** - 自动批准模式
65
65
  - 自动添加 `--dangerously-skip-permissions` 标志
66
66
  - 命令无需确认直接执行
67
- - ⚠️ **仅在您信任的配置中使用**
67
+ - **仅在您信任的配置中使用**
68
68
  - 适用场景:个人项目、可信的公司配置、快速开发
69
69
 
70
70
  - **`ccconfig safe-start`** - 安全模式
71
71
  - 不添加 `--dangerously-skip-permissions`
72
72
  - 执行每个命令前需要手动确认
73
- - **推荐用于生产环境或不可信环境**
73
+ - **推荐用于生产环境或不可信环境**
74
74
  - 适用场景:生产系统、新配置、敏感数据
75
75
 
76
76
  **优势:**
77
- - 无需配置 shell
78
- - 无需手动切换
79
- - 自动注入环境变量
80
- - 支持所有 shell
81
- - 可传递额外参数:`ccconfig start work /path/to/project --verbose`
77
+ - 无需配置 shell
78
+ - 无需手动切换
79
+ - 自动注入环境变量
80
+ - 支持所有 shell
81
+ - 可传递额外参数:`ccconfig start work /path/to/project --verbose`
82
82
 
83
83
  ### 方式 2:手动切换模式
84
84
 
@@ -269,11 +269,11 @@ Do you want to set ANTHROPIC_SMALL_FAST_MODEL? (y/N) [n]:
269
269
  ccconfig 支持命令、配置名称和选项的 shell 自动补全,让您更容易发现和使用命令。
270
270
 
271
271
  **功能:**
272
- - 命令补全 (list, add, update, use, remove 等)
273
- - 配置名称补全(动态读取您的配置)
274
- - 选项补全 (--permanent, --show-secret 等)
275
- - 模式补全 (settings, env)
276
- - 格式补全 (bash, zsh, fish 等)
272
+ - 命令补全 (list, add, update, use, remove 等)
273
+ - 配置名称补全(动态读取您的配置)
274
+ - 选项补全 (--permanent, --show-secret 等)
275
+ - 模式补全 (settings, env)
276
+ - 格式补全 (bash, zsh, fish 等)
277
277
 
278
278
  **安装:**
279
279
 
package/ccconfig.js CHANGED
@@ -1420,7 +1420,10 @@ function startClaude(name, extraArgs = [], options = {}) {
1420
1420
  // Normalize all profile env values to strings (spawn requires string values)
1421
1421
  const normalizedEnv = {};
1422
1422
  for (const [key, value] of Object.entries(profile.env)) {
1423
- normalizedEnv[key] = String(value ?? '');
1423
+ if (value === undefined || value === null) {
1424
+ continue;
1425
+ }
1426
+ normalizedEnv[key] = typeof value === 'string' ? value : String(value);
1424
1427
  }
1425
1428
  const envVars = {...process.env, ...normalizedEnv};
1426
1429
 
@@ -1430,21 +1433,91 @@ function startClaude(name, extraArgs = [], options = {}) {
1430
1433
  stdio: 'inherit' // Inherit stdin, stdout, stderr from parent process
1431
1434
  });
1432
1435
 
1436
+ // Function to restore terminal state and exit
1437
+ const exitGracefully = (code) => {
1438
+ // Reset terminal to normal mode (in case it was left in raw mode)
1439
+ if (process.stdin.isTTY && process.stdin.setRawMode) {
1440
+ try {
1441
+ process.stdin.setRawMode(false);
1442
+ } catch (e) {
1443
+ // Ignore errors during cleanup
1444
+ }
1445
+ }
1446
+
1447
+ const canResetTerminal = process.platform !== 'win32' && process.stdin.isTTY && process.stdout.isTTY;
1448
+
1449
+ // Use stty to restore terminal settings on Unix-like systems
1450
+ // This is more comprehensive than just setRawMode
1451
+ if (canResetTerminal) {
1452
+ try {
1453
+ // 'stty sane' restores terminal to sensible settings
1454
+ // Use stdio: 'inherit' to ensure it operates on the same terminal
1455
+ execSync('stty sane', { stdio: 'inherit' });
1456
+ } catch (e) {
1457
+ // If stty fails, try basic echo and icanon reset
1458
+ try {
1459
+ execSync('stty echo icanon', { stdio: 'inherit' });
1460
+ } catch (e2) {
1461
+ try {
1462
+ execSync('stty echo', { stdio: 'inherit' });
1463
+ execSync('stty icanon', { stdio: 'inherit' });
1464
+ } catch (e3) {
1465
+ // Ignore - best effort
1466
+ }
1467
+ }
1468
+ }
1469
+ }
1470
+
1471
+ process.exit(code || 0);
1472
+ };
1473
+
1474
+ // Handle SIGINT (Ctrl+C) and SIGTERM
1475
+ const signalHandler = (signal) => {
1476
+ // Forward signal to child process
1477
+ if (claude && !claude.killed) {
1478
+ claude.kill(signal);
1479
+ }
1480
+ // Don't exit immediately - wait for child to exit
1481
+ };
1482
+
1483
+ process.on('SIGINT', signalHandler);
1484
+ process.on('SIGTERM', signalHandler);
1485
+
1433
1486
  // Handle process exit
1434
1487
  claude.on('close', (code) => {
1488
+ // Remove signal handlers to avoid duplicate handling
1489
+ process.removeListener('SIGINT', signalHandler);
1490
+ process.removeListener('SIGTERM', signalHandler);
1491
+
1492
+ // Show project promotion message on exit
1493
+ console.log('');
1494
+ console.log('──────────────────────────────────────────');
1495
+ console.log('Thanks for using ccconfig!');
1496
+ console.log('');
1497
+ console.log('If you find this tool helpful, please consider:');
1498
+ console.log(' ⭐ Star us on GitHub: https://github.com/Danielmelody/ccconfig');
1499
+ console.log(' 📢 Share with others who use Claude Code');
1500
+ console.log('──────────────────────────────────────────');
1501
+ console.log('');
1502
+
1435
1503
  if (code !== 0 && code !== null) {
1436
1504
  console.error(`Claude Code exited with code ${code}`);
1437
- process.exit(code);
1505
+ exitGracefully(code);
1506
+ } else {
1507
+ exitGracefully(0);
1438
1508
  }
1439
- process.exit(0);
1440
1509
  });
1441
1510
 
1442
1511
  claude.on('error', (err) => {
1512
+ // Remove signal handlers
1513
+ process.removeListener('SIGINT', signalHandler);
1514
+ process.removeListener('SIGTERM', signalHandler);
1515
+
1443
1516
  console.error(`Error starting Claude Code: ${err.message}`);
1444
1517
  console.error('');
1445
1518
  console.error('Please make sure Claude Code CLI is installed:');
1446
1519
  console.error(' npm install -g claude-code');
1447
- process.exit(1);
1520
+ exitGracefully(1);
1448
1521
  });
1449
1522
  }
1450
1523
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccconfig",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Cross-platform Claude Code configuration switching tool",
5
5
  "main": "ccconfig.js",
6
6
  "bin": {