@greerviau/titer 0.1.1 → 0.1.3
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.
- package/README.md +91 -108
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,147 +1,130 @@
|
|
|
1
1
|
# titer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
titer checks whether the tests in a change actually test the change. Run it on a branch, and it compares the branch with its base:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- `scan` finds weakened tests: deleted tests, removed assertions, added skips, loosened matchers, and changed snapshots.
|
|
6
|
+
- `prove` runs the changed tests against the base code. A test that fails on base detects the change.
|
|
7
|
+
- `mutate` makes small edits to the changed source lines and checks that the changed tests catch them.
|
|
8
|
+
- `crap` scores each changed function by complexity and coverage. It is informational.
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
| `prove` | Runs the changed tests against the base code and classifies each one. |
|
|
11
|
-
| `mutate` | Mutates changed source lines and runs the changed tests against each mutant. |
|
|
12
|
-
| `crap` | Scores each changed function by complexity and coverage. Informational. |
|
|
10
|
+
titer is a CLI that coding agents and CI jobs call. It contains no model and never wraps the agent. It prints a report and exits with a pass or fail code, and the caller decides what to do.
|
|
11
|
+
|
|
12
|
+
titer gathers evidence. It cannot show that a change is correct: a test that fails on base detects a difference from base, and a reviewer still checks that the difference is the intended one.
|
|
13
13
|
|
|
14
|
-
titer
|
|
14
|
+
titer supports Python, TypeScript, TSX, JavaScript, and Rust, with pytest, unittest, vitest, and cargo test. It runs on Linux and macOS.
|
|
15
15
|
|
|
16
16
|
## Install
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Add titer as a dev dependency of your repo, so every agent and CI job runs the same version.
|
|
19
|
+
|
|
20
|
+
npm:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
npm install --save-dev @greerviau/titer
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Python with uv:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
uv add --dev titer
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Rust:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
cargo install titer
|
|
36
|
+
```
|
|
19
37
|
|
|
20
|
-
|
|
21
|
-
|---|---|---|
|
|
22
|
-
| npm | `npm install --save-dev @greerviau/titer` | `npx titer check` |
|
|
23
|
-
| Python with uv | `uv add --dev titer` | `uv run titer check` |
|
|
24
|
-
| Rust | `cargo install titer` | `titer check` |
|
|
38
|
+
Each [GitHub release](https://github.com/greerviau/titer/releases) also has binaries for Linux (x64, arm64) and macOS (x64, arm64).
|
|
25
39
|
|
|
26
|
-
|
|
40
|
+
## Set up a repo
|
|
27
41
|
|
|
28
|
-
|
|
42
|
+
Run `init` once from the repo root:
|
|
29
43
|
|
|
30
44
|
```sh
|
|
31
|
-
npx
|
|
45
|
+
npx titer init # npm
|
|
46
|
+
uv run titer init # uv
|
|
32
47
|
```
|
|
33
48
|
|
|
34
|
-
`init` detects
|
|
49
|
+
`init` detects your test runners and writes these files:
|
|
35
50
|
|
|
36
|
-
- `titer.toml`, with one `[[runner]]` per project
|
|
37
|
-
-
|
|
38
|
-
-
|
|
51
|
+
- `titer.toml`, with one `[[runner]]` per project. A monorepo gets several.
|
|
52
|
+
- A pinned dev dependency in `package.json` or `pyproject.toml`.
|
|
53
|
+
- A repo skill in `.agents/skills/titer/SKILL.md` and `.claude/skills/titer/SKILL.md`. It tells agents when to run titer, how to read the report, and never to weaken a test to make it pass.
|
|
39
54
|
|
|
40
|
-
|
|
55
|
+
Review the files and commit them. Run `init --dry-run` first to see the plan without writing anything.
|
|
41
56
|
|
|
42
|
-
titer
|
|
57
|
+
titer does not run in a repo without `titer.toml`. If `init` finds no runner, write `titer.toml` by hand with the [configuration reference](docs/configuration.md).
|
|
43
58
|
|
|
44
|
-
|
|
59
|
+
After you upgrade titer, run `init --update` to refresh the skill and the pin. `check` warns when they are out of date.
|
|
60
|
+
|
|
61
|
+
## Run a check
|
|
62
|
+
|
|
63
|
+
With your changes committed or still in the working tree, run:
|
|
45
64
|
|
|
46
65
|
```sh
|
|
47
|
-
titer check
|
|
48
|
-
|
|
66
|
+
npx titer check # npm
|
|
67
|
+
uv run titer check # uv
|
|
49
68
|
```
|
|
50
69
|
|
|
51
|
-
titer
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## Exit codes and the gate
|
|
59
|
-
|
|
60
|
-
- 0: the gate passes.
|
|
61
|
-
- 1: the gate fails.
|
|
62
|
-
- 2: the check could not run: a changed test fails on head, the canary survives, a config error, or a git error.
|
|
63
|
-
|
|
64
|
-
By default the gate fails only on an unproven change: the change touches supported source lines, no changed test is proven, and the selected tests kill none of its mutants. Survivors, passes on base, scan findings, and CRAP fail the gate only when `[gate]` asks.
|
|
65
|
-
|
|
66
|
-
## Configuration
|
|
67
|
-
|
|
68
|
-
```toml
|
|
69
|
-
base = "origin/main" # optional default for --base
|
|
70
|
-
|
|
71
|
-
[[runner]]
|
|
72
|
-
name = "api" # unique; defaults to the kind
|
|
73
|
-
kind = "unittest" # pytest, unittest, or vitest
|
|
74
|
-
cwd = "services/api" # repo-relative; globs and paths below are relative to it
|
|
75
|
-
command = ["uv", "run", "--no-sync", "python", "-m", "unittest"]
|
|
76
|
-
start_dir = "tests" # unittest only: the dir dotted ids are relative to
|
|
77
|
-
test_globs = ["**/test*.py"] # files that contain tests (defaults per kind)
|
|
78
|
-
support_globs = ["tests/**"] # other test-only files: copied to base, never mutated
|
|
79
|
-
deps = [".venv"] # dependency dirs linked into worktrees (defaults per kind)
|
|
80
|
-
env = { PYTHON_DOTENV_DISABLED = "1" }
|
|
81
|
-
|
|
82
|
-
[[runner]]
|
|
83
|
-
name = "web"
|
|
84
|
-
kind = "vitest"
|
|
85
|
-
cwd = "clients/web"
|
|
86
|
-
command = ["npx", "--no-install", "vitest", "run"]
|
|
87
|
-
|
|
88
|
-
[gate]
|
|
89
|
-
fail_on_survivors = false
|
|
90
|
-
fail_on_passes_on_base = false
|
|
91
|
-
fail_on_scan = false
|
|
92
|
-
fail_on_crap = false
|
|
93
|
-
|
|
94
|
-
[mutate]
|
|
95
|
-
budget = "120s" # time budget for a whole check
|
|
96
|
-
exclude_operators = [] # for example ["remove_call"]
|
|
97
|
-
exclude_globs = [] # repo-relative source files never mutated
|
|
98
|
-
exclude_calls = [] # callees never removed, beyond logging calls
|
|
99
|
-
|
|
100
|
-
[crap]
|
|
101
|
-
coverage_command = ["uv", "run", "--no-sync", "coverage", "json", "-o", "coverage.json"]
|
|
102
|
-
coverage_file = "coverage.json" # written by coverage_command, relative to the repo root
|
|
103
|
-
threshold = 30
|
|
70
|
+
titer compares the working tree, including untracked files, with the merge-base of HEAD and the base branch. By default the base is the remote default branch; pass `--base origin/develop` to pick another. titer runs tests in temporary worktrees and never changes your checkout.
|
|
71
|
+
|
|
72
|
+
The output starts with the gate result:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
titer gate: pass
|
|
104
76
|
```
|
|
105
77
|
|
|
106
|
-
|
|
78
|
+
The exit code tells the caller what happened:
|
|
79
|
+
|
|
80
|
+
| Code | Meaning |
|
|
81
|
+
|---|---|
|
|
82
|
+
| 0 | The gate passes. |
|
|
83
|
+
| 1 | The gate fails. By default, this means the change is unproven: no changed test fails on base, and the tests catch none of the mutants. |
|
|
84
|
+
| 2 | The check could not run. Common causes are a changed test that fails on head, a config error, and a git error. |
|
|
85
|
+
|
|
86
|
+
Agents should run `titer check --json` and read the JSON report. See the [CLI reference](docs/cli.md) for all options and the report format.
|
|
107
87
|
|
|
108
|
-
|
|
88
|
+
Common options:
|
|
89
|
+
|
|
90
|
+
- `--base REF` sets the base ref.
|
|
91
|
+
- `--only scan,prove` runs only some tiers.
|
|
92
|
+
- `--budget 60s` limits how long the whole check runs.
|
|
93
|
+
|
|
94
|
+
## Run in CI
|
|
95
|
+
|
|
96
|
+
Add the GitHub Action to a workflow that runs on pull requests:
|
|
109
97
|
|
|
110
98
|
```yaml
|
|
99
|
+
on: pull_request
|
|
100
|
+
|
|
111
101
|
permissions:
|
|
112
102
|
contents: read
|
|
113
103
|
pull-requests: write # only for comment: true
|
|
114
104
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
- uses: greerviau/titer@v0.1
|
|
128
|
-
with:
|
|
129
|
-
comment: true
|
|
105
|
+
jobs:
|
|
106
|
+
titer:
|
|
107
|
+
runs-on: ubuntu-latest
|
|
108
|
+
steps:
|
|
109
|
+
- uses: actions/checkout@v4
|
|
110
|
+
with:
|
|
111
|
+
fetch-depth: 0
|
|
112
|
+
ref: ${{ github.event.pull_request.head.sha }}
|
|
113
|
+
# Install your repo's dependencies here.
|
|
114
|
+
- uses: greerviau/titer@v0.1
|
|
115
|
+
with:
|
|
116
|
+
comment: true
|
|
130
117
|
```
|
|
131
118
|
|
|
132
|
-
The Action runs the repo
|
|
133
|
-
|
|
134
|
-
- The job summary leads with the gate result (passed, failed, or could not run) and the evidence it rests on. It then lists survivors, lines no test runs, and weakened tests, with links to the pull request's head commit. A survivor whose code is unchanged from base says so. The full test and mutant tables are collapsed. The test table shows each changed test's failure on base, so a reviewer can check that the failure is the behavior the change targets.
|
|
135
|
-
- With `annotations: true` (the default), survivors and weakened tests are warnings on their lines in the diff, and lines no test runs are notices.
|
|
136
|
-
- With `comment: true`, the same summary is posted as a pull request comment whose heading names the commit checked. Each new head commit gets a new comment, and earlier titer comments collapse as outdated, so the newest result sits next to the newest push. A rerun on the same commit updates that commit's comment. This needs `pull-requests: write`. On pull requests from forks of a public repo, GitHub gives the token read access only, so the Action warns and skips the comment.
|
|
137
|
-
|
|
138
|
-
Annotations need the pull request head checked out, as above. The default `pull_request` checkout is a merge commit whose line numbers can differ, so the Action skips annotations there.
|
|
139
|
-
|
|
140
|
-
Other inputs: `base`, `args`, `working-directory`, `command`, and `github-token`. Outputs: `exit-code`, `report` (the JSON report's path), and `summary` (the Markdown's path).
|
|
119
|
+
The Action runs the titer version your repo pins, writes a job summary, annotates the diff, and fails the job when the gate fails. See the [GitHub Action guide](docs/github-action.md) for inputs, outputs, and how it reports.
|
|
141
120
|
|
|
142
|
-
##
|
|
121
|
+
## Documentation
|
|
143
122
|
|
|
144
|
-
|
|
123
|
+
- [How titer works](docs/how-it-works.md): the tiers, test verdicts, mutation operators, and the gate.
|
|
124
|
+
- [Configuration](docs/configuration.md): every `titer.toml` setting.
|
|
125
|
+
- [CLI reference](docs/cli.md): commands, options, exit codes, agent mutants, and the JSON report.
|
|
126
|
+
- [GitHub Action](docs/github-action.md): inputs, outputs, job summary, annotations, and PR comments.
|
|
127
|
+
- [Glossary](GLOSSARY.md): the terms titer uses and what they mean.
|
|
145
128
|
|
|
146
129
|
## License
|
|
147
130
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@greerviau/titer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"license": "MIT OR Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"node": ">=18"
|
|
30
30
|
},
|
|
31
31
|
"optionalDependencies": {
|
|
32
|
-
"@greerviau/titer-linux-x64": "0.1.
|
|
33
|
-
"@greerviau/titer-linux-arm64": "0.1.
|
|
34
|
-
"@greerviau/titer-darwin-arm64": "0.1.
|
|
35
|
-
"@greerviau/titer-darwin-x64": "0.1.
|
|
32
|
+
"@greerviau/titer-linux-x64": "0.1.3",
|
|
33
|
+
"@greerviau/titer-linux-arm64": "0.1.3",
|
|
34
|
+
"@greerviau/titer-darwin-arm64": "0.1.3",
|
|
35
|
+
"@greerviau/titer-darwin-x64": "0.1.3"
|
|
36
36
|
}
|
|
37
37
|
}
|