remove option to install globally. this does not exist for any other ide

This commit is contained in:
Wendy Smoak 2026-02-19 19:19:25 -05:00
parent a974adc878
commit 0f280e590e
1 changed files with 9 additions and 108 deletions

View File

@ -1,6 +1,5 @@
const path = require('node:path'); const path = require('node:path');
const fs = require('fs-extra'); const fs = require('fs-extra');
const os = require('node:os');
const { BaseIdeSetup } = require('./_base-ide'); const { BaseIdeSetup } = require('./_base-ide');
const { WorkflowCommandGenerator } = require('./shared/workflow-command-generator'); const { WorkflowCommandGenerator } = require('./shared/workflow-command-generator');
const { AgentCommandGenerator } = require('./shared/agent-command-generator'); const { AgentCommandGenerator } = require('./shared/agent-command-generator');
@ -20,57 +19,6 @@ class CodexSkillsSetup extends BaseIdeSetup {
super('codex-skills', 'Codex', true); // preferred IDE super('codex-skills', 'Codex', true); // preferred IDE
} }
/**
* Collect configuration choices before installation
* @param {Object} options - Configuration options
* @returns {Object} Collected configuration
*/
async collectConfiguration(options = {}) {
// Non-interactive mode: use default (project) - recommended for real work
if (options.skipPrompts) {
return { installLocation: options.codexLocation || 'project' };
}
let confirmed = false;
let installLocation = 'project';
while (!confirmed) {
installLocation = await prompts.select({
message: 'Where would you like to install Codex CLI skills?',
choices: [
{
name: 'Project-specific - Recommended (<project>/.agents/skills)',
value: 'project',
},
{
name: 'Global - ($HOME/.agents/skills)',
value: 'global',
},
],
default: 'project',
});
// Show brief confirmation hint (detailed instructions available via verbose)
if (installLocation === 'project') {
await prompts.log.info('Skills installed to: <project>/.agents/skills');
} else {
await prompts.log.info('Skills installed to: $HOME/.agents/skills');
}
// Confirm the choice
confirmed = await prompts.confirm({
message: 'Proceed with this installation option?',
default: true,
});
if (!confirmed) {
await prompts.log.warn("Let's choose a different installation option.");
}
}
return { installLocation };
}
/** /**
* Setup Codex configuration * Setup Codex configuration
* @param {string} projectDir - Project directory * @param {string} projectDir - Project directory
@ -83,12 +31,9 @@ class CodexSkillsSetup extends BaseIdeSetup {
// Always use CLI mode // Always use CLI mode
const mode = 'cli'; const mode = 'cli';
// Get installation location from pre-collected config or default to project
const installLocation = options.preCollectedConfig?.installLocation || 'project';
const { artifacts, counts } = await this.collectClaudeArtifacts(projectDir, bmadDir, options); const { artifacts, counts } = await this.collectClaudeArtifacts(projectDir, bmadDir, options);
const destDir = this.getCodexSkillsDir(projectDir, installLocation); const destDir = this.getCodexSkillsDir(projectDir);
await fs.ensureDir(destDir); await fs.ensureDir(destDir);
await this.clearOldBmadSkills(destDir, options); await this.clearOldBmadSkills(destDir, options);
@ -148,7 +93,6 @@ class CodexSkillsSetup extends BaseIdeSetup {
counts, counts,
destination: destDir, destination: destDir,
written, written,
installLocation,
}; };
} }
@ -225,27 +169,11 @@ class CodexSkillsSetup extends BaseIdeSetup {
* Detect Codex installation by checking for BMAD skills * Detect Codex installation by checking for BMAD skills
*/ */
async detect(projectDir) { async detect(projectDir) {
// Check both global and project-specific locations const dir = this.getCodexSkillsDir(projectDir || process.cwd());
const globalDir = this.getCodexSkillsDir(null, 'global');
const projectDir_local = projectDir || process.cwd();
const projectSpecificDir = this.getCodexSkillsDir(projectDir_local, 'project');
// Check global location if (await fs.pathExists(dir)) {
if (await fs.pathExists(globalDir)) {
try { try {
const entries = await fs.readdir(globalDir); const entries = await fs.readdir(dir);
if (entries && entries.some((entry) => entry && typeof entry === 'string' && entry.startsWith('bmad'))) {
return true;
}
} catch {
// Ignore errors
}
}
// Check project-specific location
if (await fs.pathExists(projectSpecificDir)) {
try {
const entries = await fs.readdir(projectSpecificDir);
if (entries && entries.some((entry) => entry && typeof entry === 'string' && entry.startsWith('bmad'))) { if (entries && entries.some((entry) => entry && typeof entry === 'string' && entry.startsWith('bmad'))) {
return true; return true;
} }
@ -317,14 +245,11 @@ class CodexSkillsSetup extends BaseIdeSetup {
}; };
} }
getCodexSkillsDir(projectDir = null, location = 'project') { getCodexSkillsDir(projectDir) {
if (location === 'project' && projectDir) { if (!projectDir) {
return path.join(projectDir, '.agents', 'skills');
}
if (location === 'project' && !projectDir) {
throw new Error('projectDir is required for project-scoped skill installation'); throw new Error('projectDir is required for project-scoped skill installation');
} }
return path.join(os.homedir(), '.agents', 'skills'); return path.join(projectDir, '.agents', 'skills');
} }
/** /**
@ -374,26 +299,6 @@ class CodexSkillsSetup extends BaseIdeSetup {
return super.processContent(content, metadata, projectDir); return super.processContent(content, metadata, projectDir);
} }
/**
* Get instructions for global installation
* @returns {string} Instructions text
*/
getGlobalInstructions(destDir) {
const lines = [
'IMPORTANT: Codex Configuration',
'',
'Skills installed globally to your HOME DIRECTORY ($HOME/.agents/skills).',
'',
'These skills reference a specific _bmad path.',
"To use with other projects, you'd need to copy the _bmad dir.",
'',
'Skills are available in Codex CLI automatically.',
' Use /skills to see available skills',
' Skills can also be invoked implicitly based on task description',
];
return lines.join('\n');
}
/** /**
* Get instructions for project-specific installation * Get instructions for project-specific installation
* @param {string} projectDir - Optional project directory * @param {string} projectDir - Optional project directory
@ -417,13 +322,9 @@ class CodexSkillsSetup extends BaseIdeSetup {
* Cleanup Codex configuration * Cleanup Codex configuration
*/ */
async cleanup(projectDir = null) { async cleanup(projectDir = null) {
// Clean both global and project-specific locations
const globalDir = this.getCodexSkillsDir(null, 'global');
await this.clearOldBmadSkills(globalDir);
if (projectDir) { if (projectDir) {
const projectSpecificDir = this.getCodexSkillsDir(projectDir, 'project'); const destDir = this.getCodexSkillsDir(projectDir);
await this.clearOldBmadSkills(projectSpecificDir); await this.clearOldBmadSkills(destDir);
} }
} }