Documentation
¶
Overview ¶
Package claudemem reads the memories claude-mem (the Claude Code memory plugin, github.com/thedotmack/claude-mem) keeps, for the Memory page to import them (#8642). It only reads: claude-mem's database is opened read-only in place and nothing of its folder is written, moved or removed.
claude-mem keeps one SQLite database, claude-mem.db (WAL mode), in its data folder: CLAUDE_MEM_DATA_DIR from the environment, else the one ~/.claude-mem/settings.json names, else ~/.claude-mem (src/shared/data-dir.ts). Its tables, as SessionStore.ts makes and migrates them:
- observations: what was learned in a session, one row each. Rows from before v21 hold their content in text; later rows in title, subtitle, narrative and facts (a JSON array of strings), with text NULL. type is the mode's observation type (code mode: bugfix, feature, refactor, change, discovery, decision, gotcha, pattern, security_alert, security_note, sensitive).
- session_summaries: one or more a session: request, investigated, learned, completed, next_steps, notes.
- sdk_sessions: the sessions, with the folder each ran in (cwd, from v53) under the project's name.
project is a name claude-mem made (the git root's folder name, an owner/repo slug, a marker folder's name), merged_into_project the one a later merge moved the row to. created_at_epoch is milliseconds. Columns came in over many versions, so each is read only when the table has it.
Index ¶
Constants ¶
const Agent = "claude-mem"
Agent is the name an imported memory's source gives.
const DBName = "claude-mem.db"
DBName is claude-mem's database in its data folder.
Variables ¶
This section is empty.
Functions ¶
func Dir ¶
func Dir() string
Dir is claude-mem's data folder, as claude-mem itself decides it (resolveDataDir): CLAUDE_MEM_DATA_DIR, else the one settings.json in ~/.claude-mem names, else ~/.claude-mem. "" when there is no home.
func Find ¶
Find is claude-mem's database: "" with no error when there is none, an error when whether there is one can't be told.
func Memories ¶
Memories are the store's observations and session summaries as magpie memories, each waiting to be reviewed (Candidate) as imported, with the time claude-mem saved it. A project's memories go to the project its sessions' folders are in, else to the one of known whose name is the project's when only one is, else everywhere (tagged with the project's name). Each has an id made from what claude-mem holds, so a second import names the same memories (memory.Import skips them). A row with no text is left out. The projects the memories are kept for are returned too.
Types ¶
type Observation ¶
type Observation struct {
ID int64
Session string // memory_session_id
Project string // the project it was saved under
Merged string // merged_into_project, "" when not merged
Type string
Text string // the content of a row from before v21
Title string
Subtitle string
Narrative string
Facts []string
Created time.Time
}
Observation is one row of observations, as read.