exitproof 0.1.0__tar.gz → 0.2.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.
- {exitproof-0.1.0 → exitproof-0.2.0}/.claude-plugin/plugin.json +1 -1
- {exitproof-0.1.0 → exitproof-0.2.0}/PKG-INFO +27 -3
- {exitproof-0.1.0 → exitproof-0.2.0}/README.md +26 -2
- exitproof-0.2.0/docs/demo.py +87 -0
- exitproof-0.2.0/docs/demo.svg +1 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/pyproject.toml +1 -1
- {exitproof-0.1.0 → exitproof-0.2.0}/src/exitproof/__init__.py +10 -9
- {exitproof-0.1.0 → exitproof-0.2.0}/tests/test_cli.py +25 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/.claude-plugin/icon.png +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/.claude-plugin/marketplace.json +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/.github/workflows/ci.yml +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/.github/workflows/publish.yml +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/.gitignore +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/LICENSE +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/Makefile +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/hooks/hooks.json +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/src/exitproof/__main__.py +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/tests/fixtures/cargo_green.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/tests/fixtures/cargo_red.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/tests/fixtures/jest_green.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/tests/fixtures/jest_red.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/tests/fixtures/pytest_empty.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/tests/fixtures/pytest_green.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/tests/fixtures/pytest_red.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/tests/fixtures/unittest_green.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/tests/fixtures/unittest_red.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/tests/fixtures/vitest_green.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/tests/fixtures/vitest_red.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.2.0}/tests/test_parse.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exitproof",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Blocks the agent from finishing while its file changes are not covered by a green test run on the current files.",
|
|
5
5
|
"repository": "https://github.com/RAFAELDCOELHO/exitproof",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: exitproof
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Receipts for test runs: your coding agent can't say 'all tests pass' unless they did, on the current files.
|
|
5
5
|
Project-URL: Homepage, https://github.com/RAFAELDCOELHO/exitproof
|
|
6
6
|
Project-URL: Issues, https://github.com/RAFAELDCOELHO/exitproof/issues
|
|
@@ -16,8 +16,14 @@ Description-Content-Type: text/markdown
|
|
|
16
16
|
|
|
17
17
|
# exitproof
|
|
18
18
|
|
|
19
|
+
[](https://github.com/RAFAELDCOELHO/exitproof/actions/workflows/ci.yml)
|
|
20
|
+
|
|
19
21
|
Receipts for test runs, so "all tests pass" has to be true.
|
|
20
22
|
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
<sub>Real output, regenerated by [`docs/demo.py`](docs/demo.py).</sub>
|
|
26
|
+
|
|
21
27
|
Coding agents (Claude Code, Codex, and friends) sometimes report "all tests pass" when:
|
|
22
28
|
|
|
23
29
|
- they never re-ran the tests after their last edit,
|
|
@@ -33,7 +39,7 @@ Pure Python standard library, Python 3.9+, no dependencies.
|
|
|
33
39
|
```sh
|
|
34
40
|
uv tool install exitproof # or: pipx install exitproof
|
|
35
41
|
cd your-repo
|
|
36
|
-
exitproof install claude # add the Claude Code hooks
|
|
42
|
+
exitproof install claude # add the Claude Code hooks (or: exitproof install codex)
|
|
37
43
|
exitproof run -- pytest -q # run your tests through exitproof
|
|
38
44
|
exitproof check # exit 0 only if every recorded command is green on the current files
|
|
39
45
|
```
|
|
@@ -44,6 +50,8 @@ Or install the hooks as a Claude Code plugin (no PATH setup; needs `python3`):
|
|
|
44
50
|
/plugin install exitproof --marketplace RAFAELDCOELHO/exitproof
|
|
45
51
|
```
|
|
46
52
|
|
|
53
|
+
From a shell: `claude plugin install exitproof --marketplace RAFAELDCOELHO/exitproof`.
|
|
54
|
+
|
|
47
55
|
Any command works, not just pytest: `exitproof run -- npm test`, `exitproof run -- cargo test`, `exitproof run "make test && make lint"`.
|
|
48
56
|
|
|
49
57
|
## What it looks like
|
|
@@ -118,7 +126,7 @@ What the hooks do:
|
|
|
118
126
|
|
|
119
127
|
- After 3 blocks in one turn it lets the agent stop, so it can never loop forever. You get a visible message instead: `exitproof: agent stopped with unproven changes: ...`.
|
|
120
128
|
|
|
121
|
-
The block message tells the agent how to call exitproof: `exitproof` if it is on `PATH` (installed with `uv tool` or `pipx`), otherwise the full `python
|
|
129
|
+
The block message tells the agent how to call exitproof: `exitproof` if it is on `PATH` (installed with `uv tool` or `pipx`), otherwise the full command for the plugin's own copy (`"<python>" "<plugin>/src/exitproof/__main__.py" run -- ...`). That long command is awkward to allow in Claude Code's permission rules, so with the plugin it is easier to also `uv tool install exitproof` and allow `Bash(exitproof run:*)`.
|
|
122
130
|
|
|
123
131
|
### Tried on a real agent
|
|
124
132
|
|
|
@@ -126,6 +134,18 @@ In a scratch repo (`calc.py` plus one pytest test, hooks installed), a headless
|
|
|
126
134
|
|
|
127
135
|
When exitproof blocks, Claude Code may show a "stop hook" notice in the UI. That notice is the block working, not a crash.
|
|
128
136
|
|
|
137
|
+
## With Codex CLI
|
|
138
|
+
|
|
139
|
+
```console
|
|
140
|
+
$ exitproof install codex
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
This writes the same two hooks (SessionStart and Stop) to `.codex/hooks.json`. Use `--user` to write `~/.codex/hooks.json` instead. Codex uses the same hook shape and the same `{"decision": "block", "reason": ...}` reply as Claude Code. A block turns the reason into a new prompt, and the agent keeps working.
|
|
144
|
+
|
|
145
|
+
Codex runs only the hooks you have reviewed and trusted. After installing, open `/hooks` in Codex and trust both exitproof hooks. Project hooks in `.codex/hooks.json` also load only when the project itself is trusted. Until you trust them, Codex skips the hooks and exitproof does nothing.
|
|
146
|
+
|
|
147
|
+
Status: the hook input and output follow the [Codex hooks docs](https://learn.chatgpt.com/docs/hooks) and are covered by a test that feeds Codex-shaped events to the installed commands. It has not yet been tried in a real Codex session.
|
|
148
|
+
|
|
129
149
|
## In CI or a pre-push hook
|
|
130
150
|
|
|
131
151
|
In CI there is no history, so run and check in one step. `--strict` turns "green but skipped" and "green but ran nothing" into failures:
|
|
@@ -159,6 +179,10 @@ exec exitproof check
|
|
|
159
179
|
- **Git repos only, in practice.** Outside a git repo, runs are recorded but no fingerprint is taken, so staleness cannot be detected.
|
|
160
180
|
- **The fingerprint rereads every file** on each run and check. That is fine for typical repos but slow for very large ones.
|
|
161
181
|
|
|
182
|
+
## Related
|
|
183
|
+
|
|
184
|
+
- [greenlie](https://github.com/RAFAELDCOELHO/greenlie): a benchmark asking whether coding agents notice when the test runner gives a misleading green signal, or pass it on to the user.
|
|
185
|
+
|
|
162
186
|
## License
|
|
163
187
|
|
|
164
188
|
MIT
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
# exitproof
|
|
2
2
|
|
|
3
|
+
[](https://github.com/RAFAELDCOELHO/exitproof/actions/workflows/ci.yml)
|
|
4
|
+
|
|
3
5
|
Receipts for test runs, so "all tests pass" has to be true.
|
|
4
6
|
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
<sub>Real output, regenerated by [`docs/demo.py`](docs/demo.py).</sub>
|
|
10
|
+
|
|
5
11
|
Coding agents (Claude Code, Codex, and friends) sometimes report "all tests pass" when:
|
|
6
12
|
|
|
7
13
|
- they never re-ran the tests after their last edit,
|
|
@@ -17,7 +23,7 @@ Pure Python standard library, Python 3.9+, no dependencies.
|
|
|
17
23
|
```sh
|
|
18
24
|
uv tool install exitproof # or: pipx install exitproof
|
|
19
25
|
cd your-repo
|
|
20
|
-
exitproof install claude # add the Claude Code hooks
|
|
26
|
+
exitproof install claude # add the Claude Code hooks (or: exitproof install codex)
|
|
21
27
|
exitproof run -- pytest -q # run your tests through exitproof
|
|
22
28
|
exitproof check # exit 0 only if every recorded command is green on the current files
|
|
23
29
|
```
|
|
@@ -28,6 +34,8 @@ Or install the hooks as a Claude Code plugin (no PATH setup; needs `python3`):
|
|
|
28
34
|
/plugin install exitproof --marketplace RAFAELDCOELHO/exitproof
|
|
29
35
|
```
|
|
30
36
|
|
|
37
|
+
From a shell: `claude plugin install exitproof --marketplace RAFAELDCOELHO/exitproof`.
|
|
38
|
+
|
|
31
39
|
Any command works, not just pytest: `exitproof run -- npm test`, `exitproof run -- cargo test`, `exitproof run "make test && make lint"`.
|
|
32
40
|
|
|
33
41
|
## What it looks like
|
|
@@ -102,7 +110,7 @@ What the hooks do:
|
|
|
102
110
|
|
|
103
111
|
- After 3 blocks in one turn it lets the agent stop, so it can never loop forever. You get a visible message instead: `exitproof: agent stopped with unproven changes: ...`.
|
|
104
112
|
|
|
105
|
-
The block message tells the agent how to call exitproof: `exitproof` if it is on `PATH` (installed with `uv tool` or `pipx`), otherwise the full `python
|
|
113
|
+
The block message tells the agent how to call exitproof: `exitproof` if it is on `PATH` (installed with `uv tool` or `pipx`), otherwise the full command for the plugin's own copy (`"<python>" "<plugin>/src/exitproof/__main__.py" run -- ...`). That long command is awkward to allow in Claude Code's permission rules, so with the plugin it is easier to also `uv tool install exitproof` and allow `Bash(exitproof run:*)`.
|
|
106
114
|
|
|
107
115
|
### Tried on a real agent
|
|
108
116
|
|
|
@@ -110,6 +118,18 @@ In a scratch repo (`calc.py` plus one pytest test, hooks installed), a headless
|
|
|
110
118
|
|
|
111
119
|
When exitproof blocks, Claude Code may show a "stop hook" notice in the UI. That notice is the block working, not a crash.
|
|
112
120
|
|
|
121
|
+
## With Codex CLI
|
|
122
|
+
|
|
123
|
+
```console
|
|
124
|
+
$ exitproof install codex
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
This writes the same two hooks (SessionStart and Stop) to `.codex/hooks.json`. Use `--user` to write `~/.codex/hooks.json` instead. Codex uses the same hook shape and the same `{"decision": "block", "reason": ...}` reply as Claude Code. A block turns the reason into a new prompt, and the agent keeps working.
|
|
128
|
+
|
|
129
|
+
Codex runs only the hooks you have reviewed and trusted. After installing, open `/hooks` in Codex and trust both exitproof hooks. Project hooks in `.codex/hooks.json` also load only when the project itself is trusted. Until you trust them, Codex skips the hooks and exitproof does nothing.
|
|
130
|
+
|
|
131
|
+
Status: the hook input and output follow the [Codex hooks docs](https://learn.chatgpt.com/docs/hooks) and are covered by a test that feeds Codex-shaped events to the installed commands. It has not yet been tried in a real Codex session.
|
|
132
|
+
|
|
113
133
|
## In CI or a pre-push hook
|
|
114
134
|
|
|
115
135
|
In CI there is no history, so run and check in one step. `--strict` turns "green but skipped" and "green but ran nothing" into failures:
|
|
@@ -143,6 +163,10 @@ exec exitproof check
|
|
|
143
163
|
- **Git repos only, in practice.** Outside a git repo, runs are recorded but no fingerprint is taken, so staleness cannot be detected.
|
|
144
164
|
- **The fingerprint rereads every file** on each run and check. That is fine for typical repos but slow for very large ones.
|
|
145
165
|
|
|
166
|
+
## Related
|
|
167
|
+
|
|
168
|
+
- [greenlie](https://github.com/RAFAELDCOELHO/greenlie): a benchmark asking whether coding agents notice when the test runner gives a misleading green signal, or pass it on to the user.
|
|
169
|
+
|
|
146
170
|
## License
|
|
147
171
|
|
|
148
172
|
MIT
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Regenerate docs/demo.svg from a REAL run in a temp git repo.
|
|
2
|
+
|
|
3
|
+
uv run --no-project --with pytest python docs/demo.py
|
|
4
|
+
|
|
5
|
+
`exitproof` and `pytest` are shims on PATH that run this checkout's code with the current Python.
|
|
6
|
+
Long pytest failure bodies are cut to their summary lines and marked with [...].
|
|
7
|
+
"""
|
|
8
|
+
import html
|
|
9
|
+
import os
|
|
10
|
+
import subprocess
|
|
11
|
+
import sys
|
|
12
|
+
import tempfile
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
16
|
+
# no bytecode: a same-size edit within the same second would otherwise run the stale .pyc
|
|
17
|
+
ENV = {**os.environ, "PYTHONPATH": str(ROOT / "src"), "NO_COLOR": "1", "PYTHONDONTWRITEBYTECODE": "1"}
|
|
18
|
+
SCRIPT = [
|
|
19
|
+
("exitproof run -- pytest -q", None),
|
|
20
|
+
("exitproof check", None),
|
|
21
|
+
("perl -pi -e 's/a \\+ b/a - b/' calc.py", "# the agent edits calc.py..."),
|
|
22
|
+
("exitproof check", None),
|
|
23
|
+
("exitproof run -- pytest -q", None),
|
|
24
|
+
("exitproof check", None),
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def capture() -> list[tuple[str, str]]:
|
|
29
|
+
lines = []
|
|
30
|
+
with tempfile.TemporaryDirectory() as d, tempfile.TemporaryDirectory() as bin_dir:
|
|
31
|
+
# shims so every command runs exactly as displayed (and records `pytest -q`, not a local path)
|
|
32
|
+
for name, target in (("exitproof", "-m exitproof"), ("pytest", "-m pytest -p no:cacheprovider")):
|
|
33
|
+
shim = Path(bin_dir, name)
|
|
34
|
+
shim.write_text(f'#!/bin/sh\nexec "{sys.executable}" {target} "$@"\n')
|
|
35
|
+
shim.chmod(0o755)
|
|
36
|
+
env = {**ENV, "PATH": bin_dir + os.pathsep + ENV["PATH"]}
|
|
37
|
+
subprocess.run(["git", "init", "-q"], cwd=d, check=True)
|
|
38
|
+
Path(d, "calc.py").write_text("def add(a, b):\n return a + b\n")
|
|
39
|
+
Path(d, "test_calc.py").write_text(
|
|
40
|
+
"from calc import add\n\ndef test_add():\n assert add(2, 2) == 4\n\n"
|
|
41
|
+
"def test_neg():\n assert add(-1, -1) == -2\n")
|
|
42
|
+
for cmd, comment in SCRIPT:
|
|
43
|
+
if comment:
|
|
44
|
+
lines.append(("comment", comment))
|
|
45
|
+
lines.append(("cmd", cmd))
|
|
46
|
+
p = subprocess.run(cmd, shell=True, cwd=d, env=env, stdout=subprocess.PIPE,
|
|
47
|
+
stderr=subprocess.STDOUT, text=True, check=False)
|
|
48
|
+
out = p.stdout.splitlines()
|
|
49
|
+
if len(out) > 6: # pytest failure body: keep the summary
|
|
50
|
+
out = [out[0], "[...]"] + [ln for ln in out if ln.startswith("FAILED ")] + out[-2:]
|
|
51
|
+
lines += [("out", ln) for ln in out]
|
|
52
|
+
return lines
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def svg(lines: list[tuple[str, str]]) -> str:
|
|
56
|
+
lh, pad, w = 20, 16, 860
|
|
57
|
+
h = pad * 2 + 28 + lh * len(lines)
|
|
58
|
+
t, step, rows = 0.6, 0.35, []
|
|
59
|
+
times = []
|
|
60
|
+
for kind, _ in lines:
|
|
61
|
+
t += 1.1 if kind in ("cmd", "comment") else step
|
|
62
|
+
times.append(t)
|
|
63
|
+
total = times[-1] + 4
|
|
64
|
+
color = {"cmd": "#e5e7eb", "comment": "#6b7280"}
|
|
65
|
+
for i, ((kind, text), at) in enumerate(zip(lines, times)):
|
|
66
|
+
fill = color.get(kind, "#9ca3af")
|
|
67
|
+
if text.startswith(("FAIL", "FAILED")) or "exit 1 |" in text:
|
|
68
|
+
fill = "#f87171"
|
|
69
|
+
elif text.startswith("ok ") or "exit 0 |" in text:
|
|
70
|
+
fill = "#4ade80"
|
|
71
|
+
shown = ("$ " + text) if kind == "cmd" else text
|
|
72
|
+
pct = at / total * 100
|
|
73
|
+
rows.append(
|
|
74
|
+
f'<style>#l{i}{{animation:k{i} {total:.1f}s steps(1) infinite}}'
|
|
75
|
+
f'@keyframes k{i}{{0%{{opacity:0}}{pct:.2f}%{{opacity:1}}100%{{opacity:1}}}}</style>'
|
|
76
|
+
f'<text id="l{i}" x="{pad}" y="{pad + 40 + i * lh}" fill="{fill}">{html.escape(shown)}</text>')
|
|
77
|
+
return (f'<svg xmlns="http://www.w3.org/2000/svg" width="{w}" height="{h}" viewBox="0 0 {w} {h}" '
|
|
78
|
+
f'font-family="ui-monospace,SFMono-Regular,Menlo,monospace" font-size="13">'
|
|
79
|
+
f'<rect width="{w}" height="{h}" rx="10" fill="#111827"/>'
|
|
80
|
+
'<circle cx="20" cy="18" r="5" fill="#ef4444"/><circle cx="38" cy="18" r="5" fill="#f59e0b"/>'
|
|
81
|
+
'<circle cx="56" cy="18" r="5" fill="#22c55e"/>' + "".join(rows) + "</svg>\n")
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if __name__ == "__main__":
|
|
85
|
+
out = ROOT / "docs" / "demo.svg"
|
|
86
|
+
out.write_text(svg(capture()))
|
|
87
|
+
print(f"wrote {out}")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="860" height="440" viewBox="0 0 860 440" font-family="ui-monospace,SFMono-Regular,Menlo,monospace" font-size="13"><rect width="860" height="440" rx="10" fill="#111827"/><circle cx="20" cy="18" r="5" fill="#ef4444"/><circle cx="38" cy="18" r="5" fill="#f59e0b"/><circle cx="56" cy="18" r="5" fill="#22c55e"/><style>#l0{animation:k0 16.5s steps(1) infinite}@keyframes k0{0%{opacity:0}10.30%{opacity:1}100%{opacity:1}}</style><text id="l0" x="16" y="56" fill="#e5e7eb">$ exitproof run -- pytest -q</text><style>#l1{animation:k1 16.5s steps(1) infinite}@keyframes k1{0%{opacity:0}12.42%{opacity:1}100%{opacity:1}}</style><text id="l1" x="16" y="76" fill="#9ca3af">.. [100%]</text><style>#l2{animation:k2 16.5s steps(1) infinite}@keyframes k2{0%{opacity:0}14.55%{opacity:1}100%{opacity:1}}</style><text id="l2" x="16" y="96" fill="#9ca3af">2 passed in 0.00s</text><style>#l3{animation:k3 16.5s steps(1) infinite}@keyframes k3{0%{opacity:0}16.67%{opacity:1}100%{opacity:1}}</style><text id="l3" x="16" y="116" fill="#4ade80">exitproof: exit 0 | 2 passed | 0.17s | recorded</text><style>#l4{animation:k4 16.5s steps(1) infinite}@keyframes k4{0%{opacity:0}23.33%{opacity:1}100%{opacity:1}}</style><text id="l4" x="16" y="136" fill="#e5e7eb">$ exitproof check</text><style>#l5{animation:k5 16.5s steps(1) infinite}@keyframes k5{0%{opacity:0}25.45%{opacity:1}100%{opacity:1}}</style><text id="l5" x="16" y="156" fill="#4ade80">ok every recorded command is green on the current files</text><style>#l6{animation:k6 16.5s steps(1) infinite}@keyframes k6{0%{opacity:0}32.12%{opacity:1}100%{opacity:1}}</style><text id="l6" x="16" y="176" fill="#6b7280"># the agent edits calc.py...</text><style>#l7{animation:k7 16.5s steps(1) infinite}@keyframes k7{0%{opacity:0}38.79%{opacity:1}100%{opacity:1}}</style><text id="l7" x="16" y="196" fill="#e5e7eb">$ perl -pi -e 's/a \+ b/a - b/' calc.py</text><style>#l8{animation:k8 16.5s steps(1) infinite}@keyframes k8{0%{opacity:0}45.45%{opacity:1}100%{opacity:1}}</style><text id="l8" x="16" y="216" fill="#e5e7eb">$ exitproof check</text><style>#l9{animation:k9 16.5s steps(1) infinite}@keyframes k9{0%{opacity:0}47.58%{opacity:1}100%{opacity:1}}</style><text id="l9" x="16" y="236" fill="#f87171">FAIL `pytest -q` passed, but files changed after it ran (stale)</text><style>#l10{animation:k10 16.5s steps(1) infinite}@keyframes k10{0%{opacity:0}54.24%{opacity:1}100%{opacity:1}}</style><text id="l10" x="16" y="256" fill="#e5e7eb">$ exitproof run -- pytest -q</text><style>#l11{animation:k11 16.5s steps(1) infinite}@keyframes k11{0%{opacity:0}56.36%{opacity:1}100%{opacity:1}}</style><text id="l11" x="16" y="276" fill="#9ca3af">FF [100%]</text><style>#l12{animation:k12 16.5s steps(1) infinite}@keyframes k12{0%{opacity:0}58.48%{opacity:1}100%{opacity:1}}</style><text id="l12" x="16" y="296" fill="#9ca3af">[...]</text><style>#l13{animation:k13 16.5s steps(1) infinite}@keyframes k13{0%{opacity:0}60.61%{opacity:1}100%{opacity:1}}</style><text id="l13" x="16" y="316" fill="#f87171">FAILED test_calc.py::test_add - assert 0 == 4</text><style>#l14{animation:k14 16.5s steps(1) infinite}@keyframes k14{0%{opacity:0}62.73%{opacity:1}100%{opacity:1}}</style><text id="l14" x="16" y="336" fill="#f87171">FAILED test_calc.py::test_neg - assert 0 == -2</text><style>#l15{animation:k15 16.5s steps(1) infinite}@keyframes k15{0%{opacity:0}64.85%{opacity:1}100%{opacity:1}}</style><text id="l15" x="16" y="356" fill="#9ca3af">2 failed in 0.01s</text><style>#l16{animation:k16 16.5s steps(1) infinite}@keyframes k16{0%{opacity:0}66.97%{opacity:1}100%{opacity:1}}</style><text id="l16" x="16" y="376" fill="#f87171">exitproof: exit 1 | 2 failed | 0.19s | recorded</text><style>#l17{animation:k17 16.5s steps(1) infinite}@keyframes k17{0%{opacity:0}73.64%{opacity:1}100%{opacity:1}}</style><text id="l17" x="16" y="396" fill="#e5e7eb">$ exitproof check</text><style>#l18{animation:k18 16.5s steps(1) infinite}@keyframes k18{0%{opacity:0}75.76%{opacity:1}100%{opacity:1}}</style><text id="l18" x="16" y="416" fill="#f87171">FAIL `pytest -q` exited 1 (2 failed)</text></svg>
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "exitproof"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.2.0"
|
|
8
8
|
description = "Receipts for test runs: your coding agent can't say 'all tests pass' unless they did, on the current files."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -16,7 +16,7 @@ import sys
|
|
|
16
16
|
import time
|
|
17
17
|
from pathlib import Path
|
|
18
18
|
|
|
19
|
-
__version__ = "0.
|
|
19
|
+
__version__ = "0.2.0"
|
|
20
20
|
DIR = ".exitproof"
|
|
21
21
|
MAX_BLOCKS = 3 # Stop-hook blocks per turn before letting the agent stop anyway.
|
|
22
22
|
JUNK = {b"__pycache__", b".pytest_cache", b".mypy_cache", b".ruff_cache", b"node_modules", b".coverage"}
|
|
@@ -216,7 +216,7 @@ def check(cwd: str, strict: bool) -> int:
|
|
|
216
216
|
return 1 if problems else 0
|
|
217
217
|
|
|
218
218
|
|
|
219
|
-
# ---------------------------------------------------------------- Claude Code
|
|
219
|
+
# ---------------------------------------------------------------- agent hooks (Claude Code, Codex CLI)
|
|
220
220
|
|
|
221
221
|
|
|
222
222
|
def _session_file(root: str, sid: str) -> Path:
|
|
@@ -234,7 +234,7 @@ def _runner() -> str:
|
|
|
234
234
|
|
|
235
235
|
|
|
236
236
|
def hook(event: str, data: dict, strict: bool) -> dict | None:
|
|
237
|
-
"""Handle a Claude Code hook event. Returns the JSON to print, or None to allow silently."""
|
|
237
|
+
"""Handle a Claude Code or Codex CLI hook event. Returns the JSON to print, or None to allow silently."""
|
|
238
238
|
root = find_root(data.get("cwd") or os.getcwd())
|
|
239
239
|
if root is None:
|
|
240
240
|
return None
|
|
@@ -268,9 +268,10 @@ def hook(event: str, data: dict, strict: bool) -> dict | None:
|
|
|
268
268
|
return {"decision": "block", "reason": reason}
|
|
269
269
|
|
|
270
270
|
|
|
271
|
-
def install(cwd: str, user: bool, strict: bool) -> int:
|
|
271
|
+
def install(cwd: str, agent: str, user: bool, strict: bool) -> int:
|
|
272
272
|
base = Path.home() if user else Path(find_root(cwd) or cwd)
|
|
273
|
-
|
|
273
|
+
# Codex reads the same {"hooks": {Event: [{"hooks": [...]}]}} shape from .codex/hooks.json
|
|
274
|
+
path = base / ".claude" / "settings.json" if agent == "claude" else base / ".codex" / "hooks.json"
|
|
274
275
|
settings = json.loads(path.read_text()) if path.exists() else {}
|
|
275
276
|
hooks = settings.setdefault("hooks", {})
|
|
276
277
|
flag = " --strict" if strict else ""
|
|
@@ -303,9 +304,9 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
303
304
|
c = sub.add_parser("check", help="exit 1 unless every recorded command is green on the current files")
|
|
304
305
|
c.add_argument("--strict", action="store_true", help="also fail on skipped tests or 0 tests ran")
|
|
305
306
|
sub.add_parser("clear", help="forget all recorded runs")
|
|
306
|
-
i = sub.add_parser("install", help="install the Claude Code hooks")
|
|
307
|
-
i.add_argument("agent", choices=["claude"])
|
|
308
|
-
i.add_argument("--user", action="store_true", help="
|
|
307
|
+
i = sub.add_parser("install", help="install the Claude Code or Codex CLI hooks")
|
|
308
|
+
i.add_argument("agent", choices=["claude", "codex"])
|
|
309
|
+
i.add_argument("--user", action="store_true", help="write to ~ instead of the repo")
|
|
309
310
|
i.add_argument("--strict", action="store_true")
|
|
310
311
|
h = sub.add_parser("hook", help="hook entry point (reads the event JSON on stdin)")
|
|
311
312
|
h.add_argument("event", choices=["session-start", "stop"])
|
|
@@ -320,7 +321,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
320
321
|
(Path(find_root(cwd) or cwd) / DIR / "runs.jsonl").unlink(missing_ok=True)
|
|
321
322
|
return 0
|
|
322
323
|
if a.command == "install":
|
|
323
|
-
return install(cwd, a.user, a.strict)
|
|
324
|
+
return install(cwd, a.agent, a.user, a.strict)
|
|
324
325
|
try:
|
|
325
326
|
data = json.loads(sys.stdin.read() or "{}")
|
|
326
327
|
except ValueError:
|
|
@@ -115,6 +115,31 @@ def test_install_merges_and_is_idempotent(repo):
|
|
|
115
115
|
assert r.returncode == 0 and (repo / ".exitproof" / "sessions" / "i.json").exists()
|
|
116
116
|
|
|
117
117
|
|
|
118
|
+
def test_install_codex_writes_codex_hooks_json(repo):
|
|
119
|
+
assert ep(repo, "install", "codex").returncode == 0
|
|
120
|
+
assert ep(repo, "install", "codex").returncode == 0
|
|
121
|
+
s = json.loads((repo / ".codex" / "hooks.json").read_text())
|
|
122
|
+
assert not (repo / ".claude").exists()
|
|
123
|
+
[stop] = [h["command"] for e in s["hooks"]["Stop"] for h in e["hooks"]]
|
|
124
|
+
[start] = [h["command"] for e in s["hooks"]["SessionStart"] for h in e["hooks"]]
|
|
125
|
+
# stdin fields as documented for Codex hooks (session_id, cwd, turn_id, stop_hook_active, ...)
|
|
126
|
+
base = {"session_id": "cx", "cwd": str(repo), "transcript_path": None, "model": "m",
|
|
127
|
+
"permission_mode": "default"}
|
|
128
|
+
|
|
129
|
+
def fire(cmd, **extra):
|
|
130
|
+
return subprocess.run(cmd, shell=True, input=json.dumps({**base, **extra}),
|
|
131
|
+
capture_output=True, text=True, cwd=repo, check=False)
|
|
132
|
+
|
|
133
|
+
assert fire(start, hook_event_name="SessionStart", source="startup").returncode == 0
|
|
134
|
+
(repo / "app.py").write_text("x = 2\n")
|
|
135
|
+
ev = dict(hook_event_name="Stop", turn_id="t1", stop_hook_active=False, last_assistant_message="done")
|
|
136
|
+
r = fire(stop, **ev)
|
|
137
|
+
assert r.returncode == 0 and json.loads(r.stdout)["decision"] == "block"
|
|
138
|
+
ep(repo, *say("1 passed in 0.01s"))
|
|
139
|
+
r = fire(stop, **{**ev, "stop_hook_active": True})
|
|
140
|
+
assert r.returncode == 0 and r.stdout == ""
|
|
141
|
+
|
|
142
|
+
|
|
118
143
|
def test_runner_caches_do_not_make_runs_stale(repo):
|
|
119
144
|
ep(repo, *say("1 passed in 0.01s"))
|
|
120
145
|
(repo / "__pycache__").mkdir()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|