Skip to main content

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

Metadata

Release files for wengu 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wengu 1.0.1
File Size Uploaded Provenance Actions
wengu-1.0.1.tar.gz 8.2 kB Without provenance Details for wengu-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wengu 1.0.1
File Interpreter ABI Platform Actions
wengu-1.0.1-py3-none-any.whl Python 3 none any Details for wengu-1.0.1-py3-none-any.whl

Total release size: 17.7 kB

Release files / wengu-1.0.1.tar.gz

Download URL wengu-1.0.1.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
11304587621815f8a7cdf603990b7f43875c1abfa8131d2e3b83814329caee46
BLAKE2b-256 checksum
How to use checksums
06ef4d7b6cf6c6044051c4370119269ef3bf0b92df6372b3d99c535532081968
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pypi-upload-stdlib/1.0

Release files / wengu-1.0.1-py3-none-any.whl

Download URL wengu-1.0.1-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
39bc6e45edfcb107ddb50cc14c552957285bb32775e386191874ae48bc544246
BLAKE2b-256 checksum
How to use checksums
21b1a23691bcf098cb34b16ebb29b862b7aeda97a006e452e28070fc3739a7aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pypi-upload-stdlib/1.0

Security for wengu 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page