[GhostPaw codex: When one agent saves a wrong fact, every agent trusts it.]
@ghostpaw/codex
[npm] [CI] [site] [runtime deps] [MCP Registry] [node] [license] [@ghostpaw/codex on AI Agents Listing]
Agent memory as beliefs with a source, a certainty and a revision history.
Local, evidence-backed memory for agents. One SQLite file, zero runtime
dependencies.
Codex stores what an agent believes as claims with a source, a certainty,
evidence counts, decay and an honest revision history. Agents search before
they remember, confirm or correct instead of appending, and see which beliefs
are stale, fading or weakly evidenced. It runs as a TypeScript library, an MCP
server, a CLI and an Agent Skill, all generated from the same seven tools.
Website: codex.ghostpaw.dev
The release binary includes its runtime. npm and library use require Node.js 24+.
Install
Release binary (default)
Each line downloads the latest release asset, checks it against the release's SHA256SUMS and installs ghostpaw-codex into ~/.local/bin. On Linux and macOS the trailing export puts that folder on PATH for the current shell only: neither the line nor install.sh edits ~/.profile or any other shell startup file. The Windows script adds its folder to the user PATH (open a new terminal afterwards).
linux-x64:
linux-arm64:
darwin-arm64:
darwin-x64:
windows-x64 (PowerShell):
To keep ~/.local/bin on PATH in new shells, append it to ~/.profile once (this is the only step that edits a startup file):
To pin a release instead of taking the latest, pass --version:
variant is binary, npm or library; target is null outside the release binary.
A session with the 0.5.2 linux-x64 binary against a small database of five beliefs:
[ghostpaw-codex 0.5.2: version --json, belief add, a common-word search with its low-signal warning, a distinctive-word search, alias add and the aliased search]
The same session as an animated GIF.
Other release installers:
For aqua, define a
github_release package in aqua.yaml:
codex-registry.yaml:
Install scripts verify SHA256SUMS. To verify a downloaded archive's
build attestation:
Set GHOSTPAW_VERIFY=attestation for attestation verification in install.sh.
Binaries are unsigned; macOS binaries carry an ad-hoc signature. For a browser
download on macOS, remove quarantine with
xattr -d com.apple.quarantine /path/to/ghostpaw-codex.
Linux binaries require glibc 2.28+; use npx on Alpine.
See the binary build workflow.
Approximate sizes for 0.5.2 (Node 26.12.1 inside each binary):
The npm package is about 920 KB unpacked and needs Node 24+. Every release is
installed and run on ubuntu-24.04, macos-15 and windows-2025 by the
install check.
npx / npm (for npm-based environments)
The npm package requires Node 24+:
Library (for harnesses embedding it in code)
Requires Node 24+:
See Library usage.
30-second quickstart
MCP server
Every client below starts the same stdio server: ghostpaw-codex mcp.
Use the full executable path if its folder is not on PATH.
For npm-based environments, use npx -y @ghostpaw/codex mcp.
Beliefs live in ~/.ghostpaw/codex.db unless the GHOSTPAW_CODEX_DB
environment variable (absolute path) or --db <path> says otherwise.
Claude Code
or as a plugin, which also installs the skill:
Codex CLI (~/.codex/config.toml)
Cursor (.cursor/mcp.json), Claude Desktop (claude_desktop_config.json)
or a project .mcp.json:
Cline (MCP Servers → Configure MCP Servers, cline_mcp_settings.json).
VS Code often starts without ~/.local/bin on PATH, so use the absolute path
that echo "$HOME/.local/bin/ghostpaw-codex" prints (PowerShell:
"$env:LOCALAPPDATA\Programs\ghostpaw\bin\ghostpaw-codex.exe"). Merge the
entry into the existing mcpServers. Settings file locations, the
cline mcp add form and checks: llms-install.md.
For Cline CLI 3.x, cline config mcp lists the configured servers.
Claude Desktop users can also install server.mcpb from the
latest GitHub release.
A Dockerfile is included for container hosts:
docker build -t ghostpaw-codex . && docker run -i --rm -v codex:/data ghostpaw-codex.
The server speaks MCP 2026-07-28 (stateless, server/discover) and the
initialize-based revisions 2025-11-25, 2025-06-18, 2025-03-26 and 2024-11-05.
CLI
Belief additions include a nearest-belief hint when an active belief has similarity of at least 0.7; use it to confirm or merge related claims.
WARNING: belief retire hard-deletes the whole lineage (the belief and all its predecessors/successors) and cannot be undone. Use belief forget for soft removal that keeps lineage. Every retire invocation warns on stderr.
--json is accepted on every read command, including all review views, belief show, alias list, tools, describe, version, help and skill guides. Set GHOSTPAW_OUTPUT=json to opt all commands into JSON output as if --json were passed. Other values or an unset variable preserve default output, including when stdout is piped or a TTY.
Global flags can appear anywhere: --db <path>, --json, --quiet,
--compact, --help/-h, --version/-V/-v, --no-color.
NO_COLOR is accepted; output uses no terminal colors.
Noun-verb commands print short text by default, including when stdout is piped.
Search and review lists show one belief per line: id claim [certainty source strength].
Flags append reason codes; the log shows id type claim. Add, show, correct and
merge show aligned detail fields and nearby beliefs. Status and trends show
aligned key: value lines. --json prints the full tool result and --compact
removes JSON indentation. Legacy tool invocation keeps its JSON output.
--quiet prints only result ids for search, review flags and log, and the affected
belief id for writes; status, trends and version print nothing.
Use help belief, belief --help or belief correct --help for schema-derived
help. Each revision verb accepts only the flags it uses. Correction takes
--claim; forgetting also accepts --successor-id. Deferral accepts
--deferred-until as YYYY-MM-DD, DD.MM.YYYY, today, tomorrow, +3d, an ISO
date-time with timezone, or epoch milliseconds. Calendar dates resolve to local
end of day and must be in the future.
Array flags repeat, kebab-case flags map to schema properties, and values are literal, including leading @. Use JSON stdin (-) for long input. -- ends flags. A positional -, or piped stdin
with no arguments, reads a JSON object; explicit flags override its fields.
Database selection uses --db, GHOSTPAW_CODEX_DB, then ~/.ghostpaw/codex.db.
Opening the default database prints using default db <path> once on stderr.
Suppress the notice with --quiet or GHOSTPAW_QUIET=1. Commands that do not open a database print no notice.
Top-level help shows the resolved path. Version output starts with
ghostpaw-codex and identifies binary target, npm or library execution.
ghostpaw-codex skill prints the full skill reference. Use
ghostpaw-codex skill --list to list workflow guides and
ghostpaw-codex skill capture-beliefs-well to read a guide. skill --help
shows these forms; unknown guide names include a suggestion.
Errors and recovery hints go to stderr. Clarification prints the question and missing flags to stderr. With --json, usage and internal errors also print
{ok:false,error:{code,message}} to stdout. Tool results retain their full
shape. Legacy tools [--json], describe <tool>, call <tool> [JSON|-]
and <tool_name> --parameter value keep their existing exit codes.
completions bash, completions zsh and completions fish print shell scripts.
File values and leading @
File input is opt-in for each CLI argument. When an argument's help lists
(@file, @- stdin, @@ literal @), @path reads a UTF-8 file, @- reads
stdin, and @@text passes the literal value @text.
No current Codex argument enables this option: flags and positional values
keep leading @ and @@ as written. For long claims, pass a JSON object
through stdin with - (see the example above).
Agent Skill
SKILL.md (repo root) and skills/codex/SKILL.md follow the
Agent Skills format and ship in the npm package.
Copy skills/codex/ into your agent's skills folder, or print it:
Library
Wire the same tools into any LLM SDK. Each tool carries a JSON Schema:
Or embed the MCP server in your own process:
Docs
The live demo runs the library in your browser against an in-memory SQLite database. Each view below opens a different part of it:
- Dashboard: integrity score and recent beliefs
- Capture: record a belief and see close matches you already hold
- Flags: beliefs flagged for review: confirm, correct or forget
- Activity Log: activity log of every write
Why not MEMORY.md?
A markdown memory file works until it doesn't:
- It only grows. Agents append, rarely delete, and the file ends up in
every prompt. Codex returns the few beliefs that match a query
(FTS5 bm25 plus hashed character-trigram similarity, IDF-weighted with a 55% relative cutoff).
- Contradictions pile up. "We use REST" and "REST was retired" sit side by
side. Codex detects near-duplicates on every write, and corrections
supersede the old belief while keeping the lineage.
- Everything looks equally true. A guess and a confirmed fact read the
same in prose. Codex tracks source (explicit, observed, distilled,
inferred), certainty and evidence count, and flags what is stale or weakly
supported.
- No time. Codex decays freshness, so old beliefs surface for review
instead of quietly steering behaviour.
- Concurrent edits. Two agents writing one file clobber each other. Codex
is a SQLite database in WAL mode.
It stays local: one file you can copy, back up or inspect with any SQLite tool.
No server, no API key, no network.
Tools
Results are structured (outcome: success | no_op | needs_clarification | error) with entities, next-step hints and recovery advice. The MCP server,
CLI, SKILL.md and plugin manifests are generated from this registry
(npm run surfaces) and drift-checked in CI.
Performance
Measured with npm run bench on Node 24.14.0, Linux, Intel Xeon (shared
cloud vCPU), 10,000 beliefs in a file-backed database:
Cold start (process spawn to first response, median): --version 26 ms,
MCP server/discover 24 ms, first search against the 10,000-belief file
53 ms. Seeding 10,000 beliefs takes 2.2 s on disk.
Gzip sizes and cold-start medians are budgeted in budgets.json and enforced
by npm run check.
The model
State is derived, never toggled: freshness, strength, review priority and flags
are computed at read time.
Package surface
ESM and CommonJS, with type declarations for both.
Documentation
Development
npm run check is the single gate, locally and in CI. Size budgets
(budgets.json) and the public API snapshot (api-surface.json) can only
grow with an explicit approval tag in the commit message. The repo is pinned
to Node 24.14.0 via .nvmrc.
Support
If this package helps your project, consider sponsoring its maintenance:
[GitHub Sponsors]
Anonyfox • MIT License
Query aliases
Search is lexical: FTS5 bm25 plus hashed character-trigram similarity, with
IDF-like token weighting and a 55% relative cutoff. It does not provide semantic
understanding. In corpora of at least 20 active beliefs, queries matching only common terms return at most three results
with a partial_match warning.
Aliases are off by default (the table starts empty). Add directed, one-hop aliases
when query vocabulary differs from stored claims:
The library equivalents are write.addQueryAlias(db, term, alias, options?),
write.removeQueryAlias(db, term, alias) (returns whether removed), and
read.listQueryAliases(db) (sorted { term, alias, createdAt } records).
Both words are normalized with normalizeClaim and must be distinct single words.
Adding an existing pair preserves its creation time; options.now sets the time
on first insertion. Expansion is deduplicated and never follows alias chains;
the query vector uses the original query.
Provenance and revision compatibility
Belief records include provenanceSources, an append-only list of distinct origin
references. Every write with --provenance adds a reference, including duplicate
adds and unchanged corrections. Corrections and merges carry all sources forward.
The legacy provenance field remains readable with its existing single-value
behavior; use provenanceSources for the complete history.
Superseded-belief errors and belief show identify the current active successor.
Library details also expose activeSuccessorId, while supersededBy retains the
immediate lineage link. Correcting to the same normalized claim and metadata
returns no_op. A merge into --successor-id can omit --claim.
belief --help lists belief verbs. review flags --now +8d and
review flags --now 2026-11-10 accept the same date formats as deferral, including
historical dates and epoch milliseconds. Relative day offsets also accept -3d
and 30d. Calendar dates and relative days use local end of day.
New CLI and MCP database files use mode 0600; newly created parent directories
use 0700. Existing permissions are preserved. On first upgrade, legacy active
normalized duplicates consolidate into the oldest id, preserving summed evidence,
source references and lineage. Later --allow-duplicate additions remain separate.
Merge fan-in alone does not trigger unstable; repeated corrections still do.
Search treats punctuation literally; wrap the whole query in double quotes for a phrase.
Use search --fts 'alpha OR beta' for raw FTS5 syntax, or
search note --prefix "project:" to filter claims by a case-insensitive prefix
after leading whitespace. A query is required with --prefix. Library recall
options and search tool inputs also accept fts and prefix.
Default search ranks claims whose entity before the first colon matches the leading
query tokens first, ignoring case and treating spaces and hyphens alike (for example,
Agentpreneur: ... for Agentpreneur state files routine memory db). This also
applies with --prefix; --fts and quoted phrase ranking remain unchanged.
Review status integrity remains the percentage of active beliefs with certainty
at least 0.7. The new, unconfirmed count covers beliefs with one evidence item
younger than seven days; it overlaps the existing strength counts.
Review: review status --by-prefix counts active claim prefixes; review duplicates --limit 20 lists nearby active pairs immediately, honoring dismissals.