Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@omnimer/context-manager) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
context-manager
Turn agent conversations into reusable guidance and context.
把对话整理成后续 agent 可以直接复用的经验和上下文。
context-manager 帮助 agent 从历史对话里保留真正重要的信息,避免每次都从头再来。当前先服务于 Codex,后续会扩展到 Claude Code 等其它 agent。
背景与问题
Agent 用久了以后,历史对话会越来越长,但真正有用的信息很难留下来。
结果通常是两种:
- 上下文越来越重,但真正重要的内容越来越难找
- 会话结束或被压缩后,已经验证过的做法又要重新想一遍
context-manager 会自动整理这些对话,把有价值的内容沉淀下来,供后续 agent 继续使用。
核心工作流
对话
-> 提炼
-> working-memory/
-> guidance/
-> 后续 agent 按需读取它会做的事情很简单:
- 捕获对话产物
- 提炼出高信号内容
- 写入
working-memory/ - 再提炼成更精炼的
guidance/ guidance/会简单分成三类:决策、流程、约定- 让后续 agent 在需要时直接读取这些结果
快速开始
当前有两种使用方式:
通过 npm:
- 进入你要接入的目标 repo
- 运行
npm install -g @omnimer/context-manager - 运行
context-manager init --repo-root .
通过源码仓库:
- 克隆这个仓库
- 进入
context-manager/ - 运行
npm install - 进入你要接入的目标 repo
- 运行
node /path/to/context-manager/bin/context-manager.mjs init --repo-root .
如果你当前就在 context-manager/ 目录里,也可以直接指定目标 repo:
node ./bin/context-manager.mjs init --repo-root /path/to/target-repo
init 会在目标 repo 里写入 Codex hook 配置。配置会指向已安装的 context-manager 运行代码,不会在目标 repo 里复制或链接 hooks/、scripts/。
常用命令:
npm testnode scripts/compile.mjsnode scripts/lint.mjsnode scripts/replay_pending.mjsnode scripts/smoke_e2e.mjs
当前状态
当前实现是 Codex-first:
- 目前通过 Codex hooks 接入
- 会生成
working-memory/和guidance/ - 会在后续会话里通过
guidance-recall供 agent 按需读取 - 后续会扩展到其它 agent,而不是停留在 Codex 专用实现
开发与实现约定
scripts/prompts/flush.md与scripts/prompts/compile.md是默认提示词模板- 可通过
CODEX_MEMORY_COMPILER_PROMPTS_DIR覆盖模板目录 reports/pending-flush/只承担可重放入口reports/llm-failures/只承担失败诊断记录- 项目级 hook 定义位于
.codex/config.toml init只写目标 repo 的 Codex 配置,不复制或链接运行时代码guidance-recallskill 安装到~/.codex/skills/guidance-recall/compile在来源冲突时以后来的、已验证的当前状态为准,不继续固化过时 guidanceactivate_hooks.mjs是init命令的内部实现- 日常是否触发通过
reports/runtime/下的被动痕迹判断,不依赖 doctor
参考仓库
当前主要参考了这些仓库:
coleam00/claude-memory-compileropenai/codexopenai/codex-plugin-cczilliztech/memsearch
社区
欢迎提交 issue 和 pull request!感谢 linux.do 社区的讨论和反馈,帮助我们不断完善这个项目。