memory-runtime gives Codex, Claude, and Gemini a compact hot/cold memory layer
for project context.
It saves tokens without rewriting the user request, stays fail-open when memory providers are unavailable, and keeps host integrations replaceable.
Use it when you want:
- automatic project bootstrap for CLI agents
- local hot memory with optional Memory Palace cold memory
- safer recall for short references like
route A,this, orthat - explicit local skill governance without silent edits
- public-repo-friendly export tooling for sanitized memory assets
Quick links:
- Chinese quick start:
README_CN.md - Docker cold memory:
docs/COLD_MEMORY_DOCKER.md - Codex app integration:
docs/CODEX_APP.md - Configuration:
docs/CONFIGURATION.md - Setup guide:
docs/SETUP.md - Privacy and safe publishing:
docs/PRIVACY.md - Memory Palace project tools:
docs/MEMORY_PALACE_PROJECT_TOOLS.md - Public export workflow:
docs/PUBLIC_EXPORT.md - Troubleshooting:
docs/TROUBLESHOOTING.md - Changelog:
CHANGELOG.md
This repo is ready for public GitHub use as an 0.x GitHub-first runtime:
- hot memory is backed by local SQLite via
node:sqlite - cold memory can use a real Memory Palace backend
- Codex, Claude, and Gemini wrappers are implemented
- shell integration can be installed with one command
- cold-memory autostart is optional and fail-open
- ambiguous short references are anchor-expanded or cold-recall-suppressed
- local skill governance supports audit, explicit apply, rollback, and benchmark flows
The current distribution model is:
- clone from GitHub
- run locally
- install shell integration into
zshorbash - optionally audit, apply, rollback, and benchmark local skill governance
It is not an npm-published product yet.
The runtime is split into replaceable layers:
memory-core: contracts, token budget policy, routing ruleshot-memory-sqlite: fast local hot-state providercold-memory-memory-palace: cold-memory adapter for Memory Palacecold-memory-fixture: deterministic fixture adapter for tests and benchmarkshost-codex: Codex bootstrap and checkpoint integration surfacehost-claude: Claude-oriented bootstrap rendering surfacemcp-bridge: optional stdio bridge for inspection and promotion flows
CLI host
-> host adapter
-> memory-core
-> hot provider
-> cold provider
- high cohesion, low coupling
- fail-open behavior that never blocks normal development
- fast local bootstrap with strict latency and token budgets
- replaceable hot and cold memory providers
- ambiguous short references should recall less rather than recall wrong
- public-repo-friendly code with no bundled personal memory data
- Node.js
22+withnode:sqlitesupport - npm
10+ - at least one supported host CLI already installed: Codex, Claude, or Gemini
zshorbashif you want automatic wrapper loading- optional: a running Memory Palace backend for cold recall
- optional for Docker cold memory: Docker with
docker compose
- Clone the repo and install dependencies:
git clone https://github.com/Tom-Wang898/memory-runtime.git
cd memory-runtime
npm install- Install shell integration:
./scripts/install-shell-integration.sh --shell zshUse --shell bash if you want ~/.bashrc instead.
- Reload the shell:
source ~/.zshrc- Verify the wrappers and hot-memory runtime:
codex --help
claude --help
gemini --help
hmctl bootstrap --cwd "$(pwd)" --mode warm --query "runtime smoke test" --jsonIf you stop here, the runtime already works in hot-memory mode and will fail open if cold memory is unavailable.
- Optional: audit local skills without editing them:
hmctl skills-auditYou can also point it at one explicit tree:
hmctl skills-audit --root "$HOME/.codex/skills" --json- Optional: generate a safe mutation plan first:
hmctl skills-plan --root "$HOME/.codex/skills" --host codex- Optional: apply managed changes with an automatic snapshot:
hmctl skills-apply --root "$HOME/.codex/skills" --host codex- Optional: rollback from a snapshot:
hmctl skills-rollback --snapshot "$HOME/.memory-runtime/skill-governance/snapshots/<snapshot>.json"- Optional: export duplicate-skill decisions:
hmctl skills-duplicates --root "$HOME/.codex/skills" --decision-out /tmp/duplicate-decisions.json- Optional: apply duplicate decisions without deleting files:
hmctl skills-duplicates-apply --decision-file /tmp/duplicate-decisions.jsonYou can edit the exported decision file first.
Set action to skip if a duplicate group should remain untouched.
The duplicate report now includes per-path status and token metadata, and apply results include before/after deltas.
Duplicate groups are now ordered by review risk so the ugliest sets float to the top first.
- Optional: stage a sanitized public export from a private Codex or Memory Palace checkout:
hmctl public-export --list-profiles
hmctl public-export --profile codex-project-memory --source /path/to/codex --output /tmp/codex-public-export
hmctl public-export --profile memory-palace-project-tools --source /path/to/Memory-Palace --output /tmp/memory-palace-public-exportThat command only copies allowlisted files, replaces machine-specific paths with placeholders such as ${HOME} and ${CODEX_REPO_ROOT}, and fails if a private absolute path marker survives redaction.
See docs/PUBLIC_EXPORT.md for the full staging and mirror workflow.
Cold memory uses Memory Palace.
If you already run Memory Palace somewhere, set its base URL:
export MEMORY_RUNTIME_MP_BASE_URL="http://127.0.0.1:18000"If you want a stable cold-memory setup without cloning the full Memory Palace repo, use the backend-only installer:
./scripts/install-memory-palace-docker.sh
source ~/.memory-runtime/env.shThat path:
- deploys the official GHCR backend image only
- generates a local API key by default
- enables the
projectsdomain needed bymemory-runtime - writes shell exports to
~/.memory-runtime/env.sh
If you want memory-runtime to auto-start a local Memory Palace backend, also set:
export MEMORY_RUNTIME_MP_AUTOSTART=1
export MEMORY_RUNTIME_MP_BACKEND_ROOT=/absolute/path/to/Memory-Palace/backendAutostart only attempts to run when:
MEMORY_RUNTIME_MP_AUTOSTART=1- the base URL is a loopback address
- the backend root contains both
main.pyand.venv/bin/python
If any of those checks fail, the runtime degrades gracefully and continues.
Docker deployments are treated differently:
- the wrapper does not try to start or stop Docker for you
- use
install-memory-palace-docker.shonce, then keepMEMORY_RUNTIME_MP_AUTOSTART=0 - if you want the full Dashboard and SSE stack, use the official Memory Palace repo
See:
docs/COLD_MEMORY_DOCKER.mddocs/CONFIGURATION.mddocs/SETUP.mddocs/PRIVACY.md
The shell installer injects a managed block into your shell rc file and wires:
hmctlmemory_runtime_bridgecodexclaudegemini
The wrappers:
- inject compact bootstrap context before a session starts
- prefer project hot-layer memory from
projects://<slug>/digest/currentandprojects://<slug>/anchors/currentwhen the cold backend provides them - keep the raw user prompt intact
- write a lightweight checkpoint after the wrapped command exits
- avoid polluting hot memory with synthetic wrapper summaries
The skill audit companion:
- scans local skill trees only when you call it
- reports token-heavy and host-coupled skills
- supports explicit apply and rollback with snapshots
- supports explicit duplicate review and quarantine decisions
- does not auto-edit private skill directories unless you run
skills-apply
Run the full verification suite:
npm run check:allOptional benchmarks:
npm run bench:bootstrap
npm run bench:tokens
npm run bench:skills-governancedocs/ARCHITECTURE.mddocs/COLD_MEMORY_DOCKER.mddocs/CODEX_APP.mddocs/DATA_CONTRACTS.mddocs/CONFIGURATION.mddocs/SETUP.mddocs/PRIVACY.mddocs/MEMORY_PALACE_PROJECT_TOOLS.mddocs/PUBLIC_EXPORT.mddocs/SAFETY.mddocs/SOCIAL_PREVIEW.mddocs/TROUBLESHOOTING.mddocs/OPEN_SOURCE.mddocs/RELEASE.mddocs/SKILL_GOVERNANCE.md
