exitproof 0.1.0__tar.gz → 0.3.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.3.0}/.claude-plugin/plugin.json +4 -2
- {exitproof-0.1.0 → exitproof-0.3.0}/PKG-INFO +28 -4
- {exitproof-0.1.0 → exitproof-0.3.0}/README.md +27 -3
- exitproof-0.3.0/docs/demo.py +87 -0
- exitproof-0.3.0/docs/demo.svg +1 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/pyproject.toml +1 -1
- {exitproof-0.1.0 → exitproof-0.3.0}/src/exitproof/__init__.py +20 -11
- exitproof-0.3.0/tests/fixtures/bun_green.txt +7 -0
- exitproof-0.3.0/tests/fixtures/bun_red.txt +22 -0
- exitproof-0.3.0/tests/fixtures/go_green.txt +16 -0
- exitproof-0.3.0/tests/fixtures/go_red.txt +18 -0
- exitproof-0.3.0/tests/fixtures/mocha_green.txt +15 -0
- exitproof-0.3.0/tests/fixtures/mocha_red.txt +32 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/tests/test_cli.py +25 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/tests/test_parse.py +5 -2
- {exitproof-0.1.0 → exitproof-0.3.0}/.claude-plugin/icon.png +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/.claude-plugin/marketplace.json +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/.github/workflows/ci.yml +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/.github/workflows/publish.yml +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/.gitignore +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/LICENSE +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/Makefile +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/hooks/hooks.json +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/src/exitproof/__main__.py +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/tests/fixtures/cargo_green.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/tests/fixtures/cargo_red.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/tests/fixtures/jest_green.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/tests/fixtures/jest_red.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/tests/fixtures/pytest_empty.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/tests/fixtures/pytest_green.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/tests/fixtures/pytest_red.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/tests/fixtures/unittest_green.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/tests/fixtures/unittest_red.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/tests/fixtures/vitest_green.txt +0 -0
- {exitproof-0.1.0 → exitproof-0.3.0}/tests/fixtures/vitest_red.txt +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exitproof",
|
|
3
|
-
"
|
|
3
|
+
"displayName": "exitproof",
|
|
4
|
+
"version": "0.3.0",
|
|
4
5
|
"description": "Blocks the agent from finishing while its file changes are not covered by a green test run on the current files.",
|
|
5
6
|
"repository": "https://github.com/RAFAELDCOELHO/exitproof",
|
|
6
7
|
"license": "MIT",
|
|
@@ -16,5 +17,6 @@
|
|
|
16
17
|
"network": {
|
|
17
18
|
"hosts": []
|
|
18
19
|
},
|
|
19
|
-
"icon": ".claude-plugin/icon.png"
|
|
20
|
+
"icon": ".claude-plugin/icon.png",
|
|
21
|
+
"homepage": "https://github.com/RAFAELDCOELHO/exitproof"
|
|
20
22
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: exitproof
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.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:
|
|
@@ -146,7 +166,7 @@ exec exitproof check
|
|
|
146
166
|
- `exitproof run -- <cmd>` streams the command's output unchanged and returns its exit code. It then appends one JSON line to `.exitproof/runs.jsonl`: the command, exit code, duration, parsed test counts, and a fingerprint.
|
|
147
167
|
- The fingerprint is a hash of every tracked file plus every untracked file that is not ignored, as they are on disk. Ignored files do not count, and neither do `__pycache__/`, `.pytest_cache/`, `.mypy_cache/`, `.ruff_cache/`, `node_modules/` and `.coverage` anywhere in the tree. Keep other build output (`target/`, `dist/`) in `.gitignore`, or every build makes your runs stale.
|
|
148
168
|
- `exitproof check` looks at the **latest run of each distinct command string**. It fails if any of them exited non-zero or ran on different files than the current ones.
|
|
149
|
-
- Test counts are parsed from pytest, unittest, jest, vitest, `cargo test`, and `go test -v` output
|
|
169
|
+
- Test counts are parsed from pytest, unittest, jest, vitest, `cargo test`, `bun test`, mocha and `go test -v` output, each checked against real captured output in `tests/fixtures/`. Other tools still work; they just show `counts unknown`.
|
|
150
170
|
- `.exitproof/` creates its own `.gitignore`, so it is never committed and never affects the fingerprint.
|
|
151
171
|
- `exitproof clear` forgets all recorded runs.
|
|
152
172
|
|
|
@@ -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:
|
|
@@ -130,7 +150,7 @@ exec exitproof check
|
|
|
130
150
|
- `exitproof run -- <cmd>` streams the command's output unchanged and returns its exit code. It then appends one JSON line to `.exitproof/runs.jsonl`: the command, exit code, duration, parsed test counts, and a fingerprint.
|
|
131
151
|
- The fingerprint is a hash of every tracked file plus every untracked file that is not ignored, as they are on disk. Ignored files do not count, and neither do `__pycache__/`, `.pytest_cache/`, `.mypy_cache/`, `.ruff_cache/`, `node_modules/` and `.coverage` anywhere in the tree. Keep other build output (`target/`, `dist/`) in `.gitignore`, or every build makes your runs stale.
|
|
132
152
|
- `exitproof check` looks at the **latest run of each distinct command string**. It fails if any of them exited non-zero or ran on different files than the current ones.
|
|
133
|
-
- Test counts are parsed from pytest, unittest, jest, vitest, `cargo test`, and `go test -v` output
|
|
153
|
+
- Test counts are parsed from pytest, unittest, jest, vitest, `cargo test`, `bun test`, mocha and `go test -v` output, each checked against real captured output in `tests/fixtures/`. Other tools still work; they just show `counts unknown`.
|
|
134
154
|
- `.exitproof/` creates its own `.gitignore`, so it is never committed and never affects the fingerprint.
|
|
135
155
|
- `exitproof clear` forgets all recorded runs.
|
|
136
156
|
|
|
@@ -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.3.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.3.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"}
|
|
@@ -84,6 +84,9 @@ CARGO = re.compile(r"^test result: \w+\. (\d+) passed; (\d+) failed; (\d+) ignor
|
|
|
84
84
|
GO = re.compile(r"^\s*--- (PASS|FAIL|SKIP):")
|
|
85
85
|
RAN = re.compile(r"^Ran (\d+) tests? in ")
|
|
86
86
|
UNITTEST = re.compile(r"^(OK|FAILED)(?: \((.*)\))?$")
|
|
87
|
+
# bun test ("3 pass" / "1 fail" / "2 skip") and mocha ("3 passing (5ms)" / "1 failing" / "2 pending"), one per line
|
|
88
|
+
TALLY = re.compile(r"^\s*(\d+) (pass|fail|skip|todo|passing|failing|pending)(?: \(\S+\))?$")
|
|
89
|
+
TALLY_KEY = {"pass": "passed", "passing": "passed", "fail": "failed", "failing": "failed"}
|
|
87
90
|
|
|
88
91
|
|
|
89
92
|
def _zero() -> dict:
|
|
@@ -94,7 +97,7 @@ class Counts:
|
|
|
94
97
|
"""Feed output lines; result() gives test counts or None if no known summary was seen."""
|
|
95
98
|
|
|
96
99
|
def __init__(self) -> None:
|
|
97
|
-
self.cargo = self.go = self.generic = self.unittest = None
|
|
100
|
+
self.cargo = self.go = self.generic = self.unittest = self.tally = None
|
|
98
101
|
self.ran: int | None = None
|
|
99
102
|
|
|
100
103
|
def feed(self, line: str) -> None:
|
|
@@ -110,6 +113,11 @@ class Counts:
|
|
|
110
113
|
self.go = self.go or _zero()
|
|
111
114
|
self.go[{"PASS": "passed", "FAIL": "failed", "SKIP": "skipped"}[m[1]]] += 1
|
|
112
115
|
return
|
|
116
|
+
m = TALLY.match(line)
|
|
117
|
+
if m:
|
|
118
|
+
self.tally = self.tally or _zero()
|
|
119
|
+
self.tally[TALLY_KEY.get(m[2], "skipped")] += int(m[1])
|
|
120
|
+
return
|
|
113
121
|
m = RAN.match(line)
|
|
114
122
|
if m:
|
|
115
123
|
self.ran = int(m[1])
|
|
@@ -130,7 +138,7 @@ class Counts:
|
|
|
130
138
|
self.generic["errors" if word.startswith("error") else word] += int(n)
|
|
131
139
|
|
|
132
140
|
def result(self) -> dict | None:
|
|
133
|
-
return self.cargo or self.generic or self.unittest or self.go
|
|
141
|
+
return self.cargo or self.generic or self.unittest or self.tally or self.go
|
|
134
142
|
|
|
135
143
|
|
|
136
144
|
def describe(c: dict | None) -> str:
|
|
@@ -216,7 +224,7 @@ def check(cwd: str, strict: bool) -> int:
|
|
|
216
224
|
return 1 if problems else 0
|
|
217
225
|
|
|
218
226
|
|
|
219
|
-
# ---------------------------------------------------------------- Claude Code
|
|
227
|
+
# ---------------------------------------------------------------- agent hooks (Claude Code, Codex CLI)
|
|
220
228
|
|
|
221
229
|
|
|
222
230
|
def _session_file(root: str, sid: str) -> Path:
|
|
@@ -234,7 +242,7 @@ def _runner() -> str:
|
|
|
234
242
|
|
|
235
243
|
|
|
236
244
|
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."""
|
|
245
|
+
"""Handle a Claude Code or Codex CLI hook event. Returns the JSON to print, or None to allow silently."""
|
|
238
246
|
root = find_root(data.get("cwd") or os.getcwd())
|
|
239
247
|
if root is None:
|
|
240
248
|
return None
|
|
@@ -268,9 +276,10 @@ def hook(event: str, data: dict, strict: bool) -> dict | None:
|
|
|
268
276
|
return {"decision": "block", "reason": reason}
|
|
269
277
|
|
|
270
278
|
|
|
271
|
-
def install(cwd: str, user: bool, strict: bool) -> int:
|
|
279
|
+
def install(cwd: str, agent: str, user: bool, strict: bool) -> int:
|
|
272
280
|
base = Path.home() if user else Path(find_root(cwd) or cwd)
|
|
273
|
-
|
|
281
|
+
# Codex reads the same {"hooks": {Event: [{"hooks": [...]}]}} shape from .codex/hooks.json
|
|
282
|
+
path = base / ".claude" / "settings.json" if agent == "claude" else base / ".codex" / "hooks.json"
|
|
274
283
|
settings = json.loads(path.read_text()) if path.exists() else {}
|
|
275
284
|
hooks = settings.setdefault("hooks", {})
|
|
276
285
|
flag = " --strict" if strict else ""
|
|
@@ -303,9 +312,9 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
303
312
|
c = sub.add_parser("check", help="exit 1 unless every recorded command is green on the current files")
|
|
304
313
|
c.add_argument("--strict", action="store_true", help="also fail on skipped tests or 0 tests ran")
|
|
305
314
|
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="
|
|
315
|
+
i = sub.add_parser("install", help="install the Claude Code or Codex CLI hooks")
|
|
316
|
+
i.add_argument("agent", choices=["claude", "codex"])
|
|
317
|
+
i.add_argument("--user", action="store_true", help="write to ~ instead of the repo")
|
|
309
318
|
i.add_argument("--strict", action="store_true")
|
|
310
319
|
h = sub.add_parser("hook", help="hook entry point (reads the event JSON on stdin)")
|
|
311
320
|
h.add_argument("event", choices=["session-start", "stop"])
|
|
@@ -320,7 +329,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
320
329
|
(Path(find_root(cwd) or cwd) / DIR / "runs.jsonl").unlink(missing_ok=True)
|
|
321
330
|
return 0
|
|
322
331
|
if a.command == "install":
|
|
323
|
-
return install(cwd, a.user, a.strict)
|
|
332
|
+
return install(cwd, a.agent, a.user, a.strict)
|
|
324
333
|
try:
|
|
325
334
|
data = json.loads(sys.stdin.read() or "{}")
|
|
326
335
|
except ValueError:
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
bun test v1.3.12 (700fc117)
|
|
2
|
+
|
|
3
|
+
calc.test.js:
|
|
4
|
+
1 | const { test, expect } = require("bun:test");
|
|
5
|
+
2 | test("a", () => expect(1).toBe(1));
|
|
6
|
+
3 | test("b", () => expect(2).toBe(2));
|
|
7
|
+
4 | test("c", () => expect(3).toBe(3));
|
|
8
|
+
5 | test("d", () => expect(1).toBe(2));
|
|
9
|
+
^
|
|
10
|
+
error: expect(received).toBe(expected)
|
|
11
|
+
|
|
12
|
+
Expected: 2
|
|
13
|
+
Received: 1
|
|
14
|
+
|
|
15
|
+
at <anonymous> (/home/user/proj/calc.test.js:5:27)
|
|
16
|
+
(fail) d [2.33ms]
|
|
17
|
+
|
|
18
|
+
3 pass
|
|
19
|
+
2 skip
|
|
20
|
+
1 fail
|
|
21
|
+
4 expect() calls
|
|
22
|
+
Ran 6 tests across 1 file. [18.00ms]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
=== RUN TestA
|
|
2
|
+
--- PASS: TestA (0.00s)
|
|
3
|
+
=== RUN TestB
|
|
4
|
+
--- PASS: TestB (0.00s)
|
|
5
|
+
=== RUN TestC
|
|
6
|
+
--- PASS: TestC (0.00s)
|
|
7
|
+
=== RUN TestD
|
|
8
|
+
--- PASS: TestD (0.00s)
|
|
9
|
+
=== RUN TestE
|
|
10
|
+
calc_test.go:9: later
|
|
11
|
+
--- SKIP: TestE (0.00s)
|
|
12
|
+
=== RUN TestF
|
|
13
|
+
calc_test.go:10: later
|
|
14
|
+
--- SKIP: TestF (0.00s)
|
|
15
|
+
PASS
|
|
16
|
+
ok example.com/calc 0.007s
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
=== RUN TestA
|
|
2
|
+
--- PASS: TestA (0.00s)
|
|
3
|
+
=== RUN TestB
|
|
4
|
+
--- PASS: TestB (0.00s)
|
|
5
|
+
=== RUN TestC
|
|
6
|
+
--- PASS: TestC (0.00s)
|
|
7
|
+
=== RUN TestD
|
|
8
|
+
calc_test.go:8: 1 != 2
|
|
9
|
+
--- FAIL: TestD (0.00s)
|
|
10
|
+
=== RUN TestE
|
|
11
|
+
calc_test.go:9: later
|
|
12
|
+
--- SKIP: TestE (0.00s)
|
|
13
|
+
=== RUN TestF
|
|
14
|
+
calc_test.go:10: later
|
|
15
|
+
--- SKIP: TestF (0.00s)
|
|
16
|
+
FAIL
|
|
17
|
+
FAIL example.com/calc 0.010s
|
|
18
|
+
FAIL
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
npm warn Unknown user config "allow-scripts". This will stop working in the next major version of npm.
|
|
2
|
+
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
|
|
3
|
+
npm warn deprecated glob@8.1.0: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
calc
|
|
7
|
+
✔ a
|
|
8
|
+
✔ b
|
|
9
|
+
✔ c
|
|
10
|
+
1) d
|
|
11
|
+
- e
|
|
12
|
+
- f
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
3 passing (3ms)
|
|
16
|
+
2 pending
|
|
17
|
+
1 failing
|
|
18
|
+
|
|
19
|
+
1) calc
|
|
20
|
+
d:
|
|
21
|
+
|
|
22
|
+
AssertionError [ERR_ASSERTION]: 1 == 2
|
|
23
|
+
+ expected - actual
|
|
24
|
+
|
|
25
|
+
-1
|
|
26
|
+
+2
|
|
27
|
+
|
|
28
|
+
at Context.<anonymous> (test.js:6:24)
|
|
29
|
+
at process.processImmediate (node:internal/timers:504:21)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
@@ -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()
|
|
@@ -6,8 +6,7 @@ values below come from those projects, not from the parser:
|
|
|
6
6
|
red = 3 passing, 1 failing, 2 skipped/ignored tests
|
|
7
7
|
green = 3 passing, 2 skipped/ignored tests
|
|
8
8
|
empty = pytest with a test file that defines no tests
|
|
9
|
-
Runners: pytest 8, python -m unittest -v, cargo test, jest, vitest run.
|
|
10
|
-
go test was not captured (go is not installed on the capture machine).
|
|
9
|
+
Runners: pytest 8, python -m unittest -v, cargo test, jest, vitest run, bun test, mocha 10, go test -v.
|
|
11
10
|
"""
|
|
12
11
|
from pathlib import Path
|
|
13
12
|
|
|
@@ -23,6 +22,10 @@ ZERO = {"passed": 0, "failed": 0, "skipped": 0, "errors": 0}
|
|
|
23
22
|
CASES = [(f"{r}_{c}", exp) for r in ("pytest", "unittest", "cargo", "jest", "vitest")
|
|
24
23
|
for c, exp in (("red", RED), ("green", GREEN))]
|
|
25
24
|
CASES.append(("pytest_empty", ZERO))
|
|
25
|
+
# bun test 1.x and mocha 10, captured later: their green projects have 4 passing, 2 skipped/pending
|
|
26
|
+
GREEN4 = {"passed": 4, "failed": 0, "skipped": 2, "errors": 0}
|
|
27
|
+
CASES += [("bun_red", RED), ("bun_green", GREEN4), ("mocha_red", RED), ("mocha_green", GREEN4),
|
|
28
|
+
("go_red", RED), ("go_green", GREEN4)] # go test -v, go 1.x
|
|
26
29
|
|
|
27
30
|
|
|
28
31
|
def parse(name: str):
|
|
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
|