bmad初始化
This commit is contained in:
234
bmad/bmm/workflows/4-implementation/story-context/README.md
Normal file
234
bmad/bmm/workflows/4-implementation/story-context/README.md
Normal file
@@ -0,0 +1,234 @@
|
||||
# Story Context Assembly Workflow
|
||||
|
||||
## Overview
|
||||
|
||||
Assembles a dynamic Story Context XML by pulling latest documentation and existing code/library artifacts relevant to a drafted story. Creates comprehensive development context for AI agents and developers working on specific stories.
|
||||
|
||||
## Key Features
|
||||
|
||||
- **Automated Context Discovery** - Scans documentation and codebase for relevant artifacts
|
||||
- **XML Output Format** - Structured context optimized for LLM consumption
|
||||
- **Dependency Detection** - Identifies frameworks, packages, and technical dependencies
|
||||
- **Interface Mapping** - Locates existing APIs and interfaces to reuse
|
||||
- **Testing Integration** - Includes testing standards and generates test ideas
|
||||
- **Status Tracking** - Updates story status and maintains context references
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Invocation
|
||||
|
||||
```bash
|
||||
workflow story-context
|
||||
```
|
||||
|
||||
### With Specific Story
|
||||
|
||||
```bash
|
||||
# Process specific story file
|
||||
workflow story-context --input /path/to/story.md
|
||||
|
||||
# Using story path variable
|
||||
workflow story-context --story_path "docs/stories/1.2.feature-name.md"
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
- **story_path**: Path to target story markdown file (defaults to latest.md)
|
||||
- **auto_update_status**: Whether to automatically update story status (default: false)
|
||||
|
||||
## Workflow Structure
|
||||
|
||||
### Files Included
|
||||
|
||||
```
|
||||
story-context/
|
||||
├── workflow.yaml # Configuration and metadata
|
||||
├── instructions.md # Step-by-step execution guide
|
||||
├── context-template.xml # XML structure template
|
||||
├── checklist.md # Validation criteria
|
||||
└── README.md # This file
|
||||
```
|
||||
|
||||
## Workflow Process
|
||||
|
||||
### Phase 1: Story Analysis (Steps 1-2)
|
||||
|
||||
- **Story Location**: Finds and loads target story markdown file
|
||||
- **Content Parsing**: Extracts epic ID, story ID, title, acceptance criteria, and tasks
|
||||
- **Template Initialization**: Creates initial XML context structure
|
||||
- **User Story Extraction**: Parses "As a... I want... So that..." components
|
||||
|
||||
### Phase 2: Documentation Discovery (Step 3)
|
||||
|
||||
- **Keyword Analysis**: Identifies relevant terms from story content
|
||||
- **Document Scanning**: Searches docs and module documentation
|
||||
- **Authority Prioritization**: Prefers PRDs, architecture docs, and specs
|
||||
- **Context Extraction**: Captures relevant sections with snippets
|
||||
|
||||
### Phase 3: Code Analysis (Step 4)
|
||||
|
||||
- **Symbol Search**: Finds relevant modules, functions, and components
|
||||
- **Interface Identification**: Locates existing APIs and interfaces
|
||||
- **Constraint Extraction**: Identifies development patterns and requirements
|
||||
- **Reuse Opportunities**: Highlights existing code to leverage
|
||||
|
||||
### Phase 4: Dependency Analysis (Step 5)
|
||||
|
||||
- **Manifest Detection**: Scans for package.json, requirements.txt, go.mod, etc.
|
||||
- **Framework Identification**: Identifies Unity, Node.js, Python, Go ecosystems
|
||||
- **Version Tracking**: Captures dependency versions where available
|
||||
- **Configuration Discovery**: Finds relevant project configurations
|
||||
|
||||
### Phase 5: Testing Context (Step 6)
|
||||
|
||||
- **Standards Extraction**: Identifies testing frameworks and patterns
|
||||
- **Location Mapping**: Documents where tests should be placed
|
||||
- **Test Ideas**: Generates initial test concepts for acceptance criteria
|
||||
- **Framework Integration**: Links to existing test infrastructure
|
||||
|
||||
### Phase 6: Validation and Updates (Steps 7-8)
|
||||
|
||||
- **XML Validation**: Ensures proper structure and completeness
|
||||
- **Status Updates**: Changes story status from Draft to ContextReadyDraft
|
||||
- **Reference Tracking**: Adds context file reference to story document
|
||||
- **Quality Assurance**: Validates against workflow checklist
|
||||
|
||||
## Output
|
||||
|
||||
### Generated Files
|
||||
|
||||
- **Primary output**: story-context-{epic_id}.{story_id}-{date}.xml
|
||||
- **Story updates**: Modified original story file with context references
|
||||
|
||||
### Output Structure
|
||||
|
||||
```xml
|
||||
<storyContext>
|
||||
<story>
|
||||
<basicInfo>
|
||||
<epicId>...</epicId>
|
||||
<storyId>...</storyId>
|
||||
<title>...</title>
|
||||
<status>...</status>
|
||||
</basicInfo>
|
||||
<userStory>
|
||||
<asA>...</asA>
|
||||
<iWant>...</iWant>
|
||||
<soThat>...</soThat>
|
||||
</userStory>
|
||||
<acceptanceCriteria>
|
||||
<criterion id="1">...</criterion>
|
||||
</acceptanceCriteria>
|
||||
<tasks>
|
||||
<task>...</task>
|
||||
</tasks>
|
||||
</story>
|
||||
|
||||
<artifacts>
|
||||
<docs>
|
||||
<doc path="..." title="..." section="..." snippet="..."/>
|
||||
</docs>
|
||||
<code>
|
||||
<file path="..." kind="..." symbol="..." lines="..." reason="..."/>
|
||||
</code>
|
||||
<dependencies>
|
||||
<node>
|
||||
<package name="..." version="..."/>
|
||||
</node>
|
||||
</dependencies>
|
||||
</artifacts>
|
||||
|
||||
<interfaces>
|
||||
<interface name="..." kind="..." signature="..." path="..."/>
|
||||
</interfaces>
|
||||
|
||||
<constraints>
|
||||
<constraint>...</constraint>
|
||||
</constraints>
|
||||
|
||||
<tests>
|
||||
<standards>...</standards>
|
||||
<locations>
|
||||
<location>...</location>
|
||||
</locations>
|
||||
<ideas>
|
||||
<idea ac="1">...</idea>
|
||||
</ideas>
|
||||
</tests>
|
||||
</storyContext>
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- **Story File**: Valid story markdown with proper structure (epic.story.title.md format)
|
||||
- **Repository Access**: Ability to scan documentation and source code
|
||||
- **Documentation**: Project documentation in standard locations (docs/, src/, etc.)
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Before Starting
|
||||
|
||||
1. **Ensure Story Quality**: Verify story has clear acceptance criteria and tasks
|
||||
2. **Update Documentation**: Ensure relevant docs are current and discoverable
|
||||
3. **Clean Repository**: Remove obsolete code that might confuse context assembly
|
||||
|
||||
### During Execution
|
||||
|
||||
1. **Review Extracted Context**: Verify that discovered artifacts are actually relevant
|
||||
2. **Check Interface Accuracy**: Ensure identified APIs and interfaces are current
|
||||
3. **Validate Dependencies**: Confirm dependency information matches project state
|
||||
|
||||
### After Completion
|
||||
|
||||
1. **Review XML Output**: Validate the generated context makes sense
|
||||
2. **Test with Developer**: Have a developer review context usefulness
|
||||
3. **Update Story Status**: Verify story status was properly updated
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
**Issue**: Context contains irrelevant or outdated information
|
||||
|
||||
- **Solution**: Review keyword extraction and document filtering logic
|
||||
- **Check**: Ensure story title and acceptance criteria are specific and clear
|
||||
|
||||
**Issue**: Missing relevant code or interfaces
|
||||
|
||||
- **Solution**: Verify code search patterns and symbol extraction
|
||||
- **Check**: Ensure relevant code follows project naming conventions
|
||||
|
||||
**Issue**: Dependency information is incomplete or wrong
|
||||
|
||||
- **Solution**: Check for multiple package manifests or unusual project structure
|
||||
- **Check**: Verify dependency files are in expected locations and formats
|
||||
|
||||
## Customization
|
||||
|
||||
To customize this workflow:
|
||||
|
||||
1. **Modify Search Patterns**: Update instructions.md to adjust code and doc discovery
|
||||
2. **Extend XML Schema**: Customize context-template.xml for additional context types
|
||||
3. **Add Validation**: Extend checklist.md with project-specific quality criteria
|
||||
4. **Configure Dependencies**: Adjust dependency detection for specific tech stacks
|
||||
|
||||
## Version History
|
||||
|
||||
- **v6.0.0** - XML-based context assembly with comprehensive artifact discovery
|
||||
- Multi-ecosystem dependency detection
|
||||
- Interface and constraint extraction
|
||||
- Testing context integration
|
||||
- Story status management
|
||||
|
||||
## Support
|
||||
|
||||
For issues or questions:
|
||||
|
||||
- Review the workflow creation guide at `/bmad/bmb/workflows/create-workflow/workflow-creation-guide.md`
|
||||
- Validate output using `checklist.md`
|
||||
- Ensure story files follow expected markdown structure
|
||||
- Check that repository structure supports automated discovery
|
||||
|
||||
---
|
||||
|
||||
_Part of the BMad Method v6 - BMM (Method) Module_
|
||||
@@ -0,0 +1,16 @@
|
||||
# Story Context Assembly Checklist
|
||||
|
||||
```xml
|
||||
<checklist id="bmad/bmm/workflows/4-implementation/story-context/checklist">
|
||||
<item>Story fields (asA/iWant/soThat) captured</item>
|
||||
<item>Acceptance criteria list matches story draft exactly (no invention)</item>
|
||||
<item>Tasks/subtasks captured as task list</item>
|
||||
<item>Relevant docs (5-15) included with path and snippets</item>
|
||||
<item>Relevant code references included with reason and line hints</item>
|
||||
<item>Interfaces/API contracts extracted if applicable</item>
|
||||
<item>Constraints include applicable dev rules and patterns</item>
|
||||
<item>Dependencies detected from manifests and frameworks</item>
|
||||
<item>Testing standards and locations populated</item>
|
||||
<item>XML structure follows story-context template format</item>
|
||||
</checklist>
|
||||
```
|
||||
@@ -0,0 +1,34 @@
|
||||
<story-context id="bmad/bmm/workflows/4-implementation/story-context/template" v="1.0">
|
||||
<metadata>
|
||||
<epicId>{{epic_id}}</epicId>
|
||||
<storyId>{{story_id}}</storyId>
|
||||
<title>{{story_title}}</title>
|
||||
<status>{{story_status}}</status>
|
||||
<generatedAt>{{date}}</generatedAt>
|
||||
<generator>BMAD Story Context Workflow</generator>
|
||||
<sourceStoryPath>{{story_path}}</sourceStoryPath>
|
||||
</metadata>
|
||||
|
||||
<story>
|
||||
<asA>{{as_a}}</asA>
|
||||
<iWant>{{i_want}}</iWant>
|
||||
<soThat>{{so_that}}</soThat>
|
||||
<tasks>{{story_tasks}}</tasks>
|
||||
</story>
|
||||
|
||||
<acceptanceCriteria>{{acceptance_criteria}}</acceptanceCriteria>
|
||||
|
||||
<artifacts>
|
||||
<docs>{{docs_artifacts}}</docs>
|
||||
<code>{{code_artifacts}}</code>
|
||||
<dependencies>{{dependencies_artifacts}}</dependencies>
|
||||
</artifacts>
|
||||
|
||||
<constraints>{{constraints}}</constraints>
|
||||
<interfaces>{{interfaces}}</interfaces>
|
||||
<tests>
|
||||
<standards>{{test_standards}}</standards>
|
||||
<locations>{{test_locations}}</locations>
|
||||
<ideas>{{test_ideas}}</ideas>
|
||||
</tests>
|
||||
</story-context>
|
||||
@@ -0,0 +1,204 @@
|
||||
<!-- BMAD BMM Story Context Assembly Instructions (v6) -->
|
||||
|
||||
```xml
|
||||
<critical>The workflow execution engine is governed by: {project-root}/bmad/core/tasks/workflow.xml</critical>
|
||||
<critical>You MUST have already loaded and processed: {installed_path}/workflow.yaml</critical>
|
||||
<critical>Communicate all responses in {communication_language}</critical>
|
||||
<critical>Generate all documents in {document_output_language}</critical>
|
||||
<critical>This workflow assembles a Story Context file for a single drafted story by extracting acceptance criteria, tasks, relevant docs/code, interfaces, constraints, and testing guidance.</critical>
|
||||
<critical>If story_path is provided, use it. Otherwise, find the first story with status "drafted" in sprint-status.yaml. If none found, HALT.</critical>
|
||||
<critical>Check if context file already exists. If it does, ask user if they want to replace it, verify it, or cancel.</critical>
|
||||
|
||||
<critical>DOCUMENT OUTPUT: Technical context file (.context.xml). Concise, structured, project-relative paths only.</critical>
|
||||
|
||||
<workflow>
|
||||
<step n="1" goal="Find drafted story and check for existing context" tag="sprint-status">
|
||||
<check if="{{story_path}} is provided">
|
||||
<action>Use {{story_path}} directly</action>
|
||||
<action>Read COMPLETE story file and parse sections</action>
|
||||
<action>Extract story_key from filename or story metadata</action>
|
||||
<action>Verify Status is "drafted" - if not, HALT with message: "Story status must be 'drafted' to generate context"</action>
|
||||
</check>
|
||||
|
||||
<check if="{{story_path}} is NOT provided">
|
||||
<critical>MUST read COMPLETE sprint-status.yaml file from start to end to preserve order</critical>
|
||||
<action>Load the FULL file: {{output_folder}}/sprint-status.yaml</action>
|
||||
<action>Read ALL lines from beginning to end - do not skip any content</action>
|
||||
<action>Parse the development_status section completely</action>
|
||||
|
||||
<action>Find FIRST story (reading in order from top to bottom) where:
|
||||
- Key matches pattern: number-number-name (e.g., "1-2-user-auth")
|
||||
- NOT an epic key (epic-X) or retrospective (epic-X-retrospective)
|
||||
- Status value equals "drafted"
|
||||
</action>
|
||||
|
||||
<check if="no story with status 'drafted' found">
|
||||
<output>📋 No drafted stories found in sprint-status.yaml
|
||||
|
||||
All stories are either still in backlog or already marked ready/in-progress/done.
|
||||
|
||||
**Next Steps:**
|
||||
1. Run `create-story` to draft more stories
|
||||
2. Run `sprint-planning` to refresh story tracking
|
||||
</output>
|
||||
<action>HALT</action>
|
||||
</check>
|
||||
|
||||
<action>Use the first drafted story found</action>
|
||||
<action>Find matching story file in {{story_dir}} using story_key pattern</action>
|
||||
<action>Read the COMPLETE story file</action>
|
||||
</check>
|
||||
|
||||
<action>Extract {{epic_id}}, {{story_id}}, {{story_title}}, {{story_status}} from filename/content</action>
|
||||
<action>Parse sections: Story, Acceptance Criteria, Tasks/Subtasks, Dev Notes</action>
|
||||
<action>Extract user story fields (asA, iWant, soThat)</action>
|
||||
<template-output file="{default_output_file}">story_tasks</template-output>
|
||||
<template-output file="{default_output_file}">acceptance_criteria</template-output>
|
||||
|
||||
<!-- Check if context file already exists -->
|
||||
<action>Check if file exists at {default_output_file}</action>
|
||||
|
||||
<check if="context file already exists">
|
||||
<output>⚠️ Context file already exists: {default_output_file}
|
||||
|
||||
**What would you like to do?**
|
||||
1. **Replace** - Generate new context file (overwrites existing)
|
||||
2. **Verify** - Validate existing context file
|
||||
3. **Cancel** - Exit without changes
|
||||
</output>
|
||||
<ask>Choose action (replace/verify/cancel):</ask>
|
||||
|
||||
<check if="user chooses verify">
|
||||
<action>GOTO validation_step</action>
|
||||
</check>
|
||||
|
||||
<check if="user chooses cancel">
|
||||
<action>HALT with message: "Context generation cancelled"</action>
|
||||
</check>
|
||||
|
||||
<check if="user chooses replace">
|
||||
<action>Continue to generate new context file</action>
|
||||
</check>
|
||||
</check>
|
||||
|
||||
<action>Store project root path for relative path conversion: extract from {project-root} variable</action>
|
||||
<action>Define path normalization function: convert any absolute path to project-relative by removing project root prefix</action>
|
||||
<action>Initialize output by writing template to {default_output_file}</action>
|
||||
<template-output file="{default_output_file}">as_a</template-output>
|
||||
<template-output file="{default_output_file}">i_want</template-output>
|
||||
<template-output file="{default_output_file}">so_that</template-output>
|
||||
</step>
|
||||
|
||||
<step n="2" goal="Collect relevant documentation">
|
||||
<action>Scan docs and src module docs for items relevant to this story's domain: search keywords from story title, ACs, and tasks.</action>
|
||||
<action>Prefer authoritative sources: PRD, Architecture, Front-end Spec, Testing standards, module-specific docs.</action>
|
||||
<action>For each discovered document: convert absolute paths to project-relative format by removing {project-root} prefix. Store only relative paths (e.g., "docs/prd.md" not "/Users/.../docs/prd.md").</action>
|
||||
<template-output file="{default_output_file}">
|
||||
Add artifacts.docs entries with {path, title, section, snippet}:
|
||||
- path: PROJECT-RELATIVE path only (strip {project-root} prefix)
|
||||
- title: Document title
|
||||
- section: Relevant section name
|
||||
- snippet: Brief excerpt (2-3 sentences max, NO invention)
|
||||
</template-output>
|
||||
</step>
|
||||
|
||||
<step n="3" goal="Analyze existing code, interfaces, and constraints">
|
||||
<action>Search source tree for modules, files, and symbols matching story intent and AC keywords (controllers, services, components, tests).</action>
|
||||
<action>Identify existing interfaces/APIs the story should reuse rather than recreate.</action>
|
||||
<action>Extract development constraints from Dev Notes and architecture (patterns, layers, testing requirements).</action>
|
||||
<action>For all discovered code artifacts: convert absolute paths to project-relative format (strip {project-root} prefix).</action>
|
||||
<template-output file="{default_output_file}">
|
||||
Add artifacts.code entries with {path, kind, symbol, lines, reason}:
|
||||
- path: PROJECT-RELATIVE path only (e.g., "src/services/api.js" not full path)
|
||||
- kind: file type (controller, service, component, test, etc.)
|
||||
- symbol: function/class/interface name
|
||||
- lines: line range if specific (e.g., "45-67")
|
||||
- reason: brief explanation of relevance to this story
|
||||
|
||||
Populate interfaces with API/interface signatures:
|
||||
- name: Interface or API name
|
||||
- kind: REST endpoint, GraphQL, function signature, class interface
|
||||
- signature: Full signature or endpoint definition
|
||||
- path: PROJECT-RELATIVE path to definition
|
||||
|
||||
Populate constraints with development rules:
|
||||
- Extract from Dev Notes and architecture
|
||||
- Include: required patterns, layer restrictions, testing requirements, coding standards
|
||||
</template-output>
|
||||
</step>
|
||||
|
||||
<step n="4" goal="Gather dependencies and frameworks">
|
||||
<action>Detect dependency manifests and frameworks in the repo:
|
||||
- Node: package.json (dependencies/devDependencies)
|
||||
- Python: pyproject.toml/requirements.txt
|
||||
- Go: go.mod
|
||||
- Unity: Packages/manifest.json, Assets/, ProjectSettings/
|
||||
- Other: list notable frameworks/configs found</action>
|
||||
<template-output file="{default_output_file}">
|
||||
Populate artifacts.dependencies with keys for detected ecosystems and their packages with version ranges where present
|
||||
</template-output>
|
||||
</step>
|
||||
|
||||
<step n="5" goal="Testing standards and ideas">
|
||||
<action>From Dev Notes, architecture docs, testing docs, and existing tests, extract testing standards (frameworks, patterns, locations).</action>
|
||||
<template-output file="{default_output_file}">
|
||||
Populate tests.standards with a concise paragraph
|
||||
Populate tests.locations with directories or glob patterns where tests live
|
||||
Populate tests.ideas with initial test ideas mapped to acceptance criteria IDs
|
||||
</template-output>
|
||||
</step>
|
||||
|
||||
<step n="6" goal="Validate and save">
|
||||
<anchor id="validation_step" />
|
||||
<action>Validate output context file structure and content</action>
|
||||
<invoke-task>Validate against checklist at {installed_path}/checklist.md using bmad/core/tasks/validate-workflow.xml</invoke-task>
|
||||
</step>
|
||||
|
||||
<step n="7" goal="Update story file and mark ready for dev" tag="sprint-status">
|
||||
<action>Open {{story_path}}</action>
|
||||
<action>Find the "Status:" line (usually at the top)</action>
|
||||
<action>Update story file: Change Status to "ready-for-dev"</action>
|
||||
<action>Under 'Dev Agent Record' → 'Context Reference' (create if missing), add or update a list item for {default_output_file}.</action>
|
||||
<action>Save the story file.</action>
|
||||
|
||||
<!-- Update sprint status to mark ready-for-dev -->
|
||||
<action>Load the FULL file: {{output_folder}}/sprint-status.yaml</action>
|
||||
<action>Find development_status key matching {{story_key}}</action>
|
||||
<action>Verify current status is "drafted" (expected previous state)</action>
|
||||
<action>Update development_status[{{story_key}}] = "ready-for-dev"</action>
|
||||
<action>Save file, preserving ALL comments and structure including STATUS DEFINITIONS</action>
|
||||
|
||||
<check if="story key not found in file">
|
||||
<output>⚠️ Story file updated, but could not update sprint-status: {{story_key}} not found
|
||||
|
||||
You may need to run sprint-planning to refresh tracking.
|
||||
</output>
|
||||
</check>
|
||||
|
||||
<output>✅ Story context generated successfully, {user_name}!
|
||||
|
||||
**Story Details:**
|
||||
|
||||
- Story: {{epic_id}}.{{story_id}} - {{story_title}}
|
||||
- Story Key: {{story_key}}
|
||||
- Context File: {default_output_file}
|
||||
- Status: drafted → ready-for-dev
|
||||
|
||||
**Context Includes:**
|
||||
|
||||
- Documentation artifacts and references
|
||||
- Existing code and interfaces
|
||||
- Dependencies and frameworks
|
||||
- Testing standards and ideas
|
||||
- Development constraints
|
||||
|
||||
**Next Steps:**
|
||||
|
||||
1. Review the context file: {default_output_file}
|
||||
2. Run `dev-story` to implement the story
|
||||
3. Generate context for more drafted stories if needed
|
||||
</output>
|
||||
</step>
|
||||
|
||||
</workflow>
|
||||
```
|
||||
@@ -0,0 +1,30 @@
|
||||
# Story Context Creation Workflow
|
||||
name: story-context
|
||||
description: "Assemble a dynamic Story Context XML by pulling latest documentation and existing code/library artifacts relevant to a drafted story"
|
||||
author: "BMad"
|
||||
|
||||
# Critical variables
|
||||
config_source: "{project-root}/bmad/bmm/config.yaml"
|
||||
output_folder: "{config_source}:output_folder"
|
||||
user_name: "{config_source}:user_name"
|
||||
communication_language: "{config_source}:communication_language"
|
||||
document_output_language: "{config_source}:document_output_language"
|
||||
story_path: "{config_source}:dev_story_location"
|
||||
date: system-generated
|
||||
|
||||
# Workflow components
|
||||
installed_path: "{project-root}/bmad/bmm/workflows/4-implementation/story-context"
|
||||
template: "{installed_path}/context-template.xml"
|
||||
instructions: "{installed_path}/instructions.md"
|
||||
validation: "{installed_path}/checklist.md"
|
||||
|
||||
# Variables and inputs
|
||||
variables:
|
||||
story_path: "" # Optional: Explicit story path. If not provided, finds first story with status "drafted"
|
||||
story_dir: "{config_source}:dev_story_location"
|
||||
|
||||
# Output configuration
|
||||
# Uses story_key from sprint-status.yaml (e.g., "1-2-user-authentication")
|
||||
default_output_file: "{story_dir}/{{story_key}}.context.xml"
|
||||
|
||||
standalone: true
|
||||
Reference in New Issue
Block a user