eslint-plugin-ai-guard 1.4.4 → 1.4.5
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 +20 -5
- package/THIRD-PARTY-NOTICES.md +29 -0
- package/dist/cli/hook.js +16835 -0
- package/dist/cli/hook.js.map +1 -0
- package/dist/cli/index.js +2692 -547
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/mcp/server.js +966 -114
- package/dist/mcp/server.js.map +1 -1
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -39,8 +39,10 @@
|
|
|
39
39
|
- **GitHub Action** with native SARIF 2.1.0 output for GitHub Code Scanning
|
|
40
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
41
|
- **Agent safety**: `ai-guard verify` (one verdict for a change), `ai-guard scan-agent-config` (hidden text and prompt injection in `CLAUDE.md`, skills and MCP config), and `changed --test-integrity` (weakened tests)
|
|
42
|
-
- **Claude Code
|
|
43
|
-
- **
|
|
42
|
+
- **Hooks for Claude Code, Cursor and Codex** (`ai-guard init-hooks`): findings go back to the agent as it works, and it is stopped once before finishing on weakened checks or problems it introduced
|
|
43
|
+
- **A pre-commit gate** (`ai-guard init-git-hook`) that checks every commit, whichever agent or person wrote it
|
|
44
|
+
- **Works with Oxlint** as a JS plugin, with identical results checked in CI (`ai-guard init-oxlint`)
|
|
45
|
+
- **MCP server** (`ai-guard-mcp`, 9 tools) for local AI-agent workflows over STDIO
|
|
44
46
|
|
|
45
47
|
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.).
|
|
46
48
|
|
|
@@ -181,9 +183,11 @@ Linting checks the code. These check the agent:
|
|
|
181
183
|
| [`ai-guard verify`](./docs/cli/verify.md) | One verdict for the current change: lint findings it introduced, weakened tests, and agent-config issues. Pre-existing problems never block. |
|
|
182
184
|
| [`ai-guard integrity`](./docs/integrity.md) | Everything that weakens checks vs a base revision: new suppressions, skipped or removed tests, lowered coverage and TypeScript settings, removed CI steps. |
|
|
183
185
|
| [`ai-guard changed --test-integrity`](./docs/cli/test-integrity.md) | A test-focused comparison: focused, skipped, removed or weakened tests, rewritten snapshots, and test commands that can no longer fail. Overlaps with `integrity`; use `integrity` for the full set. |
|
|
186
|
+
| [`ai-guard verify-deps`](./docs/cli/verify-deps.md) | Checks npm packages before they are installed: names that don't exist (invented by assistants), look-alikes of popular packages, new or rarely used packages, install scripts, deprecations. Also as a pre-install hook for Claude Code, Cursor and Codex (`init-hooks --check-installs`) and the `ai_guard_check_package` MCP tool. Uses the npm registry; private registries are skipped. |
|
|
184
187
|
| [`ai-guard scan-agent-config`](./docs/cli/scan-agent-config.md) | Scans `CLAUDE.md`, `AGENTS.md`, `.cursorrules`, skills and MCP configs for hidden text, prompt injection, unpinned MCP servers and inline secrets. |
|
|
185
|
-
| [Claude Code
|
|
186
|
-
| [
|
|
188
|
+
| [Agent hooks: Claude Code, Cursor, Codex](./docs/integrations/agents.md) | `ai-guard init-hooks` sets up every agent a project uses. Findings reach the agent after edits; before it finishes, the whole change is verified once; `git commit --no-verify` and risky installs are caught before they run. |
|
|
189
|
+
| [Pre-commit gate](./docs/integrations/git-hook.md) | `ai-guard init-git-hook` runs `verify --staged` on every commit through husky, lefthook, simple-git-hooks or pre-commit. Only problems the commit introduces block it. |
|
|
190
|
+
| [MCP tools](./docs/mcp-server.md) | `ai_guard_scan_file`, `ai_guard_scan_diff`, `ai_guard_scan_project`, `ai_guard_rules`, `ai_guard_check_integrity`, `ai_guard_verify_change`, `ai_guard_scan_agent_config`, `ai_guard_check_package`, and `ai_guard_fix` (a diff, unless `apply` is set). |
|
|
187
191
|
|
|
188
192
|
---
|
|
189
193
|
|
|
@@ -291,9 +295,13 @@ npx ai-guard <command> [options]
|
|
|
291
295
|
| `run` | Scan your workspace using AI Guard AST rules | `--path <dir>`, `--strict`, `--security`, `--json`, `--sarif`, `--fail-on <level>`, `--max-warnings <n>`, `--inline-suppressions <mode>` |
|
|
292
296
|
| `changed` | Fast CI scan — only scans modified files in git | `--pr`, `--staged`, `--base <branch>`, `--baseline [file]`, `--integrity <off\|report\|enforce>`, `--test-integrity`, `--inline-suppressions <mode>`, `--strict`, `--sarif`, `--sarif-output <file>`, `--fail-on <level>` |
|
|
293
297
|
| `verify` | One verdict for the current change ([docs](./docs/cli/verify.md)) | `--base <ref>`, `--staged`, `--preset <name>`, `--strict`, `--json` |
|
|
298
|
+
| `verify-deps` | Check npm packages before they are installed ([docs](./docs/cli/verify-deps.md)) | `[packages...]`, `--base <ref>`, `--staged`, `--all`, `--json`, `--sarif`, `--fail-on <level>` |
|
|
294
299
|
| `scan-agent-config` | Scan agent instructions and MCP config ([docs](./docs/cli/scan-agent-config.md)) | `--path <dir>`, `--json`, `--sarif`, `--fail-on <level>`, `--update-lock` |
|
|
295
300
|
| `integrity` | Detect changes that weaken checks vs a base revision ([docs](./docs/integrity.md)) | `--base <ref>`, `--pr`, `--staged`, `--enforce`, `--json`, `--sarif`, `--accept <fingerprints\|all>` |
|
|
296
301
|
| `init` | Automatically detect environment & configure ESLint | `--preset <name>`, `--flat`, `--dry-run`, `-y, --yes` |
|
|
302
|
+
| `init-hooks` | Hooks for Claude Code, Cursor and Codex ([docs](./docs/integrations/agents.md)) | `--agent <list>`, `--check-installs`, `--no-stop-hook`, `--no-bash-guard`, `--dry-run` |
|
|
303
|
+
| `init-git-hook` | Pre-commit gate running `verify --staged` ([docs](./docs/integrations/git-hook.md)) | `--manager <name>`, `--check-deps`, `--dry-run` |
|
|
304
|
+
| `init-oxlint` | Add AI Guard to `.oxlintrc.json` ([docs](./docs/integrations/oxlint.md)) | `--preset <name>`, `--dry-run` |
|
|
297
305
|
| `init-context` | Generate prompt instruction files for AI coding agents | `-a, --all`, `--force`, `--dry-run`, `--rules <categories>` |
|
|
298
306
|
| `doctor` | Diagnose your ESLint, parser, and plugin environment | (No options needed — prints actionable diagnostic report) |
|
|
299
307
|
| `baseline` | Record existing findings, then report only new ones | `create`, `check`, `--fail-on <level>`, `--json`, `--mode <strict\|stable>`, `--preset <name>` |
|
|
@@ -378,6 +386,13 @@ This dual-layer defense minimizes review friction and ensures generated code mee
|
|
|
378
386
|
|
|
379
387
|
## Claude Code Integration
|
|
380
388
|
|
|
389
|
+
Using Cursor or Codex too? `npx ai-guard init-hooks` sets up every agent the project uses; see [Agent hooks](./docs/integrations/agents.md).
|
|
390
|
+
|
|
391
|
+
Two ways to use it with Claude Code. Pick one:
|
|
392
|
+
|
|
393
|
+
- **In a project (recommended):** `npm install --save-dev eslint-plugin-ai-guard`, then `npx ai-guard init-claude`. This writes the hooks into the project's `.claude/settings.json`, so everyone on the project gets them.
|
|
394
|
+
- **As a Claude Code plugin** (adds the MCP tools and the `/ai-guard:verify-changes` skill, and works in projects without AI Guard installed): `claude plugin marketplace add ai-guard-dev/eslint-plugin-ai-guard`, then `claude plugin install ai-guard@ai-guard-plugins`.
|
|
395
|
+
|
|
381
396
|
AI Guard integrates directly with [Claude Code](https://code.claude.com/docs/en/hooks) through hooks:
|
|
382
397
|
|
|
383
398
|
```bash
|
|
@@ -387,7 +402,7 @@ npx ai-guard init-claude
|
|
|
387
402
|
|
|
388
403
|
- **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.
|
|
389
404
|
- **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. The same hook then [verifies](./docs/cli/verify.md) lint findings and agent-config issues the session introduced (placeholder code, a canned return under a test runner, a hidden instruction in `CLAUDE.md`), which also block once. Skip both with `--no-stop-hook`.
|
|
390
|
-
- **PreToolUse (Bash)** — `git commit --no-verify` / `HUSKY=0` ask for confirmation.
|
|
405
|
+
- **PreToolUse (Bash)** — `git commit --no-verify` / `HUSKY=0` ask for confirmation. With `--check-installs` (opt-in, uses the npm registry), packages in install commands are checked first: names that don't exist are blocked, look-alikes of popular packages ask you.
|
|
391
406
|
|
|
392
407
|
```bash
|
|
393
408
|
# Preview before applying
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -921,3 +921,32 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
921
921
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
922
922
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
923
923
|
```
|
|
924
|
+
|
|
925
|
+
## npm-high-impact@1.13.0 — list of popular npm packages (MIT)
|
|
926
|
+
|
|
927
|
+
The package-check commands include a list of the most-downloaded npm packages, taken from npm-high-impact (https://github.com/wooorm/npm-high-impact).
|
|
928
|
+
|
|
929
|
+
```text
|
|
930
|
+
(The MIT License)
|
|
931
|
+
|
|
932
|
+
Copyright (c) Titus Wormer <tituswormer@gmail.com>
|
|
933
|
+
|
|
934
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
935
|
+
a copy of this software and associated documentation files (the
|
|
936
|
+
'Software'), to deal in the Software without restriction, including
|
|
937
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
938
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
939
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
940
|
+
the following conditions:
|
|
941
|
+
|
|
942
|
+
The above copyright notice and this permission notice shall be
|
|
943
|
+
included in all copies or substantial portions of the Software.
|
|
944
|
+
|
|
945
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
946
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
947
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
948
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
949
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
950
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
951
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
952
|
+
```
|