feat: add qwen-code ide support to bmad installer. (#392)
Co-authored-by: Djanghao <hstnz>
This commit is contained in:
@@ -59,6 +59,8 @@ class IdeSetup extends BaseIdeSetup {
|
||||
return this.setupGeminiCli(installDir, selectedAgent);
|
||||
case "github-copilot":
|
||||
return this.setupGitHubCopilot(installDir, selectedAgent, spinner, preConfiguredSettings);
|
||||
case "qwen-code":
|
||||
return this.setupQwenCode(installDir, selectedAgent);
|
||||
default:
|
||||
console.log(chalk.yellow(`\nIDE ${ide} not yet supported`));
|
||||
return false;
|
||||
@@ -977,6 +979,106 @@ class IdeSetup extends BaseIdeSetup {
|
||||
return true;
|
||||
}
|
||||
|
||||
async setupQwenCode(installDir, selectedAgent) {
|
||||
const qwenDir = path.join(installDir, ".qwen");
|
||||
const bmadMethodDir = path.join(qwenDir, "bmad-method");
|
||||
await fileManager.ensureDirectory(bmadMethodDir);
|
||||
|
||||
// Update logic for existing settings.json
|
||||
const settingsPath = path.join(qwenDir, "settings.json");
|
||||
if (await fileManager.pathExists(settingsPath)) {
|
||||
try {
|
||||
const settingsContent = await fileManager.readFile(settingsPath);
|
||||
const settings = JSON.parse(settingsContent);
|
||||
let updated = false;
|
||||
|
||||
// Handle contextFileName property
|
||||
if (settings.contextFileName && Array.isArray(settings.contextFileName)) {
|
||||
const originalLength = settings.contextFileName.length;
|
||||
settings.contextFileName = settings.contextFileName.filter(
|
||||
(fileName) => !fileName.startsWith("agents/")
|
||||
);
|
||||
if (settings.contextFileName.length !== originalLength) {
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
await fileManager.writeFile(
|
||||
settingsPath,
|
||||
JSON.stringify(settings, null, 2)
|
||||
);
|
||||
console.log(chalk.green("✓ Updated .qwen/settings.json - removed agent file references"));
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
chalk.yellow("Could not update .qwen/settings.json"),
|
||||
error
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove old agents directory
|
||||
const agentsDir = path.join(qwenDir, "agents");
|
||||
if (await fileManager.pathExists(agentsDir)) {
|
||||
await fileManager.removeDirectory(agentsDir);
|
||||
console.log(chalk.green("✓ Removed old .qwen/agents directory"));
|
||||
}
|
||||
|
||||
// Get all available agents
|
||||
const agents = selectedAgent ? [selectedAgent] : await this.getAllAgentIds(installDir);
|
||||
let concatenatedContent = "";
|
||||
|
||||
for (const agentId of agents) {
|
||||
// Find the source agent file
|
||||
const agentPath = await this.findAgentPath(agentId, installDir);
|
||||
|
||||
if (agentPath) {
|
||||
const agentContent = await fileManager.readFile(agentPath);
|
||||
|
||||
// Create properly formatted agent rule content (similar to gemini)
|
||||
let agentRuleContent = `# ${agentId.toUpperCase()} Agent Rule\n\n`;
|
||||
agentRuleContent += `This rule is triggered when the user types \`*${agentId}\` and activates the ${await this.getAgentTitle(
|
||||
agentId,
|
||||
installDir
|
||||
)} agent persona.\n\n`;
|
||||
agentRuleContent += "## Agent Activation\n\n";
|
||||
agentRuleContent +=
|
||||
"CRITICAL: Read the full YAML, start activation to alter your state of being, follow startup section instructions, stay in this being until told to exit this mode:\n\n";
|
||||
agentRuleContent += "```yaml\n";
|
||||
// Extract just the YAML content from the agent file
|
||||
const yamlContent = extractYamlFromAgent(agentContent);
|
||||
if (yamlContent) {
|
||||
agentRuleContent += yamlContent;
|
||||
}
|
||||
else {
|
||||
// If no YAML found, include the whole content minus the header
|
||||
agentRuleContent += agentContent.replace(/^#.*$/m, "").trim();
|
||||
}
|
||||
agentRuleContent += "\n```\n\n";
|
||||
agentRuleContent += "## File Reference\n\n";
|
||||
const relativePath = path.relative(installDir, agentPath).replace(/\\/g, '/');
|
||||
agentRuleContent += `The complete agent definition is available in [${relativePath}](${relativePath}).\n\n`;
|
||||
agentRuleContent += "## Usage\n\n";
|
||||
agentRuleContent += `When the user types \`*${agentId}\`, activate this ${await this.getAgentTitle(
|
||||
agentId,
|
||||
installDir
|
||||
)} persona and follow all instructions defined in the YAML configuration above.\n`;
|
||||
|
||||
// Add to concatenated content with separator
|
||||
concatenatedContent += agentRuleContent + "\n\n---\n\n";
|
||||
console.log(chalk.green(`✓ Added context for *${agentId}`));
|
||||
}
|
||||
}
|
||||
|
||||
// Write the concatenated content to QWEN.md
|
||||
const qwenMdPath = path.join(bmadMethodDir, "QWEN.md");
|
||||
await fileManager.writeFile(qwenMdPath, concatenatedContent);
|
||||
console.log(chalk.green(`\n✓ Created QWEN.md in ${bmadMethodDir}`));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async setupGitHubCopilot(installDir, selectedAgent, spinner = null, preConfiguredSettings = null) {
|
||||
// Configure VS Code workspace settings first to avoid UI conflicts with loading spinners
|
||||
await this.configureVsCodeSettings(installDir, spinner, preConfiguredSettings);
|
||||
|
||||
Reference in New Issue
Block a user