claude-code-autoconfig 1.0.15 → 1.0.16

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.
@@ -42,7 +42,7 @@
42
42
  "hooks": [
43
43
  {
44
44
  "type": "command",
45
- "command": "case \"$OSTYPE\" in darwin*|linux-gnu*) printf '\\033]0;claude\\007';; msys*|cygwin*) cmd.exe /c \"title claude\" 2>/dev/null;; esac"
45
+ "command": "printf '\\033]0;claude\\007' || true"
46
46
  }
47
47
  ]
48
48
  }
@@ -7,13 +7,7 @@
7
7
  "Bash(del /q \"C:\\\\CODE\\\\claude-code-autoconfig\\\\.claude\\\\retro\\\\_TEMPLATE.md\")",
8
8
  "Bash(git mv:*)",
9
9
  "WebFetch(domain:github.com)",
10
- "WebFetch(domain:agentskills.io)",
11
- "Bash(npm link)",
12
- "Bash(npm pack:*)",
13
- "Bash(npm login)",
14
- "Bash(npm login --auth-type=web)",
15
- "Bash(npm publish:*)",
16
- "Bash(npm config set:*)"
10
+ "Bash(npm publish:*)"
17
11
  ]
18
12
  }
19
13
  }
package/bin/cli.js CHANGED
@@ -13,11 +13,43 @@ const WINDOWS_RESERVED = ['CON', 'PRN', 'AUX', 'NUL', 'COM1', 'COM2', 'COM3', 'C
13
13
  'COM5', 'COM6', 'COM7', 'COM8', 'COM9', 'LPT1', 'LPT2', 'LPT3', 'LPT4', 'LPT5',
14
14
  'LPT6', 'LPT7', 'LPT8', 'LPT9'];
15
15
 
16
+ // Files/folders installed by autoconfig - don't backup these
17
+ const AUTOCONFIG_FILES = ['commands', 'guide', 'agents', 'migration'];
18
+
16
19
  function isReservedName(name) {
17
20
  const baseName = name.replace(/\.[^.]*$/, '').toUpperCase();
18
21
  return WINDOWS_RESERVED.includes(baseName);
19
22
  }
20
23
 
24
+ function hasUserContent(claudeDir) {
25
+ // Check if .claude/ has any files beyond what autoconfig installs
26
+ if (!fs.existsSync(claudeDir)) return false;
27
+
28
+ const entries = fs.readdirSync(claudeDir);
29
+ for (const entry of entries) {
30
+ if (!AUTOCONFIG_FILES.includes(entry)) {
31
+ // Found something that's not from autoconfig
32
+ return true;
33
+ }
34
+ }
35
+ return false;
36
+ }
37
+
38
+ function formatTimestamp() {
39
+ const now = new Date();
40
+ const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
41
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
42
+ const month = months[now.getMonth()];
43
+ const day = now.getDate();
44
+ const year = now.getFullYear();
45
+ const hour = now.getHours();
46
+ const min = String(now.getMinutes()).padStart(2, '0');
47
+ const ampm = hour >= 12 ? 'pm' : 'am';
48
+ const hour12 = hour % 12 || 12;
49
+
50
+ return `${month}-${day}-${year}_${hour12}-${min}${ampm}`;
51
+ }
52
+
21
53
  console.log('\x1b[36m%s\x1b[0m', '🚀 Claude Code Autoconfig');
22
54
  console.log();
23
55
 
@@ -54,7 +86,7 @@ if (!isClaudeInstalled()) {
54
86
 
55
87
  console.log('\x1b[32m%s\x1b[0m', '✅ Claude Code detected');
56
88
 
57
- // Step 2: Backup existing .claude/ if present
89
+ // Step 2: Backup existing .claude/ if it has user content
58
90
  const claudeDest = path.join(cwd, '.claude');
59
91
  const SKIP_BACKUP = ['migration']; // Don't backup the migration folder itself
60
92
  let migrationPath = null;
@@ -65,6 +97,7 @@ function copyDirForBackup(src, dest) {
65
97
 
66
98
  for (const entry of entries) {
67
99
  if (SKIP_BACKUP.includes(entry.name)) continue;
100
+ if (AUTOCONFIG_FILES.includes(entry.name)) continue; // Skip autoconfig-installed files
68
101
  if (isReservedName(entry.name)) continue;
69
102
 
70
103
  const srcPath = path.join(src, entry.name);
@@ -92,32 +125,33 @@ function collectFiles(dir, prefix = '') {
92
125
  return files;
93
126
  }
94
127
 
95
- if (fs.existsSync(claudeDest)) {
96
- // Check if there are files worth backing up (not just empty dirs)
97
- const existingEntries = fs.readdirSync(claudeDest).filter(e => e !== 'migration');
128
+ if (fs.existsSync(claudeDest) && hasUserContent(claudeDest)) {
129
+ const timestamp = formatTimestamp();
130
+ const migrationDir = path.join(claudeDest, 'migration');
131
+ migrationPath = path.join(migrationDir, timestamp);
98
132
 
99
- if (existingEntries.length > 0) {
100
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
101
- const migrationDir = path.join(claudeDest, 'migration');
102
- migrationPath = path.join(migrationDir, timestamp);
133
+ fs.mkdirSync(migrationPath, { recursive: true });
103
134
 
104
- fs.mkdirSync(migrationPath, { recursive: true });
135
+ // Copy user files to backup (excluding autoconfig-installed files)
136
+ const existingEntries = fs.readdirSync(claudeDest).filter(e =>
137
+ e !== 'migration' && !AUTOCONFIG_FILES.includes(e)
138
+ );
105
139
 
106
- // Copy existing files to backup
107
- for (const entry of existingEntries) {
108
- const srcPath = path.join(claudeDest, entry);
109
- const destPath = path.join(migrationPath, entry);
140
+ for (const entry of existingEntries) {
141
+ const srcPath = path.join(claudeDest, entry);
142
+ const destPath = path.join(migrationPath, entry);
110
143
 
111
- if (fs.statSync(srcPath).isDirectory()) {
112
- copyDirForBackup(srcPath, destPath);
113
- } else {
114
- fs.copyFileSync(srcPath, destPath);
115
- }
144
+ if (fs.statSync(srcPath).isDirectory()) {
145
+ copyDirForBackup(srcPath, destPath);
146
+ } else {
147
+ fs.copyFileSync(srcPath, destPath);
116
148
  }
149
+ }
117
150
 
118
- // Collect backed up files for metadata
119
- const backedUpFiles = collectFiles(migrationPath);
151
+ // Collect backed up files for metadata
152
+ const backedUpFiles = collectFiles(migrationPath);
120
153
 
154
+ if (backedUpFiles.length > 0) {
121
155
  // Write latest.json for the guide
122
156
  fs.writeFileSync(path.join(migrationDir, 'latest.json'), JSON.stringify({
123
157
  timestamp: timestamp,
@@ -150,6 +184,9 @@ cp .claude/migration/${timestamp}/settings.json .claude/settings.json
150
184
  fs.writeFileSync(path.join(migrationPath, 'README.md'), backupReadme);
151
185
 
152
186
  console.log('\x1b[33m%s\x1b[0m', `⚠️ Backed up existing config to .claude/migration/${timestamp}/`);
187
+ } else {
188
+ // No user files to backup, remove the empty migration folder
189
+ fs.rmdirSync(migrationPath, { recursive: true });
153
190
  }
154
191
  }
155
192
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-autoconfig",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "Intelligent, self-configuring setup for Claude Code. One command analyzes your project, configures Claude, and shows you what it did.",
5
5
  "author": "ADAC 1001 <info@adac1001.com>",
6
6
  "license": "MIT",