Skip to content

Commit a419d0f

Browse files
committed
feat: add hermes-style session recall archive
1 parent 8ff11b6 commit a419d0f

23 files changed

Lines changed: 2472 additions & 34 deletions

‎README.md‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ Stop 阶段会生成 pending suggestions,scheduler 或手动 compile 会把它
170170

171171
```bash
172172
csep recall "这个仓库之前 phase2 hooks 怎么设计的"
173+
csep recall --recent
174+
csep recall "hermes OR recall" --global
173175
```
174176

175177
`csep recall` 默认输出 Markdown,适合模型直接阅读;调试时可以用 JSON:
@@ -178,6 +180,23 @@ csep recall "这个仓库之前 phase2 hooks 怎么设计的"
178180
csep recall "focused query" --format json
179181
```
180182

183+
启用 `[session_recall]` 后,Stop hook 会把 Codex transcript 归档到本机 SQLite/FTS。
184+
后续 recall 会优先从这个 session 库里按当前 repo 检索;同一个 git common dir 下的多个
185+
worktree 视为同一个 repo,并按预算裁剪原始消息窗口:
186+
187+
```toml
188+
[session_recall]
189+
enabled = true
190+
stop_hook_archive = true
191+
```
192+
193+
也可以手动归档或回填历史会话:
194+
195+
```bash
196+
csep session-archive --transcript-path /path/to/session.jsonl --cwd /path/to/repo --session-id <id>
197+
csep session-ingest --backfill --root ~/.codex/sessions
198+
```
199+
181200
### 4. 手动跑一次 compile
182201

183202
```bash
@@ -296,14 +315,19 @@ Skill Synthesis 会维护独立运行状态,并把通过门禁的 skill 投影
296315
| `codex-self-evolution eval-compiler --fixture tests/fixtures/compiler_replay/commerce_membership_api.json` | 回放编译质量样本,输出 pass/fail 和 memory/recall/discard 指标。 |
297316
| `codex-self-evolution recall-trigger --query "..."` | 触发一次聚焦 recall。 |
298317
| `codex-self-evolution status` | 输出只读诊断快照。 |
299-
| `csep recall "..."` | 面向模型使用的 recall wrapper。 |
318+
| `csep recall "..."` | 面向模型使用的 recall wrapper,默认 repo scope。 |
319+
| `csep recall --recent` | 返回当前 repo 最近归档的 session。 |
320+
| `csep recall "..." --global` | 跨 repo/worktree 检索 session recall。 |
321+
| `csep session-archive --transcript-path ... --cwd ... --session-id ...` | 手动归档一份 Codex transcript。 |
322+
| `csep session-ingest --backfill` | 回填历史 Codex session transcript。 |
300323

301324
常用示例:
302325

303326
```bash
304327
codex-self-evolution status | python3 -m json.tool
305328
codex-self-evolution scan --backend agent:pi --max-runs-per-project 3
306329
csep recall "这个 repo 的上线检查流程"
330+
csep recall --recent
307331
```
308332

309333
## 配置优先级

‎README_zh.md‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ codex-self-evolution status # 只读诊断快照
8888
codex-self-evolution recall --query "context" --cwd /path/to/repo
8989
codex-self-evolution recall-trigger --query "remember previous flow" --cwd /path/to/repo --format json
9090
csep recall "focused query for prior repo context" # 给模型读的 Markdown recall
91+
csep recall --recent # 当前 repo 最近归档 session
92+
csep recall "hermes OR recall" --global # 跨 repo/worktree 检索
93+
csep session-archive --transcript-path /path/to/session.jsonl --cwd /path/to/repo --session-id <id>
94+
csep session-ingest --backfill --root ~/.codex/sessions
9195
```
9296

9397
等价的模块调用形式:
@@ -114,6 +118,19 @@ python -m codex_self_evolution.cli session-start --cwd /path/to/repo
114118
| `--explicit` | `recall-trigger` 可选 | 关闭 | 标记该 recall 触发为用户显式发起。 |
115119
| `--format` | `recall-trigger` / `csep recall` 可选 | `markdown` | 测试/调试用 `json`;Markdown 面向模型直接阅读。 |
116120
| `--top-k` | `recall-trigger` / `csep recall` 可选 | `3` | 聚焦召回最多返回几条。 |
121+
| `--global` | `csep recall` 可选 | 关闭 | 跨 repo/worktree 检索 session recall;默认只查当前 repo。 |
122+
| `--recent` | `csep recall` 可选 | 关闭 | 不需要 query,返回当前 scope 最近归档的 session。 |
123+
| `--budget-chars` | `csep recall` 可选 | `12000` | 控制一次 recall 输出的总字符预算,避免把历史上下文带得太大。 |
124+
125+
Session recall 默认开启。Stop hook 会把 Codex transcript 归档到本机
126+
SQLite/FTS;`csep recall` 会优先从 session 库返回受预算控制的原始消息窗口,
127+
找不到时再软 fallback 到旧 `recall/index.json`:
128+
129+
```toml
130+
[session_recall]
131+
enabled = true
132+
stop_hook_archive = true
133+
```
117134

118135
`--state-dir` 下的目录布局(默认 `~/.codex-self-evolution/projects/<mangled-cwd>/`):
119136

@@ -380,5 +397,5 @@ make preflight # 对 data/ 跑一次 compile-preflight
380397
- 最终写入归属 `src/codex_self_evolution/compiler/engine.py`(不再是单独的 `writer.py`)。
381398
- Managed skills 的源文件仍在 `skills/managed/` 下,需要 plugin-owned manifest 条目(owner = `codex-self-evolution-plugin`)。可发布的 active skill 会投影到 `~/.codex/skills/csep-managed/csep-*/SKILL.md`;compiler 拒绝改非此 owner 的 skill。
382399
- review snapshot 被标准化后保存在 `review/snapshots/` 下,便于调试与审计。
383-
- recall 使用 repo/cwd-first 排序策略。`SessionStart` 注入 Recall Contract,要求 Codex 在非平凡 repo/workspace 任务可能依赖历史上下文时自行运行 `csep recall "<focused query>"`;空结果软失败继续。
400+
- recall 优先使用本机 session archive 的 SQLite/FTS;同一个 git common dir 下的多个 worktree 会按同一个 repo scope 处理。`SessionStart` 注入 Recall Contract,要求 Codex 在非平凡 repo/workspace 任务可能依赖历史上下文时自行运行 `csep recall "<focused query>"`;空结果软失败继续。
384401
- 改动 compile 行为前建议先读 `docs/2026-04-20-compiler-existing-assets-handoff.md`,了解当前 existing-assets 流水线背后的设计依据。

0 commit comments

Comments
 (0)