You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SKILL.md 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. ---
  2. name: bmad-shard-doc
  3. description: 'Splits large markdown documents into smaller, organized files based on level 2 (default) sections. Use if the user says perform shard document'
  4. ---
  5. # Shard Document
  6. **Goal:** Split large markdown documents into smaller, organized files based on level 2 sections using `npx @kayvan/markdown-tree-parser`.
  7. ## CRITICAL RULES
  8. - MANDATORY: Execute ALL steps in the EXECUTION section IN EXACT ORDER
  9. - DO NOT skip steps or change the sequence
  10. - HALT immediately when halt-conditions are met
  11. - Each action within a step is a REQUIRED action to complete that step
  12. ## EXECUTION
  13. ### Step 1: Get Source Document
  14. - Ask user for the source document path if not provided already
  15. - Verify file exists and is accessible
  16. - Verify file is markdown format (.md extension)
  17. - If file not found or not markdown: HALT with error message
  18. ### Step 2: Get Destination Folder
  19. - Determine default destination: same location as source file, folder named after source file without .md extension
  20. - Example: `/path/to/architecture.md` --> `/path/to/architecture/`
  21. - Ask user for the destination folder path (`[y]` to confirm use of default: `[suggested-path]`, else enter a new path)
  22. - If user accepts default: use the suggested destination path
  23. - If user provides custom path: use the custom destination path
  24. - Verify destination folder exists or can be created
  25. - Check write permissions for destination
  26. - If permission denied: HALT with error message
  27. ### Step 3: Execute Sharding
  28. - Inform user that sharding is beginning
  29. - Execute command: `npx @kayvan/markdown-tree-parser explode [source-document] [destination-folder]`
  30. - Capture command output and any errors
  31. - If command fails: HALT and display error to user
  32. ### Step 4: Verify Output
  33. - Check that destination folder contains sharded files
  34. - Verify index.md was created in destination folder
  35. - Count the number of files created
  36. - If no files created: HALT with error message
  37. ### Step 5: Report Completion
  38. - Display completion report to user including:
  39. - Source document path and name
  40. - Destination folder path
  41. - Number of section files created
  42. - Confirmation that index.md was created
  43. - Any tool output or warnings
  44. - Inform user that sharding completed successfully
  45. ### Step 6: Handle Original Document
  46. > **Critical:** Keeping both the original and sharded versions defeats the purpose of sharding and can cause confusion.
  47. Present user with options for the original document:
  48. > What would you like to do with the original document `[source-document-name]`?
  49. >
  50. > Options:
  51. > - `[d]` Delete - Remove the original (recommended - shards can always be recombined)
  52. > - `[m]` Move to archive - Move original to a backup/archive location
  53. > - `[k]` Keep - Leave original in place (NOT recommended - defeats sharding purpose)
  54. >
  55. > Your choice (d/m/k):
  56. #### If user selects `d` (delete)
  57. - Delete the original source document file
  58. - Confirm deletion to user: "Original document deleted: [source-document-path]"
  59. - Note: The document can be reconstructed from shards by concatenating all section files in order
  60. #### If user selects `m` (move)
  61. - Determine default archive location: same directory as source, in an `archive` subfolder
  62. - Example: `/path/to/architecture.md` --> `/path/to/archive/architecture.md`
  63. - Ask: Archive location (`[y]` to use default: `[default-archive-path]`, or provide custom path)
  64. - If user accepts default: use default archive path
  65. - If user provides custom path: use custom archive path
  66. - Create archive directory if it does not exist
  67. - Move original document to archive location
  68. - Confirm move to user: "Original document moved to: [archive-path]"
  69. #### If user selects `k` (keep)
  70. - Display warning to user:
  71. - Keeping both original and sharded versions is NOT recommended
  72. - The discover_inputs protocol may load the wrong version
  73. - Updates to one will not reflect in the other
  74. - Duplicate content taking up space
  75. - Consider deleting or archiving the original document
  76. - Confirm user choice: "Original document kept at: [source-document-path]"
  77. ## HALT CONDITIONS
  78. - HALT if npx command fails or produces no output files