tanbopiao

wengu 温故

Community tanbopiao
Updated

温故 - Agent cross-session persistent memory, pure stdlib single file

wengu 温故

温故而知新,可以为师矣 ——《论语·为政》

Agent 跨会话持久记忆,纯标准库单文件 Python,零依赖。

Agent 每次新会话都从零开始:重读同样的文件、重问同样的问题、重踩已经一起修过的坑。wengu 把「观察沉淀 → 索引注入 → 按需取详」这三步提炼成一个单文件工具,让下一个会话从上一个会话结束的地方开始。

名字出处

「温故而知新,可以为师矣」出自《论语·为政》。旧会话沉淀为「故」,新会话注入为「新」——温故知新正是这套东西的工作方式。

用法

# 沉淀一条观察(决策/修复/功能/笔记)
wengu.py add --project myproj --type decision --title "网关改用 FastMCP" \
  --narrative "官方 SDK 无 MCPServer 类,改 FastMCP 构造函数传参" \
  --fact "SDK 1.30.0 无该类" --file kernel_mcp_server.py

# 会话结束沉淀摘要(Stop 等价物)
wengu.py summary --project myproj --text "完成两处网关修复并握手验证"

# 新会话启动:注入紧凑索引(每条约 10-20 token)
wengu.py index --project myproj --limit 50

# 三层渐进检索
wengu.py search  --project myproj --query "网关 修复"   # 第一层:关键词索引
wengu.py timeline --project myproj --id 2               # 第二层:时间上下文
wengu.py get --project myproj --id 1 --id 2             # 第三层:全文详情

# 统计
wengu.py stats --project myproj

存储为 ~/.wengu/<project>.jsonl,每行一条观察记录,纯文本、可读、可迁移——复制文件即完成备份与迁移。

与上游的取舍

上游 thedotmack/claude-mem(Apache-2.0,约 11 万星)是完整的记忆系统:Node.js + Bun 运行时、Express worker 服务、React 界面、SQLite + Chroma 向量库、19 个宿主适配器、遥测与云同步。

wengu 只提炼核心三步,外围全砍:

维度 claude-mem wengu
运行时 Node.js 20+ / Bun Python 3 标准库,零依赖
组件 worker + Express + React + SQLite + Chroma 单文件 ~220 行
检索 全文 + 向量语义 关键词打分 + 三层渐进
资源占用 完整形态数百 MB 级 实测峰值 12.5 MB
遥测 PostHog 默认开启 无
存储 SQLite + Chroma 二进制 JSONL 纯文本

如实边界

  • 关键词检索不是语义检索:同义改写查不到,需命中字面词。
  • 观察压缩(observer)需外部模型完成,wengu 只负责存取与检索,不生成内容。
  • 无 Web 界面、无云同步、无多宿主适配——单机单用户场景。

复刻哲学

功能可以复刻、架构可以复刻、逻辑可以复刻——代码算子由自己生成完善,达到同样的功能与能力,而资源占用降低一个数量级。

致谢

本项目为独立重写,与上游无代码血缘。核心场景与三层渐进检索的思路启发自 thedotmack/claude-mem(Apache-2.0),感谢上游项目的开源贡献。

许可证

MIT

MCP Client Configuration

Published on PyPI as wengu (install from official PyPI index). For MCP clients (Cline, Cherry Studio, Cursor, etc.):

{
  "mcpServers": {
    "wengu": {
      "command": "uvx",
      "args": ["--from", "wengu", "wengu-mcp"]
    }
  }
}

MCP Server · Populars

MCP Server · New

    atilaahmettaner

    TradingMCP: Market Data & Technical Analysis for AI Assistants

    MCP server for market analysis in AI assistants: screeners, multi-timeframe technical analysis, backtests and sentiment for crypto, stocks, forex and futures. 39 tools. Self-host free, or use the hosted version, TradingMCP.

    Community atilaahmettaner
    lifan-builds

    Faster Mac Use (fmu)

    Background-first, multi-cursor browser and native macOS computer-use engine for AI agents

    Community lifan-builds
    agent360dev

    Agent360 Browser MCP

    The browser tool that can stop and ask you. A 2FA code, a CAPTCHA, a choice only you can make: it asks on your screen, then carries on in the same signed-in Chrome. 41 tools, MCP clients that run local servers, MIT.

    Community agent360dev
    robinAKL

    Agent Room

    Put Claude Code, Cursor, Codex, Gemini & Antigravity in one room — real-time multi-agent AI collaboration over MCP for distributed dev, code review, PR handoff & frontend↔backend integration. Free, self-hostable, MCP-native.

    Community robinAKL
    blen-labs

    Capture MCP

    AI-native Model Context Protocol (MCP) server that integrates SAM.gov, USASpending.gov, and Tango APIs to capture and analyze federal procurement and spending data through natural language queries. Responses include both human-readable text and structured JSON so MCP-compatible clients can consume the data programmatically.

    Community blen-labs