MCPcopy Create free account
hub / github.com/JaredStewart/coderlm / _append_with_markers

Function _append_with_markers

plugin/generate.py:223–252  ·  view source on GitHub ↗
(path: Path, content: str, dry_run: bool)

Source from the content-addressed store, hash-verified

221
222
223def _append_with_markers(path: Path, content: str, dry_run: bool) -> None:
224 block = f"\n{CODEX_MARKER_START}\n{content}\n{CODEX_MARKER_END}\n"
225
226 if path.exists():
227 existing = path.read_text()
228 if CODEX_MARKER_START in existing:
229 if dry_run:
230 print(f" [dry-run] replace marked section in {path}")
231 return
232 # Replace existing block
233 start = existing.index(CODEX_MARKER_START)
234 end = existing.index(CODEX_MARKER_END) + len(CODEX_MARKER_END)
235 updated = existing[:start] + CODEX_MARKER_START + "\n" + content + "\n" + CODEX_MARKER_END + existing[end + len(CODEX_MARKER_END):]
236 # Simpler: just reconstruct
237 before = existing[:start].rstrip("\n")
238 after = existing[end:].lstrip("\n")
239 parts = [before, block.strip(), after]
240 updated = "\n\n".join(p for p in parts if p) + "\n"
241 path.write_text(updated)
242 print(f" Updated marked section in {path}")
243 return
244
245 if dry_run:
246 print(f" [dry-run] append to {path}")
247 return
248
249 path.parent.mkdir(parents=True, exist_ok=True)
250 with path.open("a") as f:
251 f.write(block)
252 print(f" Appended CodeRLM section to {path}")
253
254
255def _remove_markers(path: Path, dry_run: bool) -> None:

Callers 1

generate_platformFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected