code-auditor-mcp 3.0.2 → 3.0.4

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.
Files changed (43) hide show
  1. package/.claude-plugin/marketplace.json +20 -0
  2. package/dist/analyzers/universal/UniversalDocumentationAnalyzer.d.ts.map +1 -1
  3. package/dist/analyzers/universal/UniversalDocumentationAnalyzer.js +0 -12
  4. package/dist/analyzers/universal/UniversalDocumentationAnalyzer.js.map +1 -1
  5. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.d.ts.map +1 -1
  6. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js +0 -23
  7. package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js.map +1 -1
  8. package/dist/auditRunner.d.ts.map +1 -1
  9. package/dist/auditRunner.js +9 -4
  10. package/dist/auditRunner.js.map +1 -1
  11. package/dist/cli.js +1 -1
  12. package/dist/cli.js.map +1 -1
  13. package/dist/codeIndexDB.d.ts +1 -1
  14. package/dist/codeIndexDB.d.ts.map +1 -1
  15. package/dist/codeIndexDB.js +33 -6
  16. package/dist/codeIndexDB.js.map +1 -1
  17. package/dist/functionScanner.d.ts +8 -1
  18. package/dist/functionScanner.d.ts.map +1 -1
  19. package/dist/functionScanner.js +20 -160
  20. package/dist/functionScanner.js.map +1 -1
  21. package/dist/languages/UniversalAnalyzer.d.ts.map +1 -1
  22. package/dist/languages/UniversalAnalyzer.js +1 -4
  23. package/dist/languages/UniversalAnalyzer.js.map +1 -1
  24. package/dist/mcp-tools-shared.d.ts.map +1 -1
  25. package/dist/mcp-tools-shared.js +0 -12
  26. package/dist/mcp-tools-shared.js.map +1 -1
  27. package/dist/mcp.js +25 -6
  28. package/dist/mcp.js.map +1 -1
  29. package/dist/mcpAuditJobs.d.ts.map +1 -1
  30. package/dist/mcpAuditJobs.js +10 -5
  31. package/dist/mcpAuditJobs.js.map +1 -1
  32. package/dist/utils/fileDiscovery.d.ts.map +1 -1
  33. package/dist/utils/fileDiscovery.js +6 -1
  34. package/dist/utils/fileDiscovery.js.map +1 -1
  35. package/package.json +4 -1
  36. package/plugin/.claude-plugin/plugin.json +13 -0
  37. package/plugin/README.md +43 -0
  38. package/plugin/hooks/hooks.json +15 -0
  39. package/plugin/scripts/hook-audit.sh +66 -0
  40. package/plugin/skills/code-auditor/SKILL-RULE-KINDS.md +161 -0
  41. package/plugin/skills/code-auditor/SKILL-SEARCH.md +117 -0
  42. package/plugin/skills/code-auditor/SKILL.md +119 -0
  43. package/server.json +21 -0
@@ -0,0 +1,117 @@
1
+ # Search Operator Reference
2
+
3
+ `code-audit search <query>` supports operators for precise queries against the code index.
4
+
5
+ ## Operators
6
+
7
+ ### Type & Location
8
+
9
+ | Operator | Aliases | Example | Description |
10
+ |----------|---------|---------|-------------|
11
+ | `file:` | `path:` | `file:src/auth` | Files whose path matches the glob |
12
+ | `lang:` | `language:` | `lang:typescript` | Files in a specific language |
13
+ | `type:` | — | `type:.ts` | Files with a specific extension |
14
+ | `exported:` | — | `exported:` | Exported functions/components only |
15
+
16
+ ### Complexity
17
+
18
+ | Operator | Example | Description |
19
+ |----------|---------|-------------|
20
+ | `complexity:N` | `complexity:10` | Exact cyclomatic complexity |
21
+ | `complexity:>N` | `complexity:>10` | Greater than N |
22
+ | `complexity:<N` | `complexity:<5` | Less than N |
23
+ | `complexity:N..M` | `complexity:5..15` | Range (inclusive) |
24
+ | `complexity:N-M` | `complexity:5-15` | Range (inclusive) |
25
+
26
+ ### Documentation
27
+
28
+ | Operator | Aliases | Example | Description |
29
+ |----------|---------|---------|-------------|
30
+ | `jsdoc:` | `doc:` | `jsdoc:` | Has JSDoc documentation |
31
+
32
+ ### Signatures
33
+
34
+ | Operator | Aliases | Example | Description |
35
+ |----------|---------|---------|-------------|
36
+ | `param:` | `parameter:` | `param:userId` | Has a parameter named userId |
37
+ | `return:` | `returns:` | `return:Promise` | Return type contains Promise |
38
+
39
+ ### React/Components
40
+
41
+ | Operator | Aliases | Example | Description |
42
+ |----------|---------|---------|-------------|
43
+ | `component:` | — | `component:functional` | Component type: functional, class, memo, forwardRef |
44
+ | `hook:` | `hooks:` | `hook:useState` | Components using a specific hook |
45
+ | `prop:` | `props:` | `prop:onClick` | Components with a specific prop |
46
+ | `entity:` | — | `entity:function` | Entity type: function or component |
47
+
48
+ ### Call Graph & Dependencies
49
+
50
+ | Operator | Aliases | Example | Description |
51
+ |----------|---------|---------|-------------|
52
+ | `calls:` | — | `calls:validateUser` | Functions that call a specific function |
53
+ | `calledby:` | `dependents-of:`, `used-by:` | `calledby:UserService` | Functions called by a specific function |
54
+ | `dep:` | `dependency:`, `uses:` | `dep:express` | Functions importing a specific module |
55
+ | `depends-on:` | `imports-from:` | `depends-on:lodash` | Functions depending on a module |
56
+ | `unused-imports` | `dead-imports` | `unused-imports` | Functions with unused imports |
57
+
58
+ ### Free-text & Matching
59
+
60
+ | Feature | Example | Description |
61
+ |---------|---------|-------------|
62
+ | Terms | `validate user` | Search function names, signatures, JSDoc, bodies via FTS5 |
63
+ | Exact phrase | `"user authentication"` | Double-quoted exact phrase match |
64
+ | Excluded terms | `validation -email` | Exclude results matching a term |
65
+ | Fuzzy search | `~` or `fuzzy` | Enable fuzzy matching |
66
+ | Stemming | `stem` or `stemming` | Enable word stemming |
67
+
68
+ ## Combining Operators
69
+
70
+ Operators combine with AND semantics. Examples:
71
+
72
+ ```bash
73
+ # Complex Go functions that call validateUser
74
+ code-audit search "calls:validateUser lang:go complexity:>10"
75
+
76
+ # Exported TypeScript functions with JSDoc in the auth directory
77
+ code-audit search "exported: lang:typescript jsdoc: file:src/auth"
78
+
79
+ # Functional components using useState but not useEffect
80
+ code-audit search "component:functional hook:useState -useEffect"
81
+
82
+ # Functions depending on lodash (to audit lodash usage before removing it)
83
+ code-audit search "dep:lodash lang:typescript"
84
+
85
+ # Find dead imports across the codebase
86
+ code-audit search "unused-imports"
87
+ ```
88
+
89
+ ## Symbol Lookup
90
+
91
+ Use `--definition` to look up a specific symbol's full metadata:
92
+
93
+ ```bash
94
+ code-audit search --definition "UserService.createUser"
95
+ ```
96
+
97
+ Returns: signature, parameters, return type, JSDoc, dependencies, callers, complexity, file location.
98
+
99
+ ## Options
100
+
101
+ | Flag | Description |
102
+ |------|-------------|
103
+ | `--json` | Output results as JSON |
104
+ | `--limit N` | Maximum results (default: 20) |
105
+ | `--language <lang>` | Filter results by language |
106
+ | `--definition` | Look up a specific symbol by name instead of searching |
107
+
108
+ ## How It Works
109
+
110
+ Free-text terms are run through the QueryParser which:
111
+ 1. Extracts operators (`calls:`, `lang:`, etc.) and their values
112
+ 2. Extracts exact phrases (quoted strings)
113
+ 3. Expands terms with synonym expansion (e.g., `get` → `fetch`, `retrieve`, `obtain`)
114
+ 4. Splits camelCase (`getUserData` → `get`, `user`, `data`) and snake_case identifiers
115
+ 5. Compiles to SQL with FTS5 MATCH expressions against the `functions_fts` virtual table
116
+
117
+ This means `search "getUser"` will match `getUserData`, `fetchUser`, `retrieveUser`, etc. — much broader than grep.
@@ -0,0 +1,119 @@
1
+ ---
2
+ description: Audit code quality, search the codebase semantically, enforce invariants, and fix violations inline.
3
+ ---
4
+
5
+ # Code Auditor Skill
6
+
7
+ You have the `code-audit` CLI available. It indexes every function, component, and struct in the codebase for semantic search and invariant enforcement. Use these commands instead of raw grep/find whenever possible.
8
+
9
+ ## When to use which command
10
+
11
+ ### `code-audit search` — find code by meaning, not just text
12
+
13
+ Use `code-audit search <query>` with its operator syntax instead of `grep` or `rg`. The full operator reference is in `SKILL-SEARCH.md`.
14
+
15
+ Key operators:
16
+ - `calls:<fn>` — every caller of a function (uses the call graph, not regex)
17
+ - `dep:<module>` — everything importing a module
18
+ - `lang:<lang> complexity:>N` — complex functions in a specific language
19
+ - `exported:` — public API surface
20
+ - `file:<glob>` — scope to matching file paths
21
+ - `unused-imports` — dead imports to clean up
22
+
23
+ Free-text terms search function names, signatures, JSDoc, and bodies via FTS5. This is almost always faster and more accurate than grepping.
24
+
25
+ ```bash
26
+ code-audit search "calls:validateUser lang:typescript complexity:>5" --limit 20 --json
27
+ code-audit search --definition "UserService.createUser" # look up a specific symbol
28
+ code-audit search "dep:express exported:" --language go # Go functions that import express and are exported
29
+ ```
30
+
31
+ ### `code-audit audit` — run analysis before claiming work is done
32
+
33
+ Run an audit before declaring a task complete:
34
+
35
+ ```bash
36
+ code-audit audit --path . # Full audit
37
+ code-audit changed --json --fail-on critical # Diff-scoped audit (hook contract)
38
+ ```
39
+
40
+ Use `code-audit changed` after edits to confirm you haven't introduced violations. If the hook is active it already runs `code-audit changed --fail-on critical` automatically on Write/Edit — pay attention to its output.
41
+
42
+ Expected output: JSON violation list (with `--json`) or colored terminal summary. Non-zero exit code means violations at or above `--fail-on` severity were found.
43
+
44
+ ### `code-audit config` — know the project's laws
45
+
46
+ At session start, check for invariant rules:
47
+
48
+ ```bash
49
+ code-audit config rules-list # List active rules
50
+ code-audit config rules-check # Validate .codeauditor.json
51
+ ```
52
+
53
+ These are the codebase's declared constraints — "no importing X from Y," "module A must not import module B," "exported names must match this pattern," "ban specific AST patterns." You can't comply with rules you don't know about. The full rule-kind reference is in `SKILL-RULE-KINDS.md`.
54
+
55
+ ### `code-audit tasks` — queue remediation work
56
+
57
+ ```bash
58
+ code-audit tasks list # List all tasks
59
+ code-audit tasks create --title "Fix SQL injection" --priority high
60
+ code-audit tasks get <taskId> # Get task details
61
+ code-audit tasks update <taskId> --status in_progress
62
+ code-audit tasks complete <taskId> # Mark task done
63
+ code-audit tasks delete <taskId> # Delete a task
64
+ code-audit tasks from-audit # Create tasks from audit violations
65
+ ```
66
+
67
+ Use `tasks from-audit` to convert audit violations into a tracked task list. This lets you triage findings: fix criticals now, file warnings for later, dismiss suggestions. Tasks carry fingerprints so duplicates are automatically deduplicated across audit runs.
68
+
69
+ ### `code-audit index` — refresh the index after structural changes
70
+
71
+ ```bash
72
+ code-audit index sync --path .
73
+ ```
74
+
75
+ If you've added, renamed, or deleted files, run this so searches and audits reflect the current state. The index is rebuilt incrementally; a full sync is fast.
76
+
77
+ ### `code-audit map` — get a structural overview
78
+
79
+ ```bash
80
+ code-audit map -p . # Generate a codebase map
81
+ ```
82
+
83
+ Use this for a high-level architecture overview. Useful when orienting in an unfamiliar codebase.
84
+
85
+ ### `code-audit generate-config` — generate AI tool integration configs
86
+
87
+ ```bash
88
+ code-audit generate-config # Generate MCP configs for AI coding tools
89
+ code-audit generate-config --tool claude # Claude-specific MCP config
90
+ ```
91
+
92
+ Creates MCP server configuration files for AI coding assistants (Claude, Cursor, Continue, Copilot, etc.) so they can connect to code-auditor as an MCP server.
93
+
94
+ ## Interpreting hook feedback
95
+
96
+ When the PostToolUse hook blocks your edit with a violation message:
97
+
98
+ 1. **Read the violation** — it includes the invariant rule's `message` field explaining *why* the edit was blocked
99
+ 2. **Fix the violation** — change your approach to comply with the invariant
100
+ 3. **Do NOT retry the same edit** — the hook will block it again
101
+ 4. The hook runs `code-audit changed --fail-on critical`, so only critical-severity invariant violations block edits. Warnings and suggestions pass through as non-blocking output — still worth fixing.
102
+
103
+ The hook auto-installs the package via npx on first use — no manual npm step needed. If the hook reports `[code-auditor] code-audit could not run`, the npx auto-install failed (network, unsupported platform). The agent should try again; if it persists, `npm install code-auditor-mcp` is the manual fix.
104
+
105
+ ## Quick reference
106
+
107
+ | Task | Command |
108
+ |------|---------|
109
+ | Find callers | `code-audit search "calls:<fn>"` |
110
+ | Find by import | `code-audit search "dep:<module>"` |
111
+ | Complex functions | `code-audit search "lang:go complexity:>10"` |
112
+ | Look up symbol | `code-audit search --definition "<name>"` |
113
+ | Diff-scoped audit | `code-audit changed --json --fail-on critical` |
114
+ | List invariant rules | `code-audit config rules-list` |
115
+ | Triage violations | `code-audit tasks from-audit` |
116
+ | Sync index | `code-audit index sync --path .` |
117
+ | Codebase map | `code-audit map -p .` |
118
+ | Rule reference | See `SKILL-RULE-KINDS.md` |
119
+ | Search reference | See `SKILL-SEARCH.md` |
package/server.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-10-17/server.schema.json",
3
+ "name": "io.github.BenAHammond/code-auditor-mcp",
4
+ "description": "Architectural invariants and code quality analysis, enforced inside your AI agent's edit loop. MCP server + CLI + Claude Code plugin. TypeScript, JavaScript, Go.",
5
+ "repository": {
6
+ "url": "https://github.com/BenAHammond/code-auditor-mcp",
7
+ "source": "github"
8
+ },
9
+ "version": "3.0.3",
10
+ "packages": [
11
+ {
12
+ "registryType": "npm",
13
+ "registryBaseUrl": "https://registry.npmjs.org",
14
+ "identifier": "code-auditor-mcp",
15
+ "version": "3.0.3",
16
+ "transport": {
17
+ "type": "stdio"
18
+ }
19
+ }
20
+ ]
21
+ }