@kaitranntt/ccs 5.4.2-dev.1 → 5.4.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/VERSION CHANGED
@@ -1 +1 @@
1
- 5.4.2-dev.1
1
+ 5.4.3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaitranntt/ccs",
3
- "version": "5.4.2-dev.1",
3
+ "version": "5.4.3",
4
4
  "description": "Claude Code Switch - Instant profile switching between Claude Sonnet 4.5 and GLM 4.6",
5
5
  "keywords": [
6
6
  "cli",
@@ -24,6 +24,35 @@ function getCcsHome() {
24
24
  return process.env.CCS_HOME || os.homedir();
25
25
  }
26
26
 
27
+ /**
28
+ * Check if path is a broken symlink and remove it if so
29
+ * Fixes: ENOENT error when mkdir tries to create over a dangling symlink
30
+ * @param {string} targetPath - Path to check
31
+ * @returns {boolean} true if broken symlink was removed
32
+ */
33
+ function removeIfBrokenSymlink(targetPath) {
34
+ try {
35
+ // lstatSync doesn't follow symlinks - it checks the link itself
36
+ const stats = fs.lstatSync(targetPath);
37
+ if (stats.isSymbolicLink()) {
38
+ // Check if symlink target exists
39
+ try {
40
+ fs.statSync(targetPath); // This follows symlinks
41
+ return false; // Symlink is valid
42
+ } catch {
43
+ // Target doesn't exist - broken symlink
44
+ fs.unlinkSync(targetPath);
45
+ console.log(`[!] Removed broken symlink: ${targetPath}`);
46
+ return true;
47
+ }
48
+ }
49
+ return false;
50
+ } catch {
51
+ // Path doesn't exist at all
52
+ return false;
53
+ }
54
+ }
55
+
27
56
  /**
28
57
  * Validate created configuration files
29
58
  * @returns {object} { success: boolean, errors: string[], warnings: string[] }
@@ -85,6 +114,8 @@ function createConfigFiles() {
85
114
 
86
115
  // Create ~/.ccs/shared/ directory structure (Phase 1)
87
116
  const sharedDir = path.join(ccsDir, 'shared');
117
+ // Handle broken symlinks (common when upgrading from older versions)
118
+ removeIfBrokenSymlink(sharedDir);
88
119
  if (!fs.existsSync(sharedDir)) {
89
120
  fs.mkdirSync(sharedDir, { recursive: true, mode: 0o755 });
90
121
  console.log('[OK] Created directory: ~/.ccs/shared/');
@@ -94,6 +125,8 @@ function createConfigFiles() {
94
125
  const sharedSubdirs = ['commands', 'skills', 'agents', 'plugins'];
95
126
  for (const subdir of sharedSubdirs) {
96
127
  const subdirPath = path.join(sharedDir, subdir);
128
+ // Handle broken symlinks before creating directory
129
+ removeIfBrokenSymlink(subdirPath);
97
130
  if (!fs.existsSync(subdirPath)) {
98
131
  fs.mkdirSync(subdirPath, { recursive: true, mode: 0o755 });
99
132
  console.log(`[OK] Created directory: ~/.ccs/shared/${subdir}/`);