Editing — choosing the right write
Blenau writes commit to your repo (see How sync works). Choosing the right operation keeps your documents — and their structure — intact.
Pick the right operation
Section titled “Pick the right operation”| Goal | Use |
|---|---|
| Create a new document | ingest_document — creates the file and commits it |
| Change an existing section’s body | edit_section |
| Add/prepend/replace part of a section | patch_section |
| Rename a section (change its heading) | rename_section |
| Delete a section | delete_section |
Each of these is a first-class, commit-backed operation, and each accepts
dry_run: true to preview the resulting diff without writing.
Safe editing
Section titled “Safe editing”- Read the section first:
get_section(orget_document_structure) returns its current content and version. - Edit the body only.
- Write with
edit_section, passing theexpected_versionyou just read. This is optimistic locking: if someone else changed the section meanwhile, you get a clear conflict (with the current content) instead of silently overwriting their work.
Anti-patterns
Section titled “Anti-patterns”- Don’t put a heading inside
edit_section.edit_sectionreplaces a section’s body only. Anew_contentthat begins with a different## Headingis a rename, not an edit, so it’s rejected with a clear error telling you to userename_section. (This used to silently corrupt the document into a duplicate plus an orphan; it’s now a clean guardrail.) - Never re-ingest a document to “fix” it.
ingest_documentreplaces the whole document and, on a repo-backed doc, resets its provenance fromgithubtomanual— severing the link to your repo. Useedit_section/patch_sectionfor changes.
Verify your edit
Section titled “Verify your edit”After writing, call get_document_structure and confirm the headings and section
count are what you expect. Edits splice only the section you named — the rest of the
document is left byte-for-byte untouched. Limits lists the behaviors still
worth watching for.