add write, import, and export commands

write KEY: upsert a single node from stdin. Creates new or updates
existing with version bump. No-op if content unchanged.

import FILE: parse markdown sections, diff against store, upsert
changed/new nodes. Incremental — only touches what changed.

export FILE|--all: regenerate markdown from store nodes. Gathers
file-level + section nodes, reconstitutes mem markers with links
and causes from the relation graph.

Together these close the bidirectional sync loop:
  markdown → import → store → export → markdown

Also exposes memory_dir_pub() for use from main.rs.
This commit is contained in:
ProofOfConcept 2026-02-28 23:00:52 -05:00
parent 14b6457231
commit 57cf61de44
2 changed files with 234 additions and 1 deletions

View file

@ -32,6 +32,8 @@ fn memory_dir() -> PathBuf {
.join(".claude/memory")
}
pub fn memory_dir_pub() -> PathBuf { memory_dir() }
fn nodes_path() -> PathBuf { memory_dir().join("nodes.capnp") }
fn relations_path() -> PathBuf { memory_dir().join("relations.capnp") }
fn state_path() -> PathBuf { memory_dir().join("state.bin") }