2025-09-28 23:17:07 -05:00
<!-- BMAD BMM Story Context Assembly Instructions (v6) -->
2025-10-12 22:19:28 -05:00
````xml
2025-10-03 21:46:53 -05:00
< critical > The workflow execution engine is governed by: {project_root}/bmad/core/tasks/workflow.xml< / critical >
2025-09-28 23:17:07 -05:00
< critical > You MUST have already loaded and processed: {installed_path}/workflow.yaml< / critical >
2025-10-17 20:33:38 -05:00
< critical > Communicate all responses in {communication_language} and language MUST be tailored to {user_skill_level}< / critical >
< critical > Generate all documents in {document_output_language}< / critical >
2025-09-28 23:17:07 -05:00
< critical > This workflow assembles a Story Context XML for a single user story by extracting ACs, tasks, relevant docs/code, interfaces, constraints, and testing guidance to support implementation.< / critical >
< critical > Default execution mode: #yolo (non-interactive). Only ask if {{non_interactive}} == false. If auto-discovery fails, HALT and request 'story_path' or 'story_dir'.</ critical >
2025-10-17 20:33:38 -05:00
< critical > DOCUMENT OUTPUT: Technical XML context file. Concise, structured, project-relative paths only. User skill level ({user_skill_level}) affects conversation style ONLY, not context content.< / critical >
2025-10-12 22:19:28 -05:00
2025-10-17 20:33:38 -05:00
< workflow >
< step n = "1" goal = "Validate workflow sequence" >
2025-10-17 22:34:21 -05:00
< invoke-workflow path = "{project-root}/bmad/bmm/workflows/workflow-status" >
2025-10-17 20:33:38 -05:00
< param > mode: validate< / param >
< param > calling_workflow: story-context< / param >
< / invoke-workflow >
< check if = "warning != ''" >
< output > {{warning}}< / output >
< ask > Continue with story-context anyway? (y/n)< / ask >
< check if = "n" >
< output > {{suggestion}}< / output >
< action > Exit workflow< / action >
2025-10-12 22:19:28 -05:00
< / check >
< / check >
2025-10-17 20:33:38 -05:00
< action > Store {{status_file_path}} for later updates< / action >
2025-10-12 22:19:28 -05:00
< / step >
< step n = "2" goal = "Locate story and initialize output" >
2025-09-28 23:17:07 -05:00
< action > If {{story_path}} provided and valid → use it; else auto-discover from {{story_dir}}.< / action >
< action > Auto-discovery: read {{story_dir}} (dev_story_location). If invalid/missing or contains no .md files, ASK for a story file path or directory to scan.< / action >
< action > If a directory is provided, list markdown files named "story-*.md" recursively; sort by last modified time; display top {{story_selection_limit}} with index, filename, path, modified time.< / action >
< ask optional = "true" if = "{{non_interactive}} == false" > "Select a story (1-{{story_selection_limit}}) or enter a path:"< / ask >
< action > If {{non_interactive}} == true: choose the most recently modified story automatically. If none found, HALT with a clear message to provide 'story_path' or 'story_dir'. Else resolve selection into {{story_path}} and READ COMPLETE file.< / action >
< action > Extract {{epic_id}}, {{story_id}}, {{story_title}}, {{story_status}} from filename/content; parse sections: Story, Acceptance Criteria, Tasks/Subtasks, Dev Notes.< / action >
< action > Extract user story fields (asA, iWant, soThat).< / action >
2025-10-13 21:11:20 -05:00
< 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 >
2025-09-28 23:17:07 -05:00
< 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 >
2025-10-12 22:19:28 -05:00
< step n = "3" goal = "Collect relevant documentation" >
2025-10-13 21:11:20 -05:00
< action > Scan docs and src module docs for items relevant to this story's domain: search keywords from story title, ACs, and tasks.< / action >
2025-09-28 23:17:07 -05:00
< action > Prefer authoritative sources: PRD, Architecture, Front-end Spec, Testing standards, module-specific docs.< / action >
2025-10-13 21:11:20 -05:00
< 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 >
2025-09-28 23:17:07 -05:00
< template-output file = "{default_output_file}" >
2025-10-13 21:11:20 -05:00
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)
2025-09-28 23:17:07 -05:00
< / template-output >
< / step >
2025-10-12 22:19:28 -05:00
< step n = "4" goal = "Analyze existing code, interfaces, and constraints" >
2025-09-28 23:17:07 -05:00
< 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 >
2025-10-13 21:11:20 -05:00
< action > For all discovered code artifacts: convert absolute paths to project-relative format (strip {project-root} prefix).< / action >
2025-09-28 23:17:07 -05:00
< template-output file = "{default_output_file}" >
2025-10-13 21:11:20 -05:00
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
2025-09-28 23:17:07 -05:00
< / template-output >
< / step >
2025-10-12 22:19:28 -05:00
< step n = "5" goal = "Gather dependencies and frameworks" >
2025-09-28 23:17:07 -05:00
< 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 >
2025-10-12 22:19:28 -05:00
< step n = "6" goal = "Testing standards and ideas" >
2025-09-28 23:17:07 -05:00
< 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 >
2025-10-12 22:19:28 -05:00
< step n = "7" goal = "Validate and save" >
2025-09-28 23:17:07 -05:00
< action > Validate output XML structure and content.< / action >
2025-10-03 21:46:53 -05:00
< invoke-task > Validate against checklist at {installed_path}/checklist.md using bmad/core/tasks/validate-workflow.xml< / invoke-task >
2025-09-28 23:17:07 -05:00
< / step >
2025-10-12 22:19:28 -05:00
< step n = "8" goal = "Update story status and context reference" >
2025-09-28 23:17:07 -05:00
< action > Open {{story_path}}; if Status == 'Draft' then set to 'ContextReadyDraft'; otherwise leave unchanged.< / 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 >
< / step >
2025-10-12 22:19:28 -05:00
< step n = "9" goal = "Update status file on completion" >
2025-10-13 22:32:35 -05:00
< action > Search {output_folder}/ for files matching pattern: bmm-workflow-status.md< / action >
2025-10-12 22:19:28 -05:00
< action > Find the most recent file (by date in filename)< / action >
< check if = "status file exists" >
< action > Load the status file< / action >
< template-output file = "{{status_file_path}}" > current_step< / template-output >
< action > Set to: "story-context (Story {{story_id}})"< / action >
< template-output file = "{{status_file_path}}" > current_workflow< / template-output >
< action > Set to: "story-context (Story {{story_id}}) - Complete"< / action >
< template-output file = "{{status_file_path}}" > progress_percentage< / template-output >
< action > Calculate per-story weight: remaining_40_percent / total_stories / 5< / action >
< action > Increment by: {{per_story_weight}} * 1 (story-context weight is ~1% per story)< / action >
< template-output file = "{{status_file_path}}" > decisions_log< / template-output >
< action > Add entry:< / action >
```
- **{{date}}**: Completed story-context for Story {{story_id}} ({{story_title}}). Context file: {{default_output_file}}. Next: DEV agent should run dev-story to implement.
```
2025-10-16 08:58:09 -05:00
< output > **✅ Story Context Generated Successfully, {user_name}!**
2025-10-12 22:19:28 -05:00
**Story Details:**
- Story ID: {{story_id}}
- Title: {{story_title}}
- Context File: {{default_output_file}}
**Status file updated:**
- Current step: story-context (Story {{story_id}}) ✓
- Progress: {{new_progress_percentage}}%
**Next Steps:**
1. Load DEV agent (bmad/bmm/agents/dev.md)
2. Run `dev-story` workflow to implement the story
3. The context file will provide comprehensive implementation guidance
Check status anytime with: `workflow-status`
< / output >
< / check >
< check if = "status file not found" >
2025-10-16 08:58:09 -05:00
< output > **✅ Story Context Generated Successfully, {user_name}!**
2025-10-12 22:19:28 -05:00
**Story Details:**
- Story ID: {{story_id}}
- Title: {{story_title}}
- Context File: {{default_output_file}}
Note: Running in standalone mode (no status file).
To track progress across workflows, run `workflow-status` first.
**Next Steps:**
1. Load DEV agent and run `dev-story` to implement
< / output >
< / check >
< / step >
2025-09-28 23:17:07 -05:00
< / workflow >
2025-10-12 22:19:28 -05:00
````