AI 编程助手每次会话浪费大量 token 重读上下文的问题终于有了解决方案——PROJECTMEM 用本地事件日志让代理记住历史,做复杂项目开发的团队可以直接集成,减少重复调试成本。
AI 编程助手目前每次新会话都需要重新读取项目文件、重新推导之前的决策,甚至重复失败的调试尝试,消耗大量 token。PROJECTMEM 是一个开源、本地优先的记忆与判断层,通过不可变的事件日志记录开发过程(问题、尝试、修复、决策、笔记),并通过 MCP 协议生成紧凑的 AI 可读摘要。它还能在代理执行前发出警告,防止重复失败修复或编辑脆弱文件,实现“记忆即治理”。该系统完全离线运行,无遥测,日志可作为可审计的溯源链。项目包含 14 个 MCP 工具、19 个 CLI 命令,并在 10 个项目、207 个事件的自我研究中得到验证。
PROJECTMEM: A Local-First, Event-Sourced Memory and Judgment Layer for AI Coding Agents
AI coding assistants now support a growing share of software work, from quick scripts to production applications. Yet these agents remain largely stateless: each new session re-reads project files, re-derives prior decisions, and - most costly - may repeat debugging attempts that already failed. Reconstructing this context can consume an estimated 5,000-20,000 tokens per session; the bottleneck is often not model capability but missing project memory. We present projectmem, an open-source, local-first memory and judgment layer for AI coding agents. projectmem records development as an append-only, plain-text event log of typed events - issues, attempts, fixes, decisions, and notes - and deterministically projects that log into compact, AI-readable summaries served through the Model Context Protocol (MCP). Beyond storage, projectmem adds a deterministic pre-action gate that warns an agent before it repeats a previously failed fix or edits a known-fragile file. We frame this as Memory-as-Governance: memory that does not merely answer the agent but acts on its next action. The system runs fully offline with no telemetry; its immutable log also serves as a provenance trail for reproducible, auditable AI-assisted development. projectmem ships as a three-dependency Python package (14 MCP tools, 19 CLI commands, 37 automated tests) and is evaluated through a two-month self-study across 10 projects comprising 207 logged events. Source code: https://github.com/riponcm/projectmem.