@suwujs/codex-vault 0.3.2 → 0.3.4
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/bin/cli.js +18 -20
- package/package.json +1 -1
- package/plugin/VERSION +1 -1
package/bin/cli.js
CHANGED
|
@@ -64,12 +64,19 @@ function assertBash() {
|
|
|
64
64
|
function runInit() {
|
|
65
65
|
assertBash();
|
|
66
66
|
|
|
67
|
-
// Check if already installed
|
|
67
|
+
// Check if already installed (including legacy codex-mem)
|
|
68
68
|
const versionFile = path.join(process.cwd(), 'vault', '.codex-vault', 'version');
|
|
69
|
+
const legacyVersionFile = path.join(process.cwd(), 'vault', '.codex-mem', 'version');
|
|
69
70
|
if (fs.existsSync(versionFile)) {
|
|
70
71
|
const installed = fs.readFileSync(versionFile, 'utf8').trim();
|
|
71
72
|
console.log(`codex-vault v${installed} is already installed in this directory.`);
|
|
72
|
-
console.log('
|
|
73
|
+
console.log('Run "codex-vault upgrade" to update, or remove vault/.codex-vault/version to reinstall.');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (fs.existsSync(legacyVersionFile)) {
|
|
77
|
+
const installed = fs.readFileSync(legacyVersionFile, 'utf8').trim();
|
|
78
|
+
console.log(`Legacy codex-mem v${installed} detected.`);
|
|
79
|
+
console.log('Run "codex-vault uninstall" first, then "codex-vault init".');
|
|
73
80
|
return;
|
|
74
81
|
}
|
|
75
82
|
|
|
@@ -98,13 +105,19 @@ function runInit() {
|
|
|
98
105
|
function cmdUpgrade() {
|
|
99
106
|
assertBash();
|
|
100
107
|
|
|
101
|
-
// Check if installed
|
|
108
|
+
// Check if installed (including legacy codex-mem)
|
|
102
109
|
const versionFile = path.join(process.cwd(), 'vault', '.codex-vault', 'version');
|
|
103
|
-
|
|
110
|
+
const legacyVersionFile = path.join(process.cwd(), 'vault', '.codex-mem', 'version');
|
|
111
|
+
if (!fs.existsSync(versionFile) && !fs.existsSync(legacyVersionFile)) {
|
|
104
112
|
console.error('codex-vault is not installed in this directory.');
|
|
105
113
|
console.error('Run "codex-vault init" first.');
|
|
106
114
|
process.exit(1);
|
|
107
115
|
}
|
|
116
|
+
if (!fs.existsSync(versionFile) && fs.existsSync(legacyVersionFile)) {
|
|
117
|
+
console.error('Legacy codex-mem installation detected.');
|
|
118
|
+
console.error('Run "codex-vault uninstall" first, then "codex-vault init".');
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
108
121
|
|
|
109
122
|
const installedVersion = fs.readFileSync(versionFile, 'utf8').trim();
|
|
110
123
|
|
|
@@ -269,7 +282,6 @@ function cleanHooksJson(filePath, label) {
|
|
|
269
282
|
if (Object.keys(data).length === 0) {
|
|
270
283
|
fs.unlinkSync(filePath);
|
|
271
284
|
console.log(` [x] Removed ${label} (empty after cleanup)`);
|
|
272
|
-
cleanEmptyParents(path.dirname(filePath));
|
|
273
285
|
} else {
|
|
274
286
|
fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n');
|
|
275
287
|
console.log(` [x] Cleaned codex-vault hooks from ${label}`);
|
|
@@ -302,7 +314,6 @@ function cleanCodexConfigToml(cwd) {
|
|
|
302
314
|
if (content.trim() === '') {
|
|
303
315
|
fs.unlinkSync(filePath);
|
|
304
316
|
console.log(' [x] Removed .codex/config.toml (empty after cleanup)');
|
|
305
|
-
cleanEmptyParents(path.dirname(filePath));
|
|
306
317
|
} else {
|
|
307
318
|
fs.writeFileSync(filePath, content);
|
|
308
319
|
console.log(' [x] Cleaned codex_hooks from .codex/config.toml');
|
|
@@ -329,12 +340,9 @@ function removeSkills(agentDir, label, skillNames) {
|
|
|
329
340
|
|
|
330
341
|
console.log(` [x] Removed ${removed} skills from ${label}/skills/`);
|
|
331
342
|
|
|
332
|
-
// Clean up empty
|
|
343
|
+
// Clean up empty skills/ directory only — never delete the agent dir itself
|
|
333
344
|
if (isDirEmpty(skillsDir)) {
|
|
334
345
|
fs.rmdirSync(skillsDir);
|
|
335
|
-
if (isDirEmpty(agentDir)) {
|
|
336
|
-
fs.rmdirSync(agentDir);
|
|
337
|
-
}
|
|
338
346
|
}
|
|
339
347
|
}
|
|
340
348
|
|
|
@@ -409,13 +417,3 @@ function isDirEmpty(dirPath) {
|
|
|
409
417
|
}
|
|
410
418
|
}
|
|
411
419
|
|
|
412
|
-
/**
|
|
413
|
-
* Remove empty parent directories up to (but not including) cwd.
|
|
414
|
-
*/
|
|
415
|
-
function cleanEmptyParents(dirPath) {
|
|
416
|
-
const cwd = process.cwd();
|
|
417
|
-
if (dirPath === cwd || !dirPath.startsWith(cwd)) return;
|
|
418
|
-
if (isDirEmpty(dirPath)) {
|
|
419
|
-
fs.rmdirSync(dirPath);
|
|
420
|
-
}
|
|
421
|
-
}
|
package/package.json
CHANGED
package/plugin/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.4
|