agent-roast 0.6.0 → 0.8.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
@@ -38,7 +38,7 @@ npx agent-roast check --baseline .agentroast-baseline.json
38
38
  npx agent-roast --staged
39
39
 
40
40
  # Audit pull request diffs (CI gate)
41
- npx agent-roast --base origin/main --head HEAD --format github
41
+ npx agent-roast review --base origin/main --head HEAD --format github
42
42
 
43
43
  # Optional historical audit
44
44
  npx agent-roast --all --verbose
@@ -106,9 +106,65 @@ regressions) may appear in the report/summary rather than as an inline PR annota
106
106
  Use a separate SARIF category for introduced-findings review; it does not represent
107
107
  a full scan of all outstanding alerts.
108
108
 
109
- Install with `npx agent-roast@0.6.0 review --base origin/main`. For local development,
109
+ Install 0.8.0: `npx agent-roast@0.8.0 review --base origin/main`. For local development,
110
110
  run `npm run build` and use `node dist/cli.js`.
111
111
 
112
+ ### Precise exceptions (since 0.8.0)
113
+
114
+ Use `npx agent-roast@0.8.0 check --format json`, or build this checkout with
115
+ `npm run build` and run `node dist/cli.js`.
116
+
117
+ Some skipped integrations or abstract stubs are intentional. In 0.8.0 you can accept
118
+ one exact finding without switching off the rule or ignoring its whole file:
119
+
120
+ 1. Run `node dist/cli.js check --format json` and inspect the evidence. Findings
121
+ include a stable `fingerprint` (rule, relative filename and trimmed source snippet).
122
+ 2. Add a reviewed `exceptions` entry to the root `.agentroastrc.json`, with the
123
+ fingerprint, the **total** allowed occurrence count, a reason and an expiry date.
124
+ 3. Run the check again. Accepted findings remain visible with their reason/date;
125
+ additional duplicate occurrences still block. Expired exceptions stop applying.
126
+ Use a full `check` to revisit old findings; `review` continues gating newly
127
+ introduced debt, so expiration does not turn unchanged old debt into a new finding.
128
+
129
+ ```json
130
+ {
131
+ "exceptions": [
132
+ {
133
+ "fingerprint": "f4d1212234f00381d0eaed359e3229fe4ff47388affc9eac0d0d89daffea13d6",
134
+ "count": 1,
135
+ "reason": "Integration sandbox unavailable; restore under ENG-42",
136
+ "expires": "2026-11-15"
137
+ }
138
+ ]
139
+ }
140
+ ```
141
+
142
+ The example fingerprint is for `it.skip('temporary');` in `auth.test.ts`; copy the
143
+ fingerprint from **your** report. Expiry includes the specified day in UTC. Changing
144
+ the rule, path or source snippet requires review again. Counts from an exception and
145
+ baseline do not add together to accept extra identical occurrences.
146
+
147
+ For committed/staged context reviews the allowance must already exist in the trusted
148
+ base/HEAD policy. A candidate PR or unstaged config cannot approve itself; first
149
+ commits use built-in defaults. `check` intentionally reads the current root policy.
150
+ Use `--ignore-exceptions` with `check`, `review` or `--staged` to inspect accepted
151
+ findings again. This flag does not disable a separately supplied baseline.
152
+ Exceptions apply to these context/current-source workflows; historical and legacy
153
+ added-line audits do not apply them. A full scan can use baseline adoption for old
154
+ debt, while exceptions record temporary reviewed decisions about particular findings.
155
+
156
+ JSON/Markdown/terminal reports separate accepted exceptions from actionable findings.
157
+ SARIF retains accepted records with `suppressions` and their justification/expiry;
158
+ JSON and SARIF include stable occurrence identities. SARIF omits code snippets but
159
+ includes exception reasons, so review those before sharing reports.
160
+
161
+ An offline editor schema is included as `schema.json` in the npm package. When using
162
+ a local dev dependency, set `$schema` to `./node_modules/agent-roast/schema.json`.
163
+ Ignore policies are bounded to 1,000 patterns of at most 1,024 characters each.
164
+ Unknown settings, invalid severities and malformed exceptions fail with exit 2.
165
+ Root policy must be a regular UTF-8 file no larger than 64 KiB. Simple ignore globs
166
+ support `*`, `?`, `**` and directory prefixes; they are not full `.gitignore` syntax.
167
+
112
168
  ### Baseline adoption
113
169
 
114
170
  A baseline explicitly accepts the findings present at adoption time. It does not fix
@@ -175,7 +231,6 @@ Configure custom ignore paths, rule severities, and CI thresholds with a `.agent
175
231
 
176
232
  ```json
177
233
  {
178
- "$schema": "https://raw.githubusercontent.com/Nari-Ab/agent-roast/main/schema.json",
179
234
  "ignorePaths": [
180
235
  "**/*.min.js",
181
236
  "**/vendor/**",
@@ -183,11 +238,10 @@ Configure custom ignore paths, rule severities, and CI thresholds with a `.agent
183
238
  "**/fixtures/**"
184
239
  ],
185
240
  "rules": {
186
- "hallucinated-package": "error",
187
- "empty-catch": "warn",
241
+ "test-focus": "error",
242
+ "swallowed-error": "warn",
188
243
  "trivial-assert": "warn",
189
- "stub-abandonment": "warn",
190
- "mock-leak": "warn"
244
+ "stub-abandonment": "warn"
191
245
  },
192
246
  "scoreThreshold": 70
193
247
  }
@@ -203,9 +257,25 @@ npx agent-roast --staged
203
257
  npx agent-roast init --hook
204
258
  ```
205
259
 
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
260
+ Since 0.7.0, `--staged` (also `review --staged`) compares the **full source**
261
+ of changed files in HEAD and the Git index. It detects deletion-only empty handlers
262
+ and retains comment context. Existing findings do not block; additional occurrences
263
+ do. Unstaged edits, untracked files and `git add -N` intent-to-add entries are excluded.
264
+ The older 0.6.0 `--staged` command checks only added index lines. Since
265
+ 0.8.0, it also reads Git's temporary candidate index during real `commit -a` / `--only`
266
+ hooks. An alternate `GIT_INDEX_FILE` outside this checkout's Git metadata is refused
267
+ with exit 2; it cannot silently redirect the check to a different commit.
268
+
269
+ Policy comes from HEAD. Staged/unstaged config edits cannot weaken this check and
270
+ are reported; adopt policy changes in a separately reviewed commit. With no HEAD,
271
+ the first commit uses built-in defaults; use `--fail-on` for an explicit override.
272
+ For example: `node dist/cli.js review --staged --fail-on test-skip,test-focus,swallowed-error`.
273
+ Source is pinned by Git blob IDs. If HEAD or the staged inventory changes before the
274
+ scan finishes, it exits 2 and asks for a rerun. The report's `source` is `index`;
275
+ `headSha` is an `INDEX:` snapshot digest, not a commit SHA, and an unborn base is `EMPTY`.
276
+ The JSON schema version for context reviews is now `1.1.0`.
277
+
278
+ The generated hook uses the locally installed CLI (`--no-install`) and blocks on configured error rules instead of scoring
209
279
  old commits. It preserves an existing pre-commit hook.
210
280
 
211
281
  ### Configure what blocks a change
@@ -216,6 +286,7 @@ Create `.agentroastrc.json` (or run `npx agent-roast init`):
216
286
  {
217
287
  "rules": {
218
288
  "test-skip": "error",
289
+ "test-focus": "error",
219
290
  "trivial-assert": "error",
220
291
  "swallowed-error": "warn",
221
292
  "type-escape": "off"
@@ -227,7 +298,7 @@ Create `.agentroastrc.json` (or run `npx agent-roast init`):
227
298
  ```
228
299
 
229
300
  `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
301
+ `error` blocks PR/staged checks, including `test-focus` by default in 0.7.0. An explicit `failOn` array overrides which enabled
231
302
  rules block (`[]` makes the audit advisory). CLI `--fail-on` takes precedence over
232
303
  that array. History and badge audits honor disabled rules and the panic-loop window.
233
304
  History exit status is controlled by `scoreThreshold` or `--fail-under`.
@@ -236,8 +307,10 @@ Configurations generated by older versions may contain unsupported rules such as
236
307
  `hallucinated-package`, `empty-catch` or `mock-leak`; remove these entries and use
237
308
  `swallowed-error` for empty catches.
238
309
 
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
310
+ Exit codes: `0` passed, `1` blocking findings/score threshold, `2` invalid configuration,
311
+ Git refs or an incomplete scan. Since 0.8.0, legacy/history CLI audits also return 2
312
+ when lines were skipped or supported source was marked binary by Git attributes,
313
+ instead of treating missing coverage as a clean result. `--format json` also works for history audits. A history
241
314
  sample below 200 added lines has no score, but its findings are still shown.
242
315
 
243
316
  ### GitHub Actions Integration
@@ -264,18 +337,25 @@ jobs:
264
337
  - name: Run agent-roast audit
265
338
  uses: Nari-Ab/agent-roast@v1
266
339
  with:
267
- fail-on: test-skip,trivial-assert,stub-abandonment
268
340
  format: github
269
341
  ```
270
342
 
343
+ To pilot the Action without blocking on findings, set `advisory: true`. It passes
344
+ an explicit empty fail-on list; invalid configuration, Git errors and incomplete
345
+ scans still fail. The `v1` Action installs 0.8.0. The CLI equivalent is `--fail-on ''`.
346
+
271
347
  > **Security Note:** `agent-roast` runs in an isolated runner directory (`$RUNNER_TEMP`) with `--ignore-scripts` to neutralize malicious `.npmrc` files in untrusted pull requests. `pull_request_target` is not supported.
272
348
 
273
349
  ---
274
350
 
275
351
  ### What it checks
276
352
 
277
- Only **added lines** (`+`) in source code files are scanned — deleted lines, file moves, and comments never trigger false alarms.
353
+ `check` scans current source. `review` scans both full versions of changed source;
354
+ the 0.7.0 `--staged` command does the same for HEAD and index. Legacy
355
+ `--base` and history audits inspect added lines. Comment/literal masking reduces
356
+ noise; these are heuristic checks and can have false positives and missed findings.
278
357
 
358
+ - **Focused tests (`test-focus`):** Exclusive `test.only`, `it.only`, `describe.only`, `suite.only`, Playwright `test.describe.only` and common modifier chains in JS/TS-family sources. `fit` / `fdescribe` aliases are recognized in conventional test paths. Supports contiguous multiline chains and ignores literal/comment examples. Default blocking rule; an existing explicit `failOn` list must include it to block. This does not resolve imports or custom aliases; configure your runner's native forbid-only option too when available ([Playwright](https://playwright.dev/docs/api/class-testconfig#test-config-forbid-only), [Jest API](https://jestjs.io/docs/api#testonlyname-fn-timeout)).
279
359
  - **Skipped tests (`test-skip`):** `it.skip`, `describe.skip`, `xit`, `pytest.skip`, `test.todo` added to silence failing tests. (Default blocking gate).
280
360
  - **Trivial assertions (`trivial-assert`):** Tautological or dummy assertions added to fabricate test green checks (`expect(true).toBe(true)`, `expect(1).toBe(1)`, `assert True`, `self.assertTrue(True)`).
281
361
  - **Stub abandonment (`stub-abandonment`):** Dummy stubs left unimplemented in committed code (`throw new Error("Not implemented")`, `raise NotImplementedError`, Rust `todo!()` / `unimplemented!()`).
@@ -308,14 +388,30 @@ Only **added lines** (`+`) in source code files are scanned — deleted lines, f
308
388
  Use this as a focused review aid for skipped tests, compiler suppressions and obvious
309
389
  stubs, alongside a compiler, test runner and language-aware linter. Findings identify
310
390
  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.
391
+ methods can be legitimate. Since 0.8.0, the analyzer improves language-specific checks, multiline skips/assertions,
392
+ Rust raw strings/lifetimes and Java/Kotlin text blocks. Contiguous comments, Python
393
+ docstrings and multiline empty handlers are recognized. Template interpolation, complex language syntax and context outside
394
+ the added diff in legacy audit modes are not fully parsed. Custom test API aliases,
395
+ computed property calls and type/import resolution are not handled. Panic loops are an observational history heuristic.
314
396
  The discipline score summarizes added history; it does not certify current code quality.
315
397
  `check` reports actionable findings without assigning a personality or quality score.
398
+ History attribution is based on explicit text/identity heuristics; it does not prove
399
+ AI authorship. Since 0.8.0, the analyzer avoids classifying ordinary people by name fragments
400
+ or treating every automation bot as an AI author. Use `--all` for all commits.
401
+
402
+ The website demos are synthetic illustrations, labeled as such. Older GIF/video
403
+ assets are legacy demonstrations, not performance measurements or adoption evidence.
404
+ See [related tools and design choices](docs/product/related-tools.md) for approaches
405
+ reviewed in Semgrep, Ruff, Gitleaks, reviewdog and eslint-plugin-jest. No third-party
406
+ implementation was copied.
316
407
 
317
408
  ### Development
318
409
 
410
+ Develop/build/test with Node.js 20.19+ (or 22.12+). The distributed CLI still supports
411
+ Node.js 18+. Patched Vitest 4 and build tooling are development dependencies only;
412
+ CI runs the current test runner on Node 22 while CLI subprocesses and actual Git hooks
413
+ are exercised on Node 18/20/22 using `AGENT_ROAST_TEST_NODE`.
414
+
319
415
  ```bash
320
416
  npm ci
321
417
  npm run typecheck
@@ -323,7 +419,11 @@ npm test
323
419
  ```
324
420
 
325
421
  `npm test` builds the distribution first so CLI integration and bundle checks run
326
- against current code. Regression tests use disposable Git repositories.
422
+ against current code. Regression tests use disposable Git repositories. The programmatic
423
+ `auditPullRequest({ staged: true })` API retains the legacy added-lines contract;
424
+ use `reviewStagedChanges()` for the new context comparison and `ReviewResult`.
425
+ The composite Action installs exactly 0.8.0. For local development, use
426
+ `node dist/cli.js --staged` after building.
327
427
 
328
428
  ### Author & Support
329
429