BMAD-METHOD/tools/cli/lib/agent/compiler.js

426 lines
14 KiB
JavaScript
Raw Normal View History

feat: Complete BMAD agent creation system with install tooling, references, and field guidance ## Overview This commit represents a complete overhaul of the BMAD agent creation system, establishing clear standards for agent development, installation workflows, and persona design. The changes span documentation, tooling, reference implementations, and field-specific guidance. ## Key Components ### 1. Agent Installation Infrastructure **New CLI Command: `agent-install`** - Interactive agent installation with persona customization - Supports Simple (single YAML), Expert (sidecar files), and Module agents - Template variable processing with Handlebars-style syntax - Automatic compilation from YAML to XML (.md) format - Manifest tracking and IDE integration (Claude Code, Cursor, Windsurf, etc.) - Source preservation in `_cfg/custom/agents/` for reinstallation **Files Created:** - `tools/cli/commands/agent-install.js` - Main CLI command - `tools/cli/lib/agent/compiler.js` - YAML to XML compilation engine - `tools/cli/lib/agent/installer.js` - Installation orchestration - `tools/cli/lib/agent/template-engine.js` - Handlebars template processing **Compiler Features:** - Auto-injects frontmatter, activation, handlers, help/exit menu items - Smart handler inclusion (only includes action/workflow/exec/tmpl handlers actually used) - Proper XML escaping and formatting - Persona name customization (e.g., "Fred the Commit Poet") ### 2. Documentation Overhaul **Deleted Bloated/Outdated Docs (2,651 lines removed):** - Old verbose architecture docs - Redundant pattern files - Outdated workflow guides **Created Focused, Type-Specific Docs:** - `src/modules/bmb/docs/understanding-agent-types.md` - Architecture vs capability distinction - `src/modules/bmb/docs/simple-agent-architecture.md` - Self-contained agents - `src/modules/bmb/docs/expert-agent-architecture.md` - Agents with sidecar files - `src/modules/bmb/docs/module-agent-architecture.md` - Workflow-integrated agents - `src/modules/bmb/docs/agent-compilation.md` - YAML → XML process - `src/modules/bmb/docs/agent-menu-patterns.md` - Menu design patterns - `src/modules/bmb/docs/index.md` - Documentation hub **Net Result:** ~1,930 line reduction while adding MORE value through focused content ### 3. Create-Agent Workflow Enhancements **Critical Persona Field Guidance Added to Step 4:** Explains how the LLM interprets each persona field when the agent activates: - **role** → "What knowledge, skills, and capabilities do I possess?" - **identity** → "What background, experience, and context shape my responses?" - **communication_style** → "What verbal patterns, word choice, quirks, and phrasing do I use?" - **principles** → "What beliefs and operating philosophy drive my choices?" **Key Insight:** `communication_style` should ONLY describe HOW the agent talks, not restate role/identity/principles. The `communication-presets.csv` provides 60 pure communication styles with NO role/identity/principles mixed in. **Files Updated:** - `src/modules/bmb/workflows/create-agent/instructions.md` - Added persona field interpretation guide - `src/modules/bmb/workflows/create-agent/brainstorm-context.md` - Refined to 137 lines - `src/modules/bmb/workflows/create-agent/communication-presets.csv` - 60 styles across 13 categories ### 4. Reference Agent Cleanup **Removed install_config Personality Bloat:** Understanding: Future installer will handle personality customization, so stripped all personality toggles from reference agents. **commit-poet.agent.yaml** (Simple Agent): - BEFORE: 36 personality combinations (3 enthusiasm × 3 depths × 4 styles) = decision fatigue - AFTER: Single concise persona with pure communication style - Changed from verbose conditionals to: "Poetic drama and flair with every turn of a phrase. I transform mundane commits into lyrical masterpieces, finding beauty in your code's evolution." - Reduction: 248 lines → 153 lines (38% reduction) **journal-keeper.agent.yaml** (Expert Agent): - Stripped install_config, simplified communication_style - Shows proper Expert agent structure with sidecar files **security-engineer.agent.yaml & trend-analyst.agent.yaml** (Module Agents): - Added header comments explaining WHY Module Agent (design intent, not just location) - Clarified: Module agents are designed FOR ecosystem integration, not capability-limited **Files Updated:** - `src/modules/bmb/reference/agents/simple-examples/commit-poet.agent.yaml` - `src/modules/bmb/reference/agents/expert-examples/journal-keeper/journal-keeper.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/security-engineer.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/trend-analyst.agent.yaml` ### 5. BMM Agent Voice Enhancement **Gave all 9 BMM agents distinct, memorable communication voices:** **Mary (analyst)** - The favorite! Changed from generic "systematic and probing" to: "Treats analysis like a treasure hunt - excited by every clue, thrilled when patterns emerge. Asks questions that spark 'aha!' moments while structuring insights with precision." **Other Notable Voices:** - **John (pm):** "Asks 'WHY?' relentlessly like a detective on a case. Direct and data-sharp, cuts through fluff to what actually matters." - **Winston (architect):** "Speaks in calm, pragmatic tones, balancing 'what could be' with 'what should be.' Champions boring technology that actually works." - **Amelia (dev):** "Ultra-succinct. Speaks in file paths and AC IDs - every statement citable. No fluff, all precision." - **Bob (sm):** "Crisp and checklist-driven. Every word has a purpose, every requirement crystal clear. Zero tolerance for ambiguity." - **Sally (ux-designer):** "Paints pictures with words, telling user stories that make you FEEL the problem. Empathetic advocate with creative storytelling flair." **Pattern Applied:** Moved behaviors from communication_style to principles, keeping communication_style as PURE verbal patterns. **Files Updated:** - `src/modules/bmm/agents/analyst.agent.yaml` - `src/modules/bmm/agents/pm.agent.yaml` - `src/modules/bmm/agents/architect.agent.yaml` - `src/modules/bmm/agents/dev.agent.yaml` - `src/modules/bmm/agents/sm.agent.yaml` - `src/modules/bmm/agents/tea.agent.yaml` - `src/modules/bmm/agents/tech-writer.agent.yaml` - `src/modules/bmm/agents/ux-designer.agent.yaml` - `src/modules/bmm/agents/frame-expert.agent.yaml` ### 6. Linting Fixes **ESLint Compliance:** - Replaced all `'utf-8'` with `'utf8'` (unicorn/text-encoding-identifier-case) - Changed `variables.hasOwnProperty(varName)` to `Object.hasOwn(variables, varName)` (unicorn/prefer-object-has-own) - Replaced `JSON.parse(JSON.stringify(...))` with `structuredClone(...)` (unicorn/prefer-structured-clone) - Fixed empty YAML mapping values in sample files **Files Fixed:** - 7 JavaScript files across agent tooling (compiler, installer, commands, IDE integration) - 1 YAML sample file ## Architecture Decisions ### Agent Types Are About Architecture, Not Capability - **Simple:** Self-contained in single YAML (NOT limited in capability) - **Expert:** Includes sidecar files (templates, docs, etc.) - **Module:** Designed for BMAD ecosystem integration (workflows, cross-agent coordination) ### Persona Field Separation Critical for LLM Interpretation The LLM needs distinct fields to understand its role: - Mixing role/identity/principles into communication_style confuses the persona - Pure communication styles (from communication-presets.csv) have ZERO role/identity/principles content - Example DON'T: "Experienced analyst who uses systematic approaches..." (mixing identity + style) - Example DO: "Systematic and probing. Structures findings hierarchically." (pure style) ### Install-Time vs Runtime Configuration - Template variables ({{var}}) resolve at compile-time - Runtime variables ({user_name}, {bmad_folder}) resolve when agent activates - Future installer will handle personality customization, so agents should ship with single default persona ## Testing - All linting passes (ESLint with max-warnings=0) - Agent compilation tested with commit-poet, journal-keeper examples - Install workflow validated with Simple and Expert agent types - Manifest tracking and IDE integration verified ## Impact This establishes BMAD as having a complete, production-ready agent creation and installation system with: - Clear documentation for all agent types - Automated compilation and installation - Strong persona design guidance - Reference implementations showing best practices - Distinct, memorable agent voices throughout BMM module Co-Authored-By: BMad Builder <builder@bmad.dev> Co-Authored-By: Mary the Analyst <analyst@bmad.dev> Co-Authored-By: Paige the Tech Writer <tech-writer@bmad.dev>
2025-11-17 22:25:15 -06:00
/**
* BMAD Agent Compiler
* Transforms agent YAML to compiled XML (.md) format
* Uses the existing BMAD builder infrastructure for proper formatting
*/
const yaml = require('yaml');
const fs = require('node:fs');
const path = require('node:path');
const { processAgentYaml, extractInstallConfig, stripInstallConfig, getDefaultValues } = require('./template-engine');
// Use existing BMAD builder if available
let YamlXmlBuilder;
try {
YamlXmlBuilder = require('../../lib/yaml-xml-builder').YamlXmlBuilder;
} catch {
YamlXmlBuilder = null;
}
/**
* Escape XML special characters
*/
function escapeXml(text) {
if (!text) return '';
return text.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;').replaceAll("'", '&apos;');
}
/**
* Build frontmatter for agent
* @param {Object} metadata - Agent metadata
* @param {string} agentName - Final agent name
* @returns {string} YAML frontmatter
*/
function buildFrontmatter(metadata, agentName) {
const nameFromFile = agentName.replaceAll('-', ' ');
const description = metadata.title || 'BMAD Agent';
return `---
name: "${nameFromFile}"
description: "${description}"
---
You must fully embody this agent's persona and follow all activation instructions exactly as specified. NEVER break character until given an exit command.
`;
}
/**
* Build simple activation block for custom agents
* @param {Array} criticalActions - Agent-specific critical actions
* @param {Array} menuItems - Menu items to determine which handlers to include
* @param {string} deploymentType - 'ide' or 'web' - filters commands based on ide-only/web-only flags
feat: Complete BMAD agent creation system with install tooling, references, and field guidance ## Overview This commit represents a complete overhaul of the BMAD agent creation system, establishing clear standards for agent development, installation workflows, and persona design. The changes span documentation, tooling, reference implementations, and field-specific guidance. ## Key Components ### 1. Agent Installation Infrastructure **New CLI Command: `agent-install`** - Interactive agent installation with persona customization - Supports Simple (single YAML), Expert (sidecar files), and Module agents - Template variable processing with Handlebars-style syntax - Automatic compilation from YAML to XML (.md) format - Manifest tracking and IDE integration (Claude Code, Cursor, Windsurf, etc.) - Source preservation in `_cfg/custom/agents/` for reinstallation **Files Created:** - `tools/cli/commands/agent-install.js` - Main CLI command - `tools/cli/lib/agent/compiler.js` - YAML to XML compilation engine - `tools/cli/lib/agent/installer.js` - Installation orchestration - `tools/cli/lib/agent/template-engine.js` - Handlebars template processing **Compiler Features:** - Auto-injects frontmatter, activation, handlers, help/exit menu items - Smart handler inclusion (only includes action/workflow/exec/tmpl handlers actually used) - Proper XML escaping and formatting - Persona name customization (e.g., "Fred the Commit Poet") ### 2. Documentation Overhaul **Deleted Bloated/Outdated Docs (2,651 lines removed):** - Old verbose architecture docs - Redundant pattern files - Outdated workflow guides **Created Focused, Type-Specific Docs:** - `src/modules/bmb/docs/understanding-agent-types.md` - Architecture vs capability distinction - `src/modules/bmb/docs/simple-agent-architecture.md` - Self-contained agents - `src/modules/bmb/docs/expert-agent-architecture.md` - Agents with sidecar files - `src/modules/bmb/docs/module-agent-architecture.md` - Workflow-integrated agents - `src/modules/bmb/docs/agent-compilation.md` - YAML → XML process - `src/modules/bmb/docs/agent-menu-patterns.md` - Menu design patterns - `src/modules/bmb/docs/index.md` - Documentation hub **Net Result:** ~1,930 line reduction while adding MORE value through focused content ### 3. Create-Agent Workflow Enhancements **Critical Persona Field Guidance Added to Step 4:** Explains how the LLM interprets each persona field when the agent activates: - **role** → "What knowledge, skills, and capabilities do I possess?" - **identity** → "What background, experience, and context shape my responses?" - **communication_style** → "What verbal patterns, word choice, quirks, and phrasing do I use?" - **principles** → "What beliefs and operating philosophy drive my choices?" **Key Insight:** `communication_style` should ONLY describe HOW the agent talks, not restate role/identity/principles. The `communication-presets.csv` provides 60 pure communication styles with NO role/identity/principles mixed in. **Files Updated:** - `src/modules/bmb/workflows/create-agent/instructions.md` - Added persona field interpretation guide - `src/modules/bmb/workflows/create-agent/brainstorm-context.md` - Refined to 137 lines - `src/modules/bmb/workflows/create-agent/communication-presets.csv` - 60 styles across 13 categories ### 4. Reference Agent Cleanup **Removed install_config Personality Bloat:** Understanding: Future installer will handle personality customization, so stripped all personality toggles from reference agents. **commit-poet.agent.yaml** (Simple Agent): - BEFORE: 36 personality combinations (3 enthusiasm × 3 depths × 4 styles) = decision fatigue - AFTER: Single concise persona with pure communication style - Changed from verbose conditionals to: "Poetic drama and flair with every turn of a phrase. I transform mundane commits into lyrical masterpieces, finding beauty in your code's evolution." - Reduction: 248 lines → 153 lines (38% reduction) **journal-keeper.agent.yaml** (Expert Agent): - Stripped install_config, simplified communication_style - Shows proper Expert agent structure with sidecar files **security-engineer.agent.yaml & trend-analyst.agent.yaml** (Module Agents): - Added header comments explaining WHY Module Agent (design intent, not just location) - Clarified: Module agents are designed FOR ecosystem integration, not capability-limited **Files Updated:** - `src/modules/bmb/reference/agents/simple-examples/commit-poet.agent.yaml` - `src/modules/bmb/reference/agents/expert-examples/journal-keeper/journal-keeper.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/security-engineer.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/trend-analyst.agent.yaml` ### 5. BMM Agent Voice Enhancement **Gave all 9 BMM agents distinct, memorable communication voices:** **Mary (analyst)** - The favorite! Changed from generic "systematic and probing" to: "Treats analysis like a treasure hunt - excited by every clue, thrilled when patterns emerge. Asks questions that spark 'aha!' moments while structuring insights with precision." **Other Notable Voices:** - **John (pm):** "Asks 'WHY?' relentlessly like a detective on a case. Direct and data-sharp, cuts through fluff to what actually matters." - **Winston (architect):** "Speaks in calm, pragmatic tones, balancing 'what could be' with 'what should be.' Champions boring technology that actually works." - **Amelia (dev):** "Ultra-succinct. Speaks in file paths and AC IDs - every statement citable. No fluff, all precision." - **Bob (sm):** "Crisp and checklist-driven. Every word has a purpose, every requirement crystal clear. Zero tolerance for ambiguity." - **Sally (ux-designer):** "Paints pictures with words, telling user stories that make you FEEL the problem. Empathetic advocate with creative storytelling flair." **Pattern Applied:** Moved behaviors from communication_style to principles, keeping communication_style as PURE verbal patterns. **Files Updated:** - `src/modules/bmm/agents/analyst.agent.yaml` - `src/modules/bmm/agents/pm.agent.yaml` - `src/modules/bmm/agents/architect.agent.yaml` - `src/modules/bmm/agents/dev.agent.yaml` - `src/modules/bmm/agents/sm.agent.yaml` - `src/modules/bmm/agents/tea.agent.yaml` - `src/modules/bmm/agents/tech-writer.agent.yaml` - `src/modules/bmm/agents/ux-designer.agent.yaml` - `src/modules/bmm/agents/frame-expert.agent.yaml` ### 6. Linting Fixes **ESLint Compliance:** - Replaced all `'utf-8'` with `'utf8'` (unicorn/text-encoding-identifier-case) - Changed `variables.hasOwnProperty(varName)` to `Object.hasOwn(variables, varName)` (unicorn/prefer-object-has-own) - Replaced `JSON.parse(JSON.stringify(...))` with `structuredClone(...)` (unicorn/prefer-structured-clone) - Fixed empty YAML mapping values in sample files **Files Fixed:** - 7 JavaScript files across agent tooling (compiler, installer, commands, IDE integration) - 1 YAML sample file ## Architecture Decisions ### Agent Types Are About Architecture, Not Capability - **Simple:** Self-contained in single YAML (NOT limited in capability) - **Expert:** Includes sidecar files (templates, docs, etc.) - **Module:** Designed for BMAD ecosystem integration (workflows, cross-agent coordination) ### Persona Field Separation Critical for LLM Interpretation The LLM needs distinct fields to understand its role: - Mixing role/identity/principles into communication_style confuses the persona - Pure communication styles (from communication-presets.csv) have ZERO role/identity/principles content - Example DON'T: "Experienced analyst who uses systematic approaches..." (mixing identity + style) - Example DO: "Systematic and probing. Structures findings hierarchically." (pure style) ### Install-Time vs Runtime Configuration - Template variables ({{var}}) resolve at compile-time - Runtime variables ({user_name}, {bmad_folder}) resolve when agent activates - Future installer will handle personality customization, so agents should ship with single default persona ## Testing - All linting passes (ESLint with max-warnings=0) - Agent compilation tested with commit-poet, journal-keeper examples - Install workflow validated with Simple and Expert agent types - Manifest tracking and IDE integration verified ## Impact This establishes BMAD as having a complete, production-ready agent creation and installation system with: - Clear documentation for all agent types - Automated compilation and installation - Strong persona design guidance - Reference implementations showing best practices - Distinct, memorable agent voices throughout BMM module Co-Authored-By: BMad Builder <builder@bmad.dev> Co-Authored-By: Mary the Analyst <analyst@bmad.dev> Co-Authored-By: Paige the Tech Writer <tech-writer@bmad.dev>
2025-11-17 22:25:15 -06:00
* @returns {string} Activation XML
*/
function buildSimpleActivation(criticalActions = [], menuItems = [], deploymentType = 'ide') {
feat: Complete BMAD agent creation system with install tooling, references, and field guidance ## Overview This commit represents a complete overhaul of the BMAD agent creation system, establishing clear standards for agent development, installation workflows, and persona design. The changes span documentation, tooling, reference implementations, and field-specific guidance. ## Key Components ### 1. Agent Installation Infrastructure **New CLI Command: `agent-install`** - Interactive agent installation with persona customization - Supports Simple (single YAML), Expert (sidecar files), and Module agents - Template variable processing with Handlebars-style syntax - Automatic compilation from YAML to XML (.md) format - Manifest tracking and IDE integration (Claude Code, Cursor, Windsurf, etc.) - Source preservation in `_cfg/custom/agents/` for reinstallation **Files Created:** - `tools/cli/commands/agent-install.js` - Main CLI command - `tools/cli/lib/agent/compiler.js` - YAML to XML compilation engine - `tools/cli/lib/agent/installer.js` - Installation orchestration - `tools/cli/lib/agent/template-engine.js` - Handlebars template processing **Compiler Features:** - Auto-injects frontmatter, activation, handlers, help/exit menu items - Smart handler inclusion (only includes action/workflow/exec/tmpl handlers actually used) - Proper XML escaping and formatting - Persona name customization (e.g., "Fred the Commit Poet") ### 2. Documentation Overhaul **Deleted Bloated/Outdated Docs (2,651 lines removed):** - Old verbose architecture docs - Redundant pattern files - Outdated workflow guides **Created Focused, Type-Specific Docs:** - `src/modules/bmb/docs/understanding-agent-types.md` - Architecture vs capability distinction - `src/modules/bmb/docs/simple-agent-architecture.md` - Self-contained agents - `src/modules/bmb/docs/expert-agent-architecture.md` - Agents with sidecar files - `src/modules/bmb/docs/module-agent-architecture.md` - Workflow-integrated agents - `src/modules/bmb/docs/agent-compilation.md` - YAML → XML process - `src/modules/bmb/docs/agent-menu-patterns.md` - Menu design patterns - `src/modules/bmb/docs/index.md` - Documentation hub **Net Result:** ~1,930 line reduction while adding MORE value through focused content ### 3. Create-Agent Workflow Enhancements **Critical Persona Field Guidance Added to Step 4:** Explains how the LLM interprets each persona field when the agent activates: - **role** → "What knowledge, skills, and capabilities do I possess?" - **identity** → "What background, experience, and context shape my responses?" - **communication_style** → "What verbal patterns, word choice, quirks, and phrasing do I use?" - **principles** → "What beliefs and operating philosophy drive my choices?" **Key Insight:** `communication_style` should ONLY describe HOW the agent talks, not restate role/identity/principles. The `communication-presets.csv` provides 60 pure communication styles with NO role/identity/principles mixed in. **Files Updated:** - `src/modules/bmb/workflows/create-agent/instructions.md` - Added persona field interpretation guide - `src/modules/bmb/workflows/create-agent/brainstorm-context.md` - Refined to 137 lines - `src/modules/bmb/workflows/create-agent/communication-presets.csv` - 60 styles across 13 categories ### 4. Reference Agent Cleanup **Removed install_config Personality Bloat:** Understanding: Future installer will handle personality customization, so stripped all personality toggles from reference agents. **commit-poet.agent.yaml** (Simple Agent): - BEFORE: 36 personality combinations (3 enthusiasm × 3 depths × 4 styles) = decision fatigue - AFTER: Single concise persona with pure communication style - Changed from verbose conditionals to: "Poetic drama and flair with every turn of a phrase. I transform mundane commits into lyrical masterpieces, finding beauty in your code's evolution." - Reduction: 248 lines → 153 lines (38% reduction) **journal-keeper.agent.yaml** (Expert Agent): - Stripped install_config, simplified communication_style - Shows proper Expert agent structure with sidecar files **security-engineer.agent.yaml & trend-analyst.agent.yaml** (Module Agents): - Added header comments explaining WHY Module Agent (design intent, not just location) - Clarified: Module agents are designed FOR ecosystem integration, not capability-limited **Files Updated:** - `src/modules/bmb/reference/agents/simple-examples/commit-poet.agent.yaml` - `src/modules/bmb/reference/agents/expert-examples/journal-keeper/journal-keeper.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/security-engineer.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/trend-analyst.agent.yaml` ### 5. BMM Agent Voice Enhancement **Gave all 9 BMM agents distinct, memorable communication voices:** **Mary (analyst)** - The favorite! Changed from generic "systematic and probing" to: "Treats analysis like a treasure hunt - excited by every clue, thrilled when patterns emerge. Asks questions that spark 'aha!' moments while structuring insights with precision." **Other Notable Voices:** - **John (pm):** "Asks 'WHY?' relentlessly like a detective on a case. Direct and data-sharp, cuts through fluff to what actually matters." - **Winston (architect):** "Speaks in calm, pragmatic tones, balancing 'what could be' with 'what should be.' Champions boring technology that actually works." - **Amelia (dev):** "Ultra-succinct. Speaks in file paths and AC IDs - every statement citable. No fluff, all precision." - **Bob (sm):** "Crisp and checklist-driven. Every word has a purpose, every requirement crystal clear. Zero tolerance for ambiguity." - **Sally (ux-designer):** "Paints pictures with words, telling user stories that make you FEEL the problem. Empathetic advocate with creative storytelling flair." **Pattern Applied:** Moved behaviors from communication_style to principles, keeping communication_style as PURE verbal patterns. **Files Updated:** - `src/modules/bmm/agents/analyst.agent.yaml` - `src/modules/bmm/agents/pm.agent.yaml` - `src/modules/bmm/agents/architect.agent.yaml` - `src/modules/bmm/agents/dev.agent.yaml` - `src/modules/bmm/agents/sm.agent.yaml` - `src/modules/bmm/agents/tea.agent.yaml` - `src/modules/bmm/agents/tech-writer.agent.yaml` - `src/modules/bmm/agents/ux-designer.agent.yaml` - `src/modules/bmm/agents/frame-expert.agent.yaml` ### 6. Linting Fixes **ESLint Compliance:** - Replaced all `'utf-8'` with `'utf8'` (unicorn/text-encoding-identifier-case) - Changed `variables.hasOwnProperty(varName)` to `Object.hasOwn(variables, varName)` (unicorn/prefer-object-has-own) - Replaced `JSON.parse(JSON.stringify(...))` with `structuredClone(...)` (unicorn/prefer-structured-clone) - Fixed empty YAML mapping values in sample files **Files Fixed:** - 7 JavaScript files across agent tooling (compiler, installer, commands, IDE integration) - 1 YAML sample file ## Architecture Decisions ### Agent Types Are About Architecture, Not Capability - **Simple:** Self-contained in single YAML (NOT limited in capability) - **Expert:** Includes sidecar files (templates, docs, etc.) - **Module:** Designed for BMAD ecosystem integration (workflows, cross-agent coordination) ### Persona Field Separation Critical for LLM Interpretation The LLM needs distinct fields to understand its role: - Mixing role/identity/principles into communication_style confuses the persona - Pure communication styles (from communication-presets.csv) have ZERO role/identity/principles content - Example DON'T: "Experienced analyst who uses systematic approaches..." (mixing identity + style) - Example DO: "Systematic and probing. Structures findings hierarchically." (pure style) ### Install-Time vs Runtime Configuration - Template variables ({{var}}) resolve at compile-time - Runtime variables ({user_name}, {bmad_folder}) resolve when agent activates - Future installer will handle personality customization, so agents should ship with single default persona ## Testing - All linting passes (ESLint with max-warnings=0) - Agent compilation tested with commit-poet, journal-keeper examples - Install workflow validated with Simple and Expert agent types - Manifest tracking and IDE integration verified ## Impact This establishes BMAD as having a complete, production-ready agent creation and installation system with: - Clear documentation for all agent types - Automated compilation and installation - Strong persona design guidance - Reference implementations showing best practices - Distinct, memorable agent voices throughout BMM module Co-Authored-By: BMad Builder <builder@bmad.dev> Co-Authored-By: Mary the Analyst <analyst@bmad.dev> Co-Authored-By: Paige the Tech Writer <tech-writer@bmad.dev>
2025-11-17 22:25:15 -06:00
let activation = '<activation critical="MANDATORY">\n';
let stepNum = 1;
// Standard steps
activation += ` <step n="${stepNum++}">Load persona from this current agent file (already in context)</step>\n`;
activation += ` <step n="${stepNum++}">Load and read {project-root}/{bmad_folder}/core/config.yaml to get {user_name}, {communication_language}, {output_folder}</step>\n`;
activation += ` <step n="${stepNum++}">Remember: user's name is {user_name}</step>\n`;
// Agent-specific steps from critical_actions
for (const action of criticalActions) {
activation += ` <step n="${stepNum++}">${action}</step>\n`;
}
// Menu and interaction steps
activation += ` <step n="${stepNum++}">ALWAYS communicate in {communication_language}</step>\n`;
activation += ` <step n="${stepNum++}">Show greeting using {user_name} from config, communicate in {communication_language}, then display numbered list of
ALL menu items from menu section</step>\n`;
activation += ` <step n="${stepNum++}">STOP and WAIT for user input - do NOT execute menu items automatically - accept number or cmd trigger or fuzzy command
match</step>\n`;
activation += ` <step n="${stepNum++}">On user input: Number → execute menu item[n] | Text → case-insensitive substring match | Multiple matches → ask user
to clarify | No match show "Not recognized"</step>\n`;
// Filter menu items based on deployment type
const filteredMenuItems = menuItems.filter((item) => {
// Skip web-only commands for IDE deployment
if (deploymentType === 'ide' && item['web-only'] === true) {
return false;
}
// Skip ide-only commands for web deployment
if (deploymentType === 'web' && item['ide-only'] === true) {
return false;
}
return true;
});
// Detect which handlers are actually used in the filtered menu
feat: Complete BMAD agent creation system with install tooling, references, and field guidance ## Overview This commit represents a complete overhaul of the BMAD agent creation system, establishing clear standards for agent development, installation workflows, and persona design. The changes span documentation, tooling, reference implementations, and field-specific guidance. ## Key Components ### 1. Agent Installation Infrastructure **New CLI Command: `agent-install`** - Interactive agent installation with persona customization - Supports Simple (single YAML), Expert (sidecar files), and Module agents - Template variable processing with Handlebars-style syntax - Automatic compilation from YAML to XML (.md) format - Manifest tracking and IDE integration (Claude Code, Cursor, Windsurf, etc.) - Source preservation in `_cfg/custom/agents/` for reinstallation **Files Created:** - `tools/cli/commands/agent-install.js` - Main CLI command - `tools/cli/lib/agent/compiler.js` - YAML to XML compilation engine - `tools/cli/lib/agent/installer.js` - Installation orchestration - `tools/cli/lib/agent/template-engine.js` - Handlebars template processing **Compiler Features:** - Auto-injects frontmatter, activation, handlers, help/exit menu items - Smart handler inclusion (only includes action/workflow/exec/tmpl handlers actually used) - Proper XML escaping and formatting - Persona name customization (e.g., "Fred the Commit Poet") ### 2. Documentation Overhaul **Deleted Bloated/Outdated Docs (2,651 lines removed):** - Old verbose architecture docs - Redundant pattern files - Outdated workflow guides **Created Focused, Type-Specific Docs:** - `src/modules/bmb/docs/understanding-agent-types.md` - Architecture vs capability distinction - `src/modules/bmb/docs/simple-agent-architecture.md` - Self-contained agents - `src/modules/bmb/docs/expert-agent-architecture.md` - Agents with sidecar files - `src/modules/bmb/docs/module-agent-architecture.md` - Workflow-integrated agents - `src/modules/bmb/docs/agent-compilation.md` - YAML → XML process - `src/modules/bmb/docs/agent-menu-patterns.md` - Menu design patterns - `src/modules/bmb/docs/index.md` - Documentation hub **Net Result:** ~1,930 line reduction while adding MORE value through focused content ### 3. Create-Agent Workflow Enhancements **Critical Persona Field Guidance Added to Step 4:** Explains how the LLM interprets each persona field when the agent activates: - **role** → "What knowledge, skills, and capabilities do I possess?" - **identity** → "What background, experience, and context shape my responses?" - **communication_style** → "What verbal patterns, word choice, quirks, and phrasing do I use?" - **principles** → "What beliefs and operating philosophy drive my choices?" **Key Insight:** `communication_style` should ONLY describe HOW the agent talks, not restate role/identity/principles. The `communication-presets.csv` provides 60 pure communication styles with NO role/identity/principles mixed in. **Files Updated:** - `src/modules/bmb/workflows/create-agent/instructions.md` - Added persona field interpretation guide - `src/modules/bmb/workflows/create-agent/brainstorm-context.md` - Refined to 137 lines - `src/modules/bmb/workflows/create-agent/communication-presets.csv` - 60 styles across 13 categories ### 4. Reference Agent Cleanup **Removed install_config Personality Bloat:** Understanding: Future installer will handle personality customization, so stripped all personality toggles from reference agents. **commit-poet.agent.yaml** (Simple Agent): - BEFORE: 36 personality combinations (3 enthusiasm × 3 depths × 4 styles) = decision fatigue - AFTER: Single concise persona with pure communication style - Changed from verbose conditionals to: "Poetic drama and flair with every turn of a phrase. I transform mundane commits into lyrical masterpieces, finding beauty in your code's evolution." - Reduction: 248 lines → 153 lines (38% reduction) **journal-keeper.agent.yaml** (Expert Agent): - Stripped install_config, simplified communication_style - Shows proper Expert agent structure with sidecar files **security-engineer.agent.yaml & trend-analyst.agent.yaml** (Module Agents): - Added header comments explaining WHY Module Agent (design intent, not just location) - Clarified: Module agents are designed FOR ecosystem integration, not capability-limited **Files Updated:** - `src/modules/bmb/reference/agents/simple-examples/commit-poet.agent.yaml` - `src/modules/bmb/reference/agents/expert-examples/journal-keeper/journal-keeper.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/security-engineer.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/trend-analyst.agent.yaml` ### 5. BMM Agent Voice Enhancement **Gave all 9 BMM agents distinct, memorable communication voices:** **Mary (analyst)** - The favorite! Changed from generic "systematic and probing" to: "Treats analysis like a treasure hunt - excited by every clue, thrilled when patterns emerge. Asks questions that spark 'aha!' moments while structuring insights with precision." **Other Notable Voices:** - **John (pm):** "Asks 'WHY?' relentlessly like a detective on a case. Direct and data-sharp, cuts through fluff to what actually matters." - **Winston (architect):** "Speaks in calm, pragmatic tones, balancing 'what could be' with 'what should be.' Champions boring technology that actually works." - **Amelia (dev):** "Ultra-succinct. Speaks in file paths and AC IDs - every statement citable. No fluff, all precision." - **Bob (sm):** "Crisp and checklist-driven. Every word has a purpose, every requirement crystal clear. Zero tolerance for ambiguity." - **Sally (ux-designer):** "Paints pictures with words, telling user stories that make you FEEL the problem. Empathetic advocate with creative storytelling flair." **Pattern Applied:** Moved behaviors from communication_style to principles, keeping communication_style as PURE verbal patterns. **Files Updated:** - `src/modules/bmm/agents/analyst.agent.yaml` - `src/modules/bmm/agents/pm.agent.yaml` - `src/modules/bmm/agents/architect.agent.yaml` - `src/modules/bmm/agents/dev.agent.yaml` - `src/modules/bmm/agents/sm.agent.yaml` - `src/modules/bmm/agents/tea.agent.yaml` - `src/modules/bmm/agents/tech-writer.agent.yaml` - `src/modules/bmm/agents/ux-designer.agent.yaml` - `src/modules/bmm/agents/frame-expert.agent.yaml` ### 6. Linting Fixes **ESLint Compliance:** - Replaced all `'utf-8'` with `'utf8'` (unicorn/text-encoding-identifier-case) - Changed `variables.hasOwnProperty(varName)` to `Object.hasOwn(variables, varName)` (unicorn/prefer-object-has-own) - Replaced `JSON.parse(JSON.stringify(...))` with `structuredClone(...)` (unicorn/prefer-structured-clone) - Fixed empty YAML mapping values in sample files **Files Fixed:** - 7 JavaScript files across agent tooling (compiler, installer, commands, IDE integration) - 1 YAML sample file ## Architecture Decisions ### Agent Types Are About Architecture, Not Capability - **Simple:** Self-contained in single YAML (NOT limited in capability) - **Expert:** Includes sidecar files (templates, docs, etc.) - **Module:** Designed for BMAD ecosystem integration (workflows, cross-agent coordination) ### Persona Field Separation Critical for LLM Interpretation The LLM needs distinct fields to understand its role: - Mixing role/identity/principles into communication_style confuses the persona - Pure communication styles (from communication-presets.csv) have ZERO role/identity/principles content - Example DON'T: "Experienced analyst who uses systematic approaches..." (mixing identity + style) - Example DO: "Systematic and probing. Structures findings hierarchically." (pure style) ### Install-Time vs Runtime Configuration - Template variables ({{var}}) resolve at compile-time - Runtime variables ({user_name}, {bmad_folder}) resolve when agent activates - Future installer will handle personality customization, so agents should ship with single default persona ## Testing - All linting passes (ESLint with max-warnings=0) - Agent compilation tested with commit-poet, journal-keeper examples - Install workflow validated with Simple and Expert agent types - Manifest tracking and IDE integration verified ## Impact This establishes BMAD as having a complete, production-ready agent creation and installation system with: - Clear documentation for all agent types - Automated compilation and installation - Strong persona design guidance - Reference implementations showing best practices - Distinct, memorable agent voices throughout BMM module Co-Authored-By: BMad Builder <builder@bmad.dev> Co-Authored-By: Mary the Analyst <analyst@bmad.dev> Co-Authored-By: Paige the Tech Writer <tech-writer@bmad.dev>
2025-11-17 22:25:15 -06:00
const usedHandlers = new Set();
for (const item of filteredMenuItems) {
feat: Complete BMAD agent creation system with install tooling, references, and field guidance ## Overview This commit represents a complete overhaul of the BMAD agent creation system, establishing clear standards for agent development, installation workflows, and persona design. The changes span documentation, tooling, reference implementations, and field-specific guidance. ## Key Components ### 1. Agent Installation Infrastructure **New CLI Command: `agent-install`** - Interactive agent installation with persona customization - Supports Simple (single YAML), Expert (sidecar files), and Module agents - Template variable processing with Handlebars-style syntax - Automatic compilation from YAML to XML (.md) format - Manifest tracking and IDE integration (Claude Code, Cursor, Windsurf, etc.) - Source preservation in `_cfg/custom/agents/` for reinstallation **Files Created:** - `tools/cli/commands/agent-install.js` - Main CLI command - `tools/cli/lib/agent/compiler.js` - YAML to XML compilation engine - `tools/cli/lib/agent/installer.js` - Installation orchestration - `tools/cli/lib/agent/template-engine.js` - Handlebars template processing **Compiler Features:** - Auto-injects frontmatter, activation, handlers, help/exit menu items - Smart handler inclusion (only includes action/workflow/exec/tmpl handlers actually used) - Proper XML escaping and formatting - Persona name customization (e.g., "Fred the Commit Poet") ### 2. Documentation Overhaul **Deleted Bloated/Outdated Docs (2,651 lines removed):** - Old verbose architecture docs - Redundant pattern files - Outdated workflow guides **Created Focused, Type-Specific Docs:** - `src/modules/bmb/docs/understanding-agent-types.md` - Architecture vs capability distinction - `src/modules/bmb/docs/simple-agent-architecture.md` - Self-contained agents - `src/modules/bmb/docs/expert-agent-architecture.md` - Agents with sidecar files - `src/modules/bmb/docs/module-agent-architecture.md` - Workflow-integrated agents - `src/modules/bmb/docs/agent-compilation.md` - YAML → XML process - `src/modules/bmb/docs/agent-menu-patterns.md` - Menu design patterns - `src/modules/bmb/docs/index.md` - Documentation hub **Net Result:** ~1,930 line reduction while adding MORE value through focused content ### 3. Create-Agent Workflow Enhancements **Critical Persona Field Guidance Added to Step 4:** Explains how the LLM interprets each persona field when the agent activates: - **role** → "What knowledge, skills, and capabilities do I possess?" - **identity** → "What background, experience, and context shape my responses?" - **communication_style** → "What verbal patterns, word choice, quirks, and phrasing do I use?" - **principles** → "What beliefs and operating philosophy drive my choices?" **Key Insight:** `communication_style` should ONLY describe HOW the agent talks, not restate role/identity/principles. The `communication-presets.csv` provides 60 pure communication styles with NO role/identity/principles mixed in. **Files Updated:** - `src/modules/bmb/workflows/create-agent/instructions.md` - Added persona field interpretation guide - `src/modules/bmb/workflows/create-agent/brainstorm-context.md` - Refined to 137 lines - `src/modules/bmb/workflows/create-agent/communication-presets.csv` - 60 styles across 13 categories ### 4. Reference Agent Cleanup **Removed install_config Personality Bloat:** Understanding: Future installer will handle personality customization, so stripped all personality toggles from reference agents. **commit-poet.agent.yaml** (Simple Agent): - BEFORE: 36 personality combinations (3 enthusiasm × 3 depths × 4 styles) = decision fatigue - AFTER: Single concise persona with pure communication style - Changed from verbose conditionals to: "Poetic drama and flair with every turn of a phrase. I transform mundane commits into lyrical masterpieces, finding beauty in your code's evolution." - Reduction: 248 lines → 153 lines (38% reduction) **journal-keeper.agent.yaml** (Expert Agent): - Stripped install_config, simplified communication_style - Shows proper Expert agent structure with sidecar files **security-engineer.agent.yaml & trend-analyst.agent.yaml** (Module Agents): - Added header comments explaining WHY Module Agent (design intent, not just location) - Clarified: Module agents are designed FOR ecosystem integration, not capability-limited **Files Updated:** - `src/modules/bmb/reference/agents/simple-examples/commit-poet.agent.yaml` - `src/modules/bmb/reference/agents/expert-examples/journal-keeper/journal-keeper.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/security-engineer.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/trend-analyst.agent.yaml` ### 5. BMM Agent Voice Enhancement **Gave all 9 BMM agents distinct, memorable communication voices:** **Mary (analyst)** - The favorite! Changed from generic "systematic and probing" to: "Treats analysis like a treasure hunt - excited by every clue, thrilled when patterns emerge. Asks questions that spark 'aha!' moments while structuring insights with precision." **Other Notable Voices:** - **John (pm):** "Asks 'WHY?' relentlessly like a detective on a case. Direct and data-sharp, cuts through fluff to what actually matters." - **Winston (architect):** "Speaks in calm, pragmatic tones, balancing 'what could be' with 'what should be.' Champions boring technology that actually works." - **Amelia (dev):** "Ultra-succinct. Speaks in file paths and AC IDs - every statement citable. No fluff, all precision." - **Bob (sm):** "Crisp and checklist-driven. Every word has a purpose, every requirement crystal clear. Zero tolerance for ambiguity." - **Sally (ux-designer):** "Paints pictures with words, telling user stories that make you FEEL the problem. Empathetic advocate with creative storytelling flair." **Pattern Applied:** Moved behaviors from communication_style to principles, keeping communication_style as PURE verbal patterns. **Files Updated:** - `src/modules/bmm/agents/analyst.agent.yaml` - `src/modules/bmm/agents/pm.agent.yaml` - `src/modules/bmm/agents/architect.agent.yaml` - `src/modules/bmm/agents/dev.agent.yaml` - `src/modules/bmm/agents/sm.agent.yaml` - `src/modules/bmm/agents/tea.agent.yaml` - `src/modules/bmm/agents/tech-writer.agent.yaml` - `src/modules/bmm/agents/ux-designer.agent.yaml` - `src/modules/bmm/agents/frame-expert.agent.yaml` ### 6. Linting Fixes **ESLint Compliance:** - Replaced all `'utf-8'` with `'utf8'` (unicorn/text-encoding-identifier-case) - Changed `variables.hasOwnProperty(varName)` to `Object.hasOwn(variables, varName)` (unicorn/prefer-object-has-own) - Replaced `JSON.parse(JSON.stringify(...))` with `structuredClone(...)` (unicorn/prefer-structured-clone) - Fixed empty YAML mapping values in sample files **Files Fixed:** - 7 JavaScript files across agent tooling (compiler, installer, commands, IDE integration) - 1 YAML sample file ## Architecture Decisions ### Agent Types Are About Architecture, Not Capability - **Simple:** Self-contained in single YAML (NOT limited in capability) - **Expert:** Includes sidecar files (templates, docs, etc.) - **Module:** Designed for BMAD ecosystem integration (workflows, cross-agent coordination) ### Persona Field Separation Critical for LLM Interpretation The LLM needs distinct fields to understand its role: - Mixing role/identity/principles into communication_style confuses the persona - Pure communication styles (from communication-presets.csv) have ZERO role/identity/principles content - Example DON'T: "Experienced analyst who uses systematic approaches..." (mixing identity + style) - Example DO: "Systematic and probing. Structures findings hierarchically." (pure style) ### Install-Time vs Runtime Configuration - Template variables ({{var}}) resolve at compile-time - Runtime variables ({user_name}, {bmad_folder}) resolve when agent activates - Future installer will handle personality customization, so agents should ship with single default persona ## Testing - All linting passes (ESLint with max-warnings=0) - Agent compilation tested with commit-poet, journal-keeper examples - Install workflow validated with Simple and Expert agent types - Manifest tracking and IDE integration verified ## Impact This establishes BMAD as having a complete, production-ready agent creation and installation system with: - Clear documentation for all agent types - Automated compilation and installation - Strong persona design guidance - Reference implementations showing best practices - Distinct, memorable agent voices throughout BMM module Co-Authored-By: BMad Builder <builder@bmad.dev> Co-Authored-By: Mary the Analyst <analyst@bmad.dev> Co-Authored-By: Paige the Tech Writer <tech-writer@bmad.dev>
2025-11-17 22:25:15 -06:00
if (item.action) usedHandlers.add('action');
if (item.workflow) usedHandlers.add('workflow');
if (item.exec) usedHandlers.add('exec');
if (item.tmpl) usedHandlers.add('tmpl');
if (item.data) usedHandlers.add('data');
if (item['validate-workflow']) usedHandlers.add('validate-workflow');
feat: Complete BMAD agent creation system with install tooling, references, and field guidance ## Overview This commit represents a complete overhaul of the BMAD agent creation system, establishing clear standards for agent development, installation workflows, and persona design. The changes span documentation, tooling, reference implementations, and field-specific guidance. ## Key Components ### 1. Agent Installation Infrastructure **New CLI Command: `agent-install`** - Interactive agent installation with persona customization - Supports Simple (single YAML), Expert (sidecar files), and Module agents - Template variable processing with Handlebars-style syntax - Automatic compilation from YAML to XML (.md) format - Manifest tracking and IDE integration (Claude Code, Cursor, Windsurf, etc.) - Source preservation in `_cfg/custom/agents/` for reinstallation **Files Created:** - `tools/cli/commands/agent-install.js` - Main CLI command - `tools/cli/lib/agent/compiler.js` - YAML to XML compilation engine - `tools/cli/lib/agent/installer.js` - Installation orchestration - `tools/cli/lib/agent/template-engine.js` - Handlebars template processing **Compiler Features:** - Auto-injects frontmatter, activation, handlers, help/exit menu items - Smart handler inclusion (only includes action/workflow/exec/tmpl handlers actually used) - Proper XML escaping and formatting - Persona name customization (e.g., "Fred the Commit Poet") ### 2. Documentation Overhaul **Deleted Bloated/Outdated Docs (2,651 lines removed):** - Old verbose architecture docs - Redundant pattern files - Outdated workflow guides **Created Focused, Type-Specific Docs:** - `src/modules/bmb/docs/understanding-agent-types.md` - Architecture vs capability distinction - `src/modules/bmb/docs/simple-agent-architecture.md` - Self-contained agents - `src/modules/bmb/docs/expert-agent-architecture.md` - Agents with sidecar files - `src/modules/bmb/docs/module-agent-architecture.md` - Workflow-integrated agents - `src/modules/bmb/docs/agent-compilation.md` - YAML → XML process - `src/modules/bmb/docs/agent-menu-patterns.md` - Menu design patterns - `src/modules/bmb/docs/index.md` - Documentation hub **Net Result:** ~1,930 line reduction while adding MORE value through focused content ### 3. Create-Agent Workflow Enhancements **Critical Persona Field Guidance Added to Step 4:** Explains how the LLM interprets each persona field when the agent activates: - **role** → "What knowledge, skills, and capabilities do I possess?" - **identity** → "What background, experience, and context shape my responses?" - **communication_style** → "What verbal patterns, word choice, quirks, and phrasing do I use?" - **principles** → "What beliefs and operating philosophy drive my choices?" **Key Insight:** `communication_style` should ONLY describe HOW the agent talks, not restate role/identity/principles. The `communication-presets.csv` provides 60 pure communication styles with NO role/identity/principles mixed in. **Files Updated:** - `src/modules/bmb/workflows/create-agent/instructions.md` - Added persona field interpretation guide - `src/modules/bmb/workflows/create-agent/brainstorm-context.md` - Refined to 137 lines - `src/modules/bmb/workflows/create-agent/communication-presets.csv` - 60 styles across 13 categories ### 4. Reference Agent Cleanup **Removed install_config Personality Bloat:** Understanding: Future installer will handle personality customization, so stripped all personality toggles from reference agents. **commit-poet.agent.yaml** (Simple Agent): - BEFORE: 36 personality combinations (3 enthusiasm × 3 depths × 4 styles) = decision fatigue - AFTER: Single concise persona with pure communication style - Changed from verbose conditionals to: "Poetic drama and flair with every turn of a phrase. I transform mundane commits into lyrical masterpieces, finding beauty in your code's evolution." - Reduction: 248 lines → 153 lines (38% reduction) **journal-keeper.agent.yaml** (Expert Agent): - Stripped install_config, simplified communication_style - Shows proper Expert agent structure with sidecar files **security-engineer.agent.yaml & trend-analyst.agent.yaml** (Module Agents): - Added header comments explaining WHY Module Agent (design intent, not just location) - Clarified: Module agents are designed FOR ecosystem integration, not capability-limited **Files Updated:** - `src/modules/bmb/reference/agents/simple-examples/commit-poet.agent.yaml` - `src/modules/bmb/reference/agents/expert-examples/journal-keeper/journal-keeper.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/security-engineer.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/trend-analyst.agent.yaml` ### 5. BMM Agent Voice Enhancement **Gave all 9 BMM agents distinct, memorable communication voices:** **Mary (analyst)** - The favorite! Changed from generic "systematic and probing" to: "Treats analysis like a treasure hunt - excited by every clue, thrilled when patterns emerge. Asks questions that spark 'aha!' moments while structuring insights with precision." **Other Notable Voices:** - **John (pm):** "Asks 'WHY?' relentlessly like a detective on a case. Direct and data-sharp, cuts through fluff to what actually matters." - **Winston (architect):** "Speaks in calm, pragmatic tones, balancing 'what could be' with 'what should be.' Champions boring technology that actually works." - **Amelia (dev):** "Ultra-succinct. Speaks in file paths and AC IDs - every statement citable. No fluff, all precision." - **Bob (sm):** "Crisp and checklist-driven. Every word has a purpose, every requirement crystal clear. Zero tolerance for ambiguity." - **Sally (ux-designer):** "Paints pictures with words, telling user stories that make you FEEL the problem. Empathetic advocate with creative storytelling flair." **Pattern Applied:** Moved behaviors from communication_style to principles, keeping communication_style as PURE verbal patterns. **Files Updated:** - `src/modules/bmm/agents/analyst.agent.yaml` - `src/modules/bmm/agents/pm.agent.yaml` - `src/modules/bmm/agents/architect.agent.yaml` - `src/modules/bmm/agents/dev.agent.yaml` - `src/modules/bmm/agents/sm.agent.yaml` - `src/modules/bmm/agents/tea.agent.yaml` - `src/modules/bmm/agents/tech-writer.agent.yaml` - `src/modules/bmm/agents/ux-designer.agent.yaml` - `src/modules/bmm/agents/frame-expert.agent.yaml` ### 6. Linting Fixes **ESLint Compliance:** - Replaced all `'utf-8'` with `'utf8'` (unicorn/text-encoding-identifier-case) - Changed `variables.hasOwnProperty(varName)` to `Object.hasOwn(variables, varName)` (unicorn/prefer-object-has-own) - Replaced `JSON.parse(JSON.stringify(...))` with `structuredClone(...)` (unicorn/prefer-structured-clone) - Fixed empty YAML mapping values in sample files **Files Fixed:** - 7 JavaScript files across agent tooling (compiler, installer, commands, IDE integration) - 1 YAML sample file ## Architecture Decisions ### Agent Types Are About Architecture, Not Capability - **Simple:** Self-contained in single YAML (NOT limited in capability) - **Expert:** Includes sidecar files (templates, docs, etc.) - **Module:** Designed for BMAD ecosystem integration (workflows, cross-agent coordination) ### Persona Field Separation Critical for LLM Interpretation The LLM needs distinct fields to understand its role: - Mixing role/identity/principles into communication_style confuses the persona - Pure communication styles (from communication-presets.csv) have ZERO role/identity/principles content - Example DON'T: "Experienced analyst who uses systematic approaches..." (mixing identity + style) - Example DO: "Systematic and probing. Structures findings hierarchically." (pure style) ### Install-Time vs Runtime Configuration - Template variables ({{var}}) resolve at compile-time - Runtime variables ({user_name}, {bmad_folder}) resolve when agent activates - Future installer will handle personality customization, so agents should ship with single default persona ## Testing - All linting passes (ESLint with max-warnings=0) - Agent compilation tested with commit-poet, journal-keeper examples - Install workflow validated with Simple and Expert agent types - Manifest tracking and IDE integration verified ## Impact This establishes BMAD as having a complete, production-ready agent creation and installation system with: - Clear documentation for all agent types - Automated compilation and installation - Strong persona design guidance - Reference implementations showing best practices - Distinct, memorable agent voices throughout BMM module Co-Authored-By: BMad Builder <builder@bmad.dev> Co-Authored-By: Mary the Analyst <analyst@bmad.dev> Co-Authored-By: Paige the Tech Writer <tech-writer@bmad.dev>
2025-11-17 22:25:15 -06:00
}
// Only include menu-handlers section if handlers are used
if (usedHandlers.size > 0) {
activation += ` <step n="${stepNum++}">When executing a menu item: Check menu-handlers section below - extract any attributes from the selected menu item and follow the corresponding handler instructions</step>\n`;
// Menu handlers - only include what's used
activation += `
<menu-handlers>
<handlers>\n`;
if (usedHandlers.has('action')) {
activation += ` <handler type="action">
When menu item has: action="#id" Find prompt with id="id" in current agent XML, execute its content
When menu item has: action="text" Execute the text directly as an inline instruction
</handler>\n`;
}
if (usedHandlers.has('workflow')) {
activation += ` <handler type="workflow">
When menu item has: workflow="path/to/workflow.yaml"
1. CRITICAL: Always LOAD {project-root}/{bmad_folder}/core/tasks/workflow.xml
2. Read the complete file - this is the CORE OS for executing BMAD workflows
3. Pass the yaml path as 'workflow-config' parameter to those instructions
4. Execute workflow.xml instructions precisely following all steps
5. Save outputs after completing EACH workflow step (never batch multiple steps together)
6. If workflow.yaml path is "todo", inform user the workflow hasn't been implemented yet
</handler>\n`;
}
if (usedHandlers.has('exec')) {
activation += ` <handler type="exec">
When menu item has: exec="command" Execute the command directly
</handler>\n`;
}
if (usedHandlers.has('tmpl')) {
activation += ` <handler type="tmpl">
When menu item has: tmpl="template-path" Load and apply the template
</handler>\n`;
}
if (usedHandlers.has('data')) {
activation += ` <handler type="data">
When menu item has: data="path/to/x.json|yaml|yml"
Load the file, parse as JSON/YAML, make available as {data} to subsequent operations
</handler>\n`;
}
if (usedHandlers.has('validate-workflow')) {
activation += ` <handler type="validate-workflow">
When menu item has: validate-workflow="path/to/workflow.yaml"
1. CRITICAL: Always LOAD {project-root}/{bmad_folder}/core/tasks/validate-workflow.xml
2. Read the complete file - this is the CORE OS for validating BMAD workflows
3. Pass the workflow.yaml path as 'workflow' parameter to those instructions
4. Pass any checklist.md from the workflow location as 'checklist' parameter if available
5. Execute validate-workflow.xml instructions precisely following all steps
6. Generate validation report with thorough analysis
</handler>\n`;
}
feat: Complete BMAD agent creation system with install tooling, references, and field guidance ## Overview This commit represents a complete overhaul of the BMAD agent creation system, establishing clear standards for agent development, installation workflows, and persona design. The changes span documentation, tooling, reference implementations, and field-specific guidance. ## Key Components ### 1. Agent Installation Infrastructure **New CLI Command: `agent-install`** - Interactive agent installation with persona customization - Supports Simple (single YAML), Expert (sidecar files), and Module agents - Template variable processing with Handlebars-style syntax - Automatic compilation from YAML to XML (.md) format - Manifest tracking and IDE integration (Claude Code, Cursor, Windsurf, etc.) - Source preservation in `_cfg/custom/agents/` for reinstallation **Files Created:** - `tools/cli/commands/agent-install.js` - Main CLI command - `tools/cli/lib/agent/compiler.js` - YAML to XML compilation engine - `tools/cli/lib/agent/installer.js` - Installation orchestration - `tools/cli/lib/agent/template-engine.js` - Handlebars template processing **Compiler Features:** - Auto-injects frontmatter, activation, handlers, help/exit menu items - Smart handler inclusion (only includes action/workflow/exec/tmpl handlers actually used) - Proper XML escaping and formatting - Persona name customization (e.g., "Fred the Commit Poet") ### 2. Documentation Overhaul **Deleted Bloated/Outdated Docs (2,651 lines removed):** - Old verbose architecture docs - Redundant pattern files - Outdated workflow guides **Created Focused, Type-Specific Docs:** - `src/modules/bmb/docs/understanding-agent-types.md` - Architecture vs capability distinction - `src/modules/bmb/docs/simple-agent-architecture.md` - Self-contained agents - `src/modules/bmb/docs/expert-agent-architecture.md` - Agents with sidecar files - `src/modules/bmb/docs/module-agent-architecture.md` - Workflow-integrated agents - `src/modules/bmb/docs/agent-compilation.md` - YAML → XML process - `src/modules/bmb/docs/agent-menu-patterns.md` - Menu design patterns - `src/modules/bmb/docs/index.md` - Documentation hub **Net Result:** ~1,930 line reduction while adding MORE value through focused content ### 3. Create-Agent Workflow Enhancements **Critical Persona Field Guidance Added to Step 4:** Explains how the LLM interprets each persona field when the agent activates: - **role** → "What knowledge, skills, and capabilities do I possess?" - **identity** → "What background, experience, and context shape my responses?" - **communication_style** → "What verbal patterns, word choice, quirks, and phrasing do I use?" - **principles** → "What beliefs and operating philosophy drive my choices?" **Key Insight:** `communication_style` should ONLY describe HOW the agent talks, not restate role/identity/principles. The `communication-presets.csv` provides 60 pure communication styles with NO role/identity/principles mixed in. **Files Updated:** - `src/modules/bmb/workflows/create-agent/instructions.md` - Added persona field interpretation guide - `src/modules/bmb/workflows/create-agent/brainstorm-context.md` - Refined to 137 lines - `src/modules/bmb/workflows/create-agent/communication-presets.csv` - 60 styles across 13 categories ### 4. Reference Agent Cleanup **Removed install_config Personality Bloat:** Understanding: Future installer will handle personality customization, so stripped all personality toggles from reference agents. **commit-poet.agent.yaml** (Simple Agent): - BEFORE: 36 personality combinations (3 enthusiasm × 3 depths × 4 styles) = decision fatigue - AFTER: Single concise persona with pure communication style - Changed from verbose conditionals to: "Poetic drama and flair with every turn of a phrase. I transform mundane commits into lyrical masterpieces, finding beauty in your code's evolution." - Reduction: 248 lines → 153 lines (38% reduction) **journal-keeper.agent.yaml** (Expert Agent): - Stripped install_config, simplified communication_style - Shows proper Expert agent structure with sidecar files **security-engineer.agent.yaml & trend-analyst.agent.yaml** (Module Agents): - Added header comments explaining WHY Module Agent (design intent, not just location) - Clarified: Module agents are designed FOR ecosystem integration, not capability-limited **Files Updated:** - `src/modules/bmb/reference/agents/simple-examples/commit-poet.agent.yaml` - `src/modules/bmb/reference/agents/expert-examples/journal-keeper/journal-keeper.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/security-engineer.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/trend-analyst.agent.yaml` ### 5. BMM Agent Voice Enhancement **Gave all 9 BMM agents distinct, memorable communication voices:** **Mary (analyst)** - The favorite! Changed from generic "systematic and probing" to: "Treats analysis like a treasure hunt - excited by every clue, thrilled when patterns emerge. Asks questions that spark 'aha!' moments while structuring insights with precision." **Other Notable Voices:** - **John (pm):** "Asks 'WHY?' relentlessly like a detective on a case. Direct and data-sharp, cuts through fluff to what actually matters." - **Winston (architect):** "Speaks in calm, pragmatic tones, balancing 'what could be' with 'what should be.' Champions boring technology that actually works." - **Amelia (dev):** "Ultra-succinct. Speaks in file paths and AC IDs - every statement citable. No fluff, all precision." - **Bob (sm):** "Crisp and checklist-driven. Every word has a purpose, every requirement crystal clear. Zero tolerance for ambiguity." - **Sally (ux-designer):** "Paints pictures with words, telling user stories that make you FEEL the problem. Empathetic advocate with creative storytelling flair." **Pattern Applied:** Moved behaviors from communication_style to principles, keeping communication_style as PURE verbal patterns. **Files Updated:** - `src/modules/bmm/agents/analyst.agent.yaml` - `src/modules/bmm/agents/pm.agent.yaml` - `src/modules/bmm/agents/architect.agent.yaml` - `src/modules/bmm/agents/dev.agent.yaml` - `src/modules/bmm/agents/sm.agent.yaml` - `src/modules/bmm/agents/tea.agent.yaml` - `src/modules/bmm/agents/tech-writer.agent.yaml` - `src/modules/bmm/agents/ux-designer.agent.yaml` - `src/modules/bmm/agents/frame-expert.agent.yaml` ### 6. Linting Fixes **ESLint Compliance:** - Replaced all `'utf-8'` with `'utf8'` (unicorn/text-encoding-identifier-case) - Changed `variables.hasOwnProperty(varName)` to `Object.hasOwn(variables, varName)` (unicorn/prefer-object-has-own) - Replaced `JSON.parse(JSON.stringify(...))` with `structuredClone(...)` (unicorn/prefer-structured-clone) - Fixed empty YAML mapping values in sample files **Files Fixed:** - 7 JavaScript files across agent tooling (compiler, installer, commands, IDE integration) - 1 YAML sample file ## Architecture Decisions ### Agent Types Are About Architecture, Not Capability - **Simple:** Self-contained in single YAML (NOT limited in capability) - **Expert:** Includes sidecar files (templates, docs, etc.) - **Module:** Designed for BMAD ecosystem integration (workflows, cross-agent coordination) ### Persona Field Separation Critical for LLM Interpretation The LLM needs distinct fields to understand its role: - Mixing role/identity/principles into communication_style confuses the persona - Pure communication styles (from communication-presets.csv) have ZERO role/identity/principles content - Example DON'T: "Experienced analyst who uses systematic approaches..." (mixing identity + style) - Example DO: "Systematic and probing. Structures findings hierarchically." (pure style) ### Install-Time vs Runtime Configuration - Template variables ({{var}}) resolve at compile-time - Runtime variables ({user_name}, {bmad_folder}) resolve when agent activates - Future installer will handle personality customization, so agents should ship with single default persona ## Testing - All linting passes (ESLint with max-warnings=0) - Agent compilation tested with commit-poet, journal-keeper examples - Install workflow validated with Simple and Expert agent types - Manifest tracking and IDE integration verified ## Impact This establishes BMAD as having a complete, production-ready agent creation and installation system with: - Clear documentation for all agent types - Automated compilation and installation - Strong persona design guidance - Reference implementations showing best practices - Distinct, memorable agent voices throughout BMM module Co-Authored-By: BMad Builder <builder@bmad.dev> Co-Authored-By: Mary the Analyst <analyst@bmad.dev> Co-Authored-By: Paige the Tech Writer <tech-writer@bmad.dev>
2025-11-17 22:25:15 -06:00
activation += ` </handlers>
</menu-handlers>\n`;
}
activation += `
<rules>
- ALWAYS communicate in {communication_language} UNLESS contradicted by communication_style
- Stay in character until exit selected
- Menu triggers use asterisk (*) - NOT markdown, display exactly as shown
- Number all lists, use letters for sub-options
- Load files ONLY when executing menu items or a workflow or command requires it. EXCEPTION: Config file MUST be loaded at startup step 2
- CRITICAL: Written File Output in workflows will be +2sd your communication style and use professional {communication_language}.
</rules>
</activation>\n`;
return activation;
}
/**
* Build persona XML section
* @param {Object} persona - Persona object
* @returns {string} Persona XML
*/
function buildPersonaXml(persona) {
if (!persona) return '';
let xml = ' <persona>\n';
if (persona.role) {
const roleText = persona.role.trim().replaceAll(/\n+/g, ' ').replaceAll(/\s+/g, ' ');
xml += ` <role>${escapeXml(roleText)}</role>\n`;
}
if (persona.identity) {
const identityText = persona.identity.trim().replaceAll(/\n+/g, ' ').replaceAll(/\s+/g, ' ');
xml += ` <identity>${escapeXml(identityText)}</identity>\n`;
}
if (persona.communication_style) {
const styleText = persona.communication_style.trim().replaceAll(/\n+/g, ' ').replaceAll(/\s+/g, ' ');
xml += ` <communication_style>${escapeXml(styleText)}</communication_style>\n`;
}
if (persona.principles) {
let principlesText;
if (Array.isArray(persona.principles)) {
principlesText = persona.principles.join(' ');
} else {
principlesText = persona.principles.trim().replaceAll(/\n+/g, ' ');
}
xml += ` <principles>${escapeXml(principlesText)}</principles>\n`;
}
xml += ' </persona>\n';
return xml;
}
/**
* Build prompts XML section
* @param {Array} prompts - Prompts array
* @returns {string} Prompts XML
*/
function buildPromptsXml(prompts) {
if (!prompts || prompts.length === 0) return '';
let xml = ' <prompts>\n';
for (const prompt of prompts) {
xml += ` <prompt id="${prompt.id || ''}">\n`;
xml += ` <content>\n`;
// Don't escape prompt content - it's meant to be read as-is
xml += `${prompt.content || ''}\n`;
xml += ` </content>\n`;
xml += ` </prompt>\n`;
}
xml += ' </prompts>\n';
return xml;
}
/**
* Build menu XML section
* @param {Array} menuItems - Menu items
* @returns {string} Menu XML
*/
function buildMenuXml(menuItems) {
let xml = ' <menu>\n';
// Always inject *help first
xml += ` <item cmd="*help">Show numbered menu</item>\n`;
// Add user-defined menu items
if (menuItems && menuItems.length > 0) {
for (const item of menuItems) {
let trigger = item.trigger || '';
if (!trigger.startsWith('*')) {
trigger = '*' + trigger;
}
const attrs = [`cmd="${trigger}"`];
// Add handler attributes
if (item.workflow) attrs.push(`workflow="${item.workflow}"`);
if (item.exec) attrs.push(`exec="${item.exec}"`);
if (item.tmpl) attrs.push(`tmpl="${item.tmpl}"`);
if (item.data) attrs.push(`data="${item.data}"`);
if (item.action) attrs.push(`action="${item.action}"`);
xml += ` <item ${attrs.join(' ')}>${escapeXml(item.description || '')}</item>\n`;
}
}
// Always inject *exit last
xml += ` <item cmd="*exit">Exit with confirmation</item>\n`;
xml += ' </menu>\n';
return xml;
}
/**
* Compile agent YAML to proper XML format
* @param {Object} agentYaml - Parsed and processed agent YAML
* @param {string} agentName - Final agent name (for ID and frontmatter)
* @param {string} targetPath - Target path for agent ID
* @returns {string} Compiled XML string with frontmatter
*/
function compileToXml(agentYaml, agentName = '', targetPath = '') {
const agent = agentYaml.agent;
const meta = agent.metadata;
let xml = '';
// Build frontmatter
xml += buildFrontmatter(meta, agentName || meta.name || 'agent');
// Start code fence
xml += '```xml\n';
// Agent opening tag
const agentAttrs = [
`id="${targetPath || meta.id || ''}"`,
`name="${meta.name || ''}"`,
`title="${meta.title || ''}"`,
`icon="${meta.icon || '🤖'}"`,
];
xml += `<agent ${agentAttrs.join(' ')}>\n`;
// Activation block - pass menu items and deployment type to determine which handlers to include
xml += buildSimpleActivation(agent.critical_actions || [], agent.menu || [], 'ide');
feat: Complete BMAD agent creation system with install tooling, references, and field guidance ## Overview This commit represents a complete overhaul of the BMAD agent creation system, establishing clear standards for agent development, installation workflows, and persona design. The changes span documentation, tooling, reference implementations, and field-specific guidance. ## Key Components ### 1. Agent Installation Infrastructure **New CLI Command: `agent-install`** - Interactive agent installation with persona customization - Supports Simple (single YAML), Expert (sidecar files), and Module agents - Template variable processing with Handlebars-style syntax - Automatic compilation from YAML to XML (.md) format - Manifest tracking and IDE integration (Claude Code, Cursor, Windsurf, etc.) - Source preservation in `_cfg/custom/agents/` for reinstallation **Files Created:** - `tools/cli/commands/agent-install.js` - Main CLI command - `tools/cli/lib/agent/compiler.js` - YAML to XML compilation engine - `tools/cli/lib/agent/installer.js` - Installation orchestration - `tools/cli/lib/agent/template-engine.js` - Handlebars template processing **Compiler Features:** - Auto-injects frontmatter, activation, handlers, help/exit menu items - Smart handler inclusion (only includes action/workflow/exec/tmpl handlers actually used) - Proper XML escaping and formatting - Persona name customization (e.g., "Fred the Commit Poet") ### 2. Documentation Overhaul **Deleted Bloated/Outdated Docs (2,651 lines removed):** - Old verbose architecture docs - Redundant pattern files - Outdated workflow guides **Created Focused, Type-Specific Docs:** - `src/modules/bmb/docs/understanding-agent-types.md` - Architecture vs capability distinction - `src/modules/bmb/docs/simple-agent-architecture.md` - Self-contained agents - `src/modules/bmb/docs/expert-agent-architecture.md` - Agents with sidecar files - `src/modules/bmb/docs/module-agent-architecture.md` - Workflow-integrated agents - `src/modules/bmb/docs/agent-compilation.md` - YAML → XML process - `src/modules/bmb/docs/agent-menu-patterns.md` - Menu design patterns - `src/modules/bmb/docs/index.md` - Documentation hub **Net Result:** ~1,930 line reduction while adding MORE value through focused content ### 3. Create-Agent Workflow Enhancements **Critical Persona Field Guidance Added to Step 4:** Explains how the LLM interprets each persona field when the agent activates: - **role** → "What knowledge, skills, and capabilities do I possess?" - **identity** → "What background, experience, and context shape my responses?" - **communication_style** → "What verbal patterns, word choice, quirks, and phrasing do I use?" - **principles** → "What beliefs and operating philosophy drive my choices?" **Key Insight:** `communication_style` should ONLY describe HOW the agent talks, not restate role/identity/principles. The `communication-presets.csv` provides 60 pure communication styles with NO role/identity/principles mixed in. **Files Updated:** - `src/modules/bmb/workflows/create-agent/instructions.md` - Added persona field interpretation guide - `src/modules/bmb/workflows/create-agent/brainstorm-context.md` - Refined to 137 lines - `src/modules/bmb/workflows/create-agent/communication-presets.csv` - 60 styles across 13 categories ### 4. Reference Agent Cleanup **Removed install_config Personality Bloat:** Understanding: Future installer will handle personality customization, so stripped all personality toggles from reference agents. **commit-poet.agent.yaml** (Simple Agent): - BEFORE: 36 personality combinations (3 enthusiasm × 3 depths × 4 styles) = decision fatigue - AFTER: Single concise persona with pure communication style - Changed from verbose conditionals to: "Poetic drama and flair with every turn of a phrase. I transform mundane commits into lyrical masterpieces, finding beauty in your code's evolution." - Reduction: 248 lines → 153 lines (38% reduction) **journal-keeper.agent.yaml** (Expert Agent): - Stripped install_config, simplified communication_style - Shows proper Expert agent structure with sidecar files **security-engineer.agent.yaml & trend-analyst.agent.yaml** (Module Agents): - Added header comments explaining WHY Module Agent (design intent, not just location) - Clarified: Module agents are designed FOR ecosystem integration, not capability-limited **Files Updated:** - `src/modules/bmb/reference/agents/simple-examples/commit-poet.agent.yaml` - `src/modules/bmb/reference/agents/expert-examples/journal-keeper/journal-keeper.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/security-engineer.agent.yaml` - `src/modules/bmb/reference/agents/module-examples/trend-analyst.agent.yaml` ### 5. BMM Agent Voice Enhancement **Gave all 9 BMM agents distinct, memorable communication voices:** **Mary (analyst)** - The favorite! Changed from generic "systematic and probing" to: "Treats analysis like a treasure hunt - excited by every clue, thrilled when patterns emerge. Asks questions that spark 'aha!' moments while structuring insights with precision." **Other Notable Voices:** - **John (pm):** "Asks 'WHY?' relentlessly like a detective on a case. Direct and data-sharp, cuts through fluff to what actually matters." - **Winston (architect):** "Speaks in calm, pragmatic tones, balancing 'what could be' with 'what should be.' Champions boring technology that actually works." - **Amelia (dev):** "Ultra-succinct. Speaks in file paths and AC IDs - every statement citable. No fluff, all precision." - **Bob (sm):** "Crisp and checklist-driven. Every word has a purpose, every requirement crystal clear. Zero tolerance for ambiguity." - **Sally (ux-designer):** "Paints pictures with words, telling user stories that make you FEEL the problem. Empathetic advocate with creative storytelling flair." **Pattern Applied:** Moved behaviors from communication_style to principles, keeping communication_style as PURE verbal patterns. **Files Updated:** - `src/modules/bmm/agents/analyst.agent.yaml` - `src/modules/bmm/agents/pm.agent.yaml` - `src/modules/bmm/agents/architect.agent.yaml` - `src/modules/bmm/agents/dev.agent.yaml` - `src/modules/bmm/agents/sm.agent.yaml` - `src/modules/bmm/agents/tea.agent.yaml` - `src/modules/bmm/agents/tech-writer.agent.yaml` - `src/modules/bmm/agents/ux-designer.agent.yaml` - `src/modules/bmm/agents/frame-expert.agent.yaml` ### 6. Linting Fixes **ESLint Compliance:** - Replaced all `'utf-8'` with `'utf8'` (unicorn/text-encoding-identifier-case) - Changed `variables.hasOwnProperty(varName)` to `Object.hasOwn(variables, varName)` (unicorn/prefer-object-has-own) - Replaced `JSON.parse(JSON.stringify(...))` with `structuredClone(...)` (unicorn/prefer-structured-clone) - Fixed empty YAML mapping values in sample files **Files Fixed:** - 7 JavaScript files across agent tooling (compiler, installer, commands, IDE integration) - 1 YAML sample file ## Architecture Decisions ### Agent Types Are About Architecture, Not Capability - **Simple:** Self-contained in single YAML (NOT limited in capability) - **Expert:** Includes sidecar files (templates, docs, etc.) - **Module:** Designed for BMAD ecosystem integration (workflows, cross-agent coordination) ### Persona Field Separation Critical for LLM Interpretation The LLM needs distinct fields to understand its role: - Mixing role/identity/principles into communication_style confuses the persona - Pure communication styles (from communication-presets.csv) have ZERO role/identity/principles content - Example DON'T: "Experienced analyst who uses systematic approaches..." (mixing identity + style) - Example DO: "Systematic and probing. Structures findings hierarchically." (pure style) ### Install-Time vs Runtime Configuration - Template variables ({{var}}) resolve at compile-time - Runtime variables ({user_name}, {bmad_folder}) resolve when agent activates - Future installer will handle personality customization, so agents should ship with single default persona ## Testing - All linting passes (ESLint with max-warnings=0) - Agent compilation tested with commit-poet, journal-keeper examples - Install workflow validated with Simple and Expert agent types - Manifest tracking and IDE integration verified ## Impact This establishes BMAD as having a complete, production-ready agent creation and installation system with: - Clear documentation for all agent types - Automated compilation and installation - Strong persona design guidance - Reference implementations showing best practices - Distinct, memorable agent voices throughout BMM module Co-Authored-By: BMad Builder <builder@bmad.dev> Co-Authored-By: Mary the Analyst <analyst@bmad.dev> Co-Authored-By: Paige the Tech Writer <tech-writer@bmad.dev>
2025-11-17 22:25:15 -06:00
// Persona section
xml += buildPersonaXml(agent.persona);
// Prompts section (if present)
if (agent.prompts && agent.prompts.length > 0) {
xml += buildPromptsXml(agent.prompts);
}
// Menu section
xml += buildMenuXml(agent.menu || []);
// Closing agent tag
xml += '</agent>\n';
// Close code fence
xml += '```\n';
return xml;
}
/**
* Full compilation pipeline
* @param {string} yamlContent - Raw YAML string
* @param {Object} answers - Answers from install_config questions (or defaults)
* @param {string} agentName - Optional final agent name (user's custom persona name)
* @param {string} targetPath - Optional target path for agent ID
* @returns {Object} { xml: string, metadata: Object }
*/
function compileAgent(yamlContent, answers = {}, agentName = '', targetPath = '') {
// Parse YAML
const agentYaml = yaml.parse(yamlContent);
// Inject custom agent name into metadata.name if provided
// This is the user's chosen persona name (e.g., "Fred" instead of "Inkwell Von Comitizen")
if (agentName && agentYaml.agent && agentYaml.agent.metadata) {
// Convert kebab-case to title case for the name field
// e.g., "fred-commit-poet" → "Fred Commit Poet"
const titleCaseName = agentName
.split('-')
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
agentYaml.agent.metadata.name = titleCaseName;
}
// Extract install_config
const installConfig = extractInstallConfig(agentYaml);
// Merge defaults with provided answers
let finalAnswers = answers;
if (installConfig) {
const defaults = getDefaultValues(installConfig);
finalAnswers = { ...defaults, ...answers };
}
// Process templates with answers
const processedYaml = processAgentYaml(agentYaml, finalAnswers);
// Strip install_config from output
const cleanYaml = stripInstallConfig(processedYaml);
// Compile to XML
const xml = compileToXml(cleanYaml, agentName, targetPath);
return {
xml,
metadata: cleanYaml.agent.metadata,
processedYaml: cleanYaml,
};
}
/**
* Compile agent file to .md
* @param {string} yamlPath - Path to agent YAML file
* @param {Object} options - { answers: {}, outputPath: string }
* @returns {Object} Compilation result
*/
function compileAgentFile(yamlPath, options = {}) {
const yamlContent = fs.readFileSync(yamlPath, 'utf8');
const result = compileAgent(yamlContent, options.answers || {});
// Determine output path
let outputPath = options.outputPath;
if (!outputPath) {
// Default: same directory, same name, .md extension
const dir = path.dirname(yamlPath);
const basename = path.basename(yamlPath, '.agent.yaml');
outputPath = path.join(dir, `${basename}.md`);
}
// Write compiled XML
fs.writeFileSync(outputPath, result.xml, 'utf8');
return {
...result,
outputPath,
sourcePath: yamlPath,
};
}
module.exports = {
compileToXml,
compileAgent,
compileAgentFile,
escapeXml,
buildFrontmatter,
buildSimpleActivation,
buildPersonaXml,
buildPromptsXml,
buildMenuXml,
};