EditMemory
Modifies existing memory files with [[WikiLink]] preservation and checksum safety for graph integrity.
Modifies existing memory files with [[WikiLink]] preservation and checksum safety for graph integrity.
Parameters
identifier(string, required): Memory URI or title. Example:"memory://research/notes"or"notes"operation(string, required): Edit type:"append","prepend","find_replace","replace_section"content(string, required): Content to add/replace. MUST contain at least one[[WikiLink]](e.g., [[analysis]], [[findings]]).checksum(string, optional): From ReadMemory. Prevents stale edits.findText(string, optional): For find_replace. Text to find.expectedCount(int, optional): For find_replace. Expected match count.sectionName(string, optional): For replace_section. Markdown header name.
Returns
Operations
append
Adds content to file end.
prepend
Adds content to file start.
find_replace
Replaces all occurrences using simple string replacement.
⚠️ WARNING: Nested WikiLinks
Replacing text INSIDE existing [[WikiLinks]] creates nested brackets.
Example of the problem:
- File contains:
[[machine learning]] - findText:
"machine learning" - content:
"[[ML]]" - Result:
[[[[ML]]]](nested brackets - broken WikiLink)
To avoid this, replace the ENTIRE WikiLink including brackets:
- findText:
"[[machine learning]]" - content:
"[[ML]]" - Result:
[[ML]](correct)
replace_section
Replaces markdown section by header.
Workflow
- ReadMemory with
includeChecksum=true - EditMemory with checksum from step 1
- Sync if bulk edits (rebuilds graph)
Constraints
- [[WikiLink]] required: New content MUST contain at least one
[[WikiLink]](e.g., [[research]], [[methodology]]) - Checksum validation: Detects conflicts between read and edit
- Section names: Must match exact markdown header text (case-sensitive)
- expectedCount: Validates find_replace safety
- find_replace behavior: Uses simple
String.Replace()- no escaping or bracket detection. Replacing text inside[[WikiLinks]]creates nested brackets. This is intentional Ma Protocol behavior.
Integration
- ReadMemory: Get checksum before editing
- SearchMemories: Find files to update
- Sync: Rebuild graph after bulk edits
- BuildContext: Verify concept connections after edits