nem

module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2026 License: MIT

README

mnemonics

mnemonics

Your agent forgets. nem doesn't.

mnemonics versions agent context the way git versions code. The command is nem.

Go Report Card CI codecov Go Reference Release


mnemonics · /nɪˈmɒnɪks/ · noun — a system for encoding information so it's easy to recall, by linking new, complex data to stable, familiar patterns the mind already holds onto. From Greek mnēmōn ("mindful"), after Mnemosyne, the goddess of memory.

That's the whole idea. Raw conversation is the complex, perishable data; an LLM throws it away when it compacts its context window — the reasoning, the resolved edge-cases, the decisions, gone. mnemonics encodes that context into stable, recallable structure: immutable commits, a navigable index tree, and durable facts — so any agent can bring it back later with the same commands you would.

And because Claude Code, Codex and Google Antigravity all read and write the same store, they stop being separate assistants with separate amnesia and start behaving like one mind with one memory. Single binary, SQLite embedded in pure Go (no cgo), offline.

The part nobody mentions

Did you know your agent's entire history is already sitting on your disk?

Claude Code, Codex and Antigravity write every session to your local disk — plain files, on your machine, right now. That's the raw material: the reasoning, the dead-ends, the decisions you arrived at together. But it's inert. The agent can't recall it next time and you can't search it; it just piles up and goes stale.

nem reads those local logs (nem ingest) and turns them into versioned, navigable memory — recallable by you and by the agent. Nothing new to collect, nothing leaves your machine. It was already yours; nem just makes it usable.

Install

# Windows (Scoop)
scoop bucket add Dieg0Code https://github.com/Dieg0Code/scoop-bucket
scoop install nem
# macOS / Linux (Homebrew)
brew install Dieg0Code/homebrew-tap/nem

# or with Go
go install github.com/Dieg0Code/nem/cmd/nem@latest

How your agent uses it

nem init installs the skill into Claude Code, Codex and Antigravity, and pulls in your existing sessions. The agent recalls at the start of a session and persists what it resolves — no human in the loop:

nem outline                         # the map: facts + project → chat → commit
nem search "<terms>" --format llm   # hybrid search (BM25 + semantic)
nem read <hash> --format llm        # a frozen snapshot, clean for an agent
nem commit -m "decision about X"    # persist a resolved decision (immutable)
nem fact add "<who you are / how you work>"   # a durable fact, always recalled

The agent navigates the tree, reads what matters, and writes its own commits and facts. You stay in control of one thing: nem sync (sharing) is yours.

Commands

nem init / ingest set up ~/.nem; pull in Codex, Claude Code & Antigravity sessions
nem status / log active session; commit history
nem add / commit stage messages; freeze them into an immutable snapshot
nem fact durable facts + dated reminders (--due) — surfaced at the top of every session
nem outline / timeline navigate the index tree; see how decisions evolved
nem search / read hybrid retrieval (keyword/semantic); drill into content
nem annotate rewrite a node's summary (pinned; survives re-index)
nem index (re)build the tree — incremental, only computes what's new
nem sync / clone push/pull to a git remote, redacting secrets first
nem team shared team stores: a common memory base for a whole team
nem doctor check/install the optional pro deps

How it works

  • Two memoriesepisodic (commits: what happened in a conversation, retrieved by relevance) and semantic (facts: durable truths about the user, loaded at the top of every outline, never guessed by search).
  • Immutable commits — a commit copies the text of its range (a snapshot), not a pointer. What you saved never changes.
  • Navigable index — a PageIndex-style tree (project → chat → commit) with summaries the agent reasons over before drilling in. The agent is the reranker.
  • Hybrid search — BM25 (SQLite FTS5) over messages + nodes, fused (RRF) with a recency boost and optional semantic embeddings. In-process and self-contained: multilingual stemming (morphological variants match) and relevance feedback (co-occurrence expansion) lift recall without any external model.
  • Mutable summary layernem annotate lets the agent curate how a commit is described and found, without touching the immutable content.

Team memory

A team store is just another nem store at ~/.nem/teams/<name>/ with its own git remote — a common memory base a whole team (humans and their agents) pushes curated commits and facts to, so work isn't duplicated. Your personal ~/.nem stays private: nothing reaches the team unless you commit it there.

nem team add acme git@github.com:acme/nem-memory.git   # clone a shared store
nem commit --team acme -m "decided: auth via JWT"      # curate into the team
nem fact add --team acme "we deploy on Fridays"        # a shared durable fact
nem team sync acme                                     # publish (redacts secrets)

Reads are federated by default: nem search and nem outline span your personal store plus every team, tagging each hit by origin ([team:acme]) and its author — so before starting, an agent sees "Ana already resolved this". Scope it with --team <name> or --local. Commits are content-addressed, so the same work committed by two people de-dups by hash; shared facts merge by last-writer-wins (retire them with --supersedes/fact done, which propagate).

Optional: the semantic layer

Richer LLM summaries and embeddings are opt-in and run locally (Ollama) or via an OpenAI-compatible API — nem's core stays embedding-free and pure Go.

nem config set embed.backend ollama       # turn on the semantic layer
nem doctor --fix                          # installs Ollama + pulls the models
nem index                                 # build summaries + embeddings

MCP: nem mcp exposes the same capabilities as typed tools (nem_outline, nem_search, nem_read, nem_annotate, …) for agents that speak MCP.

Security

Secret redaction runs only on nem sync — the one boundary where content leaves your machine. API keys, tokens, connection strings, Authorization headers and sensitive env vars are masked before anything is pushed, and reported:

$ nem sync
exported 12 commits
redacted 7 secrets: 5 huggingface-token, 2 env-secret
synced with the remote

Development

go test ./...
go vet ./...

-race needs cgo; on Windows run from PowerShell (Git Bash DLL-shadows mingw). CI runs race + coverage on Linux.

License

MIT

Directories

Path Synopsis
cmd
nem command
Command nem versiona el contexto de los agentes como git versiona el código.
Command nem versiona el contexto de los agentes como git versiona el código.
internal
cli
Package cli define los comandos de nem sobre cobra.
Package cli define los comandos de nem sobre cobra.
config
Package config resuelve las rutas del store local de nem (~/.nem) y la configuración persistida en config.toml.
Package config resuelve las rutas del store local de nem (~/.nem) y la configuración persistida en config.toml.
db
Package db es la capa de persistencia de nem: modelos GORM sobre SQLite (glebarez/sqlite, Go puro, sin cgo) más una capa FTS5 en SQL crudo para búsqueda full-text con ranking BM25.
Package db es la capa de persistencia de nem: modelos GORM sobre SQLite (glebarez/sqlite, Go puro, sin cgo) más una capa FTS5 en SQL crudo para búsqueda full-text con ranking BM25.
embed
Package embed es la capa OPCIONAL de embeddings de nem (apagada por default).
Package embed es la capa OPCIONAL de embeddings de nem (apagada por default).
facts
Package facts contiene la lógica pura de la capa semántica siempre-cargada: clasificación de volatilidad, peso (híbrido pin+uso), derivación de valores variables (edad desde una fecha invariante) y selección por presupuesto.
Package facts contiene la lógica pura de la capa semántica siempre-cargada: clasificación de volatilidad, peso (híbrido pin+uso), derivación de valores variables (edad desde una fecha invariante) y selección por presupuesto.
index
Package index construye el árbol de índice de nem (estilo PageIndex): una tabla de contenidos jerárquica (project → chat → commit) que el agente navega y razona, sin embeddings.
Package index construye el árbol de índice de nem (estilo PageIndex): una tabla de contenidos jerárquica (project → chat → commit) que el agente navega y razona, sin embeddings.
ingest
Package ingest parsea los archivos de sesión de los agentes (Codex, Claude Code) y los persiste en el Store de nem.
Package ingest parsea los archivos de sesión de los agentes (Codex, Claude Code) y los persiste en el Store de nem.
mcp
Package mcp expone nem como servidor MCP (stdio) para que un agente lo use como herramientas tipadas, no solo por CLI.
Package mcp expone nem como servidor MCP (stdio) para que un agente lo use como herramientas tipadas, no solo por CLI.
output
Package output serializa snapshots de commits y renderiza conversaciones en los formatos que consumen humanos y agentes (llm, json, markdown).
Package output serializa snapshots de commits y renderiza conversaciones en los formatos que consumen humanos y agentes (llm, json, markdown).
redact
Package redact detecta y enmascara secretos (API keys, tokens, claves privadas) antes de que el contenido salga de la máquina vía `nem sync`.
Package redact detecta y enmascara secretos (API keys, tokens, claves privadas) antes de que el contenido salga de la máquina vía `nem sync`.
retrieve
Package retrieve fusiona varios canales de búsqueda (BM25 sobre mensajes, BM25 sobre nodos del índice y —opcional— vectores) en un único ranking mediante Reciprocal Rank Fusion (RRF) + un boost de recencia.
Package retrieve fusiona varios canales de búsqueda (BM25 sobre mensajes, BM25 sobre nodos del índice y —opcional— vectores) en un único ranking mediante Reciprocal Rank Fusion (RRF) + un boost de recencia.
scope
Package scope resuelve el alcance de lectura activo: dado un scope con nombre (de config), calcula qué chats puede ver el agente.
Package scope resuelve el alcance de lectura activo: dado un scope con nombre (de config), calcula qué chats puede ver el agente.
session
Package session detecta la sesión de agente activa: el archivo de sesión más recientemente modificado entre Codex y Claude Code.
Package session detecta la sesión de agente activa: el archivo de sesión más recientemente modificado entre Codex y Claude Code.
skill
Package skill instala el "agent skill" de nem: un SKILL.md que le enseña al agente (Claude Code, Codex, Antigravity) cuándo y cómo usar nem, cerrando el loop de que el agente persista su propio contexto.
Package skill instala el "agent skill" de nem: un SKILL.md que le enseña al agente (Claude Code, Codex, Antigravity) cuándo y cómo usar nem, cerrando el loop de que el agente persista su propio contexto.
summarize
Package summarize genera resúmenes de nodos del índice con un backend pluggable.
Package summarize genera resúmenes de nodos del índice con un backend pluggable.
sync
Package sync exporta los commits de nem a JSONL versionable por git, los sincroniza con un remoto, y reimporta lo que llega.
Package sync exporta los commits de nem a JSONL versionable por git, los sincroniza con un remoto, y reimporta lo que llega.
timing
Package timing mide la duración REAL de una conversación: el "tiempo activo" (trabajo efectivo) frente al span de calendario.
Package timing mide la duración REAL de una conversación: el "tiempo activo" (trabajo efectivo) frente al span de calendario.
when
Package when parsea y humaniza fechas para los recordatorios de nem, en Go puro y sin dependencias.
Package when parsea y humaniza fechas para los recordatorios de nem, en Go puro y sin dependencias.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL