coder-config 0.44.49 → 0.44.51

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/config-loader.js CHANGED
@@ -40,15 +40,16 @@ class ClaudeConfigManager {
40
40
  const newDir = path.join(home, '.coder-config');
41
41
  const legacyDir = path.join(home, '.claude-config');
42
42
 
43
- // Use new location, but fall back to legacy if it has data and new doesn't
43
+ // Use configured location or default to new
44
44
  if (process.env.CLAUDE_CONFIG_HOME) {
45
45
  this.installDir = process.env.CLAUDE_CONFIG_HOME;
46
- } else if (fs.existsSync(path.join(legacyDir, 'projects.json')) &&
47
- !fs.existsSync(path.join(newDir, 'projects.json'))) {
48
- // Legacy has data, new doesn't - use legacy for backwards compatibility
49
- this.installDir = legacyDir;
50
46
  } else {
51
47
  this.installDir = newDir;
48
+
49
+ // Auto-migrate from legacy directory if it exists
50
+ if (fs.existsSync(legacyDir)) {
51
+ this._autoMigrate(legacyDir, newDir);
52
+ }
52
53
  }
53
54
 
54
55
  // Look for registry in multiple places
@@ -60,6 +61,49 @@ class ClaudeConfigManager {
60
61
  this.registryPath = possiblePaths.find(p => fs.existsSync(p)) || possiblePaths[0];
61
62
  }
62
63
 
64
+ // Auto-migrate from legacy directory (called from constructor)
65
+ _autoMigrate(legacyDir, newDir) {
66
+ try {
67
+ const migrated = this._migrateDir(legacyDir, newDir);
68
+ if (migrated > 0) {
69
+ console.log(`\n✓ Auto-migrated ${migrated} item(s) from ~/.claude-config to ~/.coder-config`);
70
+ console.log(' To complete migration: rm -rf ~/.claude-config\n');
71
+ }
72
+ } catch (e) {
73
+ // Silently ignore migration errors - don't break startup
74
+ }
75
+ }
76
+
77
+ // Recursively migrate directory contents (merges with existing)
78
+ _migrateDir(srcDir, destDir) {
79
+ if (!fs.existsSync(srcDir)) return 0;
80
+
81
+ const items = fs.readdirSync(srcDir);
82
+ if (items.length === 0) return 0;
83
+
84
+ // Ensure destination exists
85
+ if (!fs.existsSync(destDir)) {
86
+ fs.mkdirSync(destDir, { recursive: true });
87
+ }
88
+
89
+ let migrated = 0;
90
+ for (const item of items) {
91
+ const src = path.join(srcDir, item);
92
+ const dest = path.join(destDir, item);
93
+ const srcStat = fs.statSync(src);
94
+
95
+ if (srcStat.isDirectory()) {
96
+ // Recursively migrate directory contents
97
+ migrated += this._migrateDir(src, dest);
98
+ } else if (!fs.existsSync(dest)) {
99
+ // Copy file if it doesn't exist in destination
100
+ fs.copyFileSync(src, dest);
101
+ migrated++;
102
+ }
103
+ }
104
+ return migrated;
105
+ }
106
+
63
107
  // Utils
64
108
  loadJson(filePath) { return loadJson(filePath); }
65
109
  saveJson(filePath, data) { return saveJson(filePath, data); }
@@ -346,6 +390,97 @@ class ClaudeConfigManager {
346
390
  return updated > 0;
347
391
  }
348
392
 
393
+ // Migrate from legacy to new directory
394
+ migrate(options = {}) {
395
+ const home = process.env.HOME || '';
396
+ const legacyDir = path.join(home, '.claude-config');
397
+ const newDir = path.join(home, '.coder-config');
398
+
399
+ // Check if legacy exists
400
+ if (!fs.existsSync(legacyDir)) {
401
+ console.log('No legacy directory found (~/.claude-config)');
402
+ console.log(`Already using: ${this.installDir}`);
403
+ return false;
404
+ }
405
+
406
+ // Check what's in legacy
407
+ const legacyFiles = fs.readdirSync(legacyDir);
408
+ if (legacyFiles.length === 0) {
409
+ console.log('Legacy directory is empty');
410
+ if (options.removeEmpty) {
411
+ fs.rmdirSync(legacyDir);
412
+ console.log('✓ Removed empty legacy directory');
413
+ }
414
+ return false;
415
+ }
416
+
417
+ console.log(`\nMigrating from ~/.claude-config to ~/.coder-config\n`);
418
+ console.log('Legacy contents:');
419
+ legacyFiles.forEach(f => console.log(` - ${f}`));
420
+ console.log('');
421
+
422
+ // Ensure new directory exists
423
+ if (!fs.existsSync(newDir)) {
424
+ fs.mkdirSync(newDir, { recursive: true });
425
+ }
426
+
427
+ // Copy each item
428
+ let migrated = 0;
429
+ let skipped = 0;
430
+ for (const item of legacyFiles) {
431
+ const src = path.join(legacyDir, item);
432
+ const dest = path.join(newDir, item);
433
+
434
+ if (fs.existsSync(dest)) {
435
+ if (options.force) {
436
+ // Remove existing and replace
437
+ if (fs.statSync(dest).isDirectory()) {
438
+ fs.rmSync(dest, { recursive: true });
439
+ } else {
440
+ fs.unlinkSync(dest);
441
+ }
442
+ } else {
443
+ console.log(` ⊘ Skipped ${item} (already exists in new location)`);
444
+ skipped++;
445
+ continue;
446
+ }
447
+ }
448
+
449
+ // Copy file or directory
450
+ if (fs.statSync(src).isDirectory()) {
451
+ copyDirRecursive(src, dest);
452
+ } else {
453
+ fs.copyFileSync(src, dest);
454
+ }
455
+ console.log(` ✓ Migrated ${item}`);
456
+ migrated++;
457
+ }
458
+
459
+ console.log('');
460
+
461
+ if (migrated > 0) {
462
+ console.log(`✅ Migrated ${migrated} item(s)`);
463
+
464
+ // Update installDir for this session
465
+ this.installDir = newDir;
466
+
467
+ if (options.removeLegacy) {
468
+ fs.rmSync(legacyDir, { recursive: true });
469
+ console.log('✓ Removed legacy directory');
470
+ } else {
471
+ console.log('\nTo complete migration, remove the legacy directory:');
472
+ console.log(' rm -rf ~/.claude-config');
473
+ }
474
+ }
475
+
476
+ if (skipped > 0) {
477
+ console.log(`\n⚠️ ${skipped} item(s) skipped (already exist)`);
478
+ console.log('Use --force to overwrite existing files');
479
+ }
480
+
481
+ return migrated > 0;
482
+ }
483
+
349
484
  // Version
350
485
  version() {
351
486
  console.log(`claude-config v${VERSION}`);
package/lib/cli.js CHANGED
@@ -283,6 +283,15 @@ function runCli(manager) {
283
283
  break;
284
284
 
285
285
  // Maintenance
286
+ case 'migrate':
287
+ const migrateOptions = {
288
+ force: args.includes('--force') || args.includes('-f'),
289
+ removeLegacy: args.includes('--remove') || args.includes('-r'),
290
+ removeEmpty: true
291
+ };
292
+ manager.migrate(migrateOptions);
293
+ break;
294
+
286
295
  case 'update':
287
296
  manager.update(args.slice(1)).catch(err => {
288
297
  console.error('Update error:', err.message);
@@ -412,6 +421,9 @@ Registry Commands:
412
421
  registry remove <name> Remove MCP from registry
413
422
 
414
423
  Maintenance:
424
+ migrate Migrate from ~/.claude-config to ~/.coder-config
425
+ migrate --force Overwrite existing files in new location
426
+ migrate --remove Remove legacy directory after migration
415
427
  update Check npm for updates and install if available
416
428
  update --check Check for updates without installing
417
429
  update /path/to/source Update from local development source
package/lib/constants.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Constants and tool path configurations
3
3
  */
4
4
 
5
- const VERSION = '0.44.49';
5
+ const VERSION = '0.44.51';
6
6
 
7
7
  // Tool-specific path configurations
8
8
  const TOOL_PATHS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coder-config",
3
- "version": "0.44.49",
3
+ "version": "0.44.51",
4
4
  "description": "Configuration manager for AI coding tools - Claude Code, Gemini CLI, Codex CLI, Antigravity. Manage MCPs, rules, permissions, memory, and workstreams.",
5
5
  "author": "regression.io",
6
6
  "main": "config-loader.js",