Splits large markdown into level-2 shards via markdown-tree-parser explode, then renames to ordered ASCII slugs (01-slug.md, 02-…). Use if the user says perform shard document
Goal: Split large markdown documents into smaller, organized files based on level 2 sections using npx @kayvan/markdown-tree-parser explode, then rename shards so filenames are safe on all platforms, include document order as a numeric prefix, and match the project language rules from BMAD config (ASCII slugs, no mojibake in names).
phn-tch-…) unless the user explicitly opts outUse this for every .md file created in the destination except index.md (keep index.md as the standard name).
{project-root} (workspace root of the project).document_output_language, then communication_language:
{project-root}/_bmad/bmm/config.yaml{project-root}/_bmad/core/config.yamlTreat as Vietnamese context when the configured (or user-stated) language matches any of these (case-insensitive, trim whitespace):
vietnam or vietnamesetiếng or tiengvi or vnOtherwise treat as English context (and other Latin document languages: use the same rules as English — ASCII slug from the heading text).
Use the level-2 section title (in source document order, top to bottom) as the source string. The final basename is always {order}-{slug}.md (see Ordered numeric prefix below), not bare slug.md.
## headings in the original source file (before explode).k to a fixed width W = max(2, number of digits in N) so lexicographic sort matches document order (e.g. N = 6 → 01…06; N = 120 → 001…120).01-giai-phap-ky-thuat.md. Do not use 1. / 2. plus a dot before the slug (ambiguous with extensions; poor cross-tool behavior). The “1, 2, …” reading order is the numeric prefix.{padded-k}-{slug}.md where the slug segment contains only [a-z0-9-] as in the rules below.From the level-2 title, build slug (filename segment only; file content unchanged):
Vietnamese context
đ → d, Đ → D-[a-z0-9-] — no Vietnamese diacritics in filenames-, strip leading/trailing -section-{k} using the same k as the ordered prefixGiải pháp kỹ thuật → 03-giai-phap-ky-thuat.mdEnglish context
-Technical Decisions → 01-technical-decisions.mdindex.mdexplode, determine section order and titles from the source .md file (## lines in order); use the source as authority if anything disagrees with tool output.{padded-k}-{slug}.md per sections above. If two titles yield the same slug, append -2, -3, … to the slug segment only (e.g. 04-foo.md, 05-foo-2.md).index.md and update every relative link so it points to the new filenames (the explode tool often writes links to old names)./path/to/architecture.md --> /path/to/architecture/[y] to confirm use of default: [suggested-path], else enter a new path)npx @kayvan/markdown-tree-parser explode [source-document] [destination-folder]index.md linksindex.md): HALT and reportindex.md was created in destination folder and that relative links resolve to renamed shard filesindex.md): ordered prefix \d+ then - then slug — only [0-9a-z-].md, zero-padded width consistent for all shards, no diacritics or mojibakeindex.md was created and links were updated after filename normalization (language mode taken from BMAD config or user)01-slug.md, 02-… (zero-padded order + hyphen + slug); Vietnamese context → unsign/slug rules; English context → English kebab-caseCritical: Keeping both the original and sharded versions defeats the purpose of sharding and can cause confusion.
Present user with options for the original document:
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):
d (delete)m (move)archive subfolder
/path/to/architecture.md --> /path/to/archive/architecture.md[y] to use default: [default-archive-path], or provide custom path)k (keep)index.md, unresolved renames)