mirror of
https://github.com/bmad-code-org/BMAD-METHOD.git
synced 2026-09-19 08:11:52 +08:00
ee25fcca6f
* refactor(augment): remove legacy YAML/XML workflow rules from code review guidelines All workflows have been converted to markdown. Remove workflow.yaml, workflow.xml, and config_source references from Augment review rules. Drop the entire xml_workflows section (5 rules) and the YAML-specific standard_workflow_instructions rule. * refactor: extract discover_inputs protocol from workflow.xml into co-located markdown Convert the discover_inputs XML protocol (FULL_LOAD, SELECTIVE_LOAD, INDEX_GUIDED strategies) into standalone markdown files placed alongside the two workflows that use it (create-story, code-review). Replace <invoke-protocol> tags with explicit file references. This decouples the workflows from workflow.xml, enabling its deletion in a follow-up. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: delete dead YAML/XML workflow engine files Remove 5 files made obsolete by the workflow.yaml → workflow.md migration: - workflow.xml (the YAML workflow interpreter engine) - dev-story/instructions.xml (superseded by workflow.md) - 3 installer templates for YAML workflow command generation References in CLI code will be cleaned up in follow-up commits. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: delete obsolete workflow handler fragments Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: remove YAML workflow code paths from CLI installer pipeline Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: remove workflow.xml references from manifests and checklists Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: remove workflow.xml references from English command docs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * test: update fixtures to remove workflow.yaml references Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: update workflow.yaml example path to workflow.md in handler-multi Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: stop tracking workflow/validate-workflow as handler attributes These handler fragments were deleted — the exec handler already covers loading .md workflow files directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: rename workflow attribute to exec in agent menu items Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address PR review findings from triage - Fix regex capture group index in module manager workflow path parsing - Remove stale workflow handler references from handler-multi.txt - Replace workflow with multi in activation-steps dispatch contract - Remove dead validate-workflow emission from compiler and xml-builder - Align commands.md wording to remove engine references - Fix relativePath anchoring in _base-ide.js recursive directory scans - Remove dead code from workflow-command-generator (unused template, generateCommandContent, writeColonArtifacts, writeDashArtifacts) - Delete unused workflow-commander.md template - Add regression test for workflow path regex --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
98 lines
2.8 KiB
JavaScript
98 lines
2.8 KiB
JavaScript
const yaml = require('yaml');
|
|
const fs = require('fs-extra');
|
|
|
|
/**
|
|
* Analyzes agent YAML files to detect which handlers are needed
|
|
*/
|
|
class AgentAnalyzer {
|
|
/**
|
|
* Analyze an agent YAML structure to determine which handlers it needs
|
|
* @param {Object} agentYaml - Parsed agent YAML object
|
|
* @returns {Object} Profile of needed handlers
|
|
*/
|
|
analyzeAgentObject(agentYaml) {
|
|
const profile = {
|
|
usedAttributes: new Set(),
|
|
hasPrompts: false,
|
|
menuItems: [],
|
|
};
|
|
|
|
// Check if agent has prompts section
|
|
if (agentYaml.agent && agentYaml.agent.prompts) {
|
|
profile.hasPrompts = true;
|
|
}
|
|
|
|
// Analyze menu items (support both 'menu' and legacy 'commands')
|
|
const menuItems = agentYaml.agent?.menu || agentYaml.agent?.commands || [];
|
|
|
|
for (const item of menuItems) {
|
|
// Track the menu item
|
|
profile.menuItems.push(item);
|
|
|
|
// Check for multi format items
|
|
if (item.multi && item.triggers) {
|
|
profile.usedAttributes.add('multi');
|
|
|
|
// Also check attributes in nested handlers
|
|
for (const triggerGroup of item.triggers) {
|
|
for (const [triggerName, execArray] of Object.entries(triggerGroup)) {
|
|
if (Array.isArray(execArray)) {
|
|
for (const exec of execArray) {
|
|
if (exec.route) {
|
|
profile.usedAttributes.add('exec');
|
|
}
|
|
if (exec.action) profile.usedAttributes.add('action');
|
|
if (exec.type && ['exec', 'action'].includes(exec.type)) {
|
|
profile.usedAttributes.add(exec.type);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
// Check for each possible attribute in legacy items
|
|
if (item.exec) {
|
|
profile.usedAttributes.add('exec');
|
|
}
|
|
if (item.tmpl) {
|
|
profile.usedAttributes.add('tmpl');
|
|
}
|
|
if (item.data) {
|
|
profile.usedAttributes.add('data');
|
|
}
|
|
if (item.action) {
|
|
profile.usedAttributes.add('action');
|
|
}
|
|
}
|
|
}
|
|
|
|
// Convert Set to Array for easier use
|
|
profile.usedAttributes = [...profile.usedAttributes];
|
|
|
|
return profile;
|
|
}
|
|
|
|
/**
|
|
* Analyze an agent YAML file
|
|
* @param {string} filePath - Path to agent YAML file
|
|
* @returns {Object} Profile of needed handlers
|
|
*/
|
|
async analyzeAgentFile(filePath) {
|
|
const content = await fs.readFile(filePath, 'utf8');
|
|
const agentYaml = yaml.parse(content);
|
|
return this.analyzeAgentObject(agentYaml);
|
|
}
|
|
|
|
/**
|
|
* Check if an agent needs a specific handler
|
|
* @param {Object} profile - Agent profile from analyze
|
|
* @param {string} handlerType - Handler type to check
|
|
* @returns {boolean} True if handler is needed
|
|
*/
|
|
needsHandler(profile, handlerType) {
|
|
return profile.usedAttributes.includes(handlerType);
|
|
}
|
|
}
|
|
|
|
module.exports = { AgentAnalyzer };
|