Problem
jcode stores memories as MemoryGraph in JSON files (~/.jcode/memory/global.json, ~/.jcode/memory/projects/<hash>.json). Each MemoryEntry has inline embeddings, tags, edges, clusters, and metadata. These must be migrated into mempalace's Drawer + KG format.
Scope
Files: New crates/jcode-mempalace-adapter/src/migrate.rs
-
Migration function:
pub async fn migrate_to_mempalace(
jcode_memory_dir: &Path, // ~/.jcode/memory/
palace_path: &Path, // target mempalace path
dry_run: bool,
) -> anyhow::Result<MigrationReport>
-
Migration steps (for each JSON file):
a. Memories → Drawers: For each MemoryEntry in the graph:
- Create
Drawer with mapped DrawerKind, content, tags, trust, confidence, strength
- Map
created_at/updated_at timestamps
- Preserve embedding in Drawer (via metadata or direct vector store insert)
- Call
MemoryProvider::add_drawer()
b. Tags → KG entities + HasTag edges: For each TagEntry:
- Create KG entity with name = tag name
- For each memory with that tag, create
HasTag triple
c. Edges → KG triples with typed edge kinds: For each Edge:
RelatesTo { weight } → KG triple with MemoryEdgeKind::RelatesTo
Supersedes → MemoryEdgeKind::Supersedes
Contradicts → MemoryEdgeKind::Contradicts
DerivedFrom → MemoryEdgeKind::DerivedFrom
InCluster → MemoryEdgeKind::InCluster
d. Clusters → KG clusters: For each ClusterEntry:
- Create cluster with centroid, member_count
- Create InCluster edges to members
e. Legacy MemoryStore (v1) format: Also handle the old MemoryStore format (flat Vec) that gets auto-migrated to MemoryGraph.
-
Safety:
- Write
.bak file before any changes
- Dry-run mode: report counts without writing
- Idempotent: running twice produces same result
-
MigrationReport:
pub struct MigrationReport {
pub memories_migrated: usize,
pub tags_migrated: usize,
pub edges_migrated: usize,
pub clusters_migrated: usize,
pub errors: Vec<String>,
pub duration: std::time::Duration,
}
-
CLI command: jcode memory migrate --to-mempalace [--dry-run] [--palace-path PATH]
Acceptance Criteria
Dependencies
Reference
jcode MemoryGraph JSON: ~/.jcode/memory/global.json, ~/.jcode/memory/projects/<hash>.json
jcode MemoryGraph struct: crates/jcode-memory-types/src/graph.rs lines 231-256
jcode MemoryEntry: crates/jcode-memory-types/src/lib.rs lines 233-266
jcode legacy migration: crates/jcode-base/src/memory.rs lines 1529-1577
Problem
jcode stores memories as
MemoryGraphin JSON files (~/.jcode/memory/global.json,~/.jcode/memory/projects/<hash>.json). EachMemoryEntryhas inline embeddings, tags, edges, clusters, and metadata. These must be migrated into mempalace's Drawer + KG format.Scope
Files: New
crates/jcode-mempalace-adapter/src/migrate.rsMigration function:
Migration steps (for each JSON file):
a. Memories → Drawers: For each
MemoryEntryin the graph:Drawerwith mapped DrawerKind, content, tags, trust, confidence, strengthcreated_at/updated_attimestampsMemoryProvider::add_drawer()b. Tags → KG entities + HasTag edges: For each
TagEntry:HasTagtriplec. Edges → KG triples with typed edge kinds: For each
Edge:RelatesTo { weight }→ KG triple with MemoryEdgeKind::RelatesToSupersedes→ MemoryEdgeKind::SupersedesContradicts→ MemoryEdgeKind::ContradictsDerivedFrom→ MemoryEdgeKind::DerivedFromInCluster→ MemoryEdgeKind::InClusterd. Clusters → KG clusters: For each
ClusterEntry:e. Legacy MemoryStore (v1) format: Also handle the old
MemoryStoreformat (flat Vec) that gets auto-migrated toMemoryGraph.Safety:
.bakfile before any changesMigrationReport:
CLI command:
jcode memory migrate --to-mempalace [--dry-run] [--palace-path PATH]Acceptance Criteria
.bakfiles created before migrationDependencies
jcode --mode rpc: strict LF-delimited JSONL protocol for IDE / external integrations #12 (MempalaceAdapter must exist for the migration to call Palace APIs)Reference
jcode MemoryGraph JSON:
~/.jcode/memory/global.json,~/.jcode/memory/projects/<hash>.jsonjcode MemoryGraph struct:
crates/jcode-memory-types/src/graph.rslines 231-256jcode MemoryEntry:
crates/jcode-memory-types/src/lib.rslines 233-266jcode legacy migration:
crates/jcode-base/src/memory.rslines 1529-1577