eslint-plugin-ai-guard 1.4.2 → 1.4.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 CHANGED
@@ -37,7 +37,8 @@
37
37
  - **ESLint plugin** with 18 deterministic rules and 4 presets (`recommended`, `strict`, `security`, `agent`)
38
38
  - **CLI** (`ai-guard`) for terminal, changed-file, and CI scanning
39
39
  - **GitHub Action** with native SARIF 2.1.0 output for GitHub Code Scanning
40
- - **Claude Code integration** with a zero-config PostToolUse hook
40
+ - **Check integrity** (`ai-guard integrity`) — detects changes that weaken checks: new suppressions, skipped or removed tests, lowered ESLint/TypeScript/coverage settings, removed CI steps
41
+ - **Claude Code integration** with hooks that send findings back to Claude and block finishing once when checks were weakened
41
42
  - **MCP server** (`ai-guard-mcp`) for local AI-agent workflows over STDIO
42
43
 
43
44
  It is engineered to detect reliability bugs, async hazards, security vulnerabilities, and code-scaffolding defects frequently introduced during AI-assisted development (GitHub Copilot, Cursor, Claude Code, Gemini Code Assist, etc.).
@@ -262,8 +263,9 @@ npx ai-guard <command> [options]
262
263
 
263
264
  | Command | Purpose | Common Options |
264
265
  | :--- | :--- | :--- |
265
- | `run` | Scan your workspace using AI Guard AST rules | `--path <dir>`, `--strict`, `--security`, `--json`, `--sarif`, `--fail-on <level>`, `--max-warnings <n>` |
266
- | `changed` | Fast CI scan — only scans modified files in git | `--pr`, `--staged`, `--base <branch>`, `--strict`, `--sarif`, `--sarif-output <file>`, `--fail-on <level>` |
266
+ | `run` | Scan your workspace using AI Guard AST rules | `--path <dir>`, `--strict`, `--security`, `--json`, `--sarif`, `--fail-on <level>`, `--max-warnings <n>`, `--inline-suppressions <mode>` |
267
+ | `changed` | Fast CI scan — only scans modified files in git | `--pr`, `--staged`, `--base <branch>`, `--baseline [file]`, `--integrity <off\|report\|enforce>`, `--inline-suppressions <mode>`, `--strict`, `--sarif`, `--sarif-output <file>`, `--fail-on <level>` |
268
+ | `integrity` | Detect changes that weaken checks vs a base revision ([docs](./docs/integrity.md)) | `--base <ref>`, `--pr`, `--staged`, `--enforce`, `--json`, `--sarif`, `--accept <fingerprints\|all>` |
267
269
  | `init` | Automatically detect environment & configure ESLint | `--preset <name>`, `--flat`, `--dry-run`, `-y, --yes` |
268
270
  | `init-context` | Generate prompt instruction files for AI coding agents | `-a, --all`, `--force`, `--dry-run`, `--rules <categories>` |
269
271
  | `doctor` | Diagnose your ESLint, parser, and plugin environment | (No options needed — prints actionable diagnostic report) |
@@ -295,8 +297,23 @@ npx ai-guard report --output ai-guard-report.html
295
297
  # 6. Save existing issues as baseline and only fail on new regressions
296
298
  npx ai-guard baseline --save
297
299
  npx ai-guard baseline --check
300
+
301
+ # 7. Fail a PR that skips tests, adds eslint-disable, or lowers coverage thresholds
302
+ npx ai-guard changed --pr --integrity enforce
298
303
  ```
299
304
 
305
+ ### Inline suppressions never hide findings silently
306
+
307
+ AI Guard reads `eslint-disable` directives itself; ESLint's own inline config is disabled in AI Guard's private ESLint instance, so a comment cannot make a finding vanish without a trace. `--inline-suppressions` selects the policy:
308
+
309
+ | Mode | Effect |
310
+ |---|---|
311
+ | `allow` (default) | A covering directive hides the finding from totals and exit codes; it is listed under "Hidden by inline directives" (JSON `suppressedIssues`, step summary, SARIF `suppressedFindingsCount`) |
312
+ | `require-reason` | Only directives with a ` -- reason` hide findings (used by the Claude Code hook) |
313
+ | `ignore` | Directives never hide AI Guard findings (always used by the MCP server) |
314
+
315
+ This applies to `ai-guard run`, `changed`, the GitHub Action, the Claude Code hook and MCP. It does not change how your own `eslint .` treats directives. TypeScript comments (`@ts-ignore`, `@ts-nocheck`) never affect AI Guard findings; `ai-guard integrity` reports newly added ones.
316
+
300
317
  ---
301
318
 
302
319
  ## AI Agent Integration (`init-context`)
@@ -332,14 +349,16 @@ This dual-layer defense minimizes review friction and ensures generated code mee
332
349
 
333
350
  ## Claude Code Integration
334
351
 
335
- AI Guard integrates directly with [Claude Code](https://docs.anthropic.com/en/docs/claude-code) as a **PostToolUse validation hook**. Every time Claude Code edits or writes a JS/TS file, AI Guard automatically scans it for common issues.
352
+ AI Guard integrates directly with [Claude Code](https://code.claude.com/docs/en/hooks) through hooks:
336
353
 
337
354
  ```bash
338
355
  # One-command setup
339
356
  npx ai-guard init-claude
340
357
  ```
341
358
 
342
- This configures a PostToolUse hook in `.claude/settings.json` that runs AI Guard's fast `agent` preset (5 high-confidence rules, ~50-200ms per file) after every file edit. Claude Code reads the diagnostics and can fix issues automatically.
359
+ - **PostToolUse** — after each edit, findings from the `agent` preset and newly weakened checks in the edited file are sent back to Claude (`decision: "block"` + `reason`, per the hooks protocol). Earlier versions printed plain stdout, which Claude Code does not show to Claude.
360
+ - **SessionStart + Stop** — before Claude finishes, [check integrity](./docs/integrity.md) runs on everything changed in the session. High-confidence weakenings (a new `.skip`, `eslint-disable`, lowered threshold…) block stopping once per finding set; advisories are shown to you, never block.
361
+ - **PreToolUse (Bash)** — `git commit --no-verify` / `HUSKY=0` ask for confirmation.
343
362
 
344
363
  ```bash
345
364
  # Preview before applying
@@ -414,6 +433,9 @@ jobs:
414
433
  | `package-manager` | Package manager: `auto` \| `npm` \| `pnpm` \| `yarn` | `'auto'` |
415
434
  | `sarif-output` | Output filepath for generated SARIF report | `'ai-guard-results.sarif'` |
416
435
  | `install-deps` | Install project dependencies prior to scanning | `'true'` |
436
+ | `baseline` | Committed baseline file; with `changed-only`, report only findings not in it | `''` |
437
+ | `integrity` | Check integrity: `off` \| `report` \| `enforce` (needs `changed-only` and `fetch-depth: 0`) | `'off'` |
438
+ | `inline-suppressions` | `allow` \| `require-reason` \| `ignore` for eslint-disable directives covering AI Guard findings | `''` (allow) |
417
439
 
418
440
  ### Action Outputs
419
441
 
@@ -423,6 +445,8 @@ jobs:
423
445
  | `high-confidence-count` | Number of high-confidence issues flagged |
424
446
  | `medium-confidence-count` | Number of medium-confidence issues flagged |
425
447
  | `files-scanned` | Count of files analyzed during the execution |
448
+ | `integrity-high-count` | High-confidence check-integrity findings (when `integrity` is enabled) |
449
+ | `integrity-advisory-count` | Advisory check-integrity findings (when `integrity` is enabled) |
426
450
  | `sarif-file` | Absolute path to the generated SARIF 2.1.0 artifact |
427
451
  | `duration-ms` | Total scan execution duration in milliseconds |
428
452
 
@@ -639,6 +663,7 @@ npx --yes --package eslint-plugin-ai-guard ai-guard-mcp
639
663
  | `ai_guard_scan_diff` | Scan changed files in git diff (including newly created untracked JS/TS files) |
640
664
  | `ai_guard_scan_project` | Scan a bounded workspace directory (current source; not yet published) |
641
665
  | `ai_guard_rules` | List rules and presets, or look up specific rules (`rules: ["no-floating-promise"]`) with remediation and docs link |
666
+ | `ai_guard_check_integrity` | Report checks weakened by current Git changes (new suppressions, skipped/removed tests, lowered configs, removed CI steps), with `tier` and `hasBlockingFindings` |
642
667
 
643
668
  All tools declare an `outputSchema`; the text content is the same result as compact JSON. Scan tools accept `maxIssues` (default 50, errors first, exact `totalIssues` and `truncated`). The `verify_changes` prompt runs the scan → fix → rescan loop.
644
669
 
@@ -619,6 +619,32 @@ The above copyright notice and this permission notice shall be included in all c
619
619
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
620
620
  ```
621
621
 
622
+ ## js-yaml@4.3.2 (MIT)
623
+
624
+ ```text
625
+ (The MIT License)
626
+
627
+ Copyright (C) 2011-2015 by Vitaly Puzrin
628
+
629
+ Permission is hereby granted, free of charge, to any person obtaining a copy
630
+ of this software and associated documentation files (the "Software"), to deal
631
+ in the Software without restriction, including without limitation the rights
632
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
633
+ copies of the Software, and to permit persons to whom the Software is
634
+ furnished to do so, subject to the following conditions:
635
+
636
+ The above copyright notice and this permission notice shall be included in
637
+ all copies or substantial portions of the Software.
638
+
639
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
640
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
641
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
642
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
643
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
644
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
645
+ THE SOFTWARE.
646
+ ```
647
+
622
648
  ## json-schema-traverse@1.0.0 (MIT)
623
649
 
624
650
  ```text
@@ -824,6 +850,32 @@ The above copyright notice and this permission notice shall be included in all c
824
850
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
825
851
  ```
826
852
 
853
+ ## tsup@8.5.1 (MIT)
854
+
855
+ ```text
856
+ MIT License
857
+
858
+ Copyright (c) 2021 EGOIST
859
+
860
+ Permission is hereby granted, free of charge, to any person obtaining a copy
861
+ of this software and associated documentation files (the "Software"), to deal
862
+ in the Software without restriction, including without limitation the rights
863
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
864
+ copies of the Software, and to permit persons to whom the Software is
865
+ furnished to do so, subject to the following conditions:
866
+
867
+ The above copyright notice and this permission notice shall be included in all
868
+ copies or substantial portions of the Software.
869
+
870
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
871
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
872
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
873
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
874
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
875
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
876
+ SOFTWARE.
877
+ ```
878
+
827
879
  ## zod@4.6.5 (MIT)
828
880
 
829
881
  ```text