Fix auggie installer to use UnifiedInstaller with flat files

- Replace individual generators with UnifiedInstaller class
- Remove nested folder structure (.augment/commands/bmad/agents/, etc.)
- Now installs flat files to .augment/commands/ (e.g., bmad_bmm_agent_pm.md)
- Use NamingStyle.FLAT_COLON and TemplateType.AUGMENT
- Remove createTaskCommand, createToolCommand, createWorkflowCommand methods
- Simplify cleanup() and update installCustomAgentLauncher() for flat structure
This commit is contained in:
Brian Madison
2026-01-24 10:55:01 -06:00
parent 7074395bdd
commit cf6cf779bb

View File

@@ -2,8 +2,7 @@ const path = require('node:path');
const fs = require('fs-extra'); const fs = require('fs-extra');
const { BaseIdeSetup } = require('./_base-ide'); const { BaseIdeSetup } = require('./_base-ide');
const chalk = require('chalk'); const chalk = require('chalk');
const { AgentCommandGenerator } = require('./shared/agent-command-generator'); const { UnifiedInstaller, NamingStyle, TemplateType } = require('./shared/unified-installer');
const { WorkflowCommandGenerator } = require('./shared/workflow-command-generator');
/** /**
* Auggie CLI setup handler * Auggie CLI setup handler
@@ -13,6 +12,7 @@ class AuggieSetup extends BaseIdeSetup {
constructor() { constructor() {
super('auggie', 'Auggie CLI'); super('auggie', 'Auggie CLI');
this.detectionPaths = ['.augment']; this.detectionPaths = ['.augment'];
this.installer = new UnifiedInstaller(this.bmadFolderName);
} }
/** /**
@@ -24,169 +24,40 @@ class AuggieSetup extends BaseIdeSetup {
async setup(projectDir, bmadDir, options = {}) { async setup(projectDir, bmadDir, options = {}) {
console.log(chalk.cyan(`Setting up ${this.name}...`)); console.log(chalk.cyan(`Setting up ${this.name}...`));
// Always use project directory // Use flat file structure in .augment/commands/
const location = path.join(projectDir, '.augment', 'commands'); const targetDir = path.join(projectDir, '.augment', 'commands');
// Clean up old BMAD installation first // Install using UnifiedInstaller
await this.cleanup(projectDir); const counts = await this.installer.install(projectDir, bmadDir, {
targetDir,
// Generate agent launchers namingStyle: NamingStyle.FLAT_COLON,
const agentGen = new AgentCommandGenerator(this.bmadFolderName); templateType: TemplateType.AUGMENT,
const { artifacts: agentArtifacts } = await agentGen.collectAgentArtifacts(bmadDir, options.selectedModules || []); includeNestedStructure: false,
}, options.selectedModules || []);
// Get tasks, tools, and workflows (ALL workflows now generate commands)
const tasks = await this.getTasks(bmadDir, true);
const tools = await this.getTools(bmadDir, true);
// Get ALL workflows using the new workflow command generator
const workflowGenerator = new WorkflowCommandGenerator(this.bmadFolderName);
const { artifacts: workflowArtifacts, counts: workflowCounts } = await workflowGenerator.collectWorkflowArtifacts(bmadDir);
// Convert workflow artifacts to expected format
const workflows = workflowArtifacts
.filter((artifact) => artifact.type === 'workflow-command')
.map((artifact) => ({
module: artifact.module,
name: path.basename(artifact.relativePath, '.md'),
path: artifact.sourcePath,
content: artifact.content,
}));
const bmadCommandsDir = path.join(location, 'bmad');
const agentsDir = path.join(bmadCommandsDir, 'agents');
const tasksDir = path.join(bmadCommandsDir, 'tasks');
const toolsDir = path.join(bmadCommandsDir, 'tools');
const workflowsDir = path.join(bmadCommandsDir, 'workflows');
await this.ensureDir(agentsDir);
await this.ensureDir(tasksDir);
await this.ensureDir(toolsDir);
await this.ensureDir(workflowsDir);
// Install agent launchers
for (const artifact of agentArtifacts) {
const targetPath = path.join(agentsDir, `${artifact.module}-${artifact.name}.md`);
await this.writeFile(targetPath, artifact.content);
}
// Install tasks
for (const task of tasks) {
const content = await this.readFile(task.path);
const commandContent = this.createTaskCommand(task, content);
const targetPath = path.join(tasksDir, `${task.module}-${task.name}.md`);
await this.writeFile(targetPath, commandContent);
}
// Install tools
for (const tool of tools) {
const content = await this.readFile(tool.path);
const commandContent = this.createToolCommand(tool, content);
const targetPath = path.join(toolsDir, `${tool.module}-${tool.name}.md`);
await this.writeFile(targetPath, commandContent);
}
// Install workflows (already generated commands)
for (const workflow of workflows) {
// Use the pre-generated workflow command content
const targetPath = path.join(workflowsDir, `${workflow.module}-${workflow.name}.md`);
await this.writeFile(targetPath, workflow.content);
}
const totalInstalled = agentArtifacts.length + tasks.length + tools.length + workflows.length;
console.log(chalk.green(`${this.name} configured:`)); console.log(chalk.green(`${this.name} configured:`));
console.log(chalk.dim(` - ${agentArtifacts.length} agents installed`)); console.log(chalk.dim(` - ${counts.agents} agents installed`));
console.log(chalk.dim(` - ${tasks.length} tasks installed`)); console.log(chalk.dim(` - ${counts.tasks} tasks installed`));
console.log(chalk.dim(` - ${tools.length} tools installed`)); console.log(chalk.dim(` - ${counts.tools} tools installed`));
console.log(chalk.dim(` - ${workflows.length} workflows installed`)); console.log(chalk.dim(` - ${counts.workflows} workflows installed`));
console.log(chalk.dim(` - Location: ${path.relative(projectDir, location)}`)); console.log(chalk.dim(` - Location: ${path.relative(projectDir, targetDir)}`));
console.log(chalk.yellow(`\n 💡 Tip: Add 'model: gpt-4o' to command frontmatter to specify AI model`)); console.log(chalk.yellow(`\n 💡 Tip: Add 'model: gpt-4o' to command frontmatter to specify AI model`));
return { return {
success: true, success: true,
agents: agentArtifacts.length, ...counts,
tasks: tasks.length,
tools: tools.length,
workflows: workflows.length,
}; };
} }
/**
* Create task command content
*/
createTaskCommand(task, content) {
const nameMatch = content.match(/name="([^"]+)"/);
const taskName = nameMatch ? nameMatch[1] : this.formatTitle(task.name);
return `---
description: "Execute the ${taskName} task"
---
# ${taskName} Task
${content}
## Module
BMAD ${task.module.toUpperCase()} module
`;
}
/**
* Create tool command content
*/
createToolCommand(tool, content) {
const nameMatch = content.match(/name="([^"]+)"/);
const toolName = nameMatch ? nameMatch[1] : this.formatTitle(tool.name);
return `---
description: "Use the ${toolName} tool"
---
# ${toolName} Tool
${content}
## Module
BMAD ${tool.module.toUpperCase()} module
`;
}
/**
* Create workflow command content
*/
createWorkflowCommand(workflow, content) {
const description = workflow.description || `Execute the ${workflow.name} workflow`;
return `---
description: "${description}"
---
# ${workflow.name} Workflow
${content}
## Module
BMAD ${workflow.module.toUpperCase()} module
`;
}
/** /**
* Cleanup Auggie configuration * Cleanup Auggie configuration
* Removes bmad* files from .augment/commands/
*/ */
async cleanup(projectDir) { async cleanup(projectDir) {
const fs = require('fs-extra'); const targetDir = path.join(projectDir, '.augment', 'commands');
await this.installer.cleanupBmadFiles(targetDir);
// Only clean up project directory
const location = path.join(projectDir, '.augment', 'commands');
const bmadDir = path.join(location, 'bmad');
if (await fs.pathExists(bmadDir)) {
await fs.remove(bmadDir);
console.log(chalk.dim(` Removed old BMAD commands`)); console.log(chalk.dim(` Removed old BMAD commands`));
} }
}
/** /**
* Install a custom agent launcher for Auggie * Install a custom agent launcher for Auggie
@@ -197,15 +68,13 @@ BMAD ${workflow.module.toUpperCase()} module
* @returns {Object} Installation result * @returns {Object} Installation result
*/ */
async installCustomAgentLauncher(projectDir, agentName, agentPath, metadata) { async installCustomAgentLauncher(projectDir, agentName, agentPath, metadata) {
// Auggie uses .augment/commands directory // Auggie uses .augment/commands directory with flat structure
const location = path.join(projectDir, '.augment', 'commands'); const targetDir = path.join(projectDir, '.augment', 'commands');
const bmadCommandsDir = path.join(location, 'bmad');
const agentsDir = path.join(bmadCommandsDir, 'agents');
// Create .augment/commands/bmad/agents directory if it doesn't exist // Create .augment/commands directory if it doesn't exist
await fs.ensureDir(agentsDir); await fs.ensureDir(targetDir);
// Create custom agent launcher // Create custom agent launcher with flat naming: bmad_custom_agent_{name}.md
const launcherContent = `--- const launcherContent = `---
description: "Use the ${agentName} custom agent" description: "Use the ${agentName} custom agent"
--- ---
@@ -226,8 +95,9 @@ The agent will follow the persona and instructions from the main agent file.
BMAD Custom agent BMAD Custom agent
`; `;
const fileName = `custom-${agentName.toLowerCase()}.md`; // Use flat naming convention consistent with UnifiedInstaller
const launcherPath = path.join(agentsDir, fileName); const fileName = `bmad_custom_agent_${agentName.toLowerCase()}.md`;
const launcherPath = path.join(targetDir, fileName);
// Write the launcher file // Write the launcher file
await fs.writeFile(launcherPath, launcherContent, 'utf8'); await fs.writeFile(launcherPath, launcherContent, 'utf8');