Repository navigation
fix: replace legacy unmarked OpenWiki section instead of appending a duplicate - #914
Merged
Colin Francis (colifran) merged 4 commits intoSep 21, 2026
Conversation
A repository set up by a pre-marker (0.0.x) release has a bare `## OpenWiki` section that OpenWiki wrote directly into AGENTS.md and CLAUDE.md, before the managed `<!-- OPENWIKI:START/END -->` markers existed. Code mode finds no markers in that file, appends a fresh managed block, and from then on only ever refreshes the block, so the old section is never reconciled and the two sit side by side as two `## OpenWiki` headings. This repo's own root AGENTS.md and CLAUDE.md are in exactly that state. prepareCodeModeAgentSnippet now looks for the legacy section before it looks for markers. A heading counts as the legacy section only when the next non-blank line is the sentence every 0.0.x template opened with, so a `## OpenWiki` section someone wrote by hand is left alone, and a heading quoted inside a fenced code block is skipped. Only the known template lines are removed, stopping at the first line that is not one of them, so hand-edited content below the old section survives. When there are no markers the managed block is placed where the old section was; when a marked block already exists the old section is removed and the block is refreshed as before. Marker validation now runs on the content that actually gets written, and the malformed-marker error path is unchanged. Co-Authored-By: Wenyu <[email protected]>
🦋 Changeset detectedLatest commit: 707dbbe The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Colin Francis (colifran)
approved these changes
Sep 21, 2026
Colin Francis (colifran)
left a comment
Collaborator
There was a problem hiding this comment.
thanks Younes Beriane (@drakeo338)!
Merged
myleo198
pushed a commit
to myleo198/openwiki
that referenced
this pull request
Sep 27, 2026
…duplicate (langchain-ai#914) * fix: replace legacy unmarked OpenWiki section instead of duplicating it A repository set up by a pre-marker (0.0.x) release has a bare `## OpenWiki` section that OpenWiki wrote directly into AGENTS.md and CLAUDE.md, before the managed `<!-- OPENWIKI:START/END -->` markers existed. Code mode finds no markers in that file, appends a fresh managed block, and from then on only ever refreshes the block, so the old section is never reconciled and the two sit side by side as two `## OpenWiki` headings. This repo's own root AGENTS.md and CLAUDE.md are in exactly that state. prepareCodeModeAgentSnippet now looks for the legacy section before it looks for markers. A heading counts as the legacy section only when the next non-blank line is the sentence every 0.0.x template opened with, so a `## OpenWiki` section someone wrote by hand is left alone, and a heading quoted inside a fenced code block is skipped. Only the known template lines are removed, stopping at the first line that is not one of them, so hand-edited content below the old section survives. When there are no markers the managed block is placed where the old section was; when a marked block already exists the old section is removed and the block is refreshed as before. Marker validation now runs on the content that actually gets written, and the malformed-marker error path is unchanged. Co-Authored-By: Wenyu <[email protected]> * fix: preserve customized legacy OpenWiki sections * docs: align changeset with PR title --------- Co-authored-by: Wenyu <[email protected]> Co-authored-by: Colin Francis <[email protected]> Co-authored-by: Colin Francis <[email protected]>
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.
Fixes #361.
OpenWiki 0.0.x had the agent write its own
## OpenWikisection into AGENTS.md and CLAUDE.md, before the managed markers existed. Code mode sees no markers in a file like that and appends the managed block underneath, and after that it only ever refreshes the block, so the old section never goes away. The root AGENTS.md and CLAUDE.md in this repo have both copies right now.This builds on Wenyu Chiou (@WenyuChiou)'s #362, which took the same approach and was closed without a comment, along with 15 other PRs in the same hour. It also no longer applies to current main, where the file has moved to
src/ingestion/. I rewrote it against main and kept Wenyu as co-author on the commit.With this change,
prepareCodeModeAgentSnippetlooks for the old section before it looks for markers. If there are no markers, the managed block goes where the old section was. If a marked block already exists, the old section is removed and the block is refreshed the same way it is now. The malformed-marker error is unchanged, and marker validation now runs on the content that actually gets written.I went back and forth on what counts as the old section. Matching the heading alone would delete a
## OpenWikisection someone wrote by hand, and that's worse than the duplicate. So a heading only counts when the next non-blank line is the sentence every released 0.0.x template opened with: "This repository has documentation located in the /openwiki directory." #362 keyed onopenwiki/quickstart.mdinstead. I didn't, because someone pointing their team at the wiki could easily link the quickstart, while that sentence only ever came from our prompt. Headings inside a fenced code block are skipped, so a README-style quote of the old snippet stays put.My first version ran the old section to the next
#/##heading. That silently deleted whatever a user had put underneath it, like a###subsection, a paragraph, a setext heading or another tool's<!-- ... -->block. Now only lines from the old template are removed: the heading, that sentence, "Start here:", the quickstart link, the "OpenWiki includes..." and "When working in this repository..." lines, and blank lines between them. Every one of those is matched exactly, not by prefix, so a line someone appended their own text to no longer looks like the template and stops the removal like any other line. It stops at the first line that isn't one of those. The trade-off is that if someone edited a line inside the old section, the removal stops there and their edited line and anything after it stay. If they only added lines after it, those stay too. Either way nothing is lost, but a heavily edited old section may be only partly cleaned up.For a CLAUDE.md that is just
@AGENTS.mdplus an old section, I remove the old section and leave only the import, since AGENTS.md carries the managed block. A CLAUDE.md that is only the import is still left byte-for-byte alone.I added sixteen tests to
test/ingestion/code-mode.test.ts:###subsection, a plain paragraph, a setext heading and an Nx-style comment block)@AGENTS.mdCLAUDE.md, and that reducing it to the import is idempotent~~~line, so the nested delimiter doesn't close the outer fence## OpenWikiwithout the sentenceThirteen of them fail on main because main leaves the duplicate. The two fenced-quote tests and the hand-written one pass on main, since main never deletes anything; they're there to keep this fix from deleting too much.
lint:check,format:checkandtypecheckare clean.#723 edits lines right next to this change in the same file, so whichever of the two lands second will have a small conflict.
It includes a patch changeset.