Skip to content

fix(compile): don't carry the template's ## Environment placeholder (#364) - #384

Merged
stackbilt-admin merged 3 commits into
mainfrom
fix/364-compile-env-placeholder
Oct 18, 2026
Merged

stackbilt-admin merged 3 commits into
mainfrom
fix/364-compile-env-placeholder

Conversation

@stackbilt-admin

Copy link
Copy Markdown
Member

Closes #364

Problem

A CLAUDE.md written by 1.9.3 holds the template's ## Environment placeholder, 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 compiled carried both into the retained block, comment included, and printed kept ## Environment, ## Environment.

Cause: divergentRetainedHeadings built a Map keyed by heading, so the second section overwrote the first. The user's body made the heading divergent, and composeCompiled's pointer branch then carried every section with that heading.

Reproduced end to end: ran npx -y @stackbilt/cli@1.9.3 bootstrap --yes in a scratch dir, appended ## Environment\n- Windows host; use Git Bash., then ran this repo's built adf compile --target claude --write --mode compiled.

Fix

  • adf-compile.ts: retained sections are now a list, not a heading-keyed map. New isTemplateRetainedSection(file, heading, bodyLines) returns true when a section matches one a pointer template for that file carries untouched; CRLF and trailing whitespace are ignored. divergentRetainedHeadings judges 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 the v1.9.3 tag, and in the current templates. It has not changed since it was added (pickaxe search of history: 8cbfd78, 3ba3957). Dropping it causes no refused-would-drop, because linesRestoreWouldDrop already exempts template lines.

Tests (adf-retained.test.ts, new describe block)

The fixture is the exact 1.9.3 bootstrap CLAUDE.md. Cases:

  • placeholder only: nothing carried, output is the bare render
  • placeholder plus a user ## Environment: only the user section is carried, and linesConvertWouldDrop is empty
  • a placeholder the user wrote under: both sections are carried
  • CRLF, and trailing spaces on the placeholder line: same results
  • the CLI compile --write --mode compiled path, for the upgrade case and for an untouched CRLF 1.9.3 file

Three of these fail on origin/main and 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

kovermier and others added 3 commits October 17, 2026 20:08
…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>
…ting blocks

Review of #384: the placeholder dates from 8cbfd78 (v0.3.3), and a retained block an earlier compile already wrote is kept verbatim, so say how to clean it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@stackbilt-admin
stackbilt-admin merged commit 8bec8fc into main Oct 18, 2026
7 checks passed
@stackbilt-admin
stackbilt-admin deleted the fix/364-compile-env-placeholder branch October 18, 2026 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compile --mode compiled carries the 1.9.3 template's ## Environment placeholder into the retained block

2 participants