hmem — Humanlike Memory for AI Agents

io.github.Bumblebiber由 GitHub 帳號 Bumblebiber 發布v1.6.7更新於 Oct 24, 2026

Persistent 5-level hierarchical memory for AI agents. SQLite-backed, lazy-loaded.

發布方自己的服務:Memory.fit

概覽

AI 產生的概覽

為 AI 助理提供持久的分層專案記憶,可跨工作階段、跨裝置與跨模型保留。

可以做什麼
把記憶以五層樹狀結構存放在本機 SQLite 的 .hmem 檔案中,依需求惰性載入,只讀取所需層級。日常伺服器提供 13 個工具,包括 read_memory、write_memory、append_memory、search_memory(FTS5 全文檢索)、find_related、load_project、create_project 與 flush_context。另有需手動啟用的 curate 伺服器,提供 11 個維護工具,用於統計、健康檢查、批次修改、標籤重新命名、匯出匯入與 ID 重新命名。工作階段透過掛鉤自動記錄,背景檢查點會擷取經驗、錯誤與決策。
適用情境
當助理在工作階段之間反覆遺失脈絡,或需要在多個專案、裝置與 AI 工具之間保持一致記憶時使用。適合想長期保存決策、錯誤、任務與慣例的開發者,也適合需要共享公司記憶庫的團隊。它不是通用的筆記軟體。},
執行需求
本機 Node.js 程序,透過 npx 執行(npm 套件 hmem-mcp),僅支援桌面環境。HMEM_STORAGE_DIR 指定 .hmem SQLite 資料庫的存放目錄(預設 ~/.hmem/);手動設定還會用到 HMEM_PROJECT_DIR 與 HMEM_AGENT_ID。背景檢查點需要 LLM:環境變數中的 API 金鑰(例如 ANTHROPIC_API_KEY、OPENAI_API_KEY 或 DEEPSEEK_API_KEY),或 PATH 中的 claude 命令列工具。跨裝置同步需要另外安裝 hmem-sync 套件、伺服器網址與 HMEM_SYNC_PASSPHRASE。
安裝前請注意
curate 伺服器的工具具破壞性:import_memory 被明確標示為破壞性操作,delete、批次修改、標籤重新命名與 ID 重新命名都會改寫記憶。自動工作階段記錄與背景檢查點會把對話內容寫入本機 .hmem 資料庫,檢查點還會把最近的對話傳送給 LLM 供應商(ANTHROPIC_API_KEY、OPENAI_API_KEY 或 DEEPSEEK_API_KEY)。跨裝置同步會把記憶傳送到所設定的伺服器,並由 HMEM_SYNC_PASSPHRASE 保護。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 hmem — Humanlike Memory for AI Agents,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

hmem — Humanlike Memory for AI Agents

[mcpindex]

Your AI forgets everything between sessions. hmem fixes that.

One load_project() call. ~3000 tokens. Your agent knows everything important about a project — every past mistake, every decision, every open task — across sessions, devices, and AI providers. No setup per conversation. No "let me re-read the codebase." It just remembers.

AI agent? Skip this file. Read AGENT_SETUP.md — written for you, not for humans.

Naming note (v8.0): This package was briefly published as its-over-9k (1.x). It is now hmem again — pure memory framework, nothing else. The its-over-9k name lives on as a separate project: the o9k token-efficiency meta-framework, which combines skills/plugins like this one. Related: TIM — hmem's next-generation successor (hypergraph memory, CRDT sync).


What This Is

hmem is not a note-taking plugin. It's a memory framework for AI agents — a complete infrastructure layer for persistent, portable, token-efficient knowledge that survives session boundaries, device switches, and provider changes.

Four core guarantees:

PillarWhat it means
Token efficiency5-level lazy loading — you pay for what you read, never more
PortabilitySame memory across Claude, Gemini, GPT, local models, any MCP client
Efficient storageHierarchical tree structure — context scales with depth, not flat append
No context wasteAuto-session capture + project briefing = zero re-read overhead

The Problem

Every AI session starts from zero. Your agent asks the same questions, makes the same mistakes, contradicts last week's decisions, and wastes 50k tokens loading context it already processed yesterday.

You've tried workarounds — CLAUDE.md files, custom prompts, manually pasting context. They don't scale. You have 10 projects. You switch between 3 devices. You use different AI tools.

The Solution

You:    "Load project"Agent:  [calls load_project("P0048") — 3000 tokens]Agent:  "v1.2.9, TypeScript/SQLite/npm. 3 open bugs, 8 roadmap items.         Last session: rebrand complete, rename_id bug fixed (89 changes).         Next: O-Entry Auto-Purge. What's the focus today?"

That's it. 3000 tokens for a complete project briefing. The agent knows the stack, the architecture, the open bugs, the recent decisions, and exactly where you left off — even if "you" was a different AI on a different machine yesterday.


How It Works

Level 1  ──  One-line summary          (always loaded — ~5k tokens for 300+ entries)  Level 2  ──  Paragraph detail        (loaded on demand)     Level 3  ──  Full context          (loaded on demand)      Level 4  ──  Extended detail      (loaded on demand)        Level 5  ──  Raw/verbatim data  (loaded on demand)

At session start, the agent loads Level 1 summaries — one line per memory. When it needs detail, it drills down. Your 300-entry memory costs 5k tokens to overview. A single project costs ~3000 tokens.

Nothing is summarized away. Level 1 is a compressed view, but Levels 2–5 hold the complete original text, word for word, accessible on demand.


Framework Features

Automatic Session Memory

Every conversation is recorded automatically. No "save your work" prompts. No manual checkpoints.

You type  →  Agent responds  →  Stop hook fires  →  Exchange saved to O-entry                                                   →  Linked to active project                                                   →  Haiku auto-titles the session

Switch projects mid-session? The O-entry switches too. Start a new session on a different device? The next agent sees every exchange from every device — the conversation never dies.

Haiku Background Checkpoints

Every N exchanges (configurable, default 5), a Haiku subagent wakes up in the background. It reads the recent conversation, extracts lessons learned, errors encountered, and decisions made, then writes them to long-term memory — with full MCP tool access. Your main agent is never interrupted.

The checkpoint also writes a handoff note to the project: "Here's what was done, here's what's in progress, here's the next step." The next agent — on any device, any provider — picks up exactly where you left off.

Project-Based, Not Session-Based

Sessions are meaningless. Projects are everything.

  • O-entries are linked to the active project, not the session
  • Checkpoint counters count project exchanges, not session messages
  • load_project shows recent conversations with full context — across all devices

Skills System

hmem ships with a complete skills layer — structured behavior files that agents load on demand. Skills define how an agent should do something (debug, write memory, curate entries, handle a session start) — separate from memory, separate from prompts.

bash
npx hmem update-skills    # Pull latest skills to your AI tool's skill directory

Skills are versioned and updated independently. Your agents get smarter without reinstalling. 21 skills ship by default:

SkillTriggers when…
hmem-session-startEvery session start — loads project + surfaces pending git work, open tasks, misrouted O-entries
hmem-using-hmemMeta-skill loaded at session start; defines mandatory memory habits
hmem-readReading from long-term memory (search, prefix filter, find_related, cross-project read)
hmem-writeWriting to hmem — picks prefix, tree location, tags, detects duplicates
hmem-searchUser references something without an ID ("the bug we had", "letzte Woche")
hmem-new-projectCreating a P-entry — handles schema, sections, O-entry linking
hmem-new-errorCreating an E-entry with the strict 5-level scaffold
hmem-activateSwitching active project mid-session, plus fixing misrouted exchanges
hmem-contextLoading specific context when load_project output isn't enough
hmem-recallDispatching a Haiku sub-agent to search hmem
hmem-dispatchDispatching an isolated sub-agent for any search/lookup/calculation
hmem-curateCleaning up an .hmem file (mark obsolete, fix titles, consolidate dupes)
hmem-migrate-oMigrating O-entries to the project-bound 5-level structure
hmem-consolidateMerging session checkpoint summaries into one final O-entry summary
hmem-wipePrep for /clear — save high-value knowledge, update Next Steps
hmem-configView/change memory settings, hooks, sync, checkpoints
hmem-setupFirst-time install of hmem for Claude Code / Gemini CLI / OpenCode
hmem-sync-setupSet up hmem-sync for cross-device sync
hmem-updateUpdate flow — runs npm update -g, syncs skills, applies migrations
hmem-releasePre-publish checklist for hmem itself
hmem-subagentTemplate for sub-agents dispatched by hmem-dispatch

Company Memory

Beyond personal memory, agents can maintain a shared company store — a separate company.hmem that multiple agents and team members can read from. Personal and company memory coexist; agents query both simultaneously.

typescript
import { openCompanyMemory } from 'hmem';const store = openCompanyMemory('/path/to/project');

Embeddable SDK

hmem ships as a fully documented TypeScript SDK — import HmemStore directly into your own agents, tools, or automation pipelines:

typescript
import {  HmemStore, openCompanyMemory, resolveHmemPath,  loadHmemConfig, saveHmemConfig, DEFAULT_CONFIG, DEFAULT_PREFIXES, formatPrefixList,  searchMemory,} from 'hmem';import type {  AgentRole, MemoryEntry, MemoryNode, HmemConfig,  SearchResult, SearchOptions, SearchScope,} from 'hmem';
const store = new HmemStore('/path/to/agent.hmem');const results = searchMemory('/path/to/project', 'auth token bug', { maxResults: 5 });

MCP Tools

hmem ships two MCP servers:

  • hmem (daily-use, 13 tools) — read, write, search, project lifecycle.
  • hmem-curate (maintenance, 11 tools) — bulk edits, schema migrations, backup/restore. Activate only when curating.

hmem — daily-use server (13)

ToolWhat it does
read_memory5-level lazy read — by ID, prefix, search, time, or tag
write_memoryCreate new entries with title, body, tags, links
append_memoryAdd child nodes to existing entries
update_memoryPatch fields: title, body, tags, irrelevant, links
search_memoryFTS5 full-text search with sub-node attribution
find_relatedFind contextually related entries by tag overlap
load_projectActivate a project + get full briefing + recent sessions
read_projectRead project without activating (comparison/reference)
create_projectScaffold a new project entry with standard schema
list_projectsList all projects with status summary
flush_contextPersist current session context to long-term memory
move_nodesMove a subtree under a different parent (also in curate server)
set_active_deviceRegister and switch between devices

hmem-curate — maintenance server (11)

ToolWhat it does
memory_statsPer-prefix counts, total tokens, favorites, hashtags, stale-list
memory_healthFind broken links, orphan tags, empty entries, dangling chains
export_memoryExport the full .hmem to a portable JSON snapshot
import_memoryImport a JSON snapshot back into a .hmem (destructive)
update_manyBulk-patch a set of entries (irrelevant, tags, body, etc.)
tag_bulkAdd/remove a tag across many entries
tag_renameRename a tag globally across all entries
move_memoryMove an entire entry to a new ID slot
move_nodesMove a subtree under a different parent (also in main server)
rename_idRename an entry's ID; rewrites all inbound links
reset_memory_cacheInvalidate the in-memory L1 cache (after raw SQL writes)

The daily hmem server is registered automatically by hmem init. hmem-curate is opt-in because its tools are destructive — register it when you need to curate:

npx hmem mcp-add-curate          # adds the curate server to Claude Code (user scope)

Then toggle it via /mcp only during curation sessions. For other MCP clients, see Manual setup.


CLI Commands

After npm install -g hmem-mcp, the hmem binary is on PATH.

User-facing

CommandPurpose
hmem initInteractive installer for AI tools (Claude Code, OpenCode, Gemini CLI, Cursor, Windsurf, Cline). Flags: --global / --local / --tools <list> / --dir <path> / --no-example
hmem update-skillsCopy/sync bundled skill files to detected AI tools (called automatically on npm install)
hmem mcp-add-curateRegister the hmem-curate MCP server with Claude Code (opt-in; toggle via /mcp when curating)
hmem doctorDetect stale or deprecated hmem MCP entries in host configs
hmem statsMemory statistics + per-project token estimates + 🔴 4k threshold flagging
hmem setup-hookRe-add the SessionStart hook to Claude Code settings (if removed)
hmem versionShow version

Hook drivers (called by AI tools, not by hand)

CommandWired intoWhat it does
hmem hook-startupUserPromptSubmitFirst-message context injection (memory overview, project list, sync status). Periodic checkpoint reminders. Reads JSON from stdin
hmem log-exchangeStop (sync)Append the latest exchange to the active O-entry
hmem checkpointStop (async)Background Haiku/DeepSeek call — extracts lessons, errors, decisions; updates project handoff note
hmem context-injectSessionStart[clear]Inject project + rules context after /clear
hmem deactivateSessionStart[clear]Clear active project for current session
hmem statuslinestatusLineRender Claude Code statusline (device · active project · checkpoint counter). Reads JSON from stdin

Curation

CommandPurpose
hmem delete <ID>Permanently delete an entry (curator only, never synced)
hmem migrate-o-entriesMigrate O-entries to the current project-bound schema
hmem summarize-session <id>Generate a summary node for a session

Sync (requires hmem-sync installed)

CommandPurpose
hmem sync pushPush local memory to the sync server
hmem sync pullPull latest memory from the sync server
hmem sync statusShow server URL · auth state · last-sync timestamp
hmem sync setup [--join]Interactive passphrase + device setup

Backup / migration

CommandPurpose
hmem export-staging <hmem> <json>Export .hmem SQLite to a portable JSON staging file
hmem import-staging <json> <hmem>Import a JSON staging file back into a .hmem

hmem serve starts the MCP stdio server directly — your AI tool launches it automatically; you only run it by hand for debugging.


Memory Categories

Default prefixes (configurable via prefixes in hmem.config.json):

PrefixCategoryExample
PProjecthmem | Active | TS/SQLite/npm
LLessonHMEM_AGENT_ID must be set in hooks — resolveHmemPath falls back to wrong DB
TTaskT0033 hmem-sync SaaS monetization — recurring monthly tier design
EError158 spurious O-entries created when Haiku MCP lacked HMEM_NO_SESSION guard
DDecisionProject-based O-entries over session-based — sessions are meaningless
MMilestonev1.0.0 — package renamed to hmem, npm rebrand complete
SSkillSkill: TypeScript debugging with source maps
NNavigatorHigh-level navigation entry (table of contents for a topic)
HHumanUser Skill: TypeScript 9, Architecture 9, React 3
RRuleMax one npm publish per day — batch changes
OOriginalAuto-recorded conversation history (every exchange, every device)
IInfrastructureStrato Server | Active | Linux | Ubuntu 22.04
CConventionTag scheme: lowercase, prefer existing tags before inventing

Add custom prefixes (e.g. A for App, F for Function reference) by listing them under prefixes in hmem.config.json — they show up in read_memory({ prefix: "X" }) filters automatically.


Quick Start

1. Install

bash
npm install -g hmem-mcp

2. Run the interactive installer

bash
npx hmem init

Detects your AI tools, creates the memory directory, configures MCP, and installs all hooks:

HookWhenWhat
UserPromptSubmitEvery messageFirst message: load memory overview. Every Nth: checkpoint reminder
Stop (sync)Every responseLog exchange to active O-entry
Stop (async)Every responseHaiku auto-titles untitled sessions
SessionStart[clear]After /clearRe-inject project context

3. Verify

Restart your AI tool, then:

read_memory()

Empty response = working (first run). Error = check the troubleshooting section.

Manual setup

Claude Code — edit ~/.claude/.mcp.json
json
{  "mcpServers": {    "hmem": {      "command": "/absolute/path/to/node",      "args": ["/absolute/path/to/hmem/dist/mcp-server.js"],      "env": {        "HMEM_PROJECT_DIR": "/home/yourname/.hmem",        "HMEM_AGENT_ID": "DEVELOPER"      }    }  }}

Find the paths:

bash
echo "Node: $(which node)"echo "Server: $(npm root -g)/hmem/dist/mcp-server.js"
Open Code — edit ~/.config/opencode/opencode.json
json
{  "mcp": {    "hmem": {      "type": "local",      "command": ["/absolute/path/to/node", "/absolute/path/to/hmem/dist/mcp-server.js"],      "environment": { "HMEM_PROJECT_DIR": "/home/yourname/.hmem" },      "enabled": true    }  }}
Cursor / Windsurf / Cline

Edit ~/.cursor/mcp.json, ~/.codeium/windsurf/mcp_config.json, or .vscode/mcp.json:

json
{  "mcpServers": {    "hmem": {      "command": "/absolute/path/to/node",      "args": ["/absolute/path/to/hmem/dist/mcp-server.js"],      "env": { "HMEM_PROJECT_DIR": "/home/yourname/.hmem" }    }  }}

Configuration

hmem.config.json in your HMEM_PROJECT_DIR (or Agents/NAME/):

json
{  "memory": {    "maxCharsPerLevel": [200, 2500, 10000, 25000, 50000],    "maxDepth": 5,    "checkpointMode": "auto",    "checkpointInterval": 5,    "recentOEntries": 10,    "maxTitleChars": 50,    "prefixes": { "X": "Custom" }  },  "sync": {    "serverUrl": "https://your-server/hmem-sync",    "userId": "yourname",    "salt": "...",    "token": "..."  }}
KeyDefaultWhat it does
checkpointMode"remind""auto" = background agent writes L/D/E. "remind" = prompts the main agent
checkpointInterval5Exchanges between checkpoints. 0 = disabled
checkpointProvider"anthropic""anthropic" or "openai" (any OpenAI-compatible: DeepSeek, Groq, …)
checkpointModel"claude-haiku-4-5-20251001"Model name for the configured provider
checkpointBaseUrl—OpenAI-compatible base URL (e.g. https://api.deepseek.com/v1)
checkpointApiKeyEnvprovider defaultEnv var holding the API key. Defaults: ANTHROPIC_API_KEY or OPENAI_API_KEY
recentOEntries10How many recent sessions to show in load_project
prefixesbuilt-inAdd custom entry types

All keys are optional. Missing keys use defaults.

Checkpoint setup per harness

The auto-checkpoint agent runs in the background after every Nth exchange. It needs an LLM call — three paths, picked automatically:

  1. API key in environment (any harness) → direct provider API loop. Configure checkpointProvider + checkpointModel + checkpointApiKeyEnv in hmem.config.json. Works from Pi, Hermes, OpenCode, and Claude Code.
  2. No API key, but claude CLI in PATH → subprocess fallback (claude -p). Zero-config for Claude Code / Claude Max users.
  3. Neither → checkpoint fails with a config-hint error.

Recommended cheap setup (DeepSeek, ~10× cheaper than Haiku):

json
{  "memory": {    "checkpointMode": "auto",    "checkpointProvider": "openai",    "checkpointModel": "deepseek-chat",    "checkpointBaseUrl": "https://api.deepseek.com/v1",    "checkpointApiKeyEnv": "DEEPSEEK_API_KEY"  }}

Then export DEEPSEEK_API_KEY=sk-... in your shell profile. Works for any harness.

Claude Code / Claude Max (zero-config): no provider settings needed — the subprocess fallback uses your existing claude login.

Per-harness exchange logging: Claude Code uses Stop hooks (installed by npx hmem init). Pi uses the built-in extension (src/extensions/pi-hmem.ts). Hermes needs the hermes-hmem plugin (see plugins/hermes-hmem/README.md). OpenCode uses the same hook system as Claude Code.

⚠ Pi users: Hook-based exchange logging is currently not working in the Pi runtime. Exchanges are not saved to O-entries automatically. Manual checkpointing via hmem checkpoint is the workaround until this is resolved.


Cross-Device Sync

Sync memories across all devices with zero-knowledge AES-256-GCM encryption.

bash
npm install -g hmem-syncnpx hmem-sync connect     # Interactive wizard — first device creates, others join

Add HMEM_SYNC_PASSPHRASE to your MCP config for automatic sync on every read/write.

Multi-server redundancy

json
{  "sync": [    { "name": "primary", "serverUrl": "https://server1/hmem-sync", "userId": "me", "salt": "...", "token": "..." },    { "name": "backup",  "serverUrl": "https://server2/hmem-sync", "userId": "me", "salt": "...", "token": "..." }  ]}

Announcements

Broadcast to all synced agents across all devices:

bash
npx hmem-sync announce --message "Server URL changing — update your config!"

Windows

On Windows with Git for Windows, Claude Code routes hook and statusLine commands through Git Bash by default. Git Bash's MSYS2 runtime crashes transiently at startup, killing the command before it runs.

Fix: add "shell": "powershell" to every hook command and to statusLine in ~/.claude/settings.json.

See settings.windows.example.json for the full working config. Key differences:

json
{  "env": {    "HMEM_PATH": "C:/Users/YOUR_USERNAME/.hmem/Agents/DEVELOPER/DEVELOPER.hmem"  },  "hooks": {    "Stop": [{      "matcher": "",      "hooks": [{        "type": "command",        "command": "node C:/Users/YOUR_USERNAME/AppData/Roaming/npm/node_modules/hmem/dist/cli.js log-exchange",        "shell": "powershell"      }]    }]  },  "statusLine": {    "type": "command",    "command": "node C:/Users/YOUR_USERNAME/AppData/Roaming/npm/node_modules/hmem/dist/cli.js statusline",    "shell": "powershell"  }}

Run npm root -g to get the correct node_modules path for your machine.

statusLine on Windows: Stable with "shell": "powershell". Without it the statusline disappears intermittently.


Troubleshooting

ProblemFix
read_memory() failsCheck HMEM_PROJECT_DIR is absolute path and directory exists
nvm: node not foundUse absolute path: which node → use as "command"
Hooks not firing (Claude Code)Restart Claude Code. Check ~/.claude/settings.json has all 4 hooks
Hooks not firing (Pi)Known issue — Pi hook integration is currently broken. Use hmem checkpoint manually as a workaround
Exchanges not loggedCheck HMEM_AGENT_ID matches your Agents/ directory name
Sync failsRun npx hmem-sync connect to re-authenticate

Updating

bash
npm update -g hmem    # MCP server + SDKnpm update -g hmem-sync      # Sync (if installed)npx hmem update-skills       # Refresh skill files

License

MIT

來源:README.md,提交 0e35095

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.6.7最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Memory 整合