fix(installer): warn on stale global legacy skill dirs
This commit is contained in:
parent
a4d9149e62
commit
3ac778b6bd
|
|
@ -1,3 +1,4 @@
|
||||||
|
const os = require('node:os');
|
||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const yaml = require('yaml');
|
const yaml = require('yaml');
|
||||||
|
|
@ -645,8 +646,12 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}}
|
||||||
if (this.installerConfig?.legacy_targets) {
|
if (this.installerConfig?.legacy_targets) {
|
||||||
if (!options.silent) await prompts.log.message(' Migrating legacy directories...');
|
if (!options.silent) await prompts.log.message(' Migrating legacy directories...');
|
||||||
for (const legacyDir of this.installerConfig.legacy_targets) {
|
for (const legacyDir of this.installerConfig.legacy_targets) {
|
||||||
await this.cleanupTarget(projectDir, legacyDir, options);
|
if (this.isGlobalPath(legacyDir)) {
|
||||||
await this.removeEmptyParents(projectDir, legacyDir);
|
await this.warnGlobalLegacy(legacyDir, options);
|
||||||
|
} else {
|
||||||
|
await this.cleanupTarget(projectDir, legacyDir, options);
|
||||||
|
await this.removeEmptyParents(projectDir, legacyDir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -670,6 +675,41 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a path is global (starts with ~ or is absolute)
|
||||||
|
* @param {string} p - Path to check
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
isGlobalPath(p) {
|
||||||
|
return p.startsWith('~') || path.isAbsolute(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warn about stale BMAD files in a global legacy directory (never auto-deletes)
|
||||||
|
* @param {string} legacyDir - Legacy directory path (may start with ~)
|
||||||
|
* @param {Object} options - Options (silent, etc.)
|
||||||
|
*/
|
||||||
|
async warnGlobalLegacy(legacyDir, options = {}) {
|
||||||
|
try {
|
||||||
|
const expanded = legacyDir.startsWith('~/')
|
||||||
|
? path.join(os.homedir(), legacyDir.slice(2))
|
||||||
|
: legacyDir === '~'
|
||||||
|
? os.homedir()
|
||||||
|
: legacyDir;
|
||||||
|
|
||||||
|
if (!(await fs.pathExists(expanded))) return;
|
||||||
|
|
||||||
|
const entries = await fs.readdir(expanded);
|
||||||
|
const bmadFiles = entries.filter((e) => typeof e === 'string' && e.startsWith('bmad'));
|
||||||
|
|
||||||
|
if (bmadFiles.length > 0 && !options.silent) {
|
||||||
|
await prompts.log.warn(`Found ${bmadFiles.length} stale BMAD file(s) in ${expanded}. Remove manually: rm ${expanded}/bmad-*`);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Errors reading global paths are silently ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanup a specific target directory
|
* Cleanup a specific target directory
|
||||||
* @param {string} projectDir - Project directory
|
* @param {string} projectDir - Project directory
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ platforms:
|
||||||
installer:
|
installer:
|
||||||
legacy_targets:
|
legacy_targets:
|
||||||
- .codex/prompts
|
- .codex/prompts
|
||||||
|
- ~/.codex/prompts
|
||||||
target_dir: .agents/skills
|
target_dir: .agents/skills
|
||||||
template_type: default
|
template_type: default
|
||||||
skill_format: true
|
skill_format: true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue