added md-tree-parser suggested install and usage
This commit is contained in:
173
bmad-core/tasks/doc-sharding-task.md
Normal file
173
bmad-core/tasks/doc-sharding-task.md
Normal file
@@ -0,0 +1,173 @@
|
||||
# Document Sharding Task
|
||||
|
||||
## Purpose
|
||||
|
||||
- Split a large document into multiple smaller documents based on level 2 sections
|
||||
- Create a folder structure to organize the sharded documents
|
||||
- Maintain all content integrity including code blocks, diagrams, and markdown formatting
|
||||
|
||||
## Recommended Method: markdown-tree-parser
|
||||
|
||||
[[LLM: First, suggest the user install and use the markdown-tree-parser tool if the md-tree command is unavailable so we can have the best performance and reliable document sharding. Let the user know this will save cost of having the LLM to the expensive sharding operation. Give instructions for MPV NPX and PNPM global installs.]]
|
||||
|
||||
### Installation and Usage
|
||||
|
||||
1. **Install globally**:
|
||||
|
||||
```bash
|
||||
npm install -g markdown-tree-parser
|
||||
```
|
||||
|
||||
2. **Use the explode command**:
|
||||
|
||||
```bash
|
||||
# For PRD
|
||||
md-tree explode docs/prd.md docs/prd
|
||||
|
||||
# For Architecture
|
||||
md-tree explode docs/architecture.md docs/architecture
|
||||
|
||||
# For any document
|
||||
md-tree explode [source-document] [destination-folder]
|
||||
```
|
||||
|
||||
3. **What it does**:
|
||||
- Automatically splits the document by level 2 sections
|
||||
- Creates properly named files
|
||||
- Adjusts heading levels appropriately
|
||||
- Handles all edge cases with code blocks and special markdown
|
||||
|
||||
If the user has markdown-tree-parser installed, use it and skip the manual process below.
|
||||
|
||||
---
|
||||
|
||||
## Manual Method (if markdown-tree-parser is not available)
|
||||
|
||||
[[LLM: Only proceed with the manual instructions below if the user cannot or does not want to use markdown-tree-parser.]]
|
||||
|
||||
### Task Instructions
|
||||
|
||||
### 1. Identify Document and Target Location
|
||||
|
||||
- Determine which document to shard (user-provided path)
|
||||
- Create a new folder under `docs/` with the same name as the document (without extension)
|
||||
- Example: `docs/prd.md` → create folder `docs/prd/`
|
||||
|
||||
### 2. Parse and Extract Sections
|
||||
|
||||
[[LLM: When sharding the document:
|
||||
|
||||
1. Read the entire document content
|
||||
2. Identify all level 2 sections (## headings)
|
||||
3. For each level 2 section:
|
||||
- Extract the section heading and ALL content until the next level 2 section
|
||||
- Include all subsections, code blocks, diagrams, lists, tables, etc.
|
||||
- Be extremely careful with:
|
||||
- Fenced code blocks (```) - ensure you capture the full block including closing backticks
|
||||
- Mermaid diagrams - preserve the complete diagram syntax
|
||||
- Nested markdown elements
|
||||
- Multi-line content that might contain ## inside code blocks
|
||||
|
||||
CRITICAL: Use proper parsing that understands markdown context. A ## inside a code block is NOT a section header.]]
|
||||
|
||||
### 3. Create Individual Files
|
||||
|
||||
For each extracted section:
|
||||
|
||||
1. **Generate filename**: Convert the section heading to lowercase-dash-case
|
||||
|
||||
- Remove special characters
|
||||
- Replace spaces with dashes
|
||||
- Example: "## Tech Stack" → `tech-stack.md`
|
||||
|
||||
2. **Adjust heading levels**:
|
||||
|
||||
- The level 2 heading becomes level 1 (# instead of ##)
|
||||
- All subsection levels decrease by 1:
|
||||
|
||||
```txt
|
||||
- ### → ##
|
||||
- #### → ###
|
||||
- ##### → ####
|
||||
- etc.
|
||||
```
|
||||
|
||||
3. **Write content**: Save the adjusted content to the new file
|
||||
|
||||
### 4. Create Index File
|
||||
|
||||
Create an `index.md` file in the sharded folder that:
|
||||
|
||||
1. Contains the original level 1 heading and any content before the first level 2 section
|
||||
2. Lists all the sharded files with links:
|
||||
|
||||
```markdown
|
||||
# Original Document Title
|
||||
|
||||
[Original introduction content if any]
|
||||
|
||||
## Sections
|
||||
|
||||
- [Section Name 1](./section-name-1.md)
|
||||
- [Section Name 2](./section-name-2.md)
|
||||
- [Section Name 3](./section-name-3.md)
|
||||
...
|
||||
```
|
||||
|
||||
### 5. Preserve Special Content
|
||||
|
||||
[[LLM: Pay special attention to preserving:
|
||||
|
||||
1. **Code blocks**: Must capture complete blocks including:
|
||||
|
||||
```language
|
||||
content
|
||||
```
|
||||
|
||||
2. **Mermaid diagrams**: Preserve complete syntax:
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
...
|
||||
```
|
||||
|
||||
3. **Tables**: Maintain proper markdown table formatting
|
||||
|
||||
4. **Lists**: Preserve indentation and nesting
|
||||
|
||||
5. **Inline code**: Preserve backticks
|
||||
|
||||
6. **Links and references**: Keep all markdown links intact
|
||||
|
||||
7. **Template markup**: If documents contain {{placeholders}} or [[LLM instructions]], preserve exactly]]
|
||||
|
||||
### 6. Validation
|
||||
|
||||
After sharding:
|
||||
|
||||
1. Verify all sections were extracted
|
||||
2. Check that no content was lost
|
||||
3. Ensure heading levels were properly adjusted
|
||||
4. Confirm all files were created successfully
|
||||
|
||||
### 7. Report Results
|
||||
|
||||
Provide a summary:
|
||||
|
||||
```text
|
||||
Document sharded successfully:
|
||||
- Source: [original document path]
|
||||
- Destination: docs/[folder-name]/
|
||||
- Files created: [count]
|
||||
- Sections:
|
||||
- section-name-1.md: "Section Title 1"
|
||||
- section-name-2.md: "Section Title 2"
|
||||
...
|
||||
```
|
||||
|
||||
## Important Notes
|
||||
|
||||
- Never modify the actual content, only adjust heading levels
|
||||
- Preserve ALL formatting, including whitespace where significant
|
||||
- Handle edge cases like sections with code blocks containing ## symbols
|
||||
- Ensure the sharding is reversible (could reconstruct the original from shards)
|
||||
@@ -149,16 +149,6 @@ Document the starter template decision and any constraints it imposes before pro
|
||||
|
||||
[[LLM: List required environment variables based on the chosen framework. Show the appropriate format and naming conventions for the framework. After presenting this section, apply `tasks#advanced-elicitation` protocol]]
|
||||
|
||||
## AI Frontend Tool Prompt
|
||||
|
||||
[[LLM: Generate a detailed prompt for AI frontend tools (v0, Cursor, Claude, etc.) customized for the chosen framework. Include framework version, tech stack, patterns, conventions, and key requirements from the UX-UI specification.]]
|
||||
|
||||
### Copy this prompt for AI tools
|
||||
|
||||
```text
|
||||
{{ai_tool_prompt}}
|
||||
```
|
||||
|
||||
## Frontend Developer Standards
|
||||
|
||||
### Critical Coding Rules
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
|
||||
{State the purpose - to define the user experience goals, information architecture, user flows, and visual design specifications for the project's user interface.}
|
||||
|
||||
- **Link to Primary Design Files:** {e.g., Figma, Sketch, Adobe XD URL}
|
||||
- **Link to Deployed Storybook / Design System:** {URL, if applicable}
|
||||
|
||||
## Overall UX Goals & Principles
|
||||
|
||||
- **Target User Personas:** {Reference personas or briefly describe key user types and their goals.}
|
||||
@@ -16,6 +13,7 @@
|
||||
## Information Architecture (IA)
|
||||
|
||||
- **Site Map / Screen Inventory:**
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
A[Homepage] --> B(Dashboard);
|
||||
@@ -24,7 +22,9 @@
|
||||
C --> E[Profile Settings];
|
||||
C --> F[Notification Settings];
|
||||
```
|
||||
|
||||
_(Or provide a list of all screens/pages)_
|
||||
|
||||
- **Navigation Structure:** {Describe primary navigation (e.g., top bar, sidebar), secondary navigation, breadcrumbs, etc.}
|
||||
|
||||
## User Flows
|
||||
@@ -35,7 +35,9 @@
|
||||
|
||||
- **Goal:** {What the user wants to achieve.}
|
||||
- **Steps / Diagram:**
|
||||
|
||||
```mermaid
|
||||
|
||||
graph TD
|
||||
Start --> EnterCredentials[Enter Email/Password];
|
||||
EnterCredentials --> ClickLogin[Click Login Button];
|
||||
@@ -44,6 +46,7 @@
|
||||
CheckAuth -- No --> ShowError[Show Error Message];
|
||||
ShowError --> EnterCredentials;
|
||||
```
|
||||
|
||||
_(Or: Link to specific flow diagram in Figma/Miro)_
|
||||
|
||||
### {Another User Flow Name}
|
||||
@@ -80,5 +83,5 @@
|
||||
|
||||
## Change Log
|
||||
|
||||
| Change | Date | Version | Description | Author |
|
||||
| ------------- | ---------- | ------- | ------------------- | -------------- |
|
||||
| Change | Date | Version | Description | Author |
|
||||
| ------ | ---- | ------- | ----------- | ------ |
|
||||
|
||||
Reference in New Issue
Block a user