claude-switch-profile 1.0.1 → 1.0.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/package.json +1 -1
- package/src/commands/create.js +15 -6
- package/src/constants.js +3 -0
- package/src/safety.js +1 -1
package/package.json
CHANGED
package/src/commands/create.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { mkdirSync, cpSync, existsSync, writeFileSync, readdirSync } from 'node:fs';
|
|
2
2
|
import { join, resolve } from 'node:path';
|
|
3
3
|
import { addProfile, getActive, setActive, profileExists, getProfileDir } from '../profile-store.js';
|
|
4
|
-
import { saveSymlinks } from '../symlink-manager.js';
|
|
5
4
|
import { saveFiles } from '../file-operations.js';
|
|
6
|
-
import { SYMLINK_ITEMS, SOURCE_FILE } from '../constants.js';
|
|
5
|
+
import { SYMLINK_ITEMS, SYMLINK_DIRS, SOURCE_FILE } from '../constants.js';
|
|
7
6
|
import { success, error, info, warn } from '../output-helpers.js';
|
|
8
7
|
|
|
9
8
|
export const createCommand = (name, options) => {
|
|
@@ -53,11 +52,21 @@ export const createCommand = (name, options) => {
|
|
|
53
52
|
// Also copy current mutable files
|
|
54
53
|
saveFiles(profileDir);
|
|
55
54
|
} else {
|
|
56
|
-
// Create
|
|
55
|
+
// Create brand new independent profile — everything fresh, nothing copied
|
|
57
56
|
mkdirSync(profileDir, { recursive: true });
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
|
|
58
|
+
// Create self-contained directories for each symlink directory item
|
|
59
|
+
const sourceMap = {};
|
|
60
|
+
for (const item of SYMLINK_DIRS) {
|
|
61
|
+
const itemDir = join(profileDir, item);
|
|
62
|
+
mkdirSync(itemDir, { recursive: true });
|
|
63
|
+
sourceMap[item] = itemDir;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
writeFileSync(join(profileDir, SOURCE_FILE), JSON.stringify(sourceMap, null, 2) + '\n');
|
|
67
|
+
// Do NOT call saveFiles() — new profile should start clean
|
|
68
|
+
// without inheriting settings.json, .env, .ck*, etc. from current state
|
|
69
|
+
info('Created new independent profile (clean state)');
|
|
61
70
|
}
|
|
62
71
|
|
|
63
72
|
addProfile(name, { description: options.description || '' });
|
package/src/constants.js
CHANGED
|
@@ -24,6 +24,9 @@ export const SYMLINK_ITEMS = [
|
|
|
24
24
|
'.luna.json',
|
|
25
25
|
];
|
|
26
26
|
|
|
27
|
+
// Directory-type symlink items (auto-created in new profiles)
|
|
28
|
+
export const SYMLINK_DIRS = ['rules', 'agents', 'skills', 'hooks'];
|
|
29
|
+
|
|
27
30
|
// Mutable files managed via copy
|
|
28
31
|
export const COPY_ITEMS = [
|
|
29
32
|
'settings.json',
|
package/src/safety.js
CHANGED
|
@@ -5,7 +5,7 @@ import { PROFILES_DIR, LOCK_FILE, BACKUP_DIR, CLAUDE_DIR, COPY_ITEMS, COPY_DIRS
|
|
|
5
5
|
import { readCurrentSymlinks } from './symlink-manager.js';
|
|
6
6
|
import { warn } from './output-helpers.js';
|
|
7
7
|
|
|
8
|
-
const MAX_BACKUPS =
|
|
8
|
+
const MAX_BACKUPS = 2;
|
|
9
9
|
|
|
10
10
|
// Acquire a lock file — atomic O_EXCL prevents TOCTOU race
|
|
11
11
|
export const acquireLock = () => {
|