Repository navigation
fix(compile): don't carry the template's ## Environment placeholder (#364) - #384
Merged
Merged
Conversation
…364) A CLAUDE.md written by 1.9.3 holds the template's `## Environment` with only its HTML comment. With a second, user-written `## Environment`, `adf compile --write --mode compiled` carried both into the retained block: divergentRetainedHeadings keyed sections by heading, so the user's copy made the heading divergent and composeCompiled then took every section with it. Judge each retained section on its own against the pointer templates (isTemplateRetainedSection; CRLF and trailing whitespace ignored), so the untouched placeholder is template text and only the user's section is carried. A placeholder the user wrote under is still carried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…laceholder # Conflicts: # CHANGELOG.md
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.
Closes #364
Problem
A
CLAUDE.mdwritten by 1.9.3 holds the template's## Environmentplaceholder, which is the heading plus<!-- Add runtime/OS/shell-specific notes here (not stack rules) -->. If the user also added their own## Environment,charter adf compile --target claude --write --mode compiledcarried both into the retained block, comment included, and printedkept ## Environment, ## Environment.Cause:
divergentRetainedHeadingsbuilt aMapkeyed by heading, so the second section overwrote the first. The user's body made the heading divergent, andcomposeCompiled's pointer branch then carried every section with that heading.Reproduced end to end: ran
npx -y @stackbilt/cli@1.9.3 bootstrap --yesin a scratch dir, appended## Environment\n- Windows host; use Git Bash., then ran this repo's builtadf compile --target claude --write --mode compiled.Fix
adf-compile.ts: retained sections are now a list, not a heading-keyed map. NewisTemplateRetainedSection(file, heading, bodyLines)returns true when a section matches one a pointer template for that file carries untouched; CRLF and trailing whitespace are ignored.divergentRetainedHeadingsjudges each section on its own and returns the same headings as before.adf-retained.ts(composeCompiled, pointer source): a section is carried only if its heading is divergent and the section itself is not template text.The placeholder text is identical in the published 1.9.3 tarball (
npm pack @stackbilt/cli@1.9.3,dist/commands/adf.js), in thev1.9.3tag, and in the current templates. It has not changed since it was added (pickaxe search of history: 8cbfd78, 3ba3957). Dropping it causes norefused-would-drop, becauselinesRestoreWouldDropalready exempts template lines.Tests (
adf-retained.test.ts, new describe block)The fixture is the exact 1.9.3 bootstrap
CLAUDE.md. Cases:## Environment: only the user section is carried, andlinesConvertWouldDropis emptycompile --write --mode compiledpath, for the upgrade case and for an untouched CRLF 1.9.3 fileThree of these fail on
origin/mainand pass with the fix. Full suite run serially: 1766 pass. The 3 failures are the known Windows-only ones (bootstrap #307, context-refresh, serve-context).🤖 Generated with Claude Code