EditMemory

Edit an existing memory FILE to add, modify, or replace content while maintaining [[concept]] connections to the knowledge graph. This tool provides safe editing operations with checksum validation to prevent conflicting changes and ensures all edits contribute to the Maenifold graph structure.

When to Use This Tool

Key Features

Parameters

ParameterTypeRequiredDescriptionExample
identifierstringYesMemory FILE identifier (URI or title)“memory://documents/machine-learning.md”
operationstringYesEdit operation type”append”, “prepend”, “find_replace”, “replace_section”
contentstringYesContent to add/replace - MUST contain [[concepts]]“New insights about [[Neural Networks]]“
checksumstringNoFile checksum from ReadMemory (prevents stale edits)“a1b2c3d4e5f6”
findTextstringNoText to find (required for find_replace)“old terminology”
sectionNamestringNoSection header name (required for replace_section)“Implementation Details”
expectedCountintNoExpected match count for find_replace validation3

Operation Types

append

Adds new content to the end of the existing file.

{
  "identifier": "memory://documents/machine-learning.md",
  "operation": "append",
  "content": "## Recent Discoveries\n\nNew research in [[Deep Learning]] shows promising results with [[Transformer Architecture]]."
}

prepend

Adds new content to the beginning of the existing file.

{
  "identifier": "memory://documents/machine-learning.md", 
  "operation": "prepend",
  "content": "# Prerequisites\n\nThis document assumes familiarity with [[Statistics]] and [[Linear Algebra]].\n\n"
}

find_replace

Replaces all occurrences of specific text with new content.

{
  "identifier": "memory://documents/machine-learning.md",
  "operation": "find_replace", 
  "content": "[[Machine Learning]] algorithms",
  "findText": "ML algorithms",
  "expectedCount": 5
}

replace_section

Replaces content under a specific markdown section header.

{
  "identifier": "memory://documents/machine-learning.md",
  "operation": "replace_section",
  "content": "Current [[TensorFlow]] and [[PyTorch]] implementations provide excellent performance.",
  "sectionName": "Implementation Tools"
}

Usage Examples

Basic Append Example

{
  "identifier": "research-notes",
  "operation": "append", 
  "content": "## Latest Findings\n\nDiscovered important connection between [[Attention Mechanisms]] and [[Memory Networks]]."
}

Adds new section to the end of the research-notes file.

Safe Find-Replace with Validation

{
  "identifier": "memory://documents/ai-overview.md",
  "operation": "find_replace",
  "content": "[[Artificial Intelligence]] systems",
  "findText": "AI systems", 
  "checksum": "a1b2c3d4e5f6",
  "expectedCount": 12
}

Replaces “AI systems” with properly linked concept, validating exactly 12 replacements occur.

Section Replacement Example

{
  "identifier": "project-status", 
  "operation": "replace_section",
  "content": "Project completed successfully. Key insights include [[Agile Methodology]] benefits and [[Continuous Integration]] improvements.",
  "sectionName": "Current Status"
}

Replaces the entire “Current Status” section with updated information.

Common Patterns

Safe Editing Workflow

  1. Read first: Use ReadMemory with includeChecksum=true to get current state
  2. Plan changes: Identify what needs updating and ensure [[concepts]] are included
  3. Edit with checksum: Use the checksum from ReadMemory to prevent conflicts
  4. Verify results: Check that operation succeeded and file maintains graph connectivity

Collaborative Editing

Graph Maintenance

Troubleshooting

”ERROR: Checksum mismatch”

Cause: File was modified between ReadMemory and EditMemory calls Solution: Re-read the file with ReadMemory to get current checksum, then retry edit

”ERROR: New content must contain at least one [[concept]]”

Cause: Edit content doesn’t include any [[WikiLink]] concepts Solution: Add relevant [[Concept Names]] to connect content to knowledge graph

”ERROR: This edit would remove all [[concepts]] from the file”

Cause: find_replace or replace_section would eliminate all graph connections Solution: Ensure replacement content includes appropriate [[concepts]]

“Expected X matches but found Y”

Cause: expectedCount validation failed in find_replace operation Solution: Check if file was modified or adjust expectedCount parameter

”ERROR: Memory file not found”

Cause: Invalid identifier or file doesn’t exist Solution: Use SearchMemories to find correct identifier or verify file exists

Section replacement not working

Cause: sectionName doesn’t match exact markdown header text Solution: Check exact section header text including capitalization and punctuation

Implementation Notes

Ma Protocol Compliance