Replies: 27 comments 25 replies
-
|
The better way to accomplish this is to embed comments in the original documents that include the target filenames, which a post-processing sharding script could then use to perform the sharding. The entire concept of utilizing the LLM for the sharding of the PRD and architecture document is then rendered obsolete. |
Beta Was this translation helpful? Give feedback.
-
|
Then it also becomes easy to re-generate everything if you wanted to make an update to a sharded document. What do you think, Brian? @bmadcode |
Beta Was this translation helpful? Give feedback.
-
|
Yeah, that's fine too, but it doesn't take care of one use case: The idea of using Markdown comment syntax for the separators is this:
Then you can just re-run a command like |
Beta Was this translation helpful? Give feedback.
-
|
Ah I think I understand - is it even worth adding the ======= filename separators than, or keep as is, but just update the task rule to wrap the content properly int he markdown comments? Or maybe a combination of both? |
Beta Was this translation helpful? Give feedback.
-
|
I am suggesting that we only modify the templates to include the sharding metadata as comments. This is separate from the system you already use to put multiple documents in one Putting these metadata comments in the templates means that your PRD and architecture document already contain within them the instructions for how to shard them. The only other change would be to remove the "shard document" task from the agents. |
Beta Was this translation helpful? Give feedback.
-
|
Got it! Ok let do it. Can you pr your script and template changes? If not I
can try to replicate this weekend
…On Wed, May 28, 2025, 10:39 PM Kayvan Sylvan ***@***.***> wrote:
I am suggesting that we only modify the templates to include the sharding
metadata as comments.
This is separate from the system you already use to put multiple documents
in one .txt file that the build-web-agent.js so that you only have to
upload a handful of documents to set up your Gem/CustomGPT. We don't have
to change that.
Putting these metadata comments in the templates means that your PDR and
architecture document already contain within them the instructions for how
to shard them.
The only other change would be to remove the "shard document" task from
the agents.
—
Reply to this email directly, view it on GitHub
<#111 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BOTVGQL7BRSZZASQCS4I2HL3AZ6QFAVCNFSM6AAAAAB6B2YGU6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMZQGQ4TKOI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
I'll work on this. Might have something by today. |
Beta Was this translation helpful? Give feedback.
-
|
Hi Brian @bmadcode - Check this new tool out: I just created it for this purpose: https://github.com/ksylvan/markdown-tree-parser You can install it via npm: $ npm install -g @kayvan/markdown-tree-parser
added 57 packages in 2s
47 packages are looking for funding
run `npm fund` for detailsFor example: $ md-tree extract ~/src/fabric-mcp/docs/architecture.md 'Coding Standards'
📄 Section "Coding Standards":
## Coding Standards
These standards are mandatory for all code generation by AI agents and human developers. Deviations are not permitted unless explicitly approved and documented as an exception in this section or a linked addendum.
* **Primary Language & Runtime:** Python >=3.11 with CPython (as per Definitive Tech Stack Selections).
* **Style Guide & Linter:**
* **Tools:** `Ruff` for formatting and primary linting, `Pylint` for additional static analysis, `isort` for import sorting (often managed via Ruff). `Pyright` for static type checking in strict mode.
* **Configuration:**
* Ruff: Configured via `.ruff.toml` and/or `pyproject.toml`.
* Pylint: Configured via `.pylintrc`.
* isort: Configured in `pyproject.toml` (often via `[tool.ruff.lint.isort]`).
* Pyright: Configured in `pyproject.toml` (under `[tool.pyright]`) for strict mode. |
Beta Was this translation helpful? Give feedback.
-
|
I'm rethinking my original idea of adding Markdown comment metadata... I think we might be able to create a sharding config file that basically lists all the headings in the |
Beta Was this translation helpful? Give feedback.
-
|
Let me think on it a bit more and I'll come up with an excellent PR. The concept involves a YAML configuration file, likely derived from the current sharding instructions. Something like this: bmad-agent/doc-sharding-config.yaml# Document Sharding Configuration
# Maps destination documents to their source sections for automated sharding
version: "1.0"
description: "Configuration for sharding large project documents into smaller, focused files"
# Configuration for PRD document sharding
prd_sharding:
source_document: "PRD.md" # Can be overridden at runtime
destination_prefix: "docs/"
sections:
- destination: "epic-{id}.md"
source_sections:
- "Epic {id}:*" # Matches Epic headings with IDs
- "**Epic {id}:**" # Alternative Epic format
description: "Individual Epic breakdown with user stories"
pattern_type: "dynamic" # Uses {id} placeholder
# Configuration for Architecture document sharding
architecture_sharding:
source_document: "architecture.md" # Can be overridden at runtime
destination_prefix: "docs/"
sections:
- destination: "api-reference.md"
source_sections:
- "API Reference"
- "API Endpoints"
- "Service Interfaces"
description: "API documentation and endpoint specifications"
- destination: "data-models.md"
source_sections:
- "Data Models"
- "Database Schema"
- "Entity Definitions"
description: "Data structure and database schema definitions"
- destination: "environment-vars.md"
source_sections:
- "Environment Variables Documentation"
- "Configuration Settings"
- "Deployment Parameters"
- "Infrastructure and Deployment Overview" # Extract config details
description: "Environment variables and configuration settings"
- destination: "project-structure.md"
source_sections:
- "Project Structure"
- "Detailed Frontend Directory Structure"
- "Backend Repository Structure"
description: "Code organization and directory structure"
- destination: "tech-stack.md"
source_sections:
- "Technology Stack"
- "Key Technologies"
- "Libraries and Frameworks"
- "Definitive Tech Stack Selections"
description: "Technology choices and framework decisions"
- destination: "operational-guidelines.md"
source_sections:
- "Coding Standards"
- "Development Guidelines"
- "Best Practices"
- "Testing Strategy"
- "Testing Decisions"
- "QA Processes"
- "Overall Testing Strategy"
- "Error Handling Strategy"
- "Security Best Practices"
description: "Development practices and operational procedures"
consolidation_note: "Organize under H3/H4 headings by source section"
- destination: "component-view.md"
source_sections:
- "Component View"
- "Architectural / Design Patterns Adopted"
description: "System components and architectural patterns"
- destination: "sequence-diagrams.md"
source_sections:
- "Core Workflow / Sequence Diagrams"
- "Workflow Diagrams"
- "Process Flow"
description: "System workflows and process diagrams"
- destination: "infra-deployment.md"
source_sections:
- "Infrastructure and Deployment Overview"
- "Deployment Strategy"
- "Cloud Infrastructure"
description: "Infrastructure setup and deployment processes"
- destination: "key-references.md"
source_sections:
- "Key Reference Documents"
- "Related Documentation"
- "External References"
description: "Links to related documentation and external resources"
# Configuration for Frontend-specific document sharding
frontend_sharding:
source_document: "front-end-architecture.md" # Can be overridden at runtime
destination_prefix: "docs/"
sections:
- destination: "front-end-project-structure.md"
source_sections:
- "Front-End Project Structure"
- "Detailed Frontend Directory Structure"
- "Component Organization"
description: "Frontend code organization and file structure"
- destination: "front-end-style-guide.md"
source_sections:
- "UI Style Guide"
- "Brand Guidelines"
- "Visual Design Specifications"
- "Styling Approach"
description: "UI styling guidelines and design system"
- destination: "front-end-component-guide.md"
source_sections:
- "Component Library"
- "Reusable UI Components Guide"
- "Atomic Design Elements"
- "Component Breakdown & Implementation Details"
description: "Component library and reusable UI elements"
- destination: "front-end-coding-standards.md"
source_sections:
- "Front-End Coding Standards"
- "JavaScript/TypeScript Style"
- "CSS Naming Conventions"
- "Accessibility Best Practices"
description: "Frontend-specific coding conventions and standards"
- destination: "front-end-state-management.md"
source_sections:
- "State Management In-Depth"
- "State Architecture"
- "Data Flow Patterns"
description: "State management patterns and data flow"
- destination: "front-end-api-interaction.md"
source_sections:
- "API Interaction Layer"
- "HTTP Client Setup"
- "Data Fetching Patterns"
description: "Frontend API communication and data fetching"
- destination: "front-end-routing-strategy.md"
source_sections:
- "Routing Strategy"
- "Navigation Patterns"
- "Route Configuration"
description: "Frontend routing and navigation implementation"
- destination: "front-end-testing-strategy.md"
source_sections:
- "Frontend Testing Strategy"
- "Component Testing"
- "UI Testing Patterns"
description: "Frontend testing approaches and methodologies"
# Global settings
global_settings:
# Whether to update docs/index.md after sharding
update_index: true
# Index file configuration
index_file: "docs/index.md"
# Whether to preserve source document after sharding
preserve_source: true
# Default extraction behavior
extraction_mode: "verbatim" # Don't modify content during extraction
# Whether to create destination directories if they don't exist
create_directories: true
# Backup settings
create_backup: true
backup_suffix: ".backup"
# Content formatting
preserve_markdown_formatting: true
include_section_headers: true
# Error handling
skip_missing_sections: true
warn_on_missing_sections: true
# Metadata for tracking
metadata:
created_by: "bmad-agent"
version: "1.0"
last_updated: "2025-05-30"
description: "Configuration for automated document sharding to improve developer documentation accessibility"
|
Beta Was this translation helpful? Give feedback.
-
|
Looks like you are on it - thanks I had no time tonight! A few things I was thinking about that might be tricky (but you might already be considering. Some sections result in multiple files with a pattern (such as the epics) - is there a way to genericize if there were another similar type of section in the future (if we gotta brute force it though, thats fine) Right now the dumb way I set it up, multiple sections will go to a single file, which I hate in hindsight - I am fine with getting rid of this idea though (although we could make it an option) - But I think it would be much better to have each section being carved out go to its own files and we can just update the agent instructions (and I am working on a simplification for that also!) - so if it makes it easier, each section could just go to a file similar to the section name (or overridden in the template sharding instructions) One other potential idea - more want an opinion though - the original idea for the sharding and I never got it fully implemented, was to actually explode the larger documents, and then have them have links to the smaller files, and not also retain the content in the larger files. The idea being - it would then be easier to make update for example to the source map, or coding standards or tech list - could just update the file directly. Also - the idea is, a lot of these files should go away once MVP is done (or at least moved to an archive and ignored from the LLM in the future - but some files would still make sense to remain (source map, coding standards, maybe some others that will help the LLMs going forward in future endevours) - and a root contributing.md file being the entryway to actually finding these files for future human or ai contribution. Anyways - this is all a bit more than what you got yourself into, just sharing what the longer term goal I never really got to was, but do see coming maybe with 3.2 or 3.3 - I think its a minor change, not requiring another version bump and migration IMO. |
Beta Was this translation helpful? Give feedback.
-
@bmadcode In terms of this question , Brian, you are the originator of the idea, so call your shot. Tell me how you'd like it, and with the I really do like the idea of exploding the big doc into component parts and transforming the source document into just a table of contents placeholder. 🤔 One possible simplification could be to use the Proof-of-concept: And generating the md-tree toc docs/architecture.md --output generated > generated/index.mdThis results in a completely navigable tree like this: |
Beta Was this translation helpful? Give feedback.
-
|
Another interesting capability of my tool, in case you like nerding out about stuff like this: |
Beta Was this translation helpful? Give feedback.
-
|
@bmadcode As of 1.2.1 (just published), For example, using my md-tree explode-doc architecture.md output_dirThe generated Check it out! I think this is the simplest solution for us to use in managing BMAD-generated documents. So the flow is:
|
Beta Was this translation helpful? Give feedback.
-
|
I fixed a few bugs in I renamed the sharding command to be called Most important, if you run the |
Beta Was this translation helpful? Give feedback.
-
|
Md-Exploder! That is an epic name and potential logo, just sayin... 😀
…On Fri, May 30, 2025, 3:21 PM Kayvan Sylvan ***@***.***> wrote:
I fixed a few bugs in @kayvan/markdown-tree-parser
I renamed the sharding command to be calledexplode and implemented an
assemble command to put it back together.
$ md-tree
📚 md-tree v1.3.2 - Markdown Tree Parser CLI
Usage: md-tree <command> <file> [options]
Commands:
list <file> List all headings in the file
extract <file> <heading> Extract a specific section by heading text
extract-all <file> [level] Extract all sections at level (default: 2)
explode <file> <output-dir> Extract all level 2 sections and create index
assemble <dir> <output-file> Reassemble exploded document from directory
tree <file> Show the document structure as a tree
search <file> <selector> Search using CSS-like selectors
stats <file> Show document statistics
toc <file> Generate table of contents
version Show version information
help Show this help message
Options:
--output, -o <dir> Output directory for extracted files
--level, -l <number> Heading level to work with
--format, -f <json|text> Output format (default: text)
--max-level <number> Maximum heading level for TOC (default: 3)
Examples:
md-tree list README.md
md-tree extract README.md "Installation"
md-tree extract-all README.md 2 --output ./sections
md-tree explode README.md ./exploded
md-tree assemble ./exploded reassembled.md
md-tree tree README.md
md-tree search README.md "heading[depth=2]"
md-tree stats README.md
md-tree toc README.md --max-level 2
For more information, visit: https://github.com/ksylvan/markdown-tree-parser
Most important, if you run the explode and assemble commands, the
operation perfectly recreates your original
large markdown file:
—
Reply to this email directly, view it on GitHub
<#111 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BOTVGQPWZGQP5WOM3XDB4X33BC4UFAVCNFSM6AAAAAB6B2YGU6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMZSGUYTINQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Excited to get this all working tonight or this weekend. Also getting a lot
of feedback about the current flow being too slow and long in some areas
working with the agents. Have a good streamlining idea in mind without
losing effectiveness. Combined with this, really gonna make things much
easier and faster!
…On Fri, May 30, 2025, 3:51 PM brian madison ***@***.***> wrote:
Md-Exploder! That is an epic name and potential logo, just sayin... 😀
On Fri, May 30, 2025, 3:21 PM Kayvan Sylvan ***@***.***>
wrote:
> I fixed a few bugs in @kayvan/markdown-tree-parser
>
> I renamed the sharding command to be calledexplode and implemented an
> assemble command to put it back together.
>
> $ md-tree
>
> 📚 md-tree v1.3.2 - Markdown Tree Parser CLI
>
> Usage: md-tree <command> <file> [options]
>
> Commands:
> list <file> List all headings in the file
> extract <file> <heading> Extract a specific section by heading text
> extract-all <file> [level] Extract all sections at level (default: 2)
> explode <file> <output-dir> Extract all level 2 sections and create index
> assemble <dir> <output-file> Reassemble exploded document from directory
> tree <file> Show the document structure as a tree
> search <file> <selector> Search using CSS-like selectors
> stats <file> Show document statistics
> toc <file> Generate table of contents
> version Show version information
> help Show this help message
>
> Options:
> --output, -o <dir> Output directory for extracted files
> --level, -l <number> Heading level to work with
> --format, -f <json|text> Output format (default: text)
> --max-level <number> Maximum heading level for TOC (default: 3)
>
> Examples:
> md-tree list README.md
> md-tree extract README.md "Installation"
> md-tree extract-all README.md 2 --output ./sections
> md-tree explode README.md ./exploded
> md-tree assemble ./exploded reassembled.md
> md-tree tree README.md
> md-tree search README.md "heading[depth=2]"
> md-tree stats README.md
> md-tree toc README.md --max-level 2
>
> For more information, visit: https://github.com/ksylvan/markdown-tree-parser
>
> Most important, if you run the explode and assemble commands, the
> operation perfectly recreates your original
> large markdown file:
>
> —
> Reply to this email directly, view it on GitHub
> <#111 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/BOTVGQPWZGQP5WOM3XDB4X33BC4UFAVCNFSM6AAAAAB6B2YGU6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMZSGUYTINQ>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
Beta Was this translation helpful? Give feedback.
-
|
I'm done with The latest version is # Via npm
npm install -g @kayvan/markdown-tree-parser
# Via pnpm
pnpm install -g @kayvan/markdown-tree-parser |
Beta Was this translation helpful? Give feedback.
-
|
Hey guys, following your discussion I just want to show my appreciation for your dedication. I love your thought process of improving. It was a bit annoying, honestly, to go through the compiled files. i love the md exploder ;) This might also come in handy to create change validation reports and having a traceable history of the changes (should be optional, knowing it will increase the text files in the repos, but also can add an option to outsource it and store it on an S3 bucket). let me know what you think - I can create a new issue for it, don't want to hijack this thread intentionally. |
Beta Was this translation helpful? Give feedback.
-
|
@icklers Thanks. @kayvan/markdown-tree-parser is now at version 1.4.1 (with the only functional change being the logo and some package upgrades). I really like that the idea of this utility grew out of discussions with Brian @bmadcode around how to improve the document sharding and make it easier too, based on problems I ran into when trying to shard my large documents that contained diagrams or markdown code blocks. |
Beta Was this translation helpful? Give feedback.
-
|
Correct. As long as the documents are created with proper headings (start at level 1 saying what the document is "# Product Requirements Document for My Awesome Project") and then have all the subsections at level 2 - and sub-subsections as needed, then the My convention would be to do this, for example: And navigating to one of the sub-documents: And then in my README or other places where the |
Beta Was this translation helpful? Give feedback.
-
|
I am going to update the template to just make each epic a level 2 item instead of bolded items under the epics overview - basically I am going to optimize the template headings to support this process. BTW @ksylvan found a minor bug in the repo when using extract instead of explode - I will try to add a fix for it later with a PR against your repo, want to help contribute back to your awesome new tool! |
Beta Was this translation helpful? Give feedback.
-
|
Awe you beat me to it 🤣
…On Sat, May 31, 2025, 8:31 PM Kayvan Sylvan ***@***.***> wrote:
Fixed in v1.4.2 please update 😄
Thanks for the bug report: ksylvan/markdown-tree-parser#2
<ksylvan/markdown-tree-parser#2>
—
Reply to this email directly, view it on GitHub
<#111 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BOTVGQJDLA4EOMSKV56BZDL3BJJVNAVCNFSM6AAAAAB6B2YGU6VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMZTGE4TMMQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
@ksylvan it would be great if i could run |
Beta Was this translation helpful? Give feedback.
-
|
oh-oh, there are 2 similarly named packages: @bmadcode i think you are referencing the wrong one in v4 ( cc @ksylvan |
Beta Was this translation helpful? Give feedback.
-
|
i tried out exploding with i think it would be great if the |
Beta Was this translation helpful? Give feedback.
-
|
Ah shoot - If I put the wrong one good catch! Ill check in a bit! |
Beta Was this translation helpful? Give feedback.








Uh oh!
There was an error while loading. Please reload this page.
-
See issue #110
Here's the demonstration chat of talking to the agent and having it create a much easier-to-process sharding output:
https://g.co/gemini/share/ab3ff0e8f09d
And then I copy the whole output (using the "..." Copy that preserved the Markdown formatting of the entire output) and run my Python extraction script:
(fabric-mcp) kayvan@dharma src/fabric-mcp [develop?] $ python scripts/extract_files.py temp_output input.txt Written: temp_output/docs/epic-1.md Written: temp_output/docs/epic-2.md Written: temp_output/docs/epic-3.md Written: temp_output/docs/epic-4.mdAnd voila! All the epic files are there. Now I look them over, fix the heading levels, and pop them into my
docs/directory.The prompt I used is here as a text file:
sharding-prompt.txt
Beta Was this translation helpful? Give feedback.
All reactions