Cogmem

io.github.writerslogic由 GitHub 账号 writerslogic 发布v2.7.1更新于 Oct 24, 2026

A self-improving, verifiable memory layer for AI coding agents.

已验证STDIO仅桌面知识与记忆开发者工具

概览

AI 生成的概览

为 AI 编程代理提供本地记忆层,存储经过签名、可验证的经验并在会话间召回。

可以做什么
Cogmem 为助手提供持久且可自我改进的编程记忆。它暴露八个工具——recall、note、status、verify、receipt、tree_head、progress 和 review_pending——以及实时用户模型和按项目状态等只读资源。记忆以 did:key 身份签名为 W3C 可验证凭证,并记录在哈希链式透明日志中,因此被篡改或注入的记忆可被检测并拒绝。它还会建模代理反复出现的错误,并在工具调用边界拦截。
适用场景
当你希望代理跨会话保留经验、决策和项目状态,而不是重复同样的错误时,值得添加。它适合重视记忆准确性和防篡改的编程工作流,且你愿意运行本地服务和钩子。
运行要求
通过 pip(cogmem)或克隆安装脚本本地安装;需要 Python 3.12+。MCP 服务器以 stdio 方式运行,命令为 cogmem mcp。可选 [recall] 附加组件通过 fastembed 提供本地语义召回。cogmem init 或 install.sh 会接入 Claude Code 钩子。学习流程需要 ANTHROPIC_API_KEY。数据位于 COGMEM_HOME(默认 ~/.claude/cogmem)。
安装前请注意
学习流程并非本地:采集、整合、反馈评判和模型综合会把相关会话记录发送到 Anthropic API,需要 ANTHROPIC_API_KEY。召回和嵌入在本地运行。Ed25519 身份私钥会生成并存储在 vault 下;迁移或重装到新的 COGMEM_HOME 会创建新身份,除非迁移 vault。钩子会写入 Claude Code 设置并捕获会话。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Cogmem,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[cogmem logo]

cogmem

A self-improving, verifiable memory layer for AI coding agents.


[CI] [CodeQL] [OpenSSF Scorecard] [OpenSSF Best Practices] [License] [Code of Conduct] [GitHub Sponsors]

A self-improving, verifiable memory layer for AI coding agents.

cogmem learns how you work across sessions so your agent gets more accurate and more autonomous over time: it stops repeating mistakes, keeps a live model of each project, and surfaces the right lesson at the right moment. Every memory is cryptographically signed and tamper-evident, so a poisoned or altered memory can be detected and rejected before it ever steers the agent.

Developed by WritersLogic — local-first recall; your memory and identity key stay on your machine (see Privacy).

Installation

From PyPI

bash
pip install cogmem            # CLI + MCP server + verifiable-memory toolspip install 'cogmem[recall]'  # add local semantic recall (fastembed)cogmem init                   # wire the Claude Code hooks + build the index

pip install cogmem gives you the cogmem CLI and the MCP server (cogmem mcp, or uvx cogmem mcp on demand) — the verifiable-memory tools need only the core install. Add the [recall] extra for local semantic recall, then run cogmem init to wire the full learning loop (the SessionStart/UserPromptSubmit/Stop hooks and the index) into Claude Code. cogmem init is idempotent; re-run it any time.

Clone installer (turnkey, with the warm daemon)

The clone installer does everything pip install + cogmem init does, plus sets up the warm recall daemon (launchd/systemd) as a managed service:

bash
git clone https://github.com/writerslogic/cogmem.gitcd cogmem./install.sh

Or in one line:

bash
curl -fsSL https://raw.githubusercontent.com/writerslogic/cogmem/main/install.sh | bash

install.sh is idempotent — run it again any time to upgrade in place. It sets up the code under ~/.claude/cogmem, a self-contained virtualenv with dependencies, the cogmem CLI on your PATH, the Claude Code hooks, and a warm recall daemon (a launchd agent on macOS, a systemd --user service on Linux). Requires Python 3.12+; semantic recall runs on a local model (fastembed, no external API). Pass --no-daemon or --no-hooks to skip those steps; set COGMEM_HOME to install elsewhere — the CLI, engine, and hooks all resolve it at runtime, so a non-default install keeps its memory and identity fully self-contained.

Custom Installation

Install to a different directory

Set COGMEM_HOME to place cogmem somewhere other than the default ~/.claude/cogmem:

bash
COGMEM_HOME=/opt/cogmem ./install.sh

Or with the one-liner:

bash
curl -fsSL https://raw.githubusercontent.com/writerslogic/cogmem/main/install.sh | COGMEM_HOME=/opt/cogmem bash

The installer copies the code, creates the virtualenv, and symlinks the CLI to ~/.local/bin/cogmem (or wherever COGMEM_BIN points).

CLI path

Set COGMEM_BIN to control where the cogmem CLI symlink is placed:

bash
COGMEM_BIN=$HOME/.cargo/bin COGMEM_HOME=/opt/cogmem ./install.sh

If COGMEM_BIN is not on your PATH, the installer prints a warning. You can always invoke cogmem directly from $COGMEM_HOME/cogmem.

How data directories and identity keys are resolved

At runtime the CLI and engine read COGMEM_HOME from the environment. When it is unset they fall back to ~/.claude/cogmem. All runtime data lives under the vault/ subdirectory:

PathPurpose
$COGMEM_HOME/vault/identity/agent.keyEd25519 private key (agent identity, did:key)
$COGMEM_HOME/vault/credentials/W3C Verifiable Credential storage
$COGMEM_HOME/vault/rules/Layer-A (always-load) and Layer-B (recall) rules
$COGMEM_HOME/vault/provenance/log.jsonlAppend-only hash-chained transparency log
$COGMEM_HOME/vault/provenance/statements/COSE_Sign1 SCITT signed statements
$COGMEM_HOME/engine/.venv/Python virtualenv with dependencies
$COGMEM_HOME/hooks/Claude Code hook scripts

The identity key is generated on first run (via cogmem status or any engine operation) and persisted at $COGMEM_HOME/vault/identity/agent.key. The corresponding did:key is derived from the Ed25519 public key. Moving or reinstalling cogmem to a new COGMEM_HOME creates a fresh identity unless you migrate the vault/ directory.

MCP client with a non-default install

The standard MCP client configuration works regardless of COGMEM_HOME because the cogmem CLI resolves the environment variable at runtime:

json
{  "mcpServers": {    "cogmem": { "command": "cogmem", "args": ["mcp"] }  }}

If the CLI is not on your PATH, use the full path:

json
{  "mcpServers": {    "cogmem": { "command": "/opt/cogmem/cogmem", "args": ["mcp"] }  }}

Or prefix with COGMEM_HOME in a shell wrapper:

json
{  "mcpServers": {    "cogmem": { "command": "env", "args": ["COGMEM_HOME=/opt/cogmem", "cogmem", "mcp"] }  }}

Quick Start

bash
cogmem status           # health check, metrics, agent DIDcogmem doctor           # end-to-end learning-loop health (daemon, API key, trust, backlog)cogmem recall "..."     # surface relevant past lessons for a taskcogmem note "..."       # record a decision or finding mid-taskcogmem verify           # verify every memory's credential + the transparency logcogmem receipt <id>     # inclusion proof that a memory is committed in the signed logcogmem statement <id>   # COSE_Sign1 SCITT signed statement (verifiable by HMS too)cogmem trust            # show the trusted agent identity (warns on a key mismatch)cogmem trust --rotate   # re-anchor trust after an intentional key changecogmem review list      # approve always-load rulescogmem mcp              # run the MCP server (stdio) for any MCP client

MCP Integration

Run cogmem as an MCP server and connect any MCP-compatible client:

json
{  "mcpServers": {    "cogmem": { "command": "cogmem", "args": ["mcp"] }  }}

Eight tools are exposed: recall, note, status, verify, receipt, tree_head, progress, review_pending, plus read-only resources (the live user model and per-project state).

Claude Code Integration

install.sh wires cogmem into Claude Code automatically (idempotently merged into ~/.claude/settings.json) — no manual invocation required. Five hooks make the memory loop run in the background:

EventHookWhat it does
SessionStartcogmem-activate.shinjects promoted always-load (Layer-A) rules + the self-check
UserPromptSubmitcogmem-recall.shsemantic Layer-B recall for the current prompt
PreToolUse(Bash)cogmem-guard.shintercepts known mistakes at the tool-call boundary before they happen
PostToolUse(Edit|Write)cogmem-context.shtracks which files the session is actively editing
Stopcogmem-capture.shcaptures the session into memory (acquisition + consolidation)

Every hook is strictly fail-open: any error, timeout, or cold daemon injects nothing and never blocks your prompt. The scripts live in ~/.claude/cogmem/hooks/; re-run install.sh (or ./install.sh --no-daemon) to refresh the wiring.

Why cogmem? -- learns from outcomes, models failure modes, verifiable memory

Chat-memory systems (Mem0, Letta, Zep) store and retrieve facts. cogmem is built for coding agents and goes further on three axes:

It learns from outcomes. A feedback loop scores whether a recalled lesson actually helped, refines rules that prove wrong, and retires ones that mislead.

It models its own failure modes. cogmem tracks where the agent tends to go wrong in your work and intercepts known mistakes at the tool-call boundary — before they happen, not afterward.

Its memory is verifiable. Each memory is a W3C Verifiable Credential signed by the agent's did:key, recorded in a tamper-evident, SCITT-style transparency log. Agent memory is an attack surface; cogmem makes it auditable and poison-resistant.

Features -- two-layer memory, outcome feedback, self-model, project state, cross-project narrative, self-regulation, verifiable credentials
  • Two-layer memory: always-loaded directives (scope-gated, human-approved) plus a semantic recall tail (local cross-encoder reranking, no data leaves the machine).
  • Outcome feedback and self-refinement: memories earn or lose trust based on whether they actually helped; contradicted rules are corrected through a safe pipeline.
  • Self-model and guard: a model of the agent's recurring mistakes, compiled into tripwires that intercept them at the PreToolUse boundary.
  • Project-state model: a living per-project state (goal, claims, open questions, blockers) that gives situational continuity and reasons across time.
  • Cross-project progress narrative: momentum, stalls, and dependencies across projects, surfaced as alerts.
  • Self-regulation: recall thresholds tuned automatically against an eval harness.
  • Verifiable Agent Memory: did:key identity, W3C VC-signed memories, COSE_Sign1 SCITT signed statements (byte-compatible with HMS), a hash-chained transparency log with signed Merkle tree head and RFC 6962 inclusion receipts, optional poison-resistance enforcement. See PROVENANCE.md.
Verifiable Memory -- did:key identity, W3C VC, COSE/SCITT, hash-chained log, poison-resistance

cogmem treats every stored memory as a signed artifact:

  • did:key identity: each agent gets a persistent Ed25519 identity, exposed as a W3C DID.
  • W3C Verifiable Credentials: every memory is signed with eddsa-jcs-2022 Data Integrity proofs.
  • COSE_Sign1 / SCITT signed statements: byte-identical to the envelope format used by holographic-memory and crosstalk — independently verifiable by any of the three implementations.
  • Hash-chained transparency log: append-only JSONL with SHA-256 chaining, a signed Merkle tree head, and RFC 6962-style inclusion receipts.
  • Revocation: every credential carries a W3C Bitstring Status List entry; a demoted or retired memory is revoked in a signed status-list credential.
  • Poison-resistance: altered or injected memories fail verification and are rejected before influencing the agent.
bash
cogmem verify              # check all memories and the log headcogmem receipt <memory-id> # prove a memory is in the signed logcogmem revoke <memory-id>  # revoke a memory (Bitstring Status List)cogmem status-list         # emit the signed revocation status-list credential

See PROVENANCE.md for the full specification.

Verify the C2PA sample yourself:

bash
# examples/c2pa-agent-credential/ is a real signed C2PA manifest# whose agent identity validates in c2patool./examples/c2pa-agent-credential/verify.sh

This proves the whole chain: agent identity (cawg.ica.credential_valid) bound to real cognition — a signed cogmem memory and a signed crosstalk reasoning audit, each an independently verifiable Ed25519 COSE/SCITT statement.

Standards alignment

cogmem is built on published standards, and it is precise about where it conforms versus where it is -style (compatible in shape and crypto, short of full profile conformance). The primitives are real Ed25519 signatures over real canonical byte structures — nothing here is mocked.

StandardWhat cogmem implementsStatus
W3C DIDdid:key (Ed25519), did:web (publishes an OKP publicKeyJwk), did:jwk — all with working resolversConformant
W3C VC Data Model 2.0VC v2 context, credential id, validFrom/validUntil, AgentMemoryCredential / AIAgentCredential / IdentityClaimsAggregationCredentialConformant; Verifiable Presentations are roadmap
W3C Data Integrity — eddsa-jcs-2022Ed25519 Data Integrity proof over RFC 8785 JCS canonical bytes (UTF-16 key ordering, literal-UTF-8 strings)Conformant
W3C Bitstring Status ListEvery memory carries a BitstringStatusListEntry; a demoted/retired memory is revoked (GZIP + multibase encodedList) and published in a signed BitstringStatusListCredentialConformant
IETF COSE (RFC 9052)Untagged and tag-18 COSE_Sign1, EdDSA (-8)Conformant; byte-interoperable with the coset-based verifiers in the sibling projects
IETF SCITTCOSE_Sign1 signed statements + an append-only, hash-chained, signed logSCITT-style. Conformant Signed-Statement headers (CWT_Claims), COSE Receipts, and a Transparency Service distinct from the issuer are roadmap — see below
RFC 6962 MerkleSigned tree head, inclusion proofs, verificationConformant proof math; a witness co-signs the tree head for independent transparency
CAWG Identity Assertion (ICA)IdentityClaimsAggregationCredential in a tag-18 COSE_Sign1 over application/vc, cross-checked against the C2PA SignerPayloadInteroperable with the ICA verifier in c2pa-rs

Toward full SCITT conformance. Three bounded steps, no new cryptography: (1) move iss/sub/content-type from the statement payload into the COSE protected header as CWT_Claims; (2) emit inclusion proofs as COSE Receipts (draft-ietf-cose-merkle-tree-proofs) in the statement's unprotected header; (3) make the external witness a mandatory Transparency-Service role distinct from the issuing agent. Steps 1–2 are re-encoding; step 3 is the architectural one, since a single-party log is a compatible format rather than meaningful transparency.

Privacy

cogmem is local-first by design. Memories, embeddings, and the identity key live on your machine, and semantic recall is fully local — the embedding and reranker models (fastembed) run on-device, so querying your memory never leaves the machine.

The learning pipeline is not local: acquisition, consolidation, the feedback judge, and the project/user-model synthesis send the relevant session transcript to the Anthropic API (ANTHROPIC_API_KEY). That is how rules are extracted and scored. If you need fully-offline operation, run with --no-hooks (recall still works) until a local-model extraction path lands. In short: recall is local; learning calls the API.

Part of the Agent-Provenance Stack

cogmem is one component of the WritersLogic verifiable agent-provenance pipeline — agent identity, memory, reasoning, and signed output, cryptographically bound end to end.

ProjectRole
cogmem (this repo)Agent identity (CAWG credential) + verifiable, tamper-evident memory (COSE/SCITT)
crosstalkMulti-model orchestrator; signs each turn's reasoning/orchestration audit
holographic-memoryDurable holographic memory store; cross-verifies signed statements and agent identity
WritersProofC2PA producer: binds identity + memory + reasoning to the signed asset

All four share one substrate — COSE_Sign1 / SCITT signed statements (Ed25519) and W3C DID identity — specified in UNIFIED-PROVENANCE.md.

Security

Found a vulnerability? Please report it privately — see SECURITY.md.

License

Apache-2.0 — see LICENSE.

来源:README.md,提交 e49b1d7

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v2.7.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分