nem

module
v0.2.1 Latest Latest
Warning

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

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

README

nem

Your agent forgets. nem doesn't.

nem versions agent context the way git versions code. When an LLM compacts its context window, it discards reasoning, resolved edge-cases, and prior decisions. nem persists that context explicitly, makes it searchable and portable across agents and machines — and the agent uses it with the same commands a human would.

Features

  • Ingests Codex and Claude Code sessions (conversation + reasoning + tool calls, with tool outputs truncated so they don't burn tokens).
  • Immutable commits: each commit copies the text of the range (a snapshot), not a pointer — what you saved never changes.
  • Full-text search with BM25 ranking (SQLite FTS5), prioritizing conversation over tool noise.
  • Git-based sync with automatic secret redaction: API keys and tokens (OpenAI, Anthropic, HuggingFace, AWS, GitHub, GitLab, Stripe, wandb, …), connection strings, Authorization headers, and sensitive env vars are masked before anything leaves your machine.
  • Agent skill: nem init installs a SKILL.md into Claude Code and Codex so the agent knows when and how to use nem on its own.
  • Single binary, SQLite embedded in pure Go (no cgo) → a static executable. Works offline.

Stack

Go · GORM over glebarez/sqlite (modernc, no cgo) · SQLite FTS5/BM25 · cobra · git (via os/exec).

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

With Go:

go install github.com/Dieg0Code/nem/cmd/nem@latest

Prebuilt binaries: download the archive for your OS/arch from the Releases page and put nem on your PATH.

From source:

go build -o nem ./cmd/nem

Usage (MVP)

nem init                          # creates ~/.nem + git, installs the agent skill
nem ingest                        # ingest Codex and Claude (or: nem ingest codex)
nem status                        # active session + uncommitted messages

nem add -L 20                     # stage the last 20 messages
nem add --from <msgID> --to <id>  # ...or an exact range
nem commit -m "decision about X"  # immutable snapshot

nem log                           # commit history
nem read HEAD --format llm        # the commit, clean for an agent
nem search "decay" --format llm   # BM25 search (--role all includes tools)

nem remote add origin <url>       # configure the remote
nem sync                          # export (redacting) → git push → import
nem clone <url>                   # clone the store on another machine
Output formats

read and search accept --format:

  • llm — clean, no metadata, for agent ingestion
  • json — structured
  • markdown — human-readable (default)

The agent skill

nem init installs a SKILL.md into the agents present on your machine (~/.claude/skills/nem/ and ~/.codex/skills/nem/). It teaches the agent to recall prior context at the start of a session (nem status / nem search / nem read HEAD) and to persist resolved decisions (nem add + nem commit, writing its own commit message). nem sync stays in your hands.

nem init --no-skill    # skip skill installation
nem skill install      # (re)install the skill later, e.g. after upgrading nem

nem only ever owns the nem skill directory — it never touches your other skills.

Security: secret redaction

Scrubbing runs only on nem sync (the one boundary where content leaves your machine). The local DB keeps the raw text — just like ~/.codex and ~/.claude already do — so ingesting adds no new exposure. nem sync redacts and reports:

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

Architecture

cmd/nem/            entrypoint
internal/
  cli/              cobra commands
  config/           paths (~/.nem, nem.db, store/)
  db/               GORM models + Store (interface) + FTS5
  ingest/           codex/claude parsers (Parser interface)
  session/          active-session detection
  output/           snapshots + llm/json/markdown formats
  redact/           secret detection and masking
  skill/            embedded SKILL.md + installer
  sync/             JSONL export/import + git

Every component follows the interface + functional options pattern: New*(...) (Interface, error) returns the interface, which makes testing with mocks trivial.

Development

go test ./...        # full suite
go vet ./...

The race detector (go test -race) requires cgo. On Windows run the tests from PowerShell (not Git Bash, which DLL-shadows the mingw toolchain). In CI it runs on Linux (.github/workflows/ci.yml).

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).
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) 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) 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.

Jump to

Keyboard shortcuts

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