2025-12-10 20:50:24 +09:00
|
|
|
<tool id=".bmad/core/tasks/shard-doc" name="Shard Document"
|
2025-10-26 19:38:38 -05:00
|
|
|
description="Splits large markdown documents into smaller, organized files based on level 2 (default) sections" webskip="true"
|
|
|
|
|
standalone="true">
|
2025-10-26 15:03:54 -05:00
|
|
|
<objective>Split large markdown documents into smaller, organized files based on level 2 sections using @kayvan/markdown-tree-parser tool</objective>
|
|
|
|
|
|
|
|
|
|
<llm critical="true">
|
|
|
|
|
<i>MANDATORY: Execute ALL steps in the flow section IN EXACT ORDER</i>
|
|
|
|
|
<i>DO NOT skip steps or change the sequence</i>
|
|
|
|
|
<i>HALT immediately when halt-conditions are met</i>
|
|
|
|
|
<i>Each action xml tag within step xml tag is a REQUIRED action to complete that step</i>
|
|
|
|
|
<i>Sections outside flow (validation, output, critical-context) provide essential context - review and apply throughout execution</i>
|
|
|
|
|
</llm>
|
|
|
|
|
|
|
|
|
|
<critical-context>
|
2025-10-31 16:51:25 -05:00
|
|
|
<i>Uses `npx @kayvan/markdown-tree-parser` to automatically shard documents by level 2 headings and generate an index</i>
|
2025-10-26 15:03:54 -05:00
|
|
|
</critical-context>
|
|
|
|
|
|
|
|
|
|
<flow>
|
2025-10-31 16:51:25 -05:00
|
|
|
<step n="1" title="Get Source Document">
|
2025-10-26 15:03:54 -05:00
|
|
|
<action>Ask user for the source document path if not provided already</action>
|
|
|
|
|
<action>Verify file exists and is accessible</action>
|
|
|
|
|
<action>Verify file is markdown format (.md extension)</action>
|
|
|
|
|
<action if="file not found or not markdown">HALT with error message</action>
|
|
|
|
|
</step>
|
|
|
|
|
|
2025-10-31 16:51:25 -05:00
|
|
|
<step n="2" title="Get Destination Folder">
|
2025-10-26 15:03:54 -05:00
|
|
|
<action>Determine default destination: same location as source file, folder named after source file without .md extension</action>
|
|
|
|
|
<action>Example: /path/to/architecture.md → /path/to/architecture/</action>
|
|
|
|
|
<action>Ask user for the destination folder path ([y] to confirm use of default: [suggested-path], else enter a new path)</action>
|
|
|
|
|
<action if="user accepts default">Use the suggested destination path</action>
|
|
|
|
|
<action if="user provides custom path">Use the custom destination path</action>
|
|
|
|
|
<action>Verify destination folder exists or can be created</action>
|
|
|
|
|
<action>Check write permissions for destination</action>
|
|
|
|
|
<action if="permission denied">HALT with error message</action>
|
|
|
|
|
</step>
|
|
|
|
|
|
2025-10-31 16:51:25 -05:00
|
|
|
<step n="3" title="Execute Sharding">
|
2025-10-26 15:03:54 -05:00
|
|
|
<action>Inform user that sharding is beginning</action>
|
2025-11-14 07:23:54 +07:00
|
|
|
<action>Execute command: `npx @kayvan/markdown-tree-parser explode [source-document] [destination-folder]`</action>
|
2025-10-26 15:03:54 -05:00
|
|
|
<action>Capture command output and any errors</action>
|
|
|
|
|
<action if="command fails">HALT and display error to user</action>
|
|
|
|
|
</step>
|
|
|
|
|
|
2025-10-31 16:51:25 -05:00
|
|
|
<step n="4" title="Verify Output">
|
2025-10-26 15:03:54 -05:00
|
|
|
<action>Check that destination folder contains sharded files</action>
|
|
|
|
|
<action>Verify index.md was created in destination folder</action>
|
|
|
|
|
<action>Count the number of files created</action>
|
|
|
|
|
<action if="no files created">HALT with error message</action>
|
|
|
|
|
</step>
|
|
|
|
|
|
2025-10-31 16:51:25 -05:00
|
|
|
<step n="5" title="Report Completion">
|
2025-10-26 15:03:54 -05:00
|
|
|
<action>Display completion report to user including:</action>
|
|
|
|
|
<i>- Source document path and name</i>
|
|
|
|
|
<i>- Destination folder path</i>
|
|
|
|
|
<i>- Number of section files created</i>
|
|
|
|
|
<i>- Confirmation that index.md was created</i>
|
|
|
|
|
<i>- Any tool output or warnings</i>
|
|
|
|
|
<action>Inform user that sharding completed successfully</action>
|
|
|
|
|
</step>
|
feat(workflows): Implement intelligent file discovery protocol and Phase 4 BMGD workflows
## Core Workflow Engine Enhancements
### discover_inputs Protocol (MAJOR)
- Added reusable `discover_inputs` protocol to workflow.xml for intelligent file loading
- Supports three loading strategies:
- FULL_LOAD: Load all shards for PRD, Architecture, UX (changed pattern from /index.md to /*/*.md)
- SELECTIVE_LOAD: Load specific shard via template variable (e.g., epic-{{epic_num}}.md)
- INDEX_GUIDED: Load index, analyze TOC, intelligently load relevant docs (with "DO NOT BE LAZY" mandate)
- Auto-discovers whole vs sharded documents with proper fallback
- Provides transparent reporting of loaded content with file counts
- Invoked via <invoke-protocol name="discover_inputs" /> tag in workflow instructions
### Advanced Elicitation Improvements
- Renamed adv-elicit.xml to advanced-elicitation.xml for clarity
- Updated all references across agents and commands
### Shard Document Tool Enhancement
- Added Step 6: Handle Original Document with three options:
- [d] Delete - Remove original (recommended, prevents confusion)
- [m] Move to archive - Backup original to archive folder
- [k] Keep - Warning about defeating sharding purpose
- Prevents issue where both whole and sharded versions exist, confusing discover_inputs protocol
## BMM Module - Input File Pattern Standardization
### Phase 1 - Analysis (1 workflow)
- product-brief: Added load_strategy (FULL_LOAD for research/brainstorming, INDEX_GUIDED for document_project)
- Updated instructions.md to use invoke-protocol, replaced manual fuzzy matching
### Phase 2 - Planning (4 workflows)
- prd: Added load_strategy, updated instructions to reference {product_brief_content}, {research_content}
- create-ux-design: Added load_strategy, removed fuzzy matching from instructions
- tech-spec: Added load_strategy for brownfield context discovery
- All epics patterns updated to support SELECTIVE_LOAD for specific epic shards
### Phase 3 - Solutioning (2 workflows)
- architecture: Added load_strategy, updated instructions to use pre-loaded {prd_content}, {epics_content}, {ux_design_content}
- solutioning-gate-check: Added load_strategy, replaced manual discovery with protocol invocation
### Phase 4 - Implementation (8 workflows)
- code-review: Added load_strategy, fixed sharded patterns to /*/*.md, added step 1.5 for protocol
- correct-course: Added complete input_file_patterns section (was missing), added step 0.5
- create-story: Added load_strategy, updated to SELECTIVE_LOAD for epics, added step 1.5
- dev-story: Added complete input_file_patterns section (was missing), added step 0.5
- epic-tech-context: Added load_strategy, updated PRD extraction to use {prd_content}, added step 1.5
- retrospective: Added load_strategy for architecture/prd (FULL_LOAD), epics (SELECTIVE_LOAD), added step 0.5
- sprint-planning: Fixed sharded pattern to load ALL epics (/*/*.md), added step 0.5
- story-context: Added load_strategy, updated doc collection to reference pre-loaded content, added step 1.5
### Sprint Artifacts Path Corrections
- story-done: Added missing sprint_artifacts variable, fixed sprint_status path from {context_dir} to {sprint_artifacts}
- story-ready: Added missing sprint_artifacts variable
- story-context: Fixed undefined {context_dir} -> {sprint_artifacts}
- correct-course: Added sprint_artifacts and sprint_status variables
## BMGD Module - Phase 4 Production Workflows (NEW)
Added complete Phase 4 implementation workflows for game development:
- code-review: Senior developer review for completed game features
- correct-course: Sprint change management for game projects
- create-story: Story generation for game mechanics/features
- dev-story: Feature implementation workflow
- epic-tech-context: Technical spec generation per game epic
- retrospective: Epic completion review and lessons learned
- sprint-planning: Game development sprint status tracking
- story-context: Dynamic context assembly for game stories
- story-done: Story completion workflow
- story-ready: Story readiness workflow
All BMGD workflows follow BMM patterns with game-specific adaptations.
## Agent Updates
### BMM Agents
- Updated all 7 BMM agents (analyst, architect, dev, pm, sm, tea, tech-writer, ux-designer)
- Standardized web bundle configurations
### BMGD Agents
- Updated 4 game development agents (game-architect, game-designer, game-dev, game-scrum-master)
- Aligned with BMM agent structure
### CIS Agents
- Updated 5 creative intelligence agents for consistency
## Documentation & Configuration
- Updated CHANGELOG.md with Phase 4 workflow additions
- Updated files-manifest.csv and task-manifest.csv
- Updated .claude commands for all agents
- Fixed formatting issues from previous commits
## Breaking Changes
NONE - All changes are backward compatible. Workflows without input_file_patterns continue to work.
Workflows with input_file_patterns now benefit from intelligent auto-loading.
## Migration Notes
Existing workflows can gradually adopt discover_inputs protocol by:
1. Adding load_strategy to existing input_file_patterns in workflow.yaml
2. Adding <invoke-protocol name="discover_inputs" /> step in instructions.md
3. Replacing manual file loading with references to {pattern_name_content} variables
2025-11-12 19:18:38 -06:00
|
|
|
|
|
|
|
|
<step n="6" title="Handle Original Document">
|
|
|
|
|
<critical>Keeping both the original and sharded versions defeats the purpose of sharding and can cause confusion</critical>
|
|
|
|
|
<action>Present user with options for the original document:</action>
|
|
|
|
|
|
|
|
|
|
<ask>What would you like to do with the original document `[source-document-name]`?
|
|
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
[d] Delete - Remove the original (recommended - shards can always be recombined)
|
|
|
|
|
[m] Move to archive - Move original to a backup/archive location
|
|
|
|
|
[k] Keep - Leave original in place (NOT recommended - defeats sharding purpose)
|
|
|
|
|
|
|
|
|
|
Your choice (d/m/k):</ask>
|
|
|
|
|
|
|
|
|
|
<check if="user selects 'd' (delete)">
|
|
|
|
|
<action>Delete the original source document file</action>
|
|
|
|
|
<action>Confirm deletion to user: "✓ Original document deleted: [source-document-path]"</action>
|
|
|
|
|
<note>The document can be reconstructed from shards by concatenating all section files in order</note>
|
|
|
|
|
</check>
|
|
|
|
|
|
|
|
|
|
<check if="user selects 'm' (move)">
|
|
|
|
|
<action>Determine default archive location: same directory as source, in an "archive" subfolder</action>
|
|
|
|
|
<action>Example: /path/to/architecture.md → /path/to/archive/architecture.md</action>
|
|
|
|
|
<ask>Archive location ([y] to use default: [default-archive-path], or provide custom path):</ask>
|
|
|
|
|
<action if="user accepts default">Use default archive path</action>
|
|
|
|
|
<action if="user provides custom path">Use custom archive path</action>
|
|
|
|
|
<action>Create archive directory if it doesn't exist</action>
|
|
|
|
|
<action>Move original document to archive location</action>
|
|
|
|
|
<action>Confirm move to user: "✓ Original document moved to: [archive-path]"</action>
|
|
|
|
|
</check>
|
|
|
|
|
|
|
|
|
|
<check if="user selects 'k' (keep)">
|
|
|
|
|
<action>Display warning to user:</action>
|
|
|
|
|
<output>⚠️ WARNING: Keeping both original and sharded versions is NOT recommended.
|
|
|
|
|
|
|
|
|
|
This creates confusion because:
|
|
|
|
|
- The discover_inputs protocol may load the wrong version
|
|
|
|
|
- Updates to one won't reflect in the other
|
|
|
|
|
- You'll have duplicate content taking up space
|
|
|
|
|
|
|
|
|
|
Consider deleting or archiving the original document.</output>
|
|
|
|
|
<action>Confirm user choice: "Original document kept at: [source-document-path]"</action>
|
|
|
|
|
</check>
|
|
|
|
|
</step>
|
2025-10-26 15:03:54 -05:00
|
|
|
</flow>
|
|
|
|
|
|
|
|
|
|
<halt-conditions critical="true">
|
2025-10-31 16:51:25 -05:00
|
|
|
<i>HALT if npx command fails or produces no output files</i>
|
2025-10-26 15:03:54 -05:00
|
|
|
</halt-conditions>
|
2025-11-14 07:23:54 +07:00
|
|
|
</tool>
|