agent-roast 0.4.0 → 0.6.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/README.md CHANGED
@@ -5,11 +5,10 @@
5
5
  <img src="docs/assets/logo.svg" alt="agent-roast" width="380">
6
6
  </picture>
7
7
 
8
- <h2>Audit your git history for AI coding agent infractions and panic loops</h2>
8
+ <h2>Catch coding shortcuts before they ship</h2>
9
9
 
10
10
  <p>
11
- <a href="https://github.com/Nari-Ab/agent-roast/actions"><img src="https://img.shields.io/badge/CI-passing-2ea44f?logo=github&logoColor=white" alt="CI"></a>
12
- <a href="https://github.com/Nari-Ab/agent-roast"><img src="https://img.shields.io/badge/roast%20audit-verified-2ea44f" alt="Roast Audit"></a>
11
+ <a href="https://github.com/Nari-Ab/agent-roast/actions/workflows/test.yml"><img src="https://github.com/Nari-Ab/agent-roast/actions/workflows/test.yml/badge.svg" alt="CLI tests"></a>
13
12
  <a href="https://www.npmjs.com/package/agent-roast"><img src="https://img.shields.io/npm/v/agent-roast?color=cb3837&logo=npm&logoColor=white" alt="npm"></a>
14
13
  <a href="https://www.npmjs.com/package/agent-roast"><img src="https://img.shields.io/npm/dt/agent-roast?label=downloads&color=0969da" alt="downloads"></a>
15
14
  <a href="https://nari-ab.github.io/agent-roast/"><img src="https://img.shields.io/badge/site-live-1f9d55" alt="site"></a>
@@ -18,31 +17,124 @@
18
17
 
19
18
  </div>
20
19
 
21
- `agent-roast` scans recorded git diffs for shortcuts taken by AI coding assistants (Claude Code, Cursor, Codex, Antigravity, Aider). It checks for skipped tests, fake tautological assertions, abandoned stubs, compiler type escapes (`as any`), swallowed errors, and panic revert loops, then outputs a discipline score and line proofs. 100% offline, zero API keys, zero telemetry.
20
+ `agent-roast` is an offline review aid for skipped tests, fake assertions, swallowed
21
+ errors, unfinished stubs and type-check bypasses. Start with the code you have now;
22
+ no AI commit tags, cloud account, API key or commit history are required for `check`.
23
+ A Git repository is required; `git init` is sufficient.
22
24
 
23
25
  ```bash
24
- # Initialize in your repository (creates .agentroastrc.json)
25
- npx agent-roast init
26
- npx agent-roast init --ci # generate .github/workflows/agent-roast.yml
27
- npx agent-roast init --hook # install .git/hooks/pre-commit
26
+ # Inspect current tracked + non-ignored untracked source files
27
+ npx agent-roast check
28
28
 
29
- # Audit repository history
30
- npx agent-roast # scan AI-attributed commits (last 90 days)
31
- npx agent-roast --all # scan entire repository history
32
- npx agent-roast --verbose # show commit SHAs and line proofs
33
- npx agent-roast --fail-under 70 # exit code 1 if score is below 70
29
+ # Understand a finding and what to do next
30
+ npx agent-roast explain swallowed-error
31
+
32
+ # Adopt it in an existing project without blocking on all historical debt
33
+ npx agent-roast check --write-baseline .agentroast-baseline.json
34
+ # Review the findings and commit this policy file, then gate only new problems
35
+ npx agent-roast check --baseline .agentroast-baseline.json
36
+
37
+ # Verify precisely what you are about to commit
38
+ npx agent-roast --staged
34
39
 
35
40
  # Audit pull request diffs (CI gate)
36
- npx agent-roast --base origin/main --head HEAD
37
- npx agent-roast --base origin/main --head HEAD --fail-on test-skip,trivial-assert,stub-abandonment --format github
38
- npx agent-roast --base origin/main --format markdown # rich markdown for PR comments
39
-
40
- # Generate AI discipline badge for your README
41
- npx agent-roast badge # prints Shields.io Markdown snippet
42
- npx agent-roast badge --out ./badge.svg # exports standalone SVG badge
43
- npx agent-roast badge --json # Shields.io dynamic endpoint payload
41
+ npx agent-roast --base origin/main --head HEAD --format github
42
+
43
+ # Optional historical audit
44
+ npx agent-roast --all --verbose
45
+ ```
46
+
47
+ A finding includes its file and line, the source snippet, and a concrete next step.
48
+ To see the complete machine-readable result, use `check --format json`; terminal
49
+ output shows the first 20 findings. `check --format markdown` produces a review table.
50
+
51
+ ### Context review for pull requests
52
+
53
+ ```bash
54
+ # Compare committed source at the common ancestor and candidate head
55
+ agent-roast review --base origin/main --head HEAD
56
+ agent-roast review --base origin/main --format markdown
57
+
58
+ # Export a report for tools that consume SARIF 2.1.0
59
+ agent-roast review --base origin/main --format sarif > agentroast.sarif
60
+ agent-roast check --format sarif > current-code.sarif
61
+ ```
62
+
63
+ `review` compares **full contents of changed source files**, so deleting the only
64
+ handler inside a `catch` is detectable even when no suspicious line was added.
65
+ It reports new findings, existing findings, and patterns no longer detected. Only
66
+ new blocking findings fail the check; no manually generated baseline is required.
67
+ Deleting a file is reported as disappearance of a pattern, not proof of a correct fix.
68
+
69
+ Source is read directly from immutable Git blobs at the merge-base and head. The
70
+ worktree and index are left untouched, and project code, hooks, diff programs and
71
+ package scripts are never executed. Use `check` for uncommitted working files, and
72
+ `--staged` for the index. Source comparison and policy are pinned to the reported SHAs.
73
+
74
+ Policy comes from the explicitly supplied **base ref tip**; source comparison starts
75
+ at the merge-base. Candidate changes to `.agentroastrc.json`, `.agentroastrc` or
76
+ `agent-roast.config.json` are reported and ignored for this review. Adopt policy
77
+ changes through separate human review. An explicit `--fail-on` overrides blocking
78
+ severity but does not enable rules disabled by base policy.
79
+
80
+ ```bash
81
+ # Advisory pilot: inspect findings before deciding what should block the team
82
+ agent-roast review --base origin/main --fail-on ''
83
+ # Gate the shortcuts the team agrees matter
84
+ agent-roast review --base origin/main --fail-on test-skip,trivial-assert,swallowed-error
44
85
  ```
45
86
 
87
+ Matching uses rule, source snippet and occurrence count within a file pair. Line
88
+ shifts and Git-recognized pure renames do not turn old debt into new debt. A second
89
+ identical occurrence is new. This is not semantic tracking: rewritten snippets or
90
+ language changes can require fresh review, and Git's rename recognition is heuristic.
91
+
92
+ Limits: 1,000 changed files, 2 MiB per source blob, 50 MiB across inspected versions,
93
+ 30 seconds per Git command. Symlinked/binary/oversized source and missing comparison
94
+ objects yield exit 2, never a clean pass. Partial clones and ambiguous multiple
95
+ merge-bases are unsupported; fetch complete local history (`fetch-depth: 0`). The
96
+ report counts excluded and unsupported changes explicitly. Only changed supported
97
+ files are compared; this is not a whole-repository safety certification.
98
+
99
+ SARIF includes rule metadata, relative locations, stable occurrence fingerprints
100
+ and whether the scan completed. Source snippets are omitted from SARIF. JSON and
101
+ Markdown reports contain evidence snippets and should be handled as source code.
102
+ SARIF output is generated offline; uploading it is a separate, optional operation.
103
+ GitHub supports SARIF ingestion, but this release has not been tested with a live
104
+ code-scanning upload. Some findings on unchanged lines (including deletion-only
105
+ regressions) may appear in the report/summary rather than as an inline PR annotation.
106
+ Use a separate SARIF category for introduced-findings review; it does not represent
107
+ a full scan of all outstanding alerts.
108
+
109
+ Install with `npx agent-roast@0.6.0 review --base origin/main`. For local development,
110
+ run `npm run build` and use `node dist/cli.js`.
111
+
112
+ ### Baseline adoption
113
+
114
+ A baseline explicitly accepts the findings present at adoption time. It does not fix
115
+ or hide new code. Fingerprints use the rule, repository-relative filename and source
116
+ snippet; line numbers are excluded so adding clean code above a finding does not
117
+ break it. Occurrence counts ensure a second identical shortcut is still new. Moving
118
+ a finding to another file or changing its snippet requires a fresh review. Baselines
119
+ contain hashes and counts, not source code. The report shows both accepted and new
120
+ findings and counts accepted findings no longer present.
121
+
122
+ Baseline use is explicit (`--baseline`), and writes refuse to overwrite existing
123
+ files. To refresh accepted debt, inspect the full scan and write a **new** baseline
124
+ file for review. Treat baseline changes as policy changes in code review. Do not
125
+ silently regenerate one in CI. Input/output baseline paths are relative to the
126
+ directory passed to `check` (or the current directory if omitted).
127
+
128
+ `check` scans the repository containing the supplied path, applies its root config,
129
+ respects Git ignores for untracked files, and excludes generated dependencies/build
130
+ outputs. It checks working files, while `--staged` checks the index. Git submodules
131
+ are not recursively scanned. A supported file that is binary, too large, unreadable
132
+ or a symlink makes the scan incomplete (exit 2); incomplete scans cannot create a
133
+ baseline. Limits are 2 MiB per source file and 50 MiB per scan. Intentional generated
134
+ or unsupported input should be excluded in `ignorePaths`, not silently counted clean.
135
+
136
+ History auditing remains available when you want an overview of prior shortcuts:
137
+
46
138
  What a report looks like (a real repository audit, trimmed):
47
139
 
48
140
  ```text
@@ -103,6 +195,51 @@ Configure custom ignore paths, rule severities, and CI thresholds with a `.agent
103
195
 
104
196
  ---
105
197
 
198
+ ### Check code before committing
199
+
200
+ ```bash
201
+ npm install --save-dev agent-roast
202
+ npx agent-roast --staged
203
+ npx agent-roast init --hook
204
+ ```
205
+
206
+ `--staged` audits exactly the Git index, including an initial commit without HEAD.
207
+ Unstaged edits and untracked files are excluded. The generated hook uses the locally
208
+ installed CLI (`--no-install`) and blocks on configured error rules instead of scoring
209
+ old commits. It preserves an existing pre-commit hook.
210
+
211
+ ### Configure what blocks a change
212
+
213
+ Create `.agentroastrc.json` (or run `npx agent-roast init`):
214
+
215
+ ```json
216
+ {
217
+ "rules": {
218
+ "test-skip": "error",
219
+ "trivial-assert": "error",
220
+ "swallowed-error": "warn",
221
+ "type-escape": "off"
222
+ },
223
+ "ignorePaths": ["**/generated/**", "**/vendor/**"],
224
+ "panicLoopWindowMinutes": 10,
225
+ "scoreThreshold": 70
226
+ }
227
+ ```
228
+
229
+ `off` removes findings and score penalties; `warn` reports without blocking a diff;
230
+ `error` blocks PR/staged checks. An explicit `failOn` array overrides which enabled
231
+ rules block (`[]` makes the audit advisory). CLI `--fail-on` takes precedence over
232
+ that array. History and badge audits honor disabled rules and the panic-loop window.
233
+ History exit status is controlled by `scoreThreshold` or `--fail-under`.
234
+ Invalid JSON, unknown rule names and invalid settings stop the audit with exit code 2.
235
+ Configurations generated by older versions may contain unsupported rules such as
236
+ `hallucinated-package`, `empty-catch` or `mock-leak`; remove these entries and use
237
+ `swallowed-error` for empty catches.
238
+
239
+ Exit codes: `0` passed, `1` blocking findings/score threshold, `2` invalid audit
240
+ configuration or Git refs. `--format json` also works for history audits. A history
241
+ sample below 200 added lines has no score, but its findings are still shown.
242
+
106
243
  ### GitHub Actions Integration
107
244
 
108
245
  Add `agent-roast` as a gate in your pull request workflow (`.github/workflows/agent-roast.yml`):
@@ -162,10 +299,32 @@ Only **added lines** (`+`) in source code files are scanned — deleted lines, f
162
299
  - **Requirements:** Git 2.30+ (for `--end-of-options` argument isolation), Node.js 18+.
163
300
  - **100% Local:** Instant streaming parser runs directly on your machine.
164
301
  - **Zero Telemetry:** No cloud dependencies, no LLM API calls, no network traffic. Verified by static bundle inspection.
165
- - **Hermetic:** Enforces `-c core.quotepath=false -c diff.noprefix=false` to guarantee identical behavior across all environments.
302
+ - **Git isolation:** Forces stable diff paths, disables fsmonitor/external diff execution, and reads review content by object identity.
166
303
 
167
304
  ---
168
305
 
306
+ ### Scope and limitations
307
+
308
+ Use this as a focused review aid for skipped tests, compiler suppressions and obvious
309
+ stubs, alongside a compiler, test runner and language-aware linter. Findings identify
310
+ patterns, not proof of AI authorship or developer intent. Deliberate skips and abstract
311
+ methods can be legitimate. Contiguous block comments, Python docstrings and multi-line empty handlers are
312
+ recognized. Template interpolation, complex language syntax and context outside
313
+ the added diff are not fully parsed. Panic loops are an observational history heuristic.
314
+ The discipline score summarizes added history; it does not certify current code quality.
315
+ `check` reports actionable findings without assigning a personality or quality score.
316
+
317
+ ### Development
318
+
319
+ ```bash
320
+ npm ci
321
+ npm run typecheck
322
+ npm test
323
+ ```
324
+
325
+ `npm test` builds the distribution first so CLI integration and bundle checks run
326
+ against current code. Regression tests use disposable Git repositories.
327
+
169
328
  ### Author & Support
170
329
 
171
330
  Created by Nariman Abdukarimov ([abdukarimov.nariman07@gmail.com](mailto:abdukarimov.nariman07@gmail.com)).