What happens
When openwiki code mode runs against a repository whose AGENTS.md/CLAUDE.md contains an unmarked ## OpenWiki section (written by a version before the <!-- OPENWIKI:START/END --> markers existed, or hand-copied), the marker-based upsert in writeCodeModeAgentSnippet (src/code-mode.ts) finds no markers and appends a second ## OpenWiki section instead of replacing the legacy one. Subsequent runs keep the duplicate forever: the marked block is refreshed in place, but the legacy section is never detected or removed.
Reproduction — visible in this repo's own root files
CLAUDE.md and AGENTS.md at the repository root both currently contain the duplication:
- an unmarked
## OpenWiki section at line 1 (old snippet wording: "This repository has documentation located in the /openwiki directory…"), and
- the managed block with a second
## OpenWiki inside <!-- OPENWIKI:START --> / <!-- OPENWIKI:END --> at lines 13–21.
Every agent that reads these files sees two adjacent, slightly-contradictory OpenWiki sections.
Why it matters
The agent files are the product's integration surface — coding agents are told to trust them for orientation. Duplicated/stale instruction blocks propagate confusion to every consumer, and the duplication grows worse for any user who upgraded across the marker introduction.
Expected
A refresh should own exactly one OpenWiki section: detect a legacy unmarked ## OpenWiki section, replace it in place (or remove it when a marked block already exists), while leaving user-authored sections that merely share the heading untouched.
I have a tightly-scoped fix with regression tests ready — PR incoming.
What happens
When
openwikicode mode runs against a repository whoseAGENTS.md/CLAUDE.mdcontains an unmarked## OpenWikisection (written by a version before the<!-- OPENWIKI:START/END -->markers existed, or hand-copied), the marker-based upsert inwriteCodeModeAgentSnippet(src/code-mode.ts) finds no markers and appends a second## OpenWikisection instead of replacing the legacy one. Subsequent runs keep the duplicate forever: the marked block is refreshed in place, but the legacy section is never detected or removed.Reproduction — visible in this repo's own root files
CLAUDE.mdandAGENTS.mdat the repository root both currently contain the duplication:## OpenWikisection at line 1 (old snippet wording: "This repository has documentation located in the /openwiki directory…"), and## OpenWikiinside<!-- OPENWIKI:START -->/<!-- OPENWIKI:END -->at lines 13–21.Every agent that reads these files sees two adjacent, slightly-contradictory OpenWiki sections.
Why it matters
The agent files are the product's integration surface — coding agents are told to trust them for orientation. Duplicated/stale instruction blocks propagate confusion to every consumer, and the duplication grows worse for any user who upgraded across the marker introduction.
Expected
A refresh should own exactly one OpenWiki section: detect a legacy unmarked
## OpenWikisection, replace it in place (or remove it when a marked block already exists), while leaving user-authored sections that merely share the heading untouched.I have a tightly-scoped fix with regression tests ready — PR incoming.