Skip to content

Commit 5ac3fed

Browse files
committed
release: publish csep 1.0.0
1 parent 1f44235 commit 5ac3fed

57 files changed

Lines changed: 1029 additions & 21458 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 118 additions & 180 deletions
Large diffs are not rendered by default.

‎README_en.md‎

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# Codex Self-Evolution Plugin
2+
3+
[![tests](https://github.com/T0UGH/codex-self-evolution-plugin/actions/workflows/test.yml/badge.svg)](https://github.com/T0UGH/codex-self-evolution-plugin/actions/workflows/test.yml)
4+
[![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5+
[![python: 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/)
6+
7+
[中文](README.md) | English
8+
9+
Turn every Codex session into progress for the next one.
10+
11+
> Use your idle Codex 5.3 Spark quota to let Codex build up experience in the background.
12+
13+
If you run several Codex sessions a day, the annoying part shows up quickly: Codex can finish the current task, but the next session still walks into the repo like it has never been there. You repeat the test command, the project boundaries, and the style preferences you just corrected.
14+
15+
You can build a full harness yourself and manage prompts, scripts, knowledge files, and logs. That works, but it is a lot of machinery. `csep` takes the smaller path: it hooks into the Codex lifecycle and lets Codex accumulate experience from real work.
16+
17+
Codex Self-Evolution Plugin, or `csep`, injects stable background into Codex during `SessionStart`; archives the transcript on `Stop`; and, when a session is worth keeping, starts a background reflection worker that writes memory or `csep-reflect-*` skills. Historical sessions are stored locally in SQLite/FTS and can be searched later with `csep recall`.
18+
19+
This is not a chat-history backup tool. Backups let you look back. `csep` is about making the next Codex session ask less, guess less, and repeat fewer mistakes.
20+
21+
![Codex Self-Evolution data flow](docs/assets/readme-csep-data-flow.png)
22+
23+
The diagram has three lines: `SessionStart` reads memory, `Stop` archives sessions, and the reflection worker writes memory and skills when the trigger policy fires.
24+
25+
## Why It Exists
26+
27+
After a few days with Codex, the real drag is usually not the big task. It is the small repeated context:
28+
29+
- How this repo runs tests.
30+
- What style the user dislikes.
31+
- Which files should not be touched.
32+
- Which approach was already verified last time.
33+
- Which tool or command should be used for a recurring task.
34+
- Which correction is worth turning into a long-lived rule or skill.
35+
36+
`csep` keeps that experience on your machine. At the start of the next Codex session, the stable parts are injected into context. When you need details from past work, `csep recall` searches previous sessions.
37+
38+
## What It Does
39+
40+
| Capability | When it writes | How the next session uses it |
41+
| --- | --- | --- |
42+
| Stable Memory | After the trigger policy fires, session reflection writes `USER.md` / `MEMORY.md` | `SessionStart` injects it into Codex context |
43+
| Session Recall | The `Stop` hook archives transcripts into local SQLite/FTS | `csep recall "..."` searches past sessions by repo or globally |
44+
| Reflection Skills | The reflection worker writes `~/.codex/skills/csep-reflect-*` | Codex loads them through the native skills loader |
45+
| Runtime Status | Hooks, config, logs, reflection jobs, and recall DB are read-only inspectable | `csep status` shows the current runtime state |
46+
47+
Every `Stop` archives the session, but reflection only runs when counters or high-signal keywords hit the trigger policy.
48+
49+
## Design Principles
50+
51+
- Runtime state lives under `~/.codex-self-evolution/`, not in your application repo.
52+
- `SessionStart` / `Stop` hook failures should not break normal Codex work.
53+
- Every `Stop` archives, but not every `Stop` reflects.
54+
- Reflection writes must leave a `receipt.json`; the parent process validates paths, hashes, and skill namespaces.
55+
- Memory writes stay in the current repo bucket; generated skills must use the `csep-reflect-*` prefix.
56+
- The core package uses only the Python standard library to keep install and hook behavior predictable.
57+
58+
## Install And Enable
59+
60+
You need Codex CLI, and your Codex version must support `plugins`, `hooks`, and `plugin_hooks`.
61+
62+
Recommended path:
63+
64+
```bash
65+
uvx csep setup
66+
```
67+
68+
This installs the `csep` CLI, registers this repo as a Codex plugin marketplace source, and enables the plugin in `~/.codex/config.toml`. Start a new Codex session after setup and the lifecycle hooks will run.
69+
70+
If you do not have `uv` yet:
71+
72+
```bash
73+
brew install uv
74+
uvx csep setup
75+
```
76+
77+
You can also use the setup script:
78+
79+
```bash
80+
curl -fsSL https://raw.githubusercontent.com/T0UGH/codex-self-evolution-plugin/main/scripts/setup.sh | bash
81+
```
82+
83+
Check the current state:
84+
85+
```bash
86+
csep status | python3 -m json.tool
87+
```
88+
89+
Look for `plugin_hooks.manifest_exists`, `plugin_hooks.session_start_declared`, and `plugin_hooks.stop_declared` to be `true`. After that, every `SessionStart` injects memory, every `Stop` archives the transcript, and reflection runs in the background only when triggered.
90+
91+
To check whether recall has data:
92+
93+
```bash
94+
csep recall --recent
95+
```
96+
97+
For detailed setup, verification, and troubleshooting, see [docs/getting-started.md](docs/getting-started.md).
98+
99+
## Common Commands
100+
101+
Most day-to-day use only needs these commands:
102+
103+
| Command | Purpose |
104+
| --- | --- |
105+
| `csep setup` | Install the CLI, register the Codex plugin marketplace source, and enable plugin hooks |
106+
| `csep status` | Inspect plugin, hook, reflection, and recall runtime state |
107+
| `csep config path` / `show` / `validate` | Inspect config path, resolved config, and validation result |
108+
| `csep recall "..."` | Search prior sessions for the current repo |
109+
| `csep recall --recent` | List recently archived sessions for the current repo |
110+
| `csep session-reflect --status` | Inspect reflection jobs when something looks wrong |
111+
112+
`session-start`, `session-stop`, `session-archive`, and `session-ingest` are mainly for hooks, troubleshooting, and historical backfill. See [docs/getting-started.md](docs/getting-started.md) for the full command surface.
113+
114+
## Performance And Runtime Behavior
115+
116+
The foreground `SessionStart` / `Stop` hooks only do light file reads, archive-trigger bookkeeping, and state checks. Model reflection runs in the background and does not block normal Codex shutdown.
117+
118+
On this machine, local logs from May 15, 2026 showed this foreground hook range over the most recent samples:
119+
120+
| Path | median | p95 |
121+
| --- | --- | --- |
122+
| `session-start` | 26ms | 51ms |
123+
| `session-stop` | 15ms | 33ms |
124+
125+
`session-reflect` is a background model task. Expect seconds to minutes, but it is not waited on by the Codex Stop hook.
126+
127+
## Runtime Directory
128+
129+
Default runtime root:
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+
Each repo gets a bucket based on its absolute path. Application repos stay clean; runtime state stays in the user's home directory.
153+
154+
## Safety Boundaries
155+
156+
`csep` lets a background reflection worker read the current session and write local files, so the boundary is explicit:
157+
158+
- Provider secrets do not go into the repo. Put them in `~/.codex-self-evolution/.env.provider`.
159+
- Runtime state does not get written into application repos.
160+
- Skills outside the `csep-reflect-*` namespace are not accepted as generated artifacts.
161+
- The child thread's natural-language claim is not trusted; the parent process validates `receipt.json`.
162+
- Foreground hooks do not run long model work, so Codex can exit normally.
163+
164+
## Boundaries / Non-Goals
165+
166+
- Not a cloud memory service.
167+
- Not a team knowledge base.
168+
- Not a general agent framework.
169+
- Not the old reviewer / compiler / scheduler pipeline.
170+
171+
It does one thing: turn local Codex sessions into a learning loop that can be verified, recalled, and extended over time.
172+
173+
## Current Status
174+
175+
Available today:
176+
177+
- Codex start automatically injects historical background.
178+
- Codex stop automatically archives the current session.
179+
- Triggered background reflection can decide whether to write memory or skills.
180+
- Memory writes are protected by `receipt.json` and parent-process validation.
181+
- Generated skills are restricted to the `csep-reflect-*` prefix.
182+
- `csep recall` can search previous sessions for the current repo.
183+
- Multiple worktrees of the same repo try to share the same repo memory.
184+
- `csep status` / `csep config` provide read-only troubleshooting entry points.
185+
186+
Still being refined:
187+
188+
- First-run onboarding
189+
- Reflection quality evaluation
190+
- README diagrams and demo assets
191+
- Claude Code / Cursor and other client support
192+
193+
## Development
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+
You can also use the repo's `uv` environment:
202+
203+
```bash
204+
uv run pytest -q
205+
uv run python -m build
206+
uv run twine check dist/*
207+
```
208+
209+
## Docs
210+
211+
| Doc | What it covers |
212+
| --- | --- |
213+
| [docs/getting-started.md](docs/getting-started.md) | Local install, enablement, verification, and troubleshooting |
214+
| [docs/architecture.md](docs/architecture.md) | Current Memory / Reflection Skills / Session Recall architecture |
215+
| [docs/session-reflection.md](docs/session-reflection.md) | Session reflection worker, trigger policy, and write boundaries |
216+
| [docs/session-recall.md](docs/session-recall.md) | SQLite/FTS session recall writes, search, and boundaries |
217+
218+
## License
219+
220+
MIT

0 commit comments

Comments
 (0)