code-auditor-mcp 3.4.18 → 3.5.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/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +68 -0
- package/README.md +5 -5
- package/dist/analyzers/applicability.d.ts +13 -0
- package/dist/analyzers/applicability.d.ts.map +1 -1
- package/dist/analyzers/applicability.js +37 -0
- package/dist/analyzers/applicability.js.map +1 -1
- package/dist/analyzers/cross-language/APIContractAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/cross-language/APIContractAnalyzer.js +23 -2
- package/dist/analyzers/cross-language/APIContractAnalyzer.js.map +1 -1
- package/dist/analyzers/cross-language/DependencyGraphBuilder.d.ts +52 -9
- package/dist/analyzers/cross-language/DependencyGraphBuilder.d.ts.map +1 -1
- package/dist/analyzers/cross-language/DependencyGraphBuilder.js +228 -55
- package/dist/analyzers/cross-language/DependencyGraphBuilder.js.map +1 -1
- package/dist/analyzers/cross-language/SchemaValidator.d.ts +19 -12
- package/dist/analyzers/cross-language/SchemaValidator.d.ts.map +1 -1
- package/dist/analyzers/cross-language/SchemaValidator.js +78 -111
- package/dist/analyzers/cross-language/SchemaValidator.js.map +1 -1
- package/dist/analyzers/crossDomain/CrossDomainAnalyzer.d.ts +0 -6
- package/dist/analyzers/crossDomain/CrossDomainAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/crossDomain/CrossDomainAnalyzer.js +85 -73
- package/dist/analyzers/crossDomain/CrossDomainAnalyzer.js.map +1 -1
- package/dist/analyzers/documentationAnalyzer.js +5 -5
- package/dist/analyzers/documentationAnalyzer.js.map +1 -1
- package/dist/analyzers/invariantsAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/invariantsAnalyzer.js +1 -0
- package/dist/analyzers/invariantsAnalyzer.js.map +1 -1
- package/dist/analyzers/provenance.d.ts +7 -9
- package/dist/analyzers/provenance.d.ts.map +1 -1
- package/dist/analyzers/provenance.js +88 -124
- package/dist/analyzers/provenance.js.map +1 -1
- package/dist/analyzers/reactAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/reactAnalyzer.js +120 -21
- package/dist/analyzers/reactAnalyzer.js.map +1 -1
- package/dist/analyzers/ruleRegistry.d.ts +21 -0
- package/dist/analyzers/ruleRegistry.d.ts.map +1 -1
- package/dist/analyzers/ruleRegistry.js +61 -12
- package/dist/analyzers/ruleRegistry.js.map +1 -1
- package/dist/analyzers/universal/UniversalConventionsAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalConventionsAnalyzer.js +60 -24
- package/dist/analyzers/universal/UniversalConventionsAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalDRYAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalDRYAnalyzer.js +5 -2
- package/dist/analyzers/universal/UniversalDRYAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalDataAccessAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js +82 -71
- package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalDocumentationAnalyzer.d.ts +2 -1
- package/dist/analyzers/universal/UniversalDocumentationAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalDocumentationAnalyzer.js +23 -12
- package/dist/analyzers/universal/UniversalDocumentationAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalSOLIDAnalyzer.d.ts +11 -1
- package/dist/analyzers/universal/UniversalSOLIDAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js +60 -22
- package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalStylesAnalyzer.d.ts +2 -3
- package/dist/analyzers/universal/UniversalStylesAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalStylesAnalyzer.js +258 -87
- package/dist/analyzers/universal/UniversalStylesAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/schema/codeAnalysis.d.ts.map +1 -1
- package/dist/analyzers/universal/schema/codeAnalysis.js +7 -1
- package/dist/analyzers/universal/schema/codeAnalysis.js.map +1 -1
- package/dist/analyzers/universal/schema/jsonSchema.js +7 -11
- package/dist/analyzers/universal/schema/jsonSchema.js.map +1 -1
- package/dist/auditRouter.d.ts +41 -0
- package/dist/auditRouter.d.ts.map +1 -0
- package/dist/auditRouter.js +185 -0
- package/dist/auditRouter.js.map +1 -0
- package/dist/auditRunner.d.ts.map +1 -1
- package/dist/auditRunner.js +93 -57
- package/dist/auditRunner.js.map +1 -1
- package/dist/cli.js +239 -18
- package/dist/cli.js.map +1 -1
- package/dist/codeIndexDB.d.ts.map +1 -1
- package/dist/codeIndexDB.js +35 -1
- package/dist/codeIndexDB.js.map +1 -1
- package/dist/componentScanner.d.ts.map +1 -1
- package/dist/componentScanner.js +2 -1
- package/dist/componentScanner.js.map +1 -1
- package/dist/config/configLoader.d.ts +9 -0
- package/dist/config/configLoader.d.ts.map +1 -1
- package/dist/config/configLoader.js +30 -2
- package/dist/config/configLoader.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +9 -2
- package/dist/config/defaults.js.map +1 -1
- package/dist/functionScanner.d.ts.map +1 -1
- package/dist/functionScanner.js +1 -17
- package/dist/functionScanner.js.map +1 -1
- package/dist/invariants/ruleEngine.d.ts +8 -0
- package/dist/invariants/ruleEngine.d.ts.map +1 -1
- package/dist/invariants/ruleEngine.js +35 -16
- package/dist/invariants/ruleEngine.js.map +1 -1
- package/dist/languages/LanguageOrchestrator.d.ts +9 -10
- package/dist/languages/LanguageOrchestrator.d.ts.map +1 -1
- package/dist/languages/LanguageOrchestrator.js +135 -101
- package/dist/languages/LanguageOrchestrator.js.map +1 -1
- package/dist/languages/RuntimeManager.d.ts +28 -1
- package/dist/languages/RuntimeManager.d.ts.map +1 -1
- package/dist/languages/RuntimeManager.js +158 -47
- package/dist/languages/RuntimeManager.js.map +1 -1
- package/dist/languages/go/GoAdapter.d.ts +2 -0
- package/dist/languages/go/GoAdapter.d.ts.map +1 -1
- package/dist/languages/go/GoAdapter.js +15 -22
- package/dist/languages/go/GoAdapter.js.map +1 -1
- package/dist/languages/go/analyzer +0 -0
- package/dist/languages/go/analyzer-src/analyzer.go +510 -0
- package/dist/languages/go/analyzer-src/go.mod +3 -0
- package/dist/languages/go/analyzer-src/indexer.go +268 -0
- package/dist/languages/go/analyzer-src/parser.go +461 -0
- package/dist/languages/go/analyzer-src/solid.go +395 -0
- package/dist/languages/go/analyzer-src/testconventions.go +25 -0
- package/dist/languages/go/analyzer-src/types.go +148 -0
- package/dist/languages/go/go.mod +7 -0
- package/dist/languages/go/main.go +203 -0
- package/dist/languages/testConventions.d.ts +35 -0
- package/dist/languages/testConventions.d.ts.map +1 -0
- package/dist/languages/testConventions.js +51 -0
- package/dist/languages/testConventions.js.map +1 -0
- package/dist/languages/typescript/TreeSitterTypeScriptAdapter.d.ts +3 -0
- package/dist/languages/typescript/TreeSitterTypeScriptAdapter.d.ts.map +1 -1
- package/dist/languages/typescript/TreeSitterTypeScriptAdapter.js +25 -18
- package/dist/languages/typescript/TreeSitterTypeScriptAdapter.js.map +1 -1
- package/dist/mcp-tools/whitelistTools.d.ts +1 -1
- package/dist/mcp-tools-shared.d.ts +0 -3
- package/dist/mcp-tools-shared.d.ts.map +1 -1
- package/dist/mcp-tools-shared.js +8 -117
- package/dist/mcp-tools-shared.js.map +1 -1
- package/dist/mcp.js +3 -1
- package/dist/mcp.js.map +1 -1
- package/dist/mcpAuditJobs.d.ts.map +1 -1
- package/dist/mcpAuditJobs.js +13 -0
- package/dist/mcpAuditJobs.js.map +1 -1
- package/dist/nextFile.d.ts +21 -0
- package/dist/nextFile.d.ts.map +1 -0
- package/dist/nextFile.js +51 -0
- package/dist/nextFile.js.map +1 -0
- package/dist/nextFileIncremental.d.ts +141 -0
- package/dist/nextFileIncremental.d.ts.map +1 -0
- package/dist/nextFileIncremental.js +314 -0
- package/dist/nextFileIncremental.js.map +1 -0
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +22 -0
- package/dist/pipeline.js.map +1 -1
- package/dist/pipelineAdapters.d.ts +17 -0
- package/dist/pipelineAdapters.d.ts.map +1 -1
- package/dist/pipelineAdapters.js +791 -40
- package/dist/pipelineAdapters.js.map +1 -1
- package/dist/reporting/jsonReportGenerator.d.ts.map +1 -1
- package/dist/reporting/jsonReportGenerator.js +11 -30
- package/dist/reporting/jsonReportGenerator.js.map +1 -1
- package/dist/styles/styleIndexer.d.ts +7 -0
- package/dist/styles/styleIndexer.d.ts.map +1 -1
- package/dist/styles/styleIndexer.js +44 -61
- package/dist/styles/styleIndexer.js.map +1 -1
- package/dist/types/crossLanguage.d.ts +1 -0
- package/dist/types/crossLanguage.d.ts.map +1 -1
- package/dist/types.d.ts +27 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/fileDiscovery.d.ts +9 -0
- package/dist/utils/fileDiscovery.d.ts.map +1 -1
- package/dist/utils/fileDiscovery.js +18 -0
- package/dist/utils/fileDiscovery.js.map +1 -1
- package/package.json +6 -4
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/README.md +6 -6
- package/plugin/hooks/hooks.json +4 -0
- package/plugin/scripts/hook-self-audit.sh +107 -0
- package/plugin/skills/code-auditor/SKILL-RULE-KINDS.md +55 -9
- package/plugin/skills/code-auditor/SKILL.md +20 -21
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# code-auditor PostToolUse self-audit hook — enforce the self-audit scope
|
|
3
|
+
# (analyzers/ + languages/) at edit time, not just at release (Spec 33 Item 15).
|
|
4
|
+
#
|
|
5
|
+
# Reads the PostToolUse event JSON from stdin, extracts the edited file path,
|
|
6
|
+
# and — only when that file is production source in the self-audit scope — runs
|
|
7
|
+
# `code-audit self-audit --stdin --json` against it. Exit code 2 blocks the edit
|
|
8
|
+
# and feeds the finding JSON back to the agent.
|
|
9
|
+
#
|
|
10
|
+
# This hook is a no-op for every edit outside the self-audit scope (consumer
|
|
11
|
+
# projects, tests, fixtures, and the declarative ruleRegistry table), so it adds
|
|
12
|
+
# no latency to ordinary edits. It runs *in addition to* hook-audit.sh, whose
|
|
13
|
+
# diff-gate enforces invariant rules on every edit.
|
|
14
|
+
set -euo pipefail
|
|
15
|
+
|
|
16
|
+
# Read event JSON from stdin
|
|
17
|
+
event="$(cat)"
|
|
18
|
+
|
|
19
|
+
# Extract the file path from the tool input (Write and Edit both use file_path)
|
|
20
|
+
file="$(node -e "
|
|
21
|
+
try {
|
|
22
|
+
var d = JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'));
|
|
23
|
+
process.stdout.write(d.tool_input?.file_path || d.tool_input?.path || '');
|
|
24
|
+
} catch(e) { process.stdout.write(''); }
|
|
25
|
+
" <<< "${event}")"
|
|
26
|
+
|
|
27
|
+
# No file path in the event — nothing to audit
|
|
28
|
+
if [ -z "${file}" ]; then
|
|
29
|
+
exit 0
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
# Normalize the edited file to an absolute path (absolute paths pass through;
|
|
33
|
+
# relative paths resolve against the current working directory).
|
|
34
|
+
case "${file}" in
|
|
35
|
+
/*) file_abs="${file}" ;;
|
|
36
|
+
*) file_abs="$(cd "$(dirname "${file}")" 2>/dev/null && pwd)/$(basename "${file}")" ;;
|
|
37
|
+
esac
|
|
38
|
+
|
|
39
|
+
# Out-of-repo edit no-op (Spec 35 item 9): an edit outside the audited project
|
|
40
|
+
# must not error the hook.
|
|
41
|
+
if [ -n "${CLAUDE_PROJECT_DIR:-}" ]; then
|
|
42
|
+
project_abs="$(cd "${CLAUDE_PROJECT_DIR}" 2>/dev/null && pwd)" || project_abs="${CLAUDE_PROJECT_DIR%/}"
|
|
43
|
+
case "${file_abs}" in
|
|
44
|
+
"${project_abs}"/*) : ;; # inside the project — continue
|
|
45
|
+
*) exit 0 ;; # outside — nothing to self-audit
|
|
46
|
+
esac
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
# Self-audit scope gate: only production files under src/analyzers/ or
|
|
50
|
+
# src/languages/ are self-audit targets. Everything else — every file in a
|
|
51
|
+
# consumer repo, plus this repo's tests, specs, fixtures, and the declarative
|
|
52
|
+
# ruleRegistry.ts data table — is a no-op. The `self-audit` command re-checks
|
|
53
|
+
# this scope on the reported finding paths, so this is only a cheap pre-filter
|
|
54
|
+
# to keep the hook off the hot path for ordinary edits.
|
|
55
|
+
case "${file_abs}" in
|
|
56
|
+
*"/src/analyzers/"*|*"/src/languages/"*) : ;;
|
|
57
|
+
*) exit 0 ;;
|
|
58
|
+
esac
|
|
59
|
+
case "${file_abs}" in
|
|
60
|
+
*"__tests__"*|*".test."*|*".spec."*|*"fixtures"*|*"ruleRegistry.ts"*) exit 0 ;;
|
|
61
|
+
esac
|
|
62
|
+
|
|
63
|
+
# Resolve the code-audit binary. The `self-audit` command is new in 3.5.0, so a
|
|
64
|
+
# stale PATH/global binary would silently lack it — prefer the plugin's own
|
|
65
|
+
# bundled CLI first (guaranteed to be the version that ships with this hook),
|
|
66
|
+
# then fall back to project-local → PATH → npx auto-install.
|
|
67
|
+
resolve_code_audit() {
|
|
68
|
+
# 1. The plugin's own bundled CLI (ships alongside this script in the package;
|
|
69
|
+
# dist/cli.js is the `code-audit` bin target, so npm marks it executable).
|
|
70
|
+
if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -f "${CLAUDE_PLUGIN_ROOT}/../dist/cli.js" ]; then
|
|
71
|
+
echo "${CLAUDE_PLUGIN_ROOT}/../dist/cli.js"
|
|
72
|
+
return
|
|
73
|
+
fi
|
|
74
|
+
# 2. Project-local install (consumer project's own node_modules).
|
|
75
|
+
if [ -n "${CLAUDE_PROJECT_DIR:-}" ] && [ -x "${CLAUDE_PROJECT_DIR}/node_modules/.bin/code-audit" ]; then
|
|
76
|
+
echo "${CLAUDE_PROJECT_DIR}/node_modules/.bin/code-audit"
|
|
77
|
+
return
|
|
78
|
+
fi
|
|
79
|
+
# 3. Global install or PATH.
|
|
80
|
+
if command -v code-audit &>/dev/null; then
|
|
81
|
+
echo "code-audit"
|
|
82
|
+
return
|
|
83
|
+
fi
|
|
84
|
+
# 4. npx auto-install (first use downloads the package; subsequent runs use the npx cache).
|
|
85
|
+
echo "npx -y -p code-auditor-mcp@^3.0.0 code-audit"
|
|
86
|
+
}
|
|
87
|
+
CODE_AUDIT_BIN="$(resolve_code_audit)"
|
|
88
|
+
|
|
89
|
+
# Run the self-audit on the edited file. stdout/stderr are fed back to the agent.
|
|
90
|
+
set +e
|
|
91
|
+
if [ -n "${CLAUDE_PROJECT_DIR:-}" ]; then
|
|
92
|
+
echo "${file_abs}" | ${CODE_AUDIT_BIN} self-audit --stdin --json -p "${CLAUDE_PROJECT_DIR}"
|
|
93
|
+
else
|
|
94
|
+
echo "${file_abs}" | ${CODE_AUDIT_BIN} self-audit --stdin --json
|
|
95
|
+
fi
|
|
96
|
+
exit_code=$?
|
|
97
|
+
set -e
|
|
98
|
+
|
|
99
|
+
# Exit code 2 = a blocking self-audit finding; let it propagate so Claude Code
|
|
100
|
+
# feeds the finding back to the agent.
|
|
101
|
+
if [ ${exit_code} -eq 2 ]; then
|
|
102
|
+
exit 2
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
# Non-zero exit (npx auto-install failure, network issue, etc.) degrades
|
|
106
|
+
# gracefully — never wedge the agent loop.
|
|
107
|
+
exit 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Invariant Rule Kinds
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Seven rule kinds are available in `.codeauditor.json`. Rules are validated at startup — bad configs fail the audit, not silently skipped.
|
|
4
4
|
|
|
5
5
|
## Rule Kinds
|
|
6
6
|
|
|
@@ -139,15 +139,61 @@ With language and path constraints:
|
|
|
139
139
|
|
|
140
140
|
`$$$` matches zero or more nodes (like `...` in rest patterns). `$$$ARGS` is a named meta-variable. See the [ast-grep pattern guide](https://ast-grep.github.io/guide/pattern-syntax.html) for full syntax.
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
### `style-mechanism`
|
|
143
|
+
|
|
144
|
+
Enforce which styling mechanisms are allowed in files matching an optional `path` glob. A style declaration using an unapproved mechanism is flagged.
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"id": "tailwind-only-in-components",
|
|
149
|
+
"kind": "style-mechanism",
|
|
150
|
+
"severity": "warning",
|
|
151
|
+
"allow": ["tailwind"],
|
|
152
|
+
"path": "src/components/**",
|
|
153
|
+
"message": "Only Tailwind utilities in src/components/ — use the project's CSS modules elsewhere"
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
`allow` lists the permitted mechanisms (`tailwind`, `css-modules`, `styled-components`, `inline`, `css`). `path` is optional — omit it to apply the rule to every file.
|
|
158
|
+
|
|
159
|
+
### `no-raw-values`
|
|
143
160
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
161
|
+
Require designated CSS properties to reference a design token instead of a raw value. A declaration whose normalized value has no token reference (and is not in `allowValues`) is flagged.
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"id": "no-raw-colors-in-pages",
|
|
166
|
+
"kind": "no-raw-values",
|
|
167
|
+
"severity": "warning",
|
|
168
|
+
"properties": ["color", "background-color"],
|
|
169
|
+
"allowValues": ["inherit", "transparent"],
|
|
170
|
+
"path": "src/pages/**",
|
|
171
|
+
"message": "No raw colors in src/pages/ — use design tokens"
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`properties` lists the CSS properties to check. `allowValues` names values that are always permitted without a token reference. `path` is optional.
|
|
176
|
+
|
|
177
|
+
## Severity Levels
|
|
149
178
|
|
|
150
|
-
|
|
179
|
+
Severity ranks how urgent a finding is to fix. It never decides whether a
|
|
180
|
+
finding is real, and it never licenses leaving one unresolved. Whether an edit
|
|
181
|
+
is *blocked* is a separate axis: the edit hook gates on invariant rules that
|
|
182
|
+
declare `gating: true` (a binary, per-rule flag), not on severity.
|
|
183
|
+
|
|
184
|
+
| Severity | What it means |
|
|
185
|
+
|----------|---------------|
|
|
186
|
+
| `critical` | Security vulnerabilities, data-loss risks |
|
|
187
|
+
| `warning` | Architecture violations, tech debt, missing documentation |
|
|
188
|
+
| `suggestion` | Smaller defects — naming, conventions, minor correctness |
|
|
189
|
+
|
|
190
|
+
> **Severity ranks urgency, never whether a finding is real.** There is no
|
|
191
|
+
> "noise" tier — every finding is a defect to resolve. A finding that does not
|
|
192
|
+
> block the edit still fails the review unless it is fixed, or the rule that
|
|
193
|
+
> produces it is edited in `.codeauditor.json`. There is no "waive" — a finding
|
|
194
|
+
> leaves the queue only by being resolved or by changing the rule that fires it.
|
|
195
|
+
> Documentation findings are not stylistic: missing
|
|
196
|
+
> JSDoc is a maintainability defect, not a nicety.
|
|
151
197
|
|
|
152
198
|
## Validation
|
|
153
199
|
|
|
@@ -155,7 +201,7 @@ Rules are validated against `invariant-rules.schema.json` on startup. Common err
|
|
|
155
201
|
|
|
156
202
|
- **Missing required field**: each kind has required fields (e.g., `import-ban` requires `module`)
|
|
157
203
|
- **Invalid severity**: must be one of `critical`, `warning`, `suggestion`
|
|
158
|
-
- **Invalid kind**: must be one of the
|
|
204
|
+
- **Invalid kind**: must be one of the seven kinds above
|
|
159
205
|
- **Both allowFrom and denyFrom**: `call-constraint` requires exactly one
|
|
160
206
|
- **Empty pattern**: `ast-pattern` requires a non-empty `pattern` string
|
|
161
207
|
- **Invalid language**: `ast-pattern` language must be `typescript`, `javascript`, or `go`
|
|
@@ -38,12 +38,25 @@ Run an audit before declaring a task complete:
|
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
40
|
code-audit audit --path . # Full audit
|
|
41
|
-
code-audit changed --json
|
|
41
|
+
code-audit changed --json # Diff-scoped audit (hook contract)
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
Use `code-audit changed` after edits to confirm you haven't introduced violations. If the hook is active it already runs `code-audit changed
|
|
44
|
+
Use `code-audit changed` after edits to confirm you haven't introduced violations. If the hook is active it already runs `code-audit changed` automatically on Write/Edit — pay attention to its output.
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
**Every finding is a defect to resolve, not a suggestion to weigh.** After a full audit, work the violations in severity order — criticals first, then warnings, then suggestions — and fix them all. Severity ranks urgency, never whether a finding is real; there is no "noise" tier. Documentation findings (missing JSDoc) are maintainability defects, not stylistic niceties. If you choose not to fix one, record why before moving on — never silently dismiss it.
|
|
47
|
+
|
|
48
|
+
Expected output: JSON violation list (with `--json`) or colored terminal summary. The full `audit` command exits non-zero when violations at or above `--fail-on` severity exist; the diff-scoped `changed` hook gates on per-rule `gating: true` flags, not severity.
|
|
49
|
+
|
|
50
|
+
### `code-audit next-file` — fix violations one file at a time
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
code-audit next-file --path . # Highest-priority file + all its findings
|
|
54
|
+
code-audit next-file --path . --json # Machine-readable
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This is the refactoring loop. `next-file` audits the project and returns the single highest-priority file — ranked by highest-severity finding, then total finding count — with every finding on it, ordered critical → warning → suggestion. Fix that file, then run it again: a still-broken file comes back, otherwise the next-worst file surfaces. `{done:true}` means the tree is clean.
|
|
58
|
+
|
|
59
|
+
There is **no skip or decline affordance**. A finding leaves the queue only by being fixed, or by editing the rule that produces it in `.codeauditor.json` (your rules editor). If a rule keeps firing on something you judge correct, change the rule — never work around it.
|
|
47
60
|
|
|
48
61
|
### `code-audit config` — know the project's laws
|
|
49
62
|
|
|
@@ -77,20 +90,6 @@ A **built-in** `scripts-and-tests` profile ships with every install — it exclu
|
|
|
77
90
|
|
|
78
91
|
Invariant violations are **immune** to path profile gate exclusion — invariants enforce declared laws and always block.
|
|
79
92
|
|
|
80
|
-
### `code-audit tasks` — queue remediation work
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
code-audit tasks list # List all tasks
|
|
84
|
-
code-audit tasks create --title "Fix SQL injection" --priority high
|
|
85
|
-
code-audit tasks get <taskId> # Get task details
|
|
86
|
-
code-audit tasks update <taskId> --status in_progress
|
|
87
|
-
code-audit tasks complete <taskId> # Mark task done
|
|
88
|
-
code-audit tasks delete <taskId> # Delete a task
|
|
89
|
-
code-audit tasks from-audit # Create tasks from audit violations
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Use `tasks from-audit` to convert audit violations into a tracked task list so every finding is resolved, not dropped. Work findings in severity order — criticals first, then warnings, then suggestions. Tasks carry fingerprints so duplicates are automatically deduplicated across audit runs. Every finding should end as fixed, not silently dismissed; if you choose not to fix one, record why before moving on.
|
|
93
|
-
|
|
94
93
|
### `code-audit index` — refresh the index after structural changes
|
|
95
94
|
|
|
96
95
|
```bash
|
|
@@ -181,13 +180,13 @@ When an edit hook blocks your edit with a violation message:
|
|
|
181
180
|
1. **Read the violation** — it includes the invariant rule's `message` field explaining *why* the edit was blocked
|
|
182
181
|
2. **Fix the violation** — change your approach to comply with the invariant
|
|
183
182
|
3. **Do NOT retry the same edit** — the hook will block it again
|
|
184
|
-
4. The hook runs `code-audit changed
|
|
183
|
+
4. The hook runs `code-audit changed`, and its gate is binary and per-rule: an invariant rule blocks the edit only if it declares `gating: true` (regardless of severity). Warnings and suggestions are still violations and must be fixed — they pass the gate, they are not resolved.
|
|
185
184
|
|
|
186
185
|
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.
|
|
187
186
|
|
|
188
187
|
## Host-specific notes
|
|
189
188
|
|
|
190
|
-
- **Claude Code**: This skill is bundled in the `code-auditor` plugin (`claude plugin install code-auditor`). The plugin also ships a `PostToolUse` hook on `Write|Edit` that runs `code-audit changed
|
|
189
|
+
- **Claude Code**: This skill is bundled in the `code-auditor` plugin (`claude plugin install code-auditor`). The plugin also ships a `PostToolUse` hook on `Write|Edit` that runs `code-audit changed` automatically — the hook feedback section above describes that behavior. The MCP server is available as `mcp__code-auditor__*` tools for shell-less use.
|
|
191
190
|
- **Cursor**: Skill install via `code-audit install --agent cursor`. Cursor's `afterFileEdit` hook fires after the edit and cannot block retroactively, so violations are reported through the strongest available feedback channel — fix them even though the edit already landed.
|
|
192
191
|
- **Codex**: Skill install via `code-audit install --agent codex`. Codex's `PostToolUse` hook provides blocking feedback via exit code 2, replacing the tool result with violation messages.
|
|
193
192
|
- **Gemini CLI**: Skill install only (`code-audit install --agent gemini`). No hook system exists; MCP covers shell-less use.
|
|
@@ -201,11 +200,11 @@ The hook auto-installs the package via npx on first use — no manual npm step n
|
|
|
201
200
|
| Find by import | `code-audit search "dep:<module>"` |
|
|
202
201
|
| Complex functions | `code-audit search "lang:go complexity:>10"` |
|
|
203
202
|
| Look up symbol | `code-audit search --definition "<name>"` |
|
|
204
|
-
| Diff-scoped audit | `code-audit changed --json
|
|
203
|
+
| Diff-scoped audit | `code-audit changed --json` |
|
|
205
204
|
| List invariant rules | `code-audit config rules-list` |
|
|
206
205
|
| Inspect path profiles | `code-audit config profiles` |
|
|
207
206
|
| Resolve file profiles | `code-audit config profiles --file <path>` |
|
|
208
|
-
|
|
|
207
|
+
| Next file to fix | `code-audit next-file` |
|
|
209
208
|
| Sync index | `code-audit index sync --path .` |
|
|
210
209
|
| Codebase map | `code-audit map -p .` |
|
|
211
210
|
| Mine conventions | `code-audit conventions list` |
|