Class ClaudeMdMerge
java.lang.Object
network.ike.plugin.ws.bootstrap.ClaudeMdMerge
Non-destructive regeneration of a subproject
CLAUDE.md
(IKE-Network/ike-issues#917, #920).
ws:scaffold-init regenerates each subproject's CLAUDE.md
from a template on every run. A naive full overwrite destroyed two kinds of
content the template does not own:
- #920 — the
ike-managedregions thatike:scaffold-publishappends (<!-- BEGIN ike-managed: <name> --> … <!-- END ike-managed: <name> -->), causing the two generators to ping-pong the file on alternate runs. - #917 — hand-authored
##sections a developer added (e.g. a project's fast-dev build notes), silently dropped on regeneration.
merge(String, String) is a pure function so it can be unit-tested
without touching the filesystem. It:
- extracts every
ike-managedregion from the existing file verbatim (byte-for-byte, on its own lines, so the emitting plugin's line-exact marker matching still locates it) and re-appends them after the freshly generated template; - returns any top-level (
##) section whose heading the template does not itself produce as a rescued section, for the caller to preserve inCLAUDE-<name>.md— the file the scaffold never overwrites — rather than carrying it into the regeneratedCLAUDE.md.
Template-owned sections are regenerated from the template (that is the
point of regeneration); only sections the template does not emit are treated
as hand-authored. A section added as prose inside a template-owned
section (no new ## heading) is a residual gap — it is regenerated
with its section — but the reported real-world losses were whole sections,
which this preserves.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe result of merging an existingCLAUDE.mdwith a freshly generated template.static final recordA hand-authored section rescued from a regeneratedCLAUDE.md. -
Method Summary
-
Method Details
-
merge
MergeexistingCLAUDE.md content with a freshlygeneratedtemplate.- Parameters:
existing- the current on-diskCLAUDE.md, ornullwhen the file does not exist yet (fresh write)generated- the freshly generated template content- Returns:
- the merged content plus any hand-authored sections to rescue
-
normalize
-