Fix crush installer to use UnifiedInstaller

- Replace individual generators with UnifiedInstaller class
- Use NamingStyle.FLAT_COLON and TemplateType.CODEX
- Remove manual counting logic, use counts from UnifiedInstaller
- Keep cleanup() and installCustomAgentLauncher() as-is
This commit is contained in:
Brian Madison
2026-01-24 10:55:02 -06:00
parent cf6cf779bb
commit f6dab0d0ff

View File

@@ -2,14 +2,14 @@ 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');
const { TaskToolCommandGenerator } = require('./shared/task-tool-command-generator');
const { customAgentColonName } = require('./shared/path-utils'); const { customAgentColonName } = require('./shared/path-utils');
/** /**
* Crush IDE setup handler * Crush IDE setup handler
* Creates commands in .crush/commands/ directory structure using flat colon naming *
* Uses the UnifiedInstaller - all the complex artifact collection
* and writing logic is now centralized.
*/ */
class CrushSetup extends BaseIdeSetup { class CrushSetup extends BaseIdeSetup {
constructor() { constructor() {
@@ -31,47 +31,42 @@ class CrushSetup extends BaseIdeSetup {
await this.cleanup(projectDir); await this.cleanup(projectDir);
// Create .crush/commands directory // Create .crush/commands directory
const crushDir = path.join(projectDir, this.configDir); const commandsDir = path.join(projectDir, this.configDir, this.commandsDir);
const commandsDir = path.join(crushDir, this.commandsDir);
await this.ensureDir(commandsDir); await this.ensureDir(commandsDir);
// Use underscore format: files written directly to commands dir (no bmad subfolder) // Use the unified installer
// Creates: .crush/commands/bmad_bmm_pm.md // Crush uses flat colon naming (bmad_bmm_pm.md) with no frontmatter (like Codex)
const installer = new UnifiedInstaller(this.bmadFolderName);
// Generate agent launchers const counts = await installer.install(
const agentGen = new AgentCommandGenerator(this.bmadFolderName); projectDir,
const { artifacts: agentArtifacts } = await agentGen.collectAgentArtifacts(bmadDir, options.selectedModules || []); bmadDir,
{
// Write agent launcher files using flat underscore naming targetDir: commandsDir,
// Creates files like: bmad_bmm_pm.md namingStyle: NamingStyle.FLAT_COLON,
const agentCount = await agentGen.writeColonArtifacts(commandsDir, agentArtifacts); templateType: TemplateType.CODEX,
},
// Get ALL workflows using the new workflow command generator options.selectedModules || [],
const workflowGenerator = new WorkflowCommandGenerator(this.bmadFolderName); );
const { artifacts: workflowArtifacts } = await workflowGenerator.collectWorkflowArtifacts(bmadDir);
// Write workflow-command artifacts using flat underscore naming
// Creates files like: bmad_bmm_correct-course.md
const workflowCount = await workflowGenerator.writeColonArtifacts(commandsDir, workflowArtifacts);
// Generate task and tool commands using flat underscore naming
const taskToolGen = new TaskToolCommandGenerator();
const taskToolResult = await taskToolGen.generateColonTaskToolCommands(projectDir, bmadDir, commandsDir);
console.log(chalk.green(`${this.name} configured:`)); console.log(chalk.green(`${this.name} configured:`));
console.log(chalk.dim(` - ${agentCount} agent commands created`)); console.log(chalk.dim(` - ${counts.agents} agents installed`));
console.log(chalk.dim(` - ${taskToolResult.tasks} task commands created`)); if (counts.workflows > 0) {
console.log(chalk.dim(` - ${taskToolResult.tools} tool commands created`)); console.log(chalk.dim(` - ${counts.workflows} workflow commands generated`));
console.log(chalk.dim(` - ${workflowCount} workflow commands created`)); }
if (counts.tasks + counts.tools > 0) {
console.log(
chalk.dim(` - ${counts.tasks + counts.tools} task/tool commands generated (${counts.tasks} tasks, ${counts.tools} tools)`),
);
}
console.log(chalk.dim(` - Commands directory: ${path.relative(projectDir, commandsDir)}`)); console.log(chalk.dim(` - Commands directory: ${path.relative(projectDir, commandsDir)}`));
console.log(chalk.dim('\n Commands can be accessed via Crush command palette')); console.log(chalk.dim('\n Commands can be accessed via Crush command palette'));
return { return {
success: true, success: true,
agents: agentCount, agents: counts.agents,
tasks: taskToolResult.tasks || 0, tasks: counts.tasks,
tools: taskToolResult.tools || 0, tools: counts.tools,
workflows: workflowCount, workflows: counts.workflows,
}; };
} }