reset: stop replaceSection from deleting user content after the managed section#198
Open
selimdev00 wants to merge 2 commits into
Open
reset: stop replaceSection from deleting user content after the managed section#198selimdev00 wants to merge 2 commits into
selimdev00 wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
replaceSectionbounds the managed section by searching for the next##heading:If no following
##heading exists,afterbecomes""- so everything from the marker to EOF is dropped. The managed## BMAD-METHOD Integrationblock is appended at the end of the instructions file (CLAUDE.md/AGENTS.md), so any user content placed after it that isn't introduced by a##heading is silently destroyed when the section is removed duringbmalph reset:# headingand everything under itAnd because
resetdeletes the file entirely when the result trims to empty, aCLAUDE.mdwhose only##block was BMAD could be removed outright along with that trailing content.Fix
Bound the section by the next heading of the same or higher level (
#or##), skipping past the marker's own heading line first:# User Notesnow terminates the section and is preserved (was deleted).## Sectionstill terminates it (unchanged).###and deeper headings remain part of the section body - matching how the shipped BMAD snippet is structured (its internal subheadings are all###), so the block is still treated as one unit.Existing
replaceSectionbehavior (replace between headings, remove section, section-at-EOF, marker-not-found) is unchanged; all consumers (reset,mergeInstructionsFile) pass.Known limitation
Headerless prose placed directly after the managed block (no
#/##heading at all) is still absorbed - there's no boundary token to detect it. Fully solving that needs explicit<!-- BMAD:START/END -->delimiters around the section (a format change with migration for existing installs), which I left as a separate follow-up. This PR removes the common and most damaging cases without that migration.Tests
Added regression cases: trailing
#heading preserved on removal;###subheadings treated as body; marker's own heading not matched as the boundary. Full unit suite passes (1838).