rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:ys118/harnmem
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README

Cross-harness agent memory that lives in plain files.
HarnMem = harness + memory (
harnis also a Scots word for "brains"). One user, one machine, one memory store — shared by every coding agent you use.
HarnMem is a portable memory system for coding agents. It stores memories as
plain Markdown files under ~/.harnmem/, retrieves them with a local
deterministic engine, and injects a small, byte-stable hot index into each
harness session. The same store is readable by every adapter and by the CLI, so
a memory written in one harness is available in another — no server, no vector
database, no embedding model, and no runtime dependencies in the engine.
@harnmem/core (engine), @harnmem/cli (harnmem command),
pi-harnmem (pi extension, listed in the
pi.dev package gallery), dsh-harnmem
(DSH plugin), claude-harnmem
(Claude Code plugin), codex-harnmem (Codex CLI plugin),
opencode-harnmem (opencode v2 plugin), grok-harnmem (Grok CLI plugin),
cursor-harnmem (Cursor desktop plugin), hermes-harnmem (Hermes Agent
memory provider, installed through Hermes' own plugin manager) and
omp-harnmem (oh-my-pi extension plugin) — all published
on npm except hermes-harnmem, which installs through Hermes' own plugin
manager (above). Install the CLI with
npm install -g @harnmem/cli; the opencode adapter needs
opencode 2.x and is verified end to end on the 2.1.4 binary (injection, native
tools, per-turn journaling); the Grok adapter is verified on the 1.0.70 binary
(MCP initialize.instructions injection, six tools, session-end extraction);
the Cursor adapter is verified on Cursor 3.27.22 (first-prompt injection,
plugin MCP tools, session-end journaling); the Hermes adapter is verified on
Hermes Agent 0.22.5 (prefetch injection, five native tools, detached
session-end extraction); the omp adapter is verified on oh-my-pi 18.14.1
(byte-stable system-prompt injection, five tools, /memory, session-end
journaling).hermes-harnmem) is likewise implemented and verified end to end and
installs through the Hermes plugin manager. The 0.7.3 release fixes a
silent-data-loss core bug (writes with an unknown project id used to create
shards no later session could resolve, #42) and re-bumps the
engine-embedding adapters; it also publishes pi-harnmem 0.4.6 with a
preview image in the pi.dev package gallery
and the docs-recommended "*" peer ranges for host packages; 0.7.2 shipped
the omp and Hermes adapters and the UTF-8 BOM config fix, on top of
the 0.7.0 Grok and Cursor adapters and the 0.6.2 seven-package
audit wave (17 of 21 confirmed issues fixed, the structural remainder tracked
as N18-N20 in the roadmap). The Codex adapter also covers the CLI TUI trust
flow and Codex Desktop, and backfills sessions from ~/.codex/sessions until
Codex ships SessionEnd hooks.| Approach | Limitation for this use case |
|---|---|
| mem0 / Zep / Letta / OpenViking | Requires a service, vector database or Docker; heavy to install and operate |
| pi-memory | Effective inside pi, but not shared with other harnesses and no lifecycle governance |
| dsh-auto-memory | DSH-only; cross-session but not cross-harness |
| Built-in harness memory (e.g. ZCode) | Tied to one harness; store layout not reusable |
Just put everything in AGENTS.md |
No retrieval, no governance; grows noisy until models ignore it |
HarnMem's bet: the source of truth is the file system, retrieval happens in the local process, and lifecycle decisions are explainable and reversible.
@harnmem/core and @harnmem/cli use only
Node.js built-ins. No native modules, no downloads, no background daemon.trash/ + restore and an
append-only state/audit.jsonl keep it auditable.harnmem synonyms suggest reads your own memories, asks a
model for interchangeable terms a co-occurrence pass could never find (Chinese
jargon usually shares no characters), validates every group against the corpus,
and writes reviewed proposals to a local -suggested table. synonyms check
reports the rank gain before you keep it.harnmem import auto probes the known stores and prints a plan.Requirements: Node.js 22.15+ and pnpm 10 (corepack enable).
# CLI (works with every harness, no adapter needed)
npm install -g @harnmem/cli
# pi extension
pi install npm:pi-harnmem
# DSH plugin
dsh plugin --profile desktop add dsh-harnmem
# Claude Code plugin (the repo root is a Claude Code marketplace)
claude plugin marketplace add ys118/harnmem
claude plugin install harnmem@harnmem-marketplace
# Codex CLI plugin (the repo root is also a Codex marketplace)
codex plugin marketplace add ys118/harnmem
codex plugin add harnmem@harnmem-marketplace
# opencode v2 plugin (requires opencode 2.x)
opencode plugin add opencode-harnmem
# Grok CLI plugin (the repo root is also a Grok marketplace)
grok plugin marketplace add ys118/harnmem
grok plugin install grok-harnmem --trust
# Cursor desktop: copy the plugin into ~/.cursor/plugins/local, merge the
# user-level hooks, then run Developer: Reload Window
npx cursor-harnmem
# Hermes Agent memory provider (requires Hermes v0.22.5+ and Node 22.15+ on PATH)
hermes plugins install ys118/harnmem/packages/hermes-harnmem --enable
hermes memory setup
# oh-my-pi plugin (requires omp 18.14.1+)
omp plugin install omp-harnmem
All adapters read and write the same ~/.harnmem/ store, so installing more
than one shares a single memory. Every install runs fully local; nothing phones
home.
Grok CLI also auto-discovers plugins installed for Claude Code. If
claude-harnmem is installed, Grok therefore sees two plugins that declare the
same harnmem MCP server; it keeps one, and the explicitly enabled
grok-harnmem (its [plugins] enabled entry is written by
grok plugin install) wins, so sessions get the six Grok tools and the
injected index. To unload the auto-loaded Claude copy entirely (one
SessionEnd hook instead of two), add disabled = ["harnmem"] under
[plugins] in ~/.grok/config.toml; the entry is harmless when no Claude
plugin is installed. Details:
docs/design/11-grok-adapter.md.
corepack enable
pnpm install
pnpm -r build
pnpm test # every package's test suite (node --test)
# Try it without installing: load the built extension in a one-shot pi session.
pi -e ./packages/pi-harnmem/dist/index.js -p "Remember: I prefer pnpm over npm."
# From a checkout: install the local path instead of npm:pi-harnmem.
pi install ./packages/pi-harnmem
The extension injects the hot index before each turn, registers the memory
tools (harnmem_write, harnmem_search, harnmem_read, harnmem_forget,
harnmem_status — names follow the toolPrefix setting, and the harnmem_
default lets pi-memory, which owns the bare memory_* names, load alongside),
adds /memory, and runs a bounded extraction at session end.
Configuration lives in ~/.harnmem/config.json (or $HARNMEM_HOME/config.json).
# From a checkout (instead of the published package in Install above):
pnpm --filter dsh-harnmem build
dsh plugin --profile desktop add ./packages/dsh-harnmem
The plugin mounts as a cordis plugin: it injects the same hot index through
systemPrompt.section (byte-stable, with a synchronous cold-start fallback),
registers five tools prefixed harnmem_ (harnmem_write, harnmem_search,
harnmem_read, harnmem_forget, harnmem_status; the bare memory_* names
belong to dsh-auto-memory, which DSH keeps when both plugins are installed),
keeps subagent sessions read-only, and runs a bounded session-end extraction
through the host LLM service. Lifecycle and extraction decisions are written to
~/.harnmem/logs/dsh.jsonl (log: "on" is the trial default), and every
extraction outcome is emitted as a kind:"extract" event in
~/.harnmem/state/audit.jsonl. It requires DSH 0.2.x and never opens a network
connection of its own. On the DSH web GUI the plugin also registers a read-only
Memory panel (overview, memory list, detail, index and injection preview).
Installed via the marketplace commands above (requires Claude Code 2.1.x, verified against 2.1.310). The plugin:
SessionStart hook — byte-stable between
turns, an empty store injects zero bytes, and output is deterministically
truncated under Claude's 10,000-character additionalContext cap;harnmem_search, harnmem_read, harnmem_write, harnmem_forget,
harnmem_status; tool outputs are clipped well under the client's 25k-token
cap);/harnmem:memory slash command for manual search/read/write/forget/
status;@harnmem/core is vendored into the plugin package, so the installed plugin
directory is self-contained. For development against a checkout,
claude plugin marketplace add D:\projects\harnmem (or the equivalent POSIX
path) reads the repo live — code changes apply on the next session.
Installed via the marketplace commands above (requires the codex 0.164/0.165 alpha engines; verified on Windows). The plugin:
SessionStart mcp_tool hook — the tool
output lands as a developer message, is byte-stable between turns, and an
empty store injects nothing;~/.codex/sessions newer
than a durable cursor are journaled exactly once, so a session that closed
without extraction is still captured. Codex does not support SessionEnd
hooks yet — the hook is declared and skipped by current engines;config.toml.See the package README for configuration and the probe record for the full verification trail.
Installed through Hermes' own plugin manager (requires Hermes Agent v0.22.5+;
Node.js 22.15+ must be on PATH because the plugin drives the engine through a
small Node bridge). The adapter is a Python MemoryProvider plugin:
prefetch() before each model call — cached in
Python and rebuilt only on session switch, day rollover, a memory write or a
compaction, so consecutive turns inject identical bytes;harnmem_write/search/read/forget/status as native Hermes tools;read_only is set;hermes memory setup (10 fields), and reports through
hermes harnmem status.See the package README for installation, configuration and troubleshooting, and the design doc for the seam mapping.
node packages/cli/dist/main.js --help
node packages/cli/dist/main.js stats
node packages/cli/dist/main.js search "deployment rule" --limit 5
node packages/cli/dist/main.js write --type feedback \
--title "Never force-push main" \
--content "Why: shared repo. How to apply: open a PR." --importance 7
# Migrate legacy memories: dry-run by default, then --apply
node packages/cli/dist/main.js import auto # probe known stores (DSH/pi/ZCode/Claude Code)
node packages/cli/dist/main.js import dsh
node packages/cli/dist/main.js import md --path ./notes --apply # any Markdown tree
node packages/cli/dist/main.js import json --path export.json # any JSON/JSONL export
# Grow the local synonym table from your own memories (nothing is auto-applied)
node packages/cli/dist/main.js synonyms list
node packages/cli/dist/main.js synonyms suggest --llm-url http://127.0.0.1:11434/v1 --llm-model qwen3:8b
node packages/cli/dist/main.js synonyms check
node evals/gen/generate.mjs # generate deterministic corpora
node evals/gen/generate.mjs --check # prove a second generation is byte-identical
pnpm eval # all suites
pnpm eval:gate # hard gates (perf gates are advisory)
flowchart LR
subgraph Harnesses
PI[pi extension]
DSH[DSH plugin]
CC[Claude Code plugin]
CX[Codex plugin]
OP[opencode plugin]
GK[Grok plugin]
HE[Hermes plugin]
end
CLI[harnmem CLI + migration]
CORE["@harnmem/core<br/>store · retrieval · writing · lifecycle · extraction"]
PI --> CORE
DSH --> CORE
CC --> CORE
CX --> CORE
OP --> CORE
GK --> CORE
HE --> CORE
CLI --> CORE
CORE --> STD[(~/.harnmem plain files)]
CORE --> IDX[(rebuildable BM25F index)]
A session looks like this:
ensureContext(); core returns
a hot index (pinned entries, high-value entries, recent entries, digest
lines) within a token budget. The adapter injects it into the system prompt
once and keeps it byte-stable until it is invalidated.---
schema: 1
id: mem_01J8Z6Q0K4T9B2M7R5X3C8V1ND
type: feedback
category: workflow
scope: project
project: my-app-4f2a91c3d0
title: Never force-push main
description: Shared repository requires PRs; force-push rewrites others' history.
importance: 7
confidence: 0.9
pinned: false
status: active
created: 1760918400000
updated: 1760918400000
tags: [git, workflow]
links: []
supersedes: []
---
**Why:** `main` is shared; rewriting history disrupts other contributors.
**How to apply:** push feature branches and open a pull request.
Types are user, feedback, project and reference. Records are
append-only: a corrected fact creates a new record and marks the old one
status: superseded with valid_to set, so "what did I believe last month?"
is still answerable.
Default ~/.harnmem/ (Windows: C:\Users\<you>\.harnmem\):
~/.harnmem/
├── config.json # optional user config (budgets, weights, governance)
├── VERSION # store layout version
├── memories/ # SSOT: one .md file per memory
│ ├── user/ # global, cross-project scope
│ └── projects/<projectId>/
├── digests/ # optional topic digests produced by consolidation
├── prompts/ # prompt assets deployed on first run (editable)
├── data/ # synonym tables, one file per language, deployed on first run (editable)
├── projects.json # project identity registry (git remote/path -> id)
├── index/ # derived indexes; safe to delete, rebuilt on demand
├── sessions/ # raw session journals used as extraction input
├── state/ # sequence numbers, audit log, cursors, usage overlay
├── trash/ # soft-deleted entries (30-day grace, restorable)
└── logs/ # adapter logs, e.g. logs/pi.jsonl
The schema and migration mapping are specified in
docs/design/02-data-model.md.
Retrieval is deliberately local and explainable:
0.995^hours), usage, pin, two-hop link diffusion, and a staleness penalty;The formula and its calibration are documented in
docs/design/03-retrieval.md.
The harness is deterministic (no LLM, no network) and runs in about a minute; the numbers below come from the tracked eval-report.md:
| Metric | Result |
|---|---|
| Suites / queries / documents | 12 (S1-S12) / 565 / 27,510 |
| Macro Recall@10 | 1.000 |
| MRR | 0.891 |
| nDCG@10 | 0.911 |
| Cross-language (zh <-> en) recall gap | 0.000 |
| Functional gates | all passing |
| Advisory performance items | 10k import ~12 s; warm search p95 ~16 ms; index ~2.9x canonical store |
The advisory items are recorded rather than hidden: import is a one-time
migration cost, and the index-size/latency targets for very large stores are on
the roadmap. Details, per-suite numbers, ablations and gate definitions are in
docs/design/05-evaluation.md and
evals/README.md.
| Harness | Status | Notes |
|---|---|---|
| pi 1.3.0+ | Supported | Extension with injection, tools, /memory, session-end extraction; verified end to end on 1.3.0, and the peer range accepts 1.4.x |
| DeepSeek Harness 0.2.1 | Supported (0.2.x) | Cordis plugin (dsh-harnmem); verified against the desktop runtime with a disposable profile and a local mock endpoint |
| CLI (any harness) | Supported | harnmem commands read/write the same store |
| Claude Code 2.1.x | Supported | claude-harnmem plugin (SessionStart hook + stdio MCP + /harnmem:memory); verified end to end against 2.1.310; harnmem import claude migrates existing stores |
| Codex CLI 0.164/0.165 alpha | Supported (Windows) | codex-harnmem plugin (SessionStart mcp_tool hook → developer-message injection + stdio MCP + skill + rollout backfill); verified end to end on the CLI, the TUI trust flow and Codex Desktop; extraction is backfilled until Codex ships SessionEnd hooks |
| opencode 2.1.4 | Supported (2.x) | opencode-harnmem plugin (byte-stable session.hook("context") snapshot + five native tools + per-turn journaling; child sessions run read-only); verified end to end on the 2.1.4 binary |
| Grok CLI 1.0.70 | Supported (1.0.x) | grok-harnmem plugin (memory index via MCP initialize.instructions — Grok's SessionStart is observe-only; six tools + /grok-harnmem:memory + SessionEnd extraction from chat_history.jsonl; plugin id harnmem shadows an auto-loaded claude-harnmem so only one MCP server and extractor run); verified end to end on the 1.0.70 binary |
| Hermes Agent 0.22.5 | Supported (Node 22.15+ on PATH) | hermes-harnmem Python MemoryProvider plugin + vendored-engine Node bridge (per-turn prefetch injection with a Python-side snapshot cache, five native tools, detached session-end extraction, read-only subagent/cron sessions); verified end to end on a scratch HERMES_HOME (injection, recall, tool write, hermes plugins validate clean) |
| oh-my-pi 18.14.1 | Supported (18.x) | omp-harnmem extension plugin (byte-stable before_agent_start system-prompt injection + five memory tools + /memory command; quit/switch journaling, read-only subagents); verified end to end on the 18.14.1 binary |
| Other harnesses | Welcome | See the adapter contract and CONTRIBUTING.md |
Start with the documentation index. Highlights:
See docs/ROADMAP.md for the current status (verified
numbers, the running trial, known issues) and the ordered next steps.
codex-harnmem; see its
README and the probe record in
docs/research/codex-plugin.md.grok-harnmem; see its
README, docs/design/11-grok-adapter.md
and the probe record in docs/research/grok-plugin.md.cursor-harnmem; see its
README, docs/design/12-cursor-adapter.md
and the probe record in docs/research/cursor-plugin.md.hermes-harnmem and shipping in the next
release (installed through the Hermes plugin manager, not npm); see its
README, docs/design/13-hermes-adapter.md
and the research note in
docs/research/hermes-plugin.md.omp-harnmem; see its
README and the research record in
docs/research/omp-plugin.md.HarnMem is local-first: no telemetry, no background service, and the engine never
opens a network connection. The CLI is offline by default too; the only outbound
call is the opt-in harnmem synonyms suggest --llm-url bridge, which runs solely
when you pass an endpoint. Memory content is sensitive by nature — back up
~/.harnmem/, keep it out of version control, and read
SECURITY.md before reporting a vulnerability. The store uses
symlink/path containment checks, size caps, sensitive-value redaction, soft
delete and an audit log; see the design docs for details.
Contributions are welcome. Start with CONTRIBUTING.md, follow
the Code of Conduct, and run pnpm test and
pnpm eval:gate before opening a pull request. Note the contribution gate:
issues and pull requests from new contributors are auto-closed by default and
reopened once a maintainer approves them with lgtmi (issues) or lgtm
(issues and pull requests). Merging master is PR-only and requires the owner's
approval. If you drive an AI coding agent, point it at AGENTS.md:
every change goes through a worktree branch and a pull request, and agents never
push to master. Questions and ideas are welcome in
Discussions. Security issues go
through the private process in SECURITY.md.
MIT © HarnMem contributors
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: llm、deepseek-harness。