@tested/cli 0.1.0
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/LICENSE +21 -0
- package/README.md +174 -0
- package/dist/td.js +2579 -0
- package/dist/tested.js +2579 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jorge Modesto Software LTDA
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# @tested/cli
|
|
2
|
+
|
|
3
|
+
Coverage your agent can use. CLI for patch + project coverage with agent-readable JSON output.
|
|
4
|
+
|
|
5
|
+
**→ [Getting started (simple path)](docs/GETTING-STARTED.md)**
|
|
6
|
+
**→ [GitHub Action](action/README.md)** (`action/action.yml` composite)
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
Node >= 20.19.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pnpm add -D @tested/cli
|
|
14
|
+
# or
|
|
15
|
+
npx @tested/cli
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
CI uses the composite Action (`tested-hq/cli/action@main`). The Action clones this repo and builds the CLI.
|
|
19
|
+
|
|
20
|
+
```yaml
|
|
21
|
+
- uses: tested-hq/cli/action@main
|
|
22
|
+
with:
|
|
23
|
+
token: ${{ secrets.TESTED_TOKEN }}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Pin `cli-ref` to a SHA in production. See [action/README.md](action/README.md).
|
|
27
|
+
|
|
28
|
+
## First 10 minutes
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
tested setup # init + doctor + CI snippet + token help
|
|
32
|
+
tested doctor # environment checklist (exit 0/1)
|
|
33
|
+
tested run # writes coverage even if tests fail
|
|
34
|
+
tested diff # report (exit 0)
|
|
35
|
+
tested check # gate (exit 1 if under threshold)
|
|
36
|
+
tested push --pr <n> # needs TESTED_TOKEN
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Security
|
|
40
|
+
|
|
41
|
+
> **Only point `tested` at repositories you trust.** `tested run` (and the MCP
|
|
42
|
+
> server’s `write_and_verify`) executes the project’s own test runner (`npx
|
|
43
|
+
> vitest` / jest / pytest). That is equivalent to running untrusted code when
|
|
44
|
+
> the cwd is untrusted.
|
|
45
|
+
|
|
46
|
+
| Control | Detail |
|
|
47
|
+
|---------|--------|
|
|
48
|
+
| Ingest token | Prefer `TESTED_TOKEN` / `TESTED_INGEST_TOKEN` / `TESTED_TOKEN_FILE` (mode `0600`). Avoid `--token` on shared hosts — it appears on process argv (`ps`). |
|
|
49
|
+
| Safe run args | In CI, non-interactive shells, or when `TESTED_SAFE_RUN=1`, `tested run` rejects `--watch` / `--watchAll` and `--config` paths outside the repo root. |
|
|
50
|
+
| API URL | Ingest posts only to `https://` (or `http://localhost`). Redirects with Bearer token are refused. |
|
|
51
|
+
| MCP hosts | For always-on agent hosts, set `TESTED_ALLOWED_CWDS` (see `@tested/mcp`) so tools cannot target arbitrary directories. |
|
|
52
|
+
|
|
53
|
+
## Agent loop
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
tested setup # init + doctor + CI / token guidance
|
|
57
|
+
tested run # run tests with coverage (writes coverage even if tests fail)
|
|
58
|
+
tested diff # patch + project report (exit 0; not the gate)
|
|
59
|
+
tested check # enforce thresholds (exit non-zero on fail)
|
|
60
|
+
tested push --pr <n> # share URL on app.tested.dev (needs token)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Terminal UX
|
|
64
|
+
|
|
65
|
+
Human output is monochrome editorial craft: restrained color via picocolors (green / yellow / red for status only). ASCII badges (`[PASS]` / `[FAIL]`) and metric bars. Honors `NO_COLOR` and non-TTY (no ornaments when color is unsupported).
|
|
66
|
+
|
|
67
|
+
`--json` on every command keeps agent schemas stable.
|
|
68
|
+
|
|
69
|
+
## Dogfood
|
|
70
|
+
|
|
71
|
+
This repo enforces its own coverage gate on every push via husky pre-push hook:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
🐕 dogfood: running tested on itself...
|
|
75
|
+
... coverage report ...
|
|
76
|
+
🐕 patch coverage 87.2% >= 50% — push allowed
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The hook runs `tested run && tested diff` against the upstream branch (or `HEAD~1` if no upstream). Blocks push if patch coverage < 50%. Override with `git push --no-verify` (don't).
|
|
80
|
+
|
|
81
|
+
## Gating
|
|
82
|
+
|
|
83
|
+
`tested diff` is a report (exit 0) even when coverage is under the yaml threshold. `tested check` is the gate: it enforces the `thresholds` block in `.tested.yaml` and exits non-zero when patch or project coverage falls below the configured floor.
|
|
84
|
+
|
|
85
|
+
```yaml
|
|
86
|
+
thresholds:
|
|
87
|
+
patch: 80 # % of newly-added lines that must be covered
|
|
88
|
+
project: 60 # % of the whole project that must be covered
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
$ tested check
|
|
93
|
+
tested.dev — coverage gate [PASS]
|
|
94
|
+
|
|
95
|
+
Patch 87.3% (threshold 80) [PASS]
|
|
96
|
+
Project 64.1% (threshold 60) [PASS]
|
|
97
|
+
|
|
98
|
+
thresholds met
|
|
99
|
+
$ echo $?
|
|
100
|
+
0
|
|
101
|
+
|
|
102
|
+
$ tested check
|
|
103
|
+
tested.dev — coverage gate [FAIL]
|
|
104
|
+
|
|
105
|
+
Patch 42.7% (threshold 80) [FAIL]
|
|
106
|
+
Project 64.1% (threshold 60) [PASS]
|
|
107
|
+
|
|
108
|
+
→ add tests for uncovered ranges: tested diff
|
|
109
|
+
$ echo $?
|
|
110
|
+
1
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
If `thresholds` is missing from `.tested.yaml`, `tested check` prints a notice on stderr and exits 0 — configs that haven't opted in stay green.
|
|
114
|
+
|
|
115
|
+
### GitHub Actions
|
|
116
|
+
|
|
117
|
+
```yaml
|
|
118
|
+
- uses: tested-hq/cli/action@main
|
|
119
|
+
with:
|
|
120
|
+
push: true
|
|
121
|
+
pr-number: ${{ github.event.pull_request.number }}
|
|
122
|
+
token: ${{ secrets.TESTED_TOKEN }}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### `--json`
|
|
126
|
+
|
|
127
|
+
For programmatic consumers:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
$ tested check --json
|
|
131
|
+
{"patch":{"pct":87.3,"threshold":80,"pass":true},"project":{"pct":64.1,"threshold":60,"pass":true},"overall":"pass"}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`--json` suppresses the human layout; the exit code is unchanged.
|
|
135
|
+
|
|
136
|
+
## Share (`tested push`)
|
|
137
|
+
|
|
138
|
+
Push local patch/project coverage to [tested.dev](https://app.tested.dev) and get a share URL back. Closes the agent loop: local coverage → cloud link.
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
$ export TESTED_TOKEN=… # or TESTED_INGEST_TOKEN / --token
|
|
142
|
+
$ export GITHUB_PR_NUMBER=42 # or --pr 42
|
|
143
|
+
$ tested push
|
|
144
|
+
✓ shared https://app.tested.dev/share/…
|
|
145
|
+
expires 2026-…
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
| Flag / env | Purpose |
|
|
149
|
+
|---|---|
|
|
150
|
+
| `TESTED_TOKEN` / `TESTED_INGEST_TOKEN` / `TESTED_TOKEN_FILE` | Ingest auth (**preferred** — not on argv) |
|
|
151
|
+
| `--token` | Ingest auth (works; warns on TTY; visible in `ps`) |
|
|
152
|
+
| `--pr` / `GITHUB_PR_NUMBER` / `PR_NUMBER` | PR number (required) |
|
|
153
|
+
| `--url` / `TESTED_API_URL` | API base (default `https://app.tested.dev`) |
|
|
154
|
+
| `--owner` / `--name` | Repo identity (default: parse `origin` remote) |
|
|
155
|
+
| `--pr-title`, `--author`, `--base-ref`, `--head-ref` | PR metadata overrides |
|
|
156
|
+
| `--base` | Git base for the coverage diff (same as `tested diff --base`) |
|
|
157
|
+
| `--run-url` | Optional CI run URL |
|
|
158
|
+
| `--json` | Machine output: `{ "shareUrl", "expiresAt?" }` |
|
|
159
|
+
|
|
160
|
+
### `tested run` extra args
|
|
161
|
+
|
|
162
|
+
Extra args are forwarded to the runner via argv (no shell). In CI /
|
|
163
|
+
non-interactive mode / when `TESTED_SAFE_RUN=1`:
|
|
164
|
+
|
|
165
|
+
- `--watch`, `--watchAll`, `-w` are **rejected** (hang risk)
|
|
166
|
+
- `--config` / `-c` paths that resolve **outside the repo root** are **rejected**
|
|
167
|
+
|
|
168
|
+
Typical CI step after `tested check`:
|
|
169
|
+
|
|
170
|
+
```yaml
|
|
171
|
+
- run: pnpm exec tested push --pr "${{ github.event.pull_request.number }}"
|
|
172
|
+
env:
|
|
173
|
+
TESTED_TOKEN: ${{ secrets.TESTED_TOKEN }}
|
|
174
|
+
```
|