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_string must be supplied:

  • append (anchor="$") – concatenate new_string at the section end. No need to know the existing content.

  • prepend (anchor="^") – concatenate new_string at the section start. No need to know the existing content.

  • replace (old_string=...) – Edit-style unique-substring replacement of old_string with new_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 in new_string – a section body containing $VAR, $x^2$, or Ctrl-^ round-trips untouched. Append / prepend insert exactly one \n separator 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’s old_string / new_string pair.

anchor str | None

"$" to append at the end, "^" to prepend at the start. Mutually exclusive with old_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