axiom_graph_patch_section¶
- axiom_graph.mcp.server.axiom_graph_patch_section(project_root, section_id, new_string, anchor=None, old_string=None)¶
Partially edit a section’s content (append / prepend / unique-match replace).
A lightweight companion to
axiom_graph_update_section: instead of whole-replacing the section content, mutate only a slice of it. The final on-disk content,desc_hash, staleness, and re-indexing are identical to the equivalent whole-replace – this is purely an input-ergonomics optimisation (cheaper edits, no read-modify-write clobber risk for append-mostly sections like ledgers and friction logs).Exactly one of
anchor/old_stringmust be supplied:append (
anchor="$") – concatenatenew_stringat the section end. No need to know the existing content.prepend (
anchor="^") – concatenatenew_stringat the section start. No need to know the existing content.replace (
old_string=...) –Edit-style unique-substring replacement ofold_stringwithnew_string. Missing or non-unique match is a hard error and the section is left unchanged.
The
^/$mnemonics line up with regex anchors but are out-of-band parameters, never embedded innew_string– a section body containing$VAR,$x^2$, orCtrl-^round-trips untouched. Append / prepend insert exactly one\nseparator at the join (skipped when the leading side already ends with\n); into an empty section they just set the content.- Parameters:
- project_root str
Absolute path to the indexed project.
- section_id str
Full qualified section ID (dot-path notation supported for nested sections), e.g.
myproject::docs.architecture::api.errors.- new_string str
Content to add (append / prepend) or replacement string (replace). Inserted verbatim – never scanned for anchor sentinels. Mirrors
Edit’sold_string/new_stringpair.- anchor str | None
"$"to append at the end,"^"to prepend at the start. Mutually exclusive withold_string.- old_string str | None
Replace-mode target; must match exactly once within the section’s current content. Mutually exclusive with
anchor.
- Return type:
str