2025-09-28 23:17:07 -05:00
|
|
|
const path = require('node:path');
|
|
|
|
|
const { BaseIdeSetup } = require('./_base-ide');
|
|
|
|
|
const chalk = require('chalk');
|
|
|
|
|
const { getProjectRoot, getSourcePath, getModulePath } = require('../../../lib/project-root');
|
Major Enhancements:
- Installation path is now fully configurable, allowing users to specify custom installation directories during setup
- Default installation location changed to .bmad (hidden directory) for cleaner project root organization
Web Bundle Improvements:
- All web bundles (single agent and team) now include party mode support for multi-agent collaboration!
- Advanced elicitation capabilities integrated into standalone agents
- All bundles enhanced with party mode agent manifests
- Added default-party.csv files to bmm, bmgd, and cis module teams
- The default party file is what will be used with single agent bundles. teams can customize for different party configurations before web bundling through a setting in the team yaml file
- New web bundle outputs for all agents (analyst, architect, dev, pm, sm, tea, tech-writer, ux-designer, game-*, creative-squad)
Phase 4 Workflow Updates (In Progress):
- Initiated shift to separate phase 4 implementation artifacts from documentation
- Phase 4 implementation artifacts (stories, code review, sprint plan, context files) will move to dedicated location outside docs folder
- Installer questions and configuration added for artifact path selection
- Updated workflow.yaml files for code-review, sprint-planning, story-context, epic-tech-context, and retrospective workflows to support this, but still might require some udpates
Additional Changes:
- New agent and action command header models for standardization
- Enhanced web-bundle-activation-steps fragment
- Updated web-bundler.js to support new structure
- VS Code settings updated for new .bmad directory
- Party mode instructions and workflow enhanced for better orchestration
IDE Installer Updates:
- Show version number of installer in cli
- improved Installer UX
- Gemini TOML Improved to have clear loading instructions with @ commands
- All tools agent launcher mds improved to use a central file template critical indication isntead of hardcoding in 2 different locations.
2025-11-09 17:39:05 -06:00
|
|
|
const { WorkflowCommandGenerator } = require('./shared/workflow-command-generator');
|
|
|
|
|
const { TaskToolCommandGenerator } = require('./shared/task-tool-command-generator');
|
2025-10-05 15:52:48 -07:00
|
|
|
const {
|
|
|
|
|
loadModuleInjectionConfig,
|
|
|
|
|
shouldApplyInjection,
|
|
|
|
|
filterAgentInstructions,
|
|
|
|
|
resolveSubagentFiles,
|
|
|
|
|
} = require('./shared/module-injections');
|
2025-10-20 05:20:36 -07:00
|
|
|
const { getAgentsFromBmad, getAgentsFromDir } = require('./shared/bmad-artifacts');
|
2025-09-28 23:17:07 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Claude Code IDE setup handler
|
|
|
|
|
*/
|
|
|
|
|
class ClaudeCodeSetup extends BaseIdeSetup {
|
|
|
|
|
constructor() {
|
|
|
|
|
super('claude-code', 'Claude Code', true); // preferred IDE
|
|
|
|
|
this.configDir = '.claude';
|
|
|
|
|
this.commandsDir = 'commands';
|
|
|
|
|
this.agentsDir = 'agents';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Collect configuration choices before installation
|
|
|
|
|
* @param {Object} options - Configuration options
|
|
|
|
|
* @returns {Object} Collected configuration
|
|
|
|
|
*/
|
|
|
|
|
async collectConfiguration(options = {}) {
|
|
|
|
|
const config = {
|
|
|
|
|
subagentChoices: null,
|
|
|
|
|
installLocation: null,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const sourceModulesPath = getSourcePath('modules');
|
|
|
|
|
const modules = options.selectedModules || [];
|
|
|
|
|
|
|
|
|
|
for (const moduleName of modules) {
|
|
|
|
|
// Check for Claude Code sub-module injection config in SOURCE directory
|
|
|
|
|
const injectionConfigPath = path.join(sourceModulesPath, moduleName, 'sub-modules', 'claude-code', 'injections.yaml');
|
|
|
|
|
|
|
|
|
|
if (await this.exists(injectionConfigPath)) {
|
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
const yaml = require('js-yaml');
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// Load injection configuration
|
|
|
|
|
const configContent = await fs.readFile(injectionConfigPath, 'utf8');
|
|
|
|
|
const injectionConfig = yaml.load(configContent);
|
|
|
|
|
|
|
|
|
|
// Ask about subagents if they exist and we haven't asked yet
|
|
|
|
|
if (injectionConfig.subagents && !config.subagentChoices) {
|
|
|
|
|
config.subagentChoices = await this.promptSubagentInstallation(injectionConfig.subagents);
|
|
|
|
|
|
|
|
|
|
if (config.subagentChoices.install !== 'none') {
|
|
|
|
|
// Ask for installation location
|
|
|
|
|
const inquirer = require('inquirer');
|
|
|
|
|
const locationAnswer = await inquirer.prompt([
|
|
|
|
|
{
|
|
|
|
|
type: 'list',
|
|
|
|
|
name: 'location',
|
|
|
|
|
message: 'Where would you like to install Claude Code subagents?',
|
|
|
|
|
choices: [
|
|
|
|
|
{ name: 'Project level (.claude/agents/)', value: 'project' },
|
|
|
|
|
{ name: 'User level (~/.claude/agents/)', value: 'user' },
|
|
|
|
|
],
|
|
|
|
|
default: 'project',
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
config.installLocation = locationAnswer.location;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(chalk.yellow(` Warning: Failed to process ${moduleName} features: ${error.message}`));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-06 22:45:29 -06:00
|
|
|
/**
|
|
|
|
|
* Cleanup old BMAD installation before reinstalling
|
|
|
|
|
* @param {string} projectDir - Project directory
|
|
|
|
|
*/
|
|
|
|
|
async cleanup(projectDir) {
|
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
const bmadCommandsDir = path.join(projectDir, this.configDir, this.commandsDir, 'bmad');
|
|
|
|
|
|
|
|
|
|
if (await fs.pathExists(bmadCommandsDir)) {
|
|
|
|
|
await fs.remove(bmadCommandsDir);
|
|
|
|
|
console.log(chalk.dim(` Removed old BMAD commands from ${this.name}`));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-28 23:17:07 -05:00
|
|
|
/**
|
|
|
|
|
* Setup Claude Code IDE configuration
|
|
|
|
|
* @param {string} projectDir - Project directory
|
|
|
|
|
* @param {string} bmadDir - BMAD installation directory
|
|
|
|
|
* @param {Object} options - Setup options
|
|
|
|
|
*/
|
|
|
|
|
async setup(projectDir, bmadDir, options = {}) {
|
|
|
|
|
// Store project directory for use in processContent
|
|
|
|
|
this.projectDir = projectDir;
|
|
|
|
|
|
|
|
|
|
console.log(chalk.cyan(`Setting up ${this.name}...`));
|
|
|
|
|
|
2025-11-06 22:45:29 -06:00
|
|
|
// Clean up old BMAD installation first
|
|
|
|
|
await this.cleanup(projectDir);
|
|
|
|
|
|
2025-09-28 23:17:07 -05:00
|
|
|
// Create .claude/commands directory structure
|
|
|
|
|
const claudeDir = path.join(projectDir, this.configDir);
|
|
|
|
|
const commandsDir = path.join(claudeDir, this.commandsDir);
|
|
|
|
|
const bmadCommandsDir = path.join(commandsDir, 'bmad');
|
|
|
|
|
|
|
|
|
|
await this.ensureDir(bmadCommandsDir);
|
|
|
|
|
|
2025-10-20 05:20:36 -07:00
|
|
|
// Get agents from INSTALLED bmad/ directory
|
2025-10-02 21:45:59 -05:00
|
|
|
// Base installer has already built .md files from .agent.yaml sources
|
2025-10-05 15:52:48 -07:00
|
|
|
const agents = await getAgentsFromBmad(bmadDir, options.selectedModules || []);
|
2025-09-28 23:17:07 -05:00
|
|
|
|
2025-10-09 23:07:12 -05:00
|
|
|
// Create directories for each module (including standalone)
|
2025-09-28 23:17:07 -05:00
|
|
|
const modules = new Set();
|
2025-10-20 05:20:36 -07:00
|
|
|
for (const item of agents) modules.add(item.module);
|
2025-09-28 23:17:07 -05:00
|
|
|
|
|
|
|
|
for (const module of modules) {
|
|
|
|
|
await this.ensureDir(path.join(bmadCommandsDir, module));
|
|
|
|
|
await this.ensureDir(path.join(bmadCommandsDir, module, 'agents'));
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-02 21:45:59 -05:00
|
|
|
// Copy agents from bmad/ to .claude/commands/
|
2025-09-28 23:17:07 -05:00
|
|
|
let agentCount = 0;
|
|
|
|
|
for (const agent of agents) {
|
2025-10-02 21:45:59 -05:00
|
|
|
const sourcePath = agent.path;
|
|
|
|
|
const targetPath = path.join(bmadCommandsDir, agent.module, 'agents', `${agent.name}.md`);
|
|
|
|
|
|
|
|
|
|
const content = await this.readAndProcess(sourcePath, {
|
2025-09-28 23:17:07 -05:00
|
|
|
module: agent.module,
|
|
|
|
|
name: agent.name,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await this.writeFile(targetPath, content);
|
|
|
|
|
agentCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Process Claude Code specific injections for installed modules
|
2025-10-26 16:17:37 -05:00
|
|
|
// Use pre-collected configuration if available, or skip if already configured
|
|
|
|
|
if (options.preCollectedConfig && options.preCollectedConfig._alreadyConfigured) {
|
|
|
|
|
// IDE is already configured from previous installation, skip prompting
|
|
|
|
|
// Just process with default/existing configuration
|
|
|
|
|
await this.processModuleInjectionsWithConfig(projectDir, bmadDir, options, {});
|
|
|
|
|
} else if (options.preCollectedConfig) {
|
2025-09-28 23:17:07 -05:00
|
|
|
await this.processModuleInjectionsWithConfig(projectDir, bmadDir, options, options.preCollectedConfig);
|
|
|
|
|
} else {
|
|
|
|
|
await this.processModuleInjections(projectDir, bmadDir, options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Skip CLAUDE.md creation - let user manage their own CLAUDE.md file
|
|
|
|
|
// await this.createClaudeConfig(projectDir, modules);
|
|
|
|
|
|
|
|
|
|
// Generate workflow commands from manifest (if it exists)
|
Major Enhancements:
- Installation path is now fully configurable, allowing users to specify custom installation directories during setup
- Default installation location changed to .bmad (hidden directory) for cleaner project root organization
Web Bundle Improvements:
- All web bundles (single agent and team) now include party mode support for multi-agent collaboration!
- Advanced elicitation capabilities integrated into standalone agents
- All bundles enhanced with party mode agent manifests
- Added default-party.csv files to bmm, bmgd, and cis module teams
- The default party file is what will be used with single agent bundles. teams can customize for different party configurations before web bundling through a setting in the team yaml file
- New web bundle outputs for all agents (analyst, architect, dev, pm, sm, tea, tech-writer, ux-designer, game-*, creative-squad)
Phase 4 Workflow Updates (In Progress):
- Initiated shift to separate phase 4 implementation artifacts from documentation
- Phase 4 implementation artifacts (stories, code review, sprint plan, context files) will move to dedicated location outside docs folder
- Installer questions and configuration added for artifact path selection
- Updated workflow.yaml files for code-review, sprint-planning, story-context, epic-tech-context, and retrospective workflows to support this, but still might require some udpates
Additional Changes:
- New agent and action command header models for standardization
- Enhanced web-bundle-activation-steps fragment
- Updated web-bundler.js to support new structure
- VS Code settings updated for new .bmad directory
- Party mode instructions and workflow enhanced for better orchestration
IDE Installer Updates:
- Show version number of installer in cli
- improved Installer UX
- Gemini TOML Improved to have clear loading instructions with @ commands
- All tools agent launcher mds improved to use a central file template critical indication isntead of hardcoding in 2 different locations.
2025-11-09 17:39:05 -06:00
|
|
|
const workflowGen = new WorkflowCommandGenerator(this.bmadFolderName);
|
2025-11-06 22:45:29 -06:00
|
|
|
const { artifacts: workflowArtifacts } = await workflowGen.collectWorkflowArtifacts(bmadDir);
|
|
|
|
|
|
|
|
|
|
// Write only workflow-command artifacts, skip workflow-launcher READMEs
|
|
|
|
|
let workflowCommandCount = 0;
|
|
|
|
|
for (const artifact of workflowArtifacts) {
|
|
|
|
|
if (artifact.type === 'workflow-command') {
|
|
|
|
|
const moduleWorkflowsDir = path.join(bmadCommandsDir, artifact.module, 'workflows');
|
|
|
|
|
await this.ensureDir(moduleWorkflowsDir);
|
|
|
|
|
const commandPath = path.join(moduleWorkflowsDir, path.basename(artifact.relativePath));
|
|
|
|
|
await this.writeFile(commandPath, artifact.content);
|
|
|
|
|
workflowCommandCount++;
|
|
|
|
|
}
|
|
|
|
|
// Skip workflow-launcher READMEs as they would be treated as slash commands
|
|
|
|
|
}
|
2025-09-28 23:17:07 -05:00
|
|
|
|
2025-10-26 19:38:38 -05:00
|
|
|
// Generate task and tool commands from manifests (if they exist)
|
|
|
|
|
const taskToolGen = new TaskToolCommandGenerator();
|
|
|
|
|
const taskToolResult = await taskToolGen.generateTaskToolCommands(projectDir, bmadDir);
|
|
|
|
|
|
2025-09-28 23:17:07 -05:00
|
|
|
console.log(chalk.green(`✓ ${this.name} configured:`));
|
|
|
|
|
console.log(chalk.dim(` - ${agentCount} agents installed`));
|
2025-11-06 22:45:29 -06:00
|
|
|
if (workflowCommandCount > 0) {
|
|
|
|
|
console.log(chalk.dim(` - ${workflowCommandCount} workflow commands generated`));
|
2025-09-28 23:17:07 -05:00
|
|
|
}
|
2025-10-26 19:38:38 -05:00
|
|
|
if (taskToolResult.generated > 0) {
|
|
|
|
|
console.log(
|
|
|
|
|
chalk.dim(
|
|
|
|
|
` - ${taskToolResult.generated} task/tool commands generated (${taskToolResult.tasks} tasks, ${taskToolResult.tools} tools)`,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-09-28 23:17:07 -05:00
|
|
|
console.log(chalk.dim(` - Commands directory: ${path.relative(projectDir, bmadCommandsDir)}`));
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
success: true,
|
|
|
|
|
agents: agentCount,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Method removed - CLAUDE.md file management left to user
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Read and process file content
|
|
|
|
|
*/
|
|
|
|
|
async readAndProcess(filePath, metadata) {
|
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
const content = await fs.readFile(filePath, 'utf8');
|
|
|
|
|
return this.processContent(content, metadata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-15 21:17:09 -05:00
|
|
|
* Override processContent to keep {project-root} placeholder
|
2025-09-28 23:17:07 -05:00
|
|
|
*/
|
|
|
|
|
processContent(content, metadata = {}) {
|
2025-10-15 21:17:09 -05:00
|
|
|
// Use the base class method WITHOUT projectDir to preserve {project-root} placeholder
|
|
|
|
|
return super.processContent(content, metadata);
|
2025-09-28 23:17:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get agents from source modules (not installed location)
|
|
|
|
|
*/
|
|
|
|
|
async getAgentsFromSource(sourceDir, selectedModules) {
|
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
const agents = [];
|
|
|
|
|
|
|
|
|
|
// Add core agents
|
|
|
|
|
const corePath = getModulePath('core');
|
|
|
|
|
if (await fs.pathExists(path.join(corePath, 'agents'))) {
|
2025-10-05 15:52:48 -07:00
|
|
|
const coreAgents = await getAgentsFromDir(path.join(corePath, 'agents'), 'core');
|
2025-09-28 23:17:07 -05:00
|
|
|
agents.push(...coreAgents);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add module agents
|
|
|
|
|
for (const moduleName of selectedModules) {
|
|
|
|
|
const modulePath = path.join(sourceDir, moduleName);
|
|
|
|
|
const agentsPath = path.join(modulePath, 'agents');
|
|
|
|
|
|
|
|
|
|
if (await fs.pathExists(agentsPath)) {
|
2025-10-05 15:52:48 -07:00
|
|
|
const moduleAgents = await getAgentsFromDir(agentsPath, moduleName);
|
2025-09-28 23:17:07 -05:00
|
|
|
agents.push(...moduleAgents);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return agents;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Process module injections with pre-collected configuration
|
|
|
|
|
*/
|
|
|
|
|
async processModuleInjectionsWithConfig(projectDir, bmadDir, options, preCollectedConfig) {
|
|
|
|
|
// Get list of installed modules
|
|
|
|
|
const modules = options.selectedModules || [];
|
|
|
|
|
const { subagentChoices, installLocation } = preCollectedConfig;
|
|
|
|
|
|
|
|
|
|
// Get the actual source directory (not the installation directory)
|
2025-10-05 15:52:48 -07:00
|
|
|
await this.processModuleInjectionsInternal({
|
|
|
|
|
projectDir,
|
|
|
|
|
modules,
|
|
|
|
|
handler: 'claude-code',
|
|
|
|
|
subagentChoices,
|
|
|
|
|
installLocation,
|
|
|
|
|
interactive: false,
|
|
|
|
|
});
|
2025-09-28 23:17:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Process Claude Code specific injections for installed modules
|
|
|
|
|
* Looks for injections.yaml in each module's claude-code sub-module
|
|
|
|
|
*/
|
|
|
|
|
async processModuleInjections(projectDir, bmadDir, options) {
|
|
|
|
|
// Get list of installed modules
|
|
|
|
|
const modules = options.selectedModules || [];
|
|
|
|
|
let subagentChoices = null;
|
|
|
|
|
let installLocation = null;
|
|
|
|
|
|
|
|
|
|
// Get the actual source directory (not the installation directory)
|
2025-10-05 15:52:48 -07:00
|
|
|
const { subagentChoices: updatedChoices, installLocation: updatedLocation } = await this.processModuleInjectionsInternal({
|
|
|
|
|
projectDir,
|
|
|
|
|
modules,
|
|
|
|
|
handler: 'claude-code',
|
|
|
|
|
subagentChoices,
|
|
|
|
|
installLocation,
|
|
|
|
|
interactive: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (updatedChoices) {
|
|
|
|
|
subagentChoices = updatedChoices;
|
|
|
|
|
}
|
|
|
|
|
if (updatedLocation) {
|
|
|
|
|
installLocation = updatedLocation;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-28 23:17:07 -05:00
|
|
|
|
2025-10-05 15:52:48 -07:00
|
|
|
async processModuleInjectionsInternal({ projectDir, modules, handler, subagentChoices, installLocation, interactive = false }) {
|
|
|
|
|
let choices = subagentChoices;
|
|
|
|
|
let location = installLocation;
|
2025-09-28 23:17:07 -05:00
|
|
|
|
2025-10-05 15:52:48 -07:00
|
|
|
for (const moduleName of modules) {
|
|
|
|
|
const configData = await loadModuleInjectionConfig(handler, moduleName);
|
2025-09-28 23:17:07 -05:00
|
|
|
|
2025-10-05 15:52:48 -07:00
|
|
|
if (!configData) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2025-09-28 23:17:07 -05:00
|
|
|
|
2025-10-05 15:52:48 -07:00
|
|
|
const { config, handlerBaseDir } = configData;
|
2025-09-28 23:17:07 -05:00
|
|
|
|
2025-10-05 15:52:48 -07:00
|
|
|
if (interactive) {
|
|
|
|
|
console.log(chalk.cyan(`\nConfiguring ${moduleName} ${handler.replace('-', ' ')} features...`));
|
|
|
|
|
}
|
2025-09-28 23:17:07 -05:00
|
|
|
|
2025-10-05 15:52:48 -07:00
|
|
|
if (interactive && config.subagents && !choices) {
|
|
|
|
|
choices = await this.promptSubagentInstallation(config.subagents);
|
|
|
|
|
|
|
|
|
|
if (choices.install !== 'none') {
|
|
|
|
|
const inquirer = require('inquirer');
|
|
|
|
|
const locationAnswer = await inquirer.prompt([
|
|
|
|
|
{
|
|
|
|
|
type: 'list',
|
|
|
|
|
name: 'location',
|
|
|
|
|
message: 'Where would you like to install Claude Code subagents?',
|
|
|
|
|
choices: [
|
|
|
|
|
{ name: 'Project level (.claude/agents/)', value: 'project' },
|
|
|
|
|
{ name: 'User level (~/.claude/agents/)', value: 'user' },
|
|
|
|
|
],
|
|
|
|
|
default: 'project',
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
location = locationAnswer.location;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-28 23:17:07 -05:00
|
|
|
|
2025-10-05 15:52:48 -07:00
|
|
|
if (config.injections && choices && choices.install !== 'none') {
|
|
|
|
|
for (const injection of config.injections) {
|
|
|
|
|
if (shouldApplyInjection(injection, choices)) {
|
|
|
|
|
await this.injectContent(projectDir, injection, choices);
|
2025-09-28 23:17:07 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-05 15:52:48 -07:00
|
|
|
|
|
|
|
|
if (config.subagents && choices && choices.install !== 'none') {
|
|
|
|
|
await this.copySelectedSubagents(projectDir, handlerBaseDir, config.subagents, choices, location || 'project');
|
|
|
|
|
}
|
2025-09-28 23:17:07 -05:00
|
|
|
}
|
2025-10-05 15:52:48 -07:00
|
|
|
|
|
|
|
|
return { subagentChoices: choices, installLocation: location };
|
2025-09-28 23:17:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prompt user for subagent installation preferences
|
|
|
|
|
*/
|
|
|
|
|
async promptSubagentInstallation(subagentConfig) {
|
|
|
|
|
const inquirer = require('inquirer');
|
|
|
|
|
|
|
|
|
|
// First ask if they want to install subagents
|
|
|
|
|
const { install } = await inquirer.prompt([
|
|
|
|
|
{
|
|
|
|
|
type: 'list',
|
|
|
|
|
name: 'install',
|
|
|
|
|
message: 'Would you like to install Claude Code subagents for enhanced functionality?',
|
|
|
|
|
choices: [
|
|
|
|
|
{ name: 'Yes, install all subagents', value: 'all' },
|
|
|
|
|
{ name: 'Yes, let me choose specific subagents', value: 'selective' },
|
|
|
|
|
{ name: 'No, skip subagent installation', value: 'none' },
|
|
|
|
|
],
|
|
|
|
|
default: 'all',
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
if (install === 'selective') {
|
|
|
|
|
// Show list of available subagents with descriptions
|
|
|
|
|
const subagentInfo = {
|
|
|
|
|
'market-researcher.md': 'Market research and competitive analysis',
|
|
|
|
|
'requirements-analyst.md': 'Requirements extraction and validation',
|
|
|
|
|
'technical-evaluator.md': 'Technology stack evaluation',
|
|
|
|
|
'epic-optimizer.md': 'Epic and story breakdown optimization',
|
|
|
|
|
'document-reviewer.md': 'Document quality review',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const { selected } = await inquirer.prompt([
|
|
|
|
|
{
|
|
|
|
|
type: 'checkbox',
|
|
|
|
|
name: 'selected',
|
|
|
|
|
message: 'Select subagents to install:',
|
|
|
|
|
choices: subagentConfig.files.map((file) => ({
|
|
|
|
|
name: `${file.replace('.md', '')} - ${subagentInfo[file] || 'Specialized assistant'}`,
|
|
|
|
|
value: file,
|
|
|
|
|
checked: true,
|
|
|
|
|
})),
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return { install: 'selective', selected };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { install };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Inject content at specified point in file
|
|
|
|
|
*/
|
|
|
|
|
async injectContent(projectDir, injection, subagentChoices = null) {
|
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
const targetPath = path.join(projectDir, injection.file);
|
|
|
|
|
|
|
|
|
|
if (await this.exists(targetPath)) {
|
|
|
|
|
let content = await fs.readFile(targetPath, 'utf8');
|
|
|
|
|
const marker = `<!-- IDE-INJECT-POINT: ${injection.point} -->`;
|
|
|
|
|
|
|
|
|
|
if (content.includes(marker)) {
|
|
|
|
|
let injectionContent = injection.content;
|
|
|
|
|
|
|
|
|
|
// Filter content if selective subagents chosen
|
|
|
|
|
if (subagentChoices && subagentChoices.install === 'selective' && injection.point === 'pm-agent-instructions') {
|
2025-10-05 15:52:48 -07:00
|
|
|
injectionContent = filterAgentInstructions(injection.content, subagentChoices.selected);
|
2025-09-28 23:17:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
content = content.replace(marker, injectionContent);
|
|
|
|
|
await fs.writeFile(targetPath, content);
|
|
|
|
|
console.log(chalk.dim(` Injected: ${injection.point} → ${injection.file}`));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Copy selected subagents to appropriate Claude agents directory
|
|
|
|
|
*/
|
2025-10-05 15:52:48 -07:00
|
|
|
async copySelectedSubagents(projectDir, handlerBaseDir, subagentConfig, choices, location) {
|
2025-09-28 23:17:07 -05:00
|
|
|
const fs = require('fs-extra');
|
2025-10-05 15:52:48 -07:00
|
|
|
const os = require('node:os');
|
2025-09-28 23:17:07 -05:00
|
|
|
|
|
|
|
|
// Determine target directory based on user choice
|
|
|
|
|
let targetDir;
|
|
|
|
|
if (location === 'user') {
|
2025-10-05 15:52:48 -07:00
|
|
|
targetDir = path.join(os.homedir(), '.claude', 'agents');
|
2025-09-28 23:17:07 -05:00
|
|
|
console.log(chalk.dim(` Installing subagents globally to: ~/.claude/agents/`));
|
|
|
|
|
} else {
|
|
|
|
|
targetDir = path.join(projectDir, '.claude', 'agents');
|
|
|
|
|
console.log(chalk.dim(` Installing subagents to project: .claude/agents/`));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ensure target directory exists
|
|
|
|
|
await this.ensureDir(targetDir);
|
|
|
|
|
|
2025-10-05 15:52:48 -07:00
|
|
|
const resolvedFiles = await resolveSubagentFiles(handlerBaseDir, subagentConfig, choices);
|
2025-10-01 09:12:21 -05:00
|
|
|
|
|
|
|
|
let copiedCount = 0;
|
2025-10-05 15:52:48 -07:00
|
|
|
for (const resolved of resolvedFiles) {
|
2025-10-01 09:12:21 -05:00
|
|
|
try {
|
2025-10-05 15:52:48 -07:00
|
|
|
const sourcePath = resolved.absolutePath;
|
|
|
|
|
|
|
|
|
|
const subFolder = path.dirname(resolved.relativePath);
|
|
|
|
|
let targetPath;
|
|
|
|
|
if (subFolder && subFolder !== '.') {
|
|
|
|
|
const targetSubDir = path.join(targetDir, subFolder);
|
|
|
|
|
await this.ensureDir(targetSubDir);
|
|
|
|
|
targetPath = path.join(targetSubDir, path.basename(resolved.file));
|
2025-10-01 09:12:21 -05:00
|
|
|
} else {
|
2025-10-05 15:52:48 -07:00
|
|
|
targetPath = path.join(targetDir, path.basename(resolved.file));
|
2025-10-01 09:12:21 -05:00
|
|
|
}
|
2025-10-05 15:52:48 -07:00
|
|
|
|
|
|
|
|
await fs.copyFile(sourcePath, targetPath);
|
|
|
|
|
console.log(chalk.green(` ✓ Installed: ${subFolder === '.' ? '' : `${subFolder}/`}${path.basename(resolved.file, '.md')}`));
|
|
|
|
|
copiedCount++;
|
2025-10-01 09:12:21 -05:00
|
|
|
} catch (error) {
|
2025-10-05 15:52:48 -07:00
|
|
|
console.log(chalk.yellow(` ⚠ Error copying ${resolved.file}: ${error.message}`));
|
2025-09-28 23:17:07 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-01 09:12:21 -05:00
|
|
|
if (copiedCount > 0) {
|
|
|
|
|
console.log(chalk.dim(` Total subagents installed: ${copiedCount}`));
|
2025-09-28 23:17:07 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = { ClaudeCodeSetup };
|