csep 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- csep-1.0.0/LICENSE +21 -0
- csep-1.0.0/MANIFEST.in +1 -0
- csep-1.0.0/PKG-INFO +272 -0
- csep-1.0.0/README.md +220 -0
- csep-1.0.0/pyproject.toml +76 -0
- csep-1.0.0/setup.cfg +4 -0
- csep-1.0.0/src/codex_self_evolution/__init__.py +3 -0
- csep-1.0.0/src/codex_self_evolution/cli.py +554 -0
- csep-1.0.0/src/codex_self_evolution/config.py +189 -0
- csep-1.0.0/src/codex_self_evolution/config_file.py +528 -0
- csep-1.0.0/src/codex_self_evolution/config_file_template.py +37 -0
- csep-1.0.0/src/codex_self_evolution/csep.py +387 -0
- csep-1.0.0/src/codex_self_evolution/diagnostics.py +266 -0
- csep-1.0.0/src/codex_self_evolution/env_loader.py +109 -0
- csep-1.0.0/src/codex_self_evolution/hooks/__init__.py +1 -0
- csep-1.0.0/src/codex_self_evolution/hooks/session_start.py +94 -0
- csep-1.0.0/src/codex_self_evolution/logging_setup.py +124 -0
- csep-1.0.0/src/codex_self_evolution/migrate.py +334 -0
- csep-1.0.0/src/codex_self_evolution/plugin_bundle/.codex-plugin/hooks.json +26 -0
- csep-1.0.0/src/codex_self_evolution/plugin_bundle/.codex-plugin/plugin.json +34 -0
- csep-1.0.0/src/codex_self_evolution/session_recall/__init__.py +16 -0
- csep-1.0.0/src/codex_self_evolution/session_recall/archive.py +133 -0
- csep-1.0.0/src/codex_self_evolution/session_recall/models.py +28 -0
- csep-1.0.0/src/codex_self_evolution/session_recall/parser.py +170 -0
- csep-1.0.0/src/codex_self_evolution/session_recall/policy.md +25 -0
- csep-1.0.0/src/codex_self_evolution/session_recall/render.py +134 -0
- csep-1.0.0/src/codex_self_evolution/session_recall/repo.py +53 -0
- csep-1.0.0/src/codex_self_evolution/session_recall/session_recall.md +38 -0
- csep-1.0.0/src/codex_self_evolution/session_recall/store.py +391 -0
- csep-1.0.0/src/codex_self_evolution/session_recall/workflow.py +99 -0
- csep-1.0.0/src/codex_self_evolution/session_reflection/__init__.py +1 -0
- csep-1.0.0/src/codex_self_evolution/session_reflection/app_server.py +522 -0
- csep-1.0.0/src/codex_self_evolution/session_reflection/guard.py +58 -0
- csep-1.0.0/src/codex_self_evolution/session_reflection/models.py +15 -0
- csep-1.0.0/src/codex_self_evolution/session_reflection/paths.py +72 -0
- csep-1.0.0/src/codex_self_evolution/session_reflection/prompt.py +70 -0
- csep-1.0.0/src/codex_self_evolution/session_reflection/runner.py +414 -0
- csep-1.0.0/src/codex_self_evolution/session_reflection/state.py +330 -0
- csep-1.0.0/src/codex_self_evolution/session_reflection/trigger.py +463 -0
- csep-1.0.0/src/codex_self_evolution/session_reflection/validation.py +246 -0
- csep-1.0.0/src/codex_self_evolution/skill_paths.py +16 -0
- csep-1.0.0/src/codex_self_evolution/storage.py +89 -0
- csep-1.0.0/src/csep.egg-info/PKG-INFO +272 -0
- csep-1.0.0/src/csep.egg-info/SOURCES.txt +73 -0
- csep-1.0.0/src/csep.egg-info/dependency_links.txt +1 -0
- csep-1.0.0/src/csep.egg-info/entry_points.txt +3 -0
- csep-1.0.0/src/csep.egg-info/requires.txt +5 -0
- csep-1.0.0/src/csep.egg-info/top_level.txt +1 -0
- csep-1.0.0/tests/test_cli_config.py +196 -0
- csep-1.0.0/tests/test_config_file.py +104 -0
- csep-1.0.0/tests/test_config_home.py +69 -0
- csep-1.0.0/tests/test_csep_cli.py +212 -0
- csep-1.0.0/tests/test_diagnostics.py +296 -0
- csep-1.0.0/tests/test_env_loader.py +101 -0
- csep-1.0.0/tests/test_install_script.py +171 -0
- csep-1.0.0/tests/test_logging_setup.py +213 -0
- csep-1.0.0/tests/test_migrate_worktrees.py +169 -0
- csep-1.0.0/tests/test_plugin_bundle_hooks.py +133 -0
- csep-1.0.0/tests/test_session_recall_archive.py +55 -0
- csep-1.0.0/tests/test_session_recall_cli.py +79 -0
- csep-1.0.0/tests/test_session_recall_parser.py +89 -0
- csep-1.0.0/tests/test_session_recall_store.py +120 -0
- csep-1.0.0/tests/test_session_reflection_app_server.py +470 -0
- csep-1.0.0/tests/test_session_reflection_cli.py +238 -0
- csep-1.0.0/tests/test_session_reflection_config.py +180 -0
- csep-1.0.0/tests/test_session_reflection_diagnostics.py +31 -0
- csep-1.0.0/tests/test_session_reflection_guard.py +212 -0
- csep-1.0.0/tests/test_session_reflection_prompt.py +57 -0
- csep-1.0.0/tests/test_session_reflection_runner.py +846 -0
- csep-1.0.0/tests/test_session_reflection_state.py +315 -0
- csep-1.0.0/tests/test_session_reflection_trigger.py +520 -0
- csep-1.0.0/tests/test_session_reflection_validation.py +388 -0
- csep-1.0.0/tests/test_session_start.py +25 -0
- csep-1.0.0/tests/test_session_start_codex_hook.py +286 -0
- csep-1.0.0/tests/test_worktree_bucket_key.py +145 -0
csep-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 T0UGH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
csep-1.0.0/MANIFEST.in
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include tests/fixtures *.json
|
csep-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: csep
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Self-evolution loop for OpenAI Codex: session reflection, session recall, and reflection-generated skills with zero runtime dependencies.
|
|
5
|
+
Author: T0UGH
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 T0UGH
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/T0UGH/codex-self-evolution-plugin
|
|
29
|
+
Project-URL: Repository, https://github.com/T0UGH/codex-self-evolution-plugin
|
|
30
|
+
Project-URL: Issues, https://github.com/T0UGH/codex-self-evolution-plugin/issues
|
|
31
|
+
Project-URL: Documentation, https://github.com/T0UGH/codex-self-evolution-plugin/blob/main/docs/getting-started.md
|
|
32
|
+
Project-URL: Architecture, https://github.com/T0UGH/codex-self-evolution-plugin/blob/main/docs/architecture.md
|
|
33
|
+
Keywords: codex,openai,llm,memory,recall,hooks,plugin,self-evolution
|
|
34
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
35
|
+
Classifier: Intended Audience :: Developers
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Operating System :: MacOS
|
|
38
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
39
|
+
Classifier: Programming Language :: Python :: 3
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
42
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
43
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
44
|
+
Requires-Python: >=3.11
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
License-File: LICENSE
|
|
47
|
+
Provides-Extra: dev
|
|
48
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
49
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
50
|
+
Requires-Dist: twine>=5; extra == "dev"
|
|
51
|
+
Dynamic: license-file
|
|
52
|
+
|
|
53
|
+
# Codex Self-Evolution Plugin
|
|
54
|
+
|
|
55
|
+
[](https://github.com/T0UGH/codex-self-evolution-plugin/actions/workflows/test.yml)
|
|
56
|
+
[](LICENSE)
|
|
57
|
+
[](https://www.python.org/)
|
|
58
|
+
|
|
59
|
+
中文 | [English](README_en.md)
|
|
60
|
+
|
|
61
|
+
让 Codex 把每次协作变成下一次的进步。
|
|
62
|
+
|
|
63
|
+
> 用 Codex 5.3 Spark 的空闲额度,帮你的 Codex 在后台攒经验。
|
|
64
|
+
|
|
65
|
+
如果你一天开好几个 Codex session,很快会发现一个很烦的问题:它这次能把活干完,但下次还是像第一次进仓库一样。测试命令要重讲,项目边界要重讲,你刚纠正过的写法和偏好也要重讲。
|
|
66
|
+
|
|
67
|
+
当然可以自己搭一套 harness,把 prompt、脚本、知识库和日志都管起来。只是这件事太费劲了。`csep` 不要求你自己维护一整套外部流程,它直接接进 Codex 的生命周期,让 Codex 在真实使用里慢慢攒经验。
|
|
68
|
+
|
|
69
|
+
Codex Self-Evolution Plugin,简称 `csep`。它在 `SessionStart` 时把稳定背景注入 Codex 上下文;在 `Stop` 时归档 transcript;遇到值得沉淀的 session,再开一个后台 reflection worker,把经验写成 memory 或 `csep-reflect-*` skill。历史 session 会进本地 SQLite/FTS,之后可以用 `csep recall` 找回来。
|
|
70
|
+
|
|
71
|
+
它不是聊天记录备份工具。备份只能让你回看过去;`csep` 更关心下一次 Codex 能不能少问两句,少猜一点,少重复犯同一个错。
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
图里只有三条线:`SessionStart` 读 memory,`Stop` 归档 session,触发后再由 reflection worker 写 memory 和 skill。
|
|
76
|
+
|
|
77
|
+
## 为什么需要它
|
|
78
|
+
|
|
79
|
+
用了几天 Codex 后,真正消耗人的往往不是大问题,而是这些重复的小事:
|
|
80
|
+
|
|
81
|
+
- 这个仓库该怎么跑测试。
|
|
82
|
+
- 这个用户不喜欢什么风格。
|
|
83
|
+
- 哪些文件不能碰。
|
|
84
|
+
- 上次已经验证过什么方案。
|
|
85
|
+
- 某类任务应该用哪个工具、哪条命令。
|
|
86
|
+
- 哪些纠正值得变成长期规则或 skill。
|
|
87
|
+
|
|
88
|
+
`csep` 把这些经验留在本机。下次 Codex session 开始时,它们会先进入上下文;需要查旧 session 时,再用 `csep recall` 翻出来。
|
|
89
|
+
|
|
90
|
+
## 它做什么
|
|
91
|
+
|
|
92
|
+
| 能力 | 写入时机 | 下一次如何使用 |
|
|
93
|
+
| --- | --- | --- |
|
|
94
|
+
| Stable Memory | 达到 trigger 条件后,由 session reflection 写入 `USER.md` / `MEMORY.md` | `SessionStart` 自动注入 Codex 上下文 |
|
|
95
|
+
| Session Recall | `Stop` hook 把 transcript 归档到本地 SQLite/FTS | `csep recall "..."` 按当前 repo 或全局检索历史片段 |
|
|
96
|
+
| Reflection Skills | reflection worker 写入 `~/.codex/skills/csep-reflect-*` | Codex 原生 skills loader 自动加载 |
|
|
97
|
+
| Runtime Status | hooks、配置、日志、reflection job、recall DB 都可只读检查 | `csep status` 排查当前运行状态 |
|
|
98
|
+
|
|
99
|
+
每次 `Stop` 都会归档 session,但 reflection 只在计数或高信号命中后运行。
|
|
100
|
+
|
|
101
|
+
## 设计原则
|
|
102
|
+
|
|
103
|
+
- 状态默认放在 `~/.codex-self-evolution/`,不写进业务仓库。
|
|
104
|
+
- `SessionStart` / `Stop` hook 失败时尽量放行,不拖垮 Codex 正常工作。
|
|
105
|
+
- 每次 `Stop` 都会归档 session,但 reflection 不是每次都跑;只有计数或高信号命中后才 fork worker。
|
|
106
|
+
- reflection worker 写完必须留下 `receipt.json`,父进程会校验路径、hash 和 skill 命名空间。
|
|
107
|
+
- memory 写在当前 repo bucket;生成 skill 只允许落到 `csep-reflect-*`,不碰用户已有 skill。
|
|
108
|
+
- 核心包只用 Python stdlib,尽量减少安装、升级和 hook 执行时的变量。
|
|
109
|
+
|
|
110
|
+
## 安装和启用
|
|
111
|
+
|
|
112
|
+
需要本机已经有 Codex CLI,并且 Codex 支持 `plugins` / `hooks` / `plugin_hooks`。
|
|
113
|
+
|
|
114
|
+
推荐路径:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
uvx csep setup
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
这条命令会安装 `csep` CLI,把本仓库注册为 Codex plugin marketplace,并打开 `~/.codex/config.toml` 里的插件开关。装完后新开一个 Codex session,插件就会跟着生命周期 hook 运行。
|
|
121
|
+
|
|
122
|
+
没有 `uv` 的话,先装 `uv`,再跑同一条 setup:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
brew install uv
|
|
126
|
+
uvx csep setup
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
也可以直接跑安装脚本:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
curl -fsSL https://raw.githubusercontent.com/T0UGH/codex-self-evolution-plugin/main/scripts/setup.sh | bash
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
检查当前状态:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
csep status | python3 -m json.tool
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
重点看 `plugin_hooks.manifest_exists`、`plugin_hooks.session_start_declared`、`plugin_hooks.stop_declared` 是否为 `true`。之后每次 `SessionStart` 会注入 memory,每次 `Stop` 会归档 transcript;reflection 只在触发条件满足时后台运行。
|
|
142
|
+
|
|
143
|
+
想确认 recall 已经有数据,可以跑:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
csep recall --recent
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
安装、验证和排障细节见 [docs/getting-started.md](docs/getting-started.md)。
|
|
150
|
+
|
|
151
|
+
## 常用命令
|
|
152
|
+
|
|
153
|
+
日常使用基本只会碰到这几条:
|
|
154
|
+
|
|
155
|
+
| 命令 | 用途 |
|
|
156
|
+
| --- | --- |
|
|
157
|
+
| `csep setup` | 安装 CLI、注册 Codex plugin marketplace、启用 plugin hooks |
|
|
158
|
+
| `csep status` | 看插件、hook、reflection、recall 当前是否正常 |
|
|
159
|
+
| `csep config path` / `show` / `validate` | 查看配置路径、当前配置和校验结果 |
|
|
160
|
+
| `csep recall "..."` | 在当前 repo 的历史 session 里找上下文 |
|
|
161
|
+
| `csep recall --recent` | 看当前 repo 最近归档了哪些 session |
|
|
162
|
+
| `csep session-reflect --status` | reflection 没按预期运行时再看 |
|
|
163
|
+
|
|
164
|
+
`session-start`、`session-stop`、`session-archive`、`session-ingest` 主要给 hook、排障和历史回填使用。完整列表见 [docs/getting-started.md](docs/getting-started.md)。
|
|
165
|
+
|
|
166
|
+
## 性能和运行方式
|
|
167
|
+
|
|
168
|
+
`SessionStart` / `Stop` 前台只做轻量文件读写、归档触发和状态判断;模型 reflection 在后台运行,不阻塞 Codex 正常退出。
|
|
169
|
+
|
|
170
|
+
这台机器 2026-05-15 的本地日志里,最近 100 次以内的前台 hook 大致是这个量级:
|
|
171
|
+
|
|
172
|
+
| 路径 | median | p95 |
|
|
173
|
+
| --- | --- | --- |
|
|
174
|
+
| `session-start` | 26ms | 51ms |
|
|
175
|
+
| `session-stop` | 15ms | 33ms |
|
|
176
|
+
|
|
177
|
+
`session-reflect` 是后台模型任务,耗时通常按几十秒到几分钟看,不在 Codex Stop 前台等待。
|
|
178
|
+
|
|
179
|
+
## 运行时目录
|
|
180
|
+
|
|
181
|
+
默认状态目录:
|
|
182
|
+
|
|
183
|
+
```text
|
|
184
|
+
~/.codex-self-evolution/
|
|
185
|
+
├── .env.provider
|
|
186
|
+
├── config.toml
|
|
187
|
+
├── logs/
|
|
188
|
+
├── session_reflection/
|
|
189
|
+
│ ├── jobs/
|
|
190
|
+
│ ├── runs/
|
|
191
|
+
│ ├── child_threads/
|
|
192
|
+
│ ├── triggers/
|
|
193
|
+
│ ├── locks/
|
|
194
|
+
│ └── latest.json
|
|
195
|
+
├── session_recall/
|
|
196
|
+
│ └── state.db
|
|
197
|
+
└── projects/
|
|
198
|
+
└── -Users-you-code-repo/
|
|
199
|
+
└── memory/
|
|
200
|
+
├── USER.md
|
|
201
|
+
└── MEMORY.md
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
每个 repo 会按绝对路径分配独立 bucket。业务仓库保持干净,运行时状态留在用户 home 目录。
|
|
205
|
+
|
|
206
|
+
## 安全边界
|
|
207
|
+
|
|
208
|
+
`csep` 会让后台 reflection worker 读取当前 session,并写入本机文件。这里的边界要说清楚:
|
|
209
|
+
|
|
210
|
+
- provider secret 不进仓库,密钥放在 `~/.codex-self-evolution/.env.provider`。
|
|
211
|
+
- runtime state 不写进业务仓库。
|
|
212
|
+
- `csep-reflect-*` 之外的 skill 不会被当作有效产物。
|
|
213
|
+
- child thread 的口头声明不算数,父进程只认 `receipt.json` 和校验结果。
|
|
214
|
+
- hook 前台不做长耗时工作,避免影响 Codex 正常退出。
|
|
215
|
+
|
|
216
|
+
## 边界 / 不做什么
|
|
217
|
+
|
|
218
|
+
- 不是云端记忆服务。
|
|
219
|
+
- 不是团队知识库。
|
|
220
|
+
- 不是通用 agent framework。
|
|
221
|
+
- 不是旧的 reviewer / compiler / scheduler pipeline。
|
|
222
|
+
|
|
223
|
+
它只做一件事:让你本机上的 Codex session 形成可验证、可召回、能继续积累的学习闭环。
|
|
224
|
+
|
|
225
|
+
## 当前状态
|
|
226
|
+
|
|
227
|
+
能用的部分:
|
|
228
|
+
|
|
229
|
+
- Codex 启动时自动注入历史背景。
|
|
230
|
+
- Codex 停止时自动归档当前 session。
|
|
231
|
+
- 达到触发条件后,后台 reflection 会评估是否写入 memory 或 skill。
|
|
232
|
+
- memory 写入有 `receipt.json` 和父进程边界校验。
|
|
233
|
+
- 生成 skill 只允许使用 `csep-reflect-*` 前缀。
|
|
234
|
+
- `csep recall` 可以查回当前 repo 的历史 session。
|
|
235
|
+
- 同一仓库的多个 worktree 会尽量共享同一份 repo 记忆。
|
|
236
|
+
- `csep status` / `csep config` 提供只读排障入口。
|
|
237
|
+
|
|
238
|
+
还在打磨:
|
|
239
|
+
|
|
240
|
+
- first-run onboarding
|
|
241
|
+
- reflection 质量评估
|
|
242
|
+
- README 图示和演示素材
|
|
243
|
+
- Claude Code / Cursor 等其他客户端适配
|
|
244
|
+
|
|
245
|
+
## 开发
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
python3 -m venv .venv
|
|
249
|
+
.venv/bin/pip install -e '.[dev]'
|
|
250
|
+
.venv/bin/python -m pytest -q
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
也可以使用当前仓库的 `uv` 环境:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
uv run pytest -q
|
|
257
|
+
uv run python -m build
|
|
258
|
+
uv run twine check dist/*
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## 文档
|
|
262
|
+
|
|
263
|
+
| 文档 | 内容 |
|
|
264
|
+
| --- | --- |
|
|
265
|
+
| [docs/getting-started.md](docs/getting-started.md) | 本机安装、启用、验证和排障 |
|
|
266
|
+
| [docs/architecture.md](docs/architecture.md) | 当前 Memory / Reflection Skills / Session Recall 总架构 |
|
|
267
|
+
| [docs/session-reflection.md](docs/session-reflection.md) | session reflection worker、trigger policy 和写入边界 |
|
|
268
|
+
| [docs/session-recall.md](docs/session-recall.md) | SQLite/FTS session recall 的写入、检索和边界 |
|
|
269
|
+
|
|
270
|
+
## License
|
|
271
|
+
|
|
272
|
+
MIT
|
csep-1.0.0/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Codex Self-Evolution Plugin
|
|
2
|
+
|
|
3
|
+
[](https://github.com/T0UGH/codex-self-evolution-plugin/actions/workflows/test.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://www.python.org/)
|
|
6
|
+
|
|
7
|
+
中文 | [English](README_en.md)
|
|
8
|
+
|
|
9
|
+
让 Codex 把每次协作变成下一次的进步。
|
|
10
|
+
|
|
11
|
+
> 用 Codex 5.3 Spark 的空闲额度,帮你的 Codex 在后台攒经验。
|
|
12
|
+
|
|
13
|
+
如果你一天开好几个 Codex session,很快会发现一个很烦的问题:它这次能把活干完,但下次还是像第一次进仓库一样。测试命令要重讲,项目边界要重讲,你刚纠正过的写法和偏好也要重讲。
|
|
14
|
+
|
|
15
|
+
当然可以自己搭一套 harness,把 prompt、脚本、知识库和日志都管起来。只是这件事太费劲了。`csep` 不要求你自己维护一整套外部流程,它直接接进 Codex 的生命周期,让 Codex 在真实使用里慢慢攒经验。
|
|
16
|
+
|
|
17
|
+
Codex Self-Evolution Plugin,简称 `csep`。它在 `SessionStart` 时把稳定背景注入 Codex 上下文;在 `Stop` 时归档 transcript;遇到值得沉淀的 session,再开一个后台 reflection worker,把经验写成 memory 或 `csep-reflect-*` skill。历史 session 会进本地 SQLite/FTS,之后可以用 `csep recall` 找回来。
|
|
18
|
+
|
|
19
|
+
它不是聊天记录备份工具。备份只能让你回看过去;`csep` 更关心下一次 Codex 能不能少问两句,少猜一点,少重复犯同一个错。
|
|
20
|
+
|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
图里只有三条线:`SessionStart` 读 memory,`Stop` 归档 session,触发后再由 reflection worker 写 memory 和 skill。
|
|
24
|
+
|
|
25
|
+
## 为什么需要它
|
|
26
|
+
|
|
27
|
+
用了几天 Codex 后,真正消耗人的往往不是大问题,而是这些重复的小事:
|
|
28
|
+
|
|
29
|
+
- 这个仓库该怎么跑测试。
|
|
30
|
+
- 这个用户不喜欢什么风格。
|
|
31
|
+
- 哪些文件不能碰。
|
|
32
|
+
- 上次已经验证过什么方案。
|
|
33
|
+
- 某类任务应该用哪个工具、哪条命令。
|
|
34
|
+
- 哪些纠正值得变成长期规则或 skill。
|
|
35
|
+
|
|
36
|
+
`csep` 把这些经验留在本机。下次 Codex session 开始时,它们会先进入上下文;需要查旧 session 时,再用 `csep recall` 翻出来。
|
|
37
|
+
|
|
38
|
+
## 它做什么
|
|
39
|
+
|
|
40
|
+
| 能力 | 写入时机 | 下一次如何使用 |
|
|
41
|
+
| --- | --- | --- |
|
|
42
|
+
| Stable Memory | 达到 trigger 条件后,由 session reflection 写入 `USER.md` / `MEMORY.md` | `SessionStart` 自动注入 Codex 上下文 |
|
|
43
|
+
| Session Recall | `Stop` hook 把 transcript 归档到本地 SQLite/FTS | `csep recall "..."` 按当前 repo 或全局检索历史片段 |
|
|
44
|
+
| Reflection Skills | reflection worker 写入 `~/.codex/skills/csep-reflect-*` | Codex 原生 skills loader 自动加载 |
|
|
45
|
+
| Runtime Status | hooks、配置、日志、reflection job、recall DB 都可只读检查 | `csep status` 排查当前运行状态 |
|
|
46
|
+
|
|
47
|
+
每次 `Stop` 都会归档 session,但 reflection 只在计数或高信号命中后运行。
|
|
48
|
+
|
|
49
|
+
## 设计原则
|
|
50
|
+
|
|
51
|
+
- 状态默认放在 `~/.codex-self-evolution/`,不写进业务仓库。
|
|
52
|
+
- `SessionStart` / `Stop` hook 失败时尽量放行,不拖垮 Codex 正常工作。
|
|
53
|
+
- 每次 `Stop` 都会归档 session,但 reflection 不是每次都跑;只有计数或高信号命中后才 fork worker。
|
|
54
|
+
- reflection worker 写完必须留下 `receipt.json`,父进程会校验路径、hash 和 skill 命名空间。
|
|
55
|
+
- memory 写在当前 repo bucket;生成 skill 只允许落到 `csep-reflect-*`,不碰用户已有 skill。
|
|
56
|
+
- 核心包只用 Python stdlib,尽量减少安装、升级和 hook 执行时的变量。
|
|
57
|
+
|
|
58
|
+
## 安装和启用
|
|
59
|
+
|
|
60
|
+
需要本机已经有 Codex CLI,并且 Codex 支持 `plugins` / `hooks` / `plugin_hooks`。
|
|
61
|
+
|
|
62
|
+
推荐路径:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
uvx csep setup
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
这条命令会安装 `csep` CLI,把本仓库注册为 Codex plugin marketplace,并打开 `~/.codex/config.toml` 里的插件开关。装完后新开一个 Codex session,插件就会跟着生命周期 hook 运行。
|
|
69
|
+
|
|
70
|
+
没有 `uv` 的话,先装 `uv`,再跑同一条 setup:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
brew install uv
|
|
74
|
+
uvx csep setup
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
也可以直接跑安装脚本:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
curl -fsSL https://raw.githubusercontent.com/T0UGH/codex-self-evolution-plugin/main/scripts/setup.sh | bash
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
检查当前状态:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
csep status | python3 -m json.tool
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
重点看 `plugin_hooks.manifest_exists`、`plugin_hooks.session_start_declared`、`plugin_hooks.stop_declared` 是否为 `true`。之后每次 `SessionStart` 会注入 memory,每次 `Stop` 会归档 transcript;reflection 只在触发条件满足时后台运行。
|
|
90
|
+
|
|
91
|
+
想确认 recall 已经有数据,可以跑:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
csep recall --recent
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
安装、验证和排障细节见 [docs/getting-started.md](docs/getting-started.md)。
|
|
98
|
+
|
|
99
|
+
## 常用命令
|
|
100
|
+
|
|
101
|
+
日常使用基本只会碰到这几条:
|
|
102
|
+
|
|
103
|
+
| 命令 | 用途 |
|
|
104
|
+
| --- | --- |
|
|
105
|
+
| `csep setup` | 安装 CLI、注册 Codex plugin marketplace、启用 plugin hooks |
|
|
106
|
+
| `csep status` | 看插件、hook、reflection、recall 当前是否正常 |
|
|
107
|
+
| `csep config path` / `show` / `validate` | 查看配置路径、当前配置和校验结果 |
|
|
108
|
+
| `csep recall "..."` | 在当前 repo 的历史 session 里找上下文 |
|
|
109
|
+
| `csep recall --recent` | 看当前 repo 最近归档了哪些 session |
|
|
110
|
+
| `csep session-reflect --status` | reflection 没按预期运行时再看 |
|
|
111
|
+
|
|
112
|
+
`session-start`、`session-stop`、`session-archive`、`session-ingest` 主要给 hook、排障和历史回填使用。完整列表见 [docs/getting-started.md](docs/getting-started.md)。
|
|
113
|
+
|
|
114
|
+
## 性能和运行方式
|
|
115
|
+
|
|
116
|
+
`SessionStart` / `Stop` 前台只做轻量文件读写、归档触发和状态判断;模型 reflection 在后台运行,不阻塞 Codex 正常退出。
|
|
117
|
+
|
|
118
|
+
这台机器 2026-05-15 的本地日志里,最近 100 次以内的前台 hook 大致是这个量级:
|
|
119
|
+
|
|
120
|
+
| 路径 | median | p95 |
|
|
121
|
+
| --- | --- | --- |
|
|
122
|
+
| `session-start` | 26ms | 51ms |
|
|
123
|
+
| `session-stop` | 15ms | 33ms |
|
|
124
|
+
|
|
125
|
+
`session-reflect` 是后台模型任务,耗时通常按几十秒到几分钟看,不在 Codex Stop 前台等待。
|
|
126
|
+
|
|
127
|
+
## 运行时目录
|
|
128
|
+
|
|
129
|
+
默认状态目录:
|
|
130
|
+
|
|
131
|
+
```text
|
|
132
|
+
~/.codex-self-evolution/
|
|
133
|
+
├── .env.provider
|
|
134
|
+
├── config.toml
|
|
135
|
+
├── logs/
|
|
136
|
+
├── session_reflection/
|
|
137
|
+
│ ├── jobs/
|
|
138
|
+
│ ├── runs/
|
|
139
|
+
│ ├── child_threads/
|
|
140
|
+
│ ├── triggers/
|
|
141
|
+
│ ├── locks/
|
|
142
|
+
│ └── latest.json
|
|
143
|
+
├── session_recall/
|
|
144
|
+
│ └── state.db
|
|
145
|
+
└── projects/
|
|
146
|
+
└── -Users-you-code-repo/
|
|
147
|
+
└── memory/
|
|
148
|
+
├── USER.md
|
|
149
|
+
└── MEMORY.md
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
每个 repo 会按绝对路径分配独立 bucket。业务仓库保持干净,运行时状态留在用户 home 目录。
|
|
153
|
+
|
|
154
|
+
## 安全边界
|
|
155
|
+
|
|
156
|
+
`csep` 会让后台 reflection worker 读取当前 session,并写入本机文件。这里的边界要说清楚:
|
|
157
|
+
|
|
158
|
+
- provider secret 不进仓库,密钥放在 `~/.codex-self-evolution/.env.provider`。
|
|
159
|
+
- runtime state 不写进业务仓库。
|
|
160
|
+
- `csep-reflect-*` 之外的 skill 不会被当作有效产物。
|
|
161
|
+
- child thread 的口头声明不算数,父进程只认 `receipt.json` 和校验结果。
|
|
162
|
+
- hook 前台不做长耗时工作,避免影响 Codex 正常退出。
|
|
163
|
+
|
|
164
|
+
## 边界 / 不做什么
|
|
165
|
+
|
|
166
|
+
- 不是云端记忆服务。
|
|
167
|
+
- 不是团队知识库。
|
|
168
|
+
- 不是通用 agent framework。
|
|
169
|
+
- 不是旧的 reviewer / compiler / scheduler pipeline。
|
|
170
|
+
|
|
171
|
+
它只做一件事:让你本机上的 Codex session 形成可验证、可召回、能继续积累的学习闭环。
|
|
172
|
+
|
|
173
|
+
## 当前状态
|
|
174
|
+
|
|
175
|
+
能用的部分:
|
|
176
|
+
|
|
177
|
+
- Codex 启动时自动注入历史背景。
|
|
178
|
+
- Codex 停止时自动归档当前 session。
|
|
179
|
+
- 达到触发条件后,后台 reflection 会评估是否写入 memory 或 skill。
|
|
180
|
+
- memory 写入有 `receipt.json` 和父进程边界校验。
|
|
181
|
+
- 生成 skill 只允许使用 `csep-reflect-*` 前缀。
|
|
182
|
+
- `csep recall` 可以查回当前 repo 的历史 session。
|
|
183
|
+
- 同一仓库的多个 worktree 会尽量共享同一份 repo 记忆。
|
|
184
|
+
- `csep status` / `csep config` 提供只读排障入口。
|
|
185
|
+
|
|
186
|
+
还在打磨:
|
|
187
|
+
|
|
188
|
+
- first-run onboarding
|
|
189
|
+
- reflection 质量评估
|
|
190
|
+
- README 图示和演示素材
|
|
191
|
+
- Claude Code / Cursor 等其他客户端适配
|
|
192
|
+
|
|
193
|
+
## 开发
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
python3 -m venv .venv
|
|
197
|
+
.venv/bin/pip install -e '.[dev]'
|
|
198
|
+
.venv/bin/python -m pytest -q
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
也可以使用当前仓库的 `uv` 环境:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
uv run pytest -q
|
|
205
|
+
uv run python -m build
|
|
206
|
+
uv run twine check dist/*
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## 文档
|
|
210
|
+
|
|
211
|
+
| 文档 | 内容 |
|
|
212
|
+
| --- | --- |
|
|
213
|
+
| [docs/getting-started.md](docs/getting-started.md) | 本机安装、启用、验证和排障 |
|
|
214
|
+
| [docs/architecture.md](docs/architecture.md) | 当前 Memory / Reflection Skills / Session Recall 总架构 |
|
|
215
|
+
| [docs/session-reflection.md](docs/session-reflection.md) | session reflection worker、trigger policy 和写入边界 |
|
|
216
|
+
| [docs/session-recall.md](docs/session-recall.md) | SQLite/FTS session recall 的写入、检索和边界 |
|
|
217
|
+
|
|
218
|
+
## License
|
|
219
|
+
|
|
220
|
+
MIT
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "csep"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Self-evolution loop for OpenAI Codex: session reflection, session recall, and reflection-generated skills with zero runtime dependencies."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "T0UGH" },
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"codex",
|
|
17
|
+
"openai",
|
|
18
|
+
"llm",
|
|
19
|
+
"memory",
|
|
20
|
+
"recall",
|
|
21
|
+
"hooks",
|
|
22
|
+
"plugin",
|
|
23
|
+
"self-evolution",
|
|
24
|
+
]
|
|
25
|
+
# Keep runtime deps empty — the plugin only uses stdlib. If you ever add a real
|
|
26
|
+
# dep, also update the "zero runtime dependencies" wording in the description
|
|
27
|
+
# above and in README.
|
|
28
|
+
dependencies = []
|
|
29
|
+
|
|
30
|
+
# Classifiers drive PyPI search + the project page sidebar. Keep the list
|
|
31
|
+
# narrow: only things that are actually true of this package.
|
|
32
|
+
classifiers = [
|
|
33
|
+
"Development Status :: 5 - Production/Stable",
|
|
34
|
+
"Intended Audience :: Developers",
|
|
35
|
+
"License :: OSI Approved :: MIT License",
|
|
36
|
+
"Operating System :: MacOS",
|
|
37
|
+
"Operating System :: POSIX :: Linux",
|
|
38
|
+
"Programming Language :: Python :: 3",
|
|
39
|
+
"Programming Language :: Python :: 3.11",
|
|
40
|
+
"Programming Language :: Python :: 3.12",
|
|
41
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
42
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[project.urls]
|
|
46
|
+
Homepage = "https://github.com/T0UGH/codex-self-evolution-plugin"
|
|
47
|
+
Repository = "https://github.com/T0UGH/codex-self-evolution-plugin"
|
|
48
|
+
Issues = "https://github.com/T0UGH/codex-self-evolution-plugin/issues"
|
|
49
|
+
Documentation = "https://github.com/T0UGH/codex-self-evolution-plugin/blob/main/docs/getting-started.md"
|
|
50
|
+
Architecture = "https://github.com/T0UGH/codex-self-evolution-plugin/blob/main/docs/architecture.md"
|
|
51
|
+
|
|
52
|
+
[project.optional-dependencies]
|
|
53
|
+
# `pip install csep[dev]` for contributors.
|
|
54
|
+
dev = ["pytest>=7", "build>=1.0", "twine>=5"]
|
|
55
|
+
|
|
56
|
+
[project.scripts]
|
|
57
|
+
codex-self-evolution = "codex_self_evolution.cli:main"
|
|
58
|
+
csep = "codex_self_evolution.csep:main"
|
|
59
|
+
|
|
60
|
+
[tool.setuptools]
|
|
61
|
+
package-dir = {"" = "src"}
|
|
62
|
+
|
|
63
|
+
[tool.setuptools.package-data]
|
|
64
|
+
codex_self_evolution = [
|
|
65
|
+
"session_recall/policy.md",
|
|
66
|
+
"session_recall/session_recall.md",
|
|
67
|
+
"plugin_bundle/.codex-plugin/plugin.json",
|
|
68
|
+
"plugin_bundle/.codex-plugin/hooks.json",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
[tool.setuptools.packages.find]
|
|
72
|
+
where = ["src"]
|
|
73
|
+
|
|
74
|
+
[tool.pytest.ini_options]
|
|
75
|
+
testpaths = ["tests"]
|
|
76
|
+
pythonpath = ["src"]
|
csep-1.0.0/setup.cfg
ADDED