bmad初始化

This commit is contained in:
2025-11-01 19:22:39 +08:00
parent 5b21dc0bd5
commit 426ae41f54
447 changed files with 80633 additions and 0 deletions

View File

@@ -0,0 +1,112 @@
# Edit Agent Workflow
Interactive workflow for editing existing BMAD Core agents while maintaining best practices and conventions.
## Purpose
This workflow helps you refine and improve existing agents by:
- Analyzing agents against BMAD Core best practices
- Identifying issues and improvement opportunities
- Providing guided editing for specific aspects
- Validating changes against agent standards
- Ensuring consistency with agent architecture
## When to Use
Use this workflow when you need to:
- Fix issues in existing agents
- Add new menu items or workflows
- Improve agent persona or communication style
- Update configuration handling
- Convert between agent types (full/hybrid/standalone)
- Optimize agent structure and clarity
## What You'll Need
- Path to the agent file you want to edit (.yaml or .md)
- Understanding of what changes you want to make
- Access to the agent documentation (loaded automatically)
## Workflow Steps
1. **Load and analyze target agent** - Provide path to agent file
2. **Analyze against best practices** - Automatic audit of agent structure
3. **Select editing focus** - Choose what aspect to edit
4. **Load relevant documentation** - Auto-loads guides based on your choice
5. **Perform edits** - Review and approve changes iteratively
6. **Validate all changes** - Comprehensive validation checklist
7. **Generate change summary** - Summary of improvements made
## Editing Options
The workflow provides 12 focused editing options:
1. **Fix critical issues** - Address broken references, syntax errors
2. **Add/fix standard config** - Ensure config loading and variable usage
3. **Refine persona** - Improve role, communication style, principles
4. **Update activation** - Modify activation steps and greeting
5. **Manage menu items** - Add, remove, or reorganize commands
6. **Update workflow references** - Fix paths, add new workflows
7. **Enhance menu handlers** - Improve handler logic
8. **Improve command triggers** - Refine asterisk commands
9. **Optimize agent type** - Convert between full/hybrid/standalone
10. **Add new capabilities** - Add menu items, workflows, features
11. **Remove bloat** - Delete unused commands, redundant instructions
12. **Full review and update** - Comprehensive improvements
## Agent Documentation Loaded
This workflow automatically loads:
- **Agent Types Guide** - Understanding full, hybrid, and standalone agents
- **Agent Architecture** - Structure, activation, and menu patterns
- **Command Patterns** - Menu handlers and command triggers
- **Communication Styles** - Persona and communication guidance
- **Workflow Execution Engine** - How agents execute workflows
## Output
The workflow modifies your agent file in place, maintaining the original format (YAML or markdown). Changes are reviewed and approved by you before being applied.
## Best Practices
- **Start with analysis** - Let the workflow audit your agent first
- **Focus your edits** - Choose specific aspects to improve
- **Review each change** - Approve or modify proposed changes
- **Validate thoroughly** - Use the validation step to catch issues
- **Test after editing** - Invoke the edited agent to verify it works
## Tips
- If you're unsure what needs improvement, choose option 12 (Full review)
- For quick fixes, choose the specific option (like option 6 for workflow paths)
- The workflow loads documentation automatically - you don't need to read it first
- You can make multiple rounds of edits in one session
- Use the validation step to ensure you didn't miss anything
## Related Workflows
- **create-agent** - Create new agents from scratch
- **edit-workflow** - Edit workflows referenced by agents
- **audit-workflow** - Audit workflows for compliance
## Example Usage
```
User: I want to add a new workflow to the PM agent
Workflow: Analyzes agent → Loads it → You choose option 5 (manage menu items)
→ Adds new menu item with workflow reference → Validates → Done
```
## Activation
Invoke via BMad Builder agent:
```
/bmad:bmb:agents:bmad-builder
Then select: *edit-agent
```
Or directly via workflow.xml with this workflow config.

View File

@@ -0,0 +1,112 @@
# Edit Agent - Validation Checklist
Use this checklist to validate agent edits meet BMAD Core standards.
## Agent Structure Validation
- [ ] Agent file format is valid (YAML or markdown/XML)
- [ ] Agent type is clearly identified (full, hybrid, standalone)
- [ ] File naming follows convention: `{agent-name}.agent.yaml` or `{agent-name}.agent.md`
## Persona Validation
- [ ] Role is clearly defined and specific
- [ ] Identity/purpose articulates what the agent does
- [ ] Communication style is specified (if custom style desired)
- [ ] Principles are listed and actionable (if applicable)
## Activation Validation
- [ ] Step 1: Loads persona from current agent file
- [ ] Step 2: Loads config file (if agent needs user context)
- [ ] Step 3: Sets user context variables (user_name, etc.)
- [ ] Step 4: Displays greeting using user_name and shows menu
- [ ] Step 5: WAITs for user input (doesn't auto-execute)
- [ ] Step 6: Processes user selection (number or trigger text)
- [ ] Step 7: Executes appropriate menu handler
## Menu Validation
- [ ] All menu items numbered sequentially
- [ ] Each item has cmd attribute with asterisk trigger (*help, *create, etc.)
- [ ] Workflow paths are correct (if workflow attribute present)
- [ ] Help command is present (\*help)
- [ ] Exit command is present (\*exit)
- [ ] Menu items are in logical order
## Configuration Validation
- [ ] Config file path is correct for module
- [ ] Config variables loaded in activation step 2
- [ ] Error handling present if config fails to load
- [ ] user_name used in greeting and communication
- [ ] communication_language used for output
- [ ] output_folder used for file outputs (if applicable)
## Menu Handler Validation
- [ ] menu-handlers section is present
- [ ] Workflow handler loads {project-root}/bmad/core/tasks/workflow.xml
- [ ] Workflow handler passes yaml path as 'workflow-config' parameter
- [ ] Handlers check for attributes (workflow, exec, tmpl, data, action)
- [ ] Handler logic is complete and follows patterns
## Workflow Integration Validation
- [ ] All workflow paths exist and are correct
- [ ] Workflow paths use {project-root} variable
- [ ] Workflows are appropriate for agent's purpose
- [ ] Workflow parameters are passed correctly
## Communication Validation
- [ ] Agent communicates in {communication_language}
- [ ] Communication style matches persona
- [ ] Error messages are clear and helpful
- [ ] Confirmation messages for user actions
## Rules Validation
- [ ] Rules section defines agent behavior clearly
- [ ] File loading rules are specified
- [ ] Menu trigger format rules are clear
- [ ] Communication rules align with persona
## Quality Checks
- [ ] No placeholder text remains ({{AGENT_NAME}}, {ROLE}, etc.)
- [ ] No broken references or missing files
- [ ] Syntax is valid (YAML or XML)
- [ ] Indentation is consistent
- [ ] Agent purpose is clear from reading persona alone
## Type-Specific Validation
### Full Agent
- [ ] Has complete menu system with multiple items
- [ ] Loads config file for user context
- [ ] Supports multiple workflows
- [ ] Session management is clear
### Hybrid Agent
- [ ] Simplified activation (may skip some steps)
- [ ] Focused set of workflows
- [ ] May or may not have menu
- [ ] Config loading is appropriate
### Standalone Agent
- [ ] Single focused purpose
- [ ] Minimal activation (1-3 steps)
- [ ] No menu system
- [ ] Direct execution pattern
- [ ] May not need config file
## Final Checks
- [ ] Agent file has been saved
- [ ] File path is in correct module directory
- [ ] Agent is ready for testing
- [ ] Documentation is updated (if needed)

View File

@@ -0,0 +1,290 @@
# Edit Agent - Agent Editor Instructions
<critical>The workflow execution engine is governed by: {project-root}/bmad/core/tasks/workflow.xml</critical>
<critical>You MUST have already loaded and processed: {project-root}/bmad/bmb/workflows/edit-agent/workflow.yaml</critical>
<critical>This workflow uses ADAPTIVE FACILITATION - adjust your communication based on context and user needs</critical>
<critical>The goal is COLLABORATIVE IMPROVEMENT - work WITH the user, not FOR them</critical>
<critical>Communicate all responses in {communication_language}</critical>
<workflow>
<step n="1" goal="Load and deeply understand the target agent">
<ask>What is the path to the agent you want to edit?</ask>
<action>Load the agent file from the provided path</action>
<action>Load ALL agent documentation to inform understanding:
- Agent types guide: {agent_types}
- Agent architecture: {agent_architecture}
- Command patterns: {agent_commands}
- Communication styles: {communication_styles}
- Workflow execution engine: {workflow_execution_engine}
</action>
<action>Analyze the agent structure thoroughly:
- Parse persona (role, identity, communication_style, principles)
- Understand activation flow and steps
- Map menu items and their workflows
- Identify configuration dependencies
- Assess agent type (full, hybrid, standalone)
- Check workflow references for validity
- Evaluate against best practices from loaded guides
</action>
<action>Reflect understanding back to {user_name}:
Present a warm, conversational summary adapted to the agent's complexity:
- What this agent does (its role and purpose)
- How it's structured (type, menu items, workflows)
- What you notice (strengths, potential improvements, issues)
- Your initial assessment of its health
Be conversational, not clinical. Help {user_name} see their agent through your eyes.
</action>
<ask>Does this match your understanding of what this agent should do?</ask>
<template-output>agent_understanding</template-output>
</step>
<step n="2" goal="Discover improvement goals collaboratively">
<critical>Understand WHAT the user wants to improve and WHY before diving into edits</critical>
<action>Engage in collaborative discovery:
Ask open-ended questions to understand their goals:
- What prompted you to want to edit this agent?
- What isn't working the way you'd like?
- Are there specific behaviors you want to change?
- Is there functionality you want to add or remove?
- How do users interact with this agent? What feedback have they given?
Listen for clues about:
- Functional issues (broken references, missing workflows)
- User experience issues (confusing menu, unclear communication)
- Performance issues (too slow, too verbose, not adaptive enough)
- Maintenance issues (hard to update, bloated, inconsistent)
- Integration issues (doesn't work well with other agents/workflows)
</action>
<action>Based on their responses and your analysis from step 1, identify improvement opportunities:
Organize by priority and user goals:
- CRITICAL issues blocking functionality
- IMPORTANT improvements enhancing user experience
- NICE-TO-HAVE enhancements for polish
Present these conversationally, explaining WHY each matters and HOW it would help.
</action>
<action>Collaborate on priorities:
Don't just list options - discuss them:
- "I noticed {{issue}} - this could cause {{problem}}. Does this concern you?"
- "The agent could be more {{improvement}} which would help when {{use_case}}. Worth exploring?"
- "Based on what you said about {{user_goal}}, we might want to {{suggestion}}. Thoughts?"
Let the conversation flow naturally. Build a shared vision of what "better" looks like.
</action>
<template-output>improvement_goals</template-output>
</step>
<step n="3" goal="Facilitate improvements collaboratively" repeat="until-user-satisfied">
<critical>Work iteratively - improve, review, refine. Never dump all changes at once.</critical>
<action>For each improvement area, facilitate collaboratively:
1. **Explain the current state and why it matters**
- Show relevant sections of the agent
- Explain how it works now and implications
- Connect to user's goals from step 2
2. **Propose improvements with rationale**
- Suggest specific changes that align with best practices
- Explain WHY each change helps
- Provide examples from the loaded guides when helpful
- Show before/after comparisons for clarity
3. **Collaborate on the approach**
- Ask if the proposed change addresses their need
- Invite modifications or alternative approaches
- Explain tradeoffs when relevant
- Adapt based on their feedback
4. **Apply changes iteratively**
- Make one focused improvement at a time
- Show the updated section
- Confirm it meets their expectation
- Move to next improvement or refine current one
</action>
<action>Common improvement patterns to facilitate:
**If fixing broken references:**
- Identify all broken paths
- Explain what each reference should point to
- Verify new paths exist before updating
- Update and confirm working
**If refining persona/communication:**
- Review current persona definition
- Discuss desired communication style with examples
- Explore communication styles guide for patterns
- Refine language to match intent
- Test tone with example interactions
**If updating activation:**
- Walk through current activation flow
- Identify bottlenecks or confusion points
- Propose streamlined flow
- Ensure config loading works correctly
- Verify all session variables are set
**If managing menu items:**
- Review current menu organization
- Discuss if structure serves user mental model
- Add/remove/reorganize as needed
- Ensure all workflow references are valid
- Update triggers to be intuitive
**If enhancing menu handlers:**
- Explain current handler logic
- Identify where handlers could be smarter
- Propose enhanced logic based on agent architecture patterns
- Ensure handlers properly invoke workflows
**If optimizing agent type:**
- Discuss whether current type fits use case
- Explain characteristics of full/hybrid/standalone
- If converting, guide through structural changes
- Ensure all pieces align with new type
</action>
<action>Throughout improvements, educate when helpful:
Share insights from the guides naturally:
- "The agent architecture guide suggests {{pattern}} for this scenario"
- "Looking at the command patterns, we could use {{approach}}"
- "The communication styles guide has a great example of {{technique}}"
Connect improvements to broader BMAD principles without being preachy.
</action>
<ask>After each significant change:
- "Does this feel right for what you're trying to achieve?"
- "Want to refine this further, or move to the next improvement?"
- "Is there anything about this change that concerns you?"
</ask>
<template-output>improvement_implementation</template-output>
</step>
<step n="4" goal="Validate improvements holistically">
<action>Run comprehensive validation conversationally:
Don't just check boxes - explain what you're validating and why it matters:
- "Let me verify all the workflow paths resolve correctly..."
- "Checking that the activation flow works smoothly..."
- "Making sure menu handlers are wired up properly..."
- "Validating config loading is robust..."
</action>
<action>Load validation checklist: {installed_path}/checklist.md</action>
<action>Check all items from checklist systematically</action>
<check if="validation_issues_found">
<action>Present issues conversationally:
Explain what's wrong and implications:
- "I found {{issue}} which could cause {{problem}}"
- "The {{component}} needs {{fix}} because {{reason}}"
Propose fixes immediately:
- "I can fix this by {{solution}}. Should I?"
- "We have a couple options here: {{option1}} or {{option2}}. Thoughts?"
</action>
<action>Fix approved issues and re-validate</action>
</check>
<check if="validation_passes">
<action>Confirm success warmly:
"Excellent! Everything validates cleanly:
- All paths resolve correctly
- Activation flow is solid
- Menu structure is clear
- Handlers work properly
- Config loading is robust
Your agent is in great shape."
</action>
</check>
<template-output>validation_results</template-output>
</step>
<step n="5" goal="Review improvements and guide next steps">
<action>Create a conversational summary of what improved:
Tell the story of the transformation:
- "We started with {{initial_state}}"
- "You wanted to {{user_goals}}"
- "We made these key improvements: {{changes_list}}"
- "Now your agent {{improved_capabilities}}"
Highlight the impact:
- "This means users will experience {{benefit}}"
- "The agent is now more {{quality}}"
- "It follows best practices for {{patterns}}"
</action>
<action>Guide next steps based on changes made:
If significant structural changes:
- "Since we restructured the activation, you should test the agent with a real user interaction"
If workflow references changed:
- "The agent now uses {{new_workflows}} - make sure those workflows are up to date"
If this is part of larger module work:
- "This agent is part of {{module}} - consider if other agents need similar improvements"
Be a helpful guide to what comes next, not just a task completer.
</action>
<ask>Would you like to:
- Test the edited agent by invoking it
- Edit another agent
- Make additional refinements to this one
- Return to your module work
</ask>
<template-output>completion_summary</template-output>
</step>
</workflow>

View File

@@ -0,0 +1,34 @@
# Edit Agent - Agent Editor Configuration
name: "edit-agent"
description: "Edit existing BMAD agents while following all best practices and conventions"
author: "BMad"
# Critical variables load from config_source
config_source: "{project-root}/bmad/bmb/config.yaml"
communication_language: "{config_source}:communication_language"
user_name: "{config_source}:user_name"
# Required Data Files - Critical for understanding agent conventions
agent_types: "{project-root}/bmad/bmb/workflows/create-agent/agent-types.md"
agent_architecture: "{project-root}/bmad/bmb/workflows/create-agent/agent-architecture.md"
agent_commands: "{project-root}/bmad/bmb/workflows/create-agent/agent-command-patterns.md"
communication_styles: "{project-root}/bmad/bmb/workflows/create-agent/communication-styles.md"
# Workflow execution engine reference
workflow_execution_engine: "{project-root}/bmad/core/tasks/workflow.xml"
# Optional docs that can be used to understand the target agent
recommended_inputs:
- target_agent: "Path to the agent.yaml or agent.md file to edit"
- example_agents: "{project-root}/bmad/bmm/agents/"
- agent_activation_rules: "{project-root}/src/utility/models/agent-activation-ide.xml"
# Module path and component files
installed_path: "{project-root}/bmad/bmb/workflows/edit-agent"
template: false # This is an action workflow - no template needed
instructions: "{installed_path}/instructions.md"
validation: "{installed_path}/checklist.md"
standalone: true
# Web bundle configuration