code-auditor-mcp 3.5.0 → 3.6.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 +31 -0
- package/dist/analyzers/applicability.d.ts +6 -5
- package/dist/analyzers/applicability.d.ts.map +1 -1
- package/dist/analyzers/applicability.js +1 -26
- package/dist/analyzers/applicability.js.map +1 -1
- package/dist/analyzers/ruleRegistry.d.ts +14 -12
- package/dist/analyzers/ruleRegistry.d.ts.map +1 -1
- package/dist/analyzers/ruleRegistry.js +5 -96
- package/dist/analyzers/ruleRegistry.js.map +1 -1
- package/dist/analyzers/ruleTiming.d.ts +2 -2
- package/dist/analyzers/ruleTiming.js +2 -2
- package/dist/analyzers/universal/UniversalSchemaAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalSchemaAnalyzer.js +5 -2
- package/dist/analyzers/universal/UniversalSchemaAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/schema/discovery.d.ts +29 -1
- package/dist/analyzers/universal/schema/discovery.d.ts.map +1 -1
- package/dist/analyzers/universal/schema/discovery.js +76 -21
- package/dist/analyzers/universal/schema/discovery.js.map +1 -1
- package/dist/auditRunner.d.ts.map +1 -1
- package/dist/auditRunner.js +0 -27
- package/dist/auditRunner.js.map +1 -1
- package/dist/cli.js +69 -79
- package/dist/cli.js.map +1 -1
- package/dist/codeIndexDB.js +6 -6
- package/dist/codeIndexDB.js.map +1 -1
- package/dist/config/configLoader.d.ts.map +1 -1
- package/dist/config/configLoader.js +15 -0
- package/dist/config/configLoader.js.map +1 -1
- package/dist/config/defaults.d.ts +8 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +10 -1
- package/dist/config/defaults.js.map +1 -1
- package/dist/dataPaths.js +18 -1
- package/dist/dataPaths.js.map +1 -1
- package/dist/enforcement/gate.d.ts +14 -19
- package/dist/enforcement/gate.d.ts.map +1 -1
- package/dist/enforcement/gate.js +27 -45
- package/dist/enforcement/gate.js.map +1 -1
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +21 -3
- package/dist/pipeline.js.map +1 -1
- package/dist/styles/styleExtractor.js +2 -2
- package/dist/styles/styleExtractor.js.map +1 -1
- package/dist/styles/styleIndexer.js +7 -6
- package/dist/styles/styleIndexer.js.map +1 -1
- package/dist/styles/types.d.ts +3 -2
- package/dist/styles/types.d.ts.map +1 -1
- package/dist/types.d.ts +16 -30
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +12 -4
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/README.md +5 -3
- package/plugin/scripts/hook-audit.sh +20 -30
- package/plugin/scripts/hook-common.sh +63 -0
- package/plugin/scripts/hook-self-audit.sh +23 -31
- package/plugin/skills/code-auditor/SKILL.md +2 -2
|
@@ -4,15 +4,24 @@
|
|
|
4
4
|
#
|
|
5
5
|
# Reads the PostToolUse event JSON from stdin, extracts the edited file path,
|
|
6
6
|
# and — only when that file is production source in the self-audit scope — runs
|
|
7
|
-
# `code-audit self-audit
|
|
8
|
-
#
|
|
7
|
+
# `code-audit self-audit` against it. Exit code 2 blocks the edit and feeds the
|
|
8
|
+
# finding JSON back to the agent.
|
|
9
9
|
#
|
|
10
10
|
# This hook is a no-op for every edit outside the self-audit scope (consumer
|
|
11
11
|
# projects, tests, fixtures, and the declarative ruleRegistry table), so it adds
|
|
12
12
|
# no latency to ordinary edits. It runs *in addition to* hook-audit.sh, whose
|
|
13
13
|
# diff-gate enforces invariant rules on every edit.
|
|
14
|
+
#
|
|
15
|
+
# Exit codes:
|
|
16
|
+
# 0 — clean pass or out of scope
|
|
17
|
+
# 2 — a blocking self-audit finding (Claude Code feeds stdout back)
|
|
18
|
+
# 1 — the hook itself broke (binary missing, version mismatch, CLI error) —
|
|
19
|
+
# reported loudly, never a silent no-op.
|
|
14
20
|
set -euo pipefail
|
|
15
21
|
|
|
22
|
+
# Shared resolver + compatibility pinning (see hook-common.sh).
|
|
23
|
+
. "${CLAUDE_PLUGIN_ROOT}/scripts/hook-common.sh"
|
|
24
|
+
|
|
16
25
|
# Read event JSON from stdin
|
|
17
26
|
event="$(cat)"
|
|
18
27
|
|
|
@@ -60,33 +69,12 @@ case "${file_abs}" in
|
|
|
60
69
|
*"__tests__"*|*".test."*|*".spec."*|*"fixtures"*|*"ruleRegistry.ts"*) exit 0 ;;
|
|
61
70
|
esac
|
|
62
71
|
|
|
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
72
|
CODE_AUDIT_BIN="$(resolve_code_audit)"
|
|
88
73
|
|
|
89
|
-
#
|
|
74
|
+
# Pin the plugin to a compatible CLI version — fail loudly on mismatch.
|
|
75
|
+
assert_compatible "${CODE_AUDIT_BIN}" || exit 1
|
|
76
|
+
|
|
77
|
+
# Run the self-audit on the edited file. stdout/stderr feed back to the agent.
|
|
90
78
|
set +e
|
|
91
79
|
if [ -n "${CLAUDE_PROJECT_DIR:-}" ]; then
|
|
92
80
|
echo "${file_abs}" | ${CODE_AUDIT_BIN} self-audit --stdin --json -p "${CLAUDE_PROJECT_DIR}"
|
|
@@ -96,12 +84,16 @@ fi
|
|
|
96
84
|
exit_code=$?
|
|
97
85
|
set -e
|
|
98
86
|
|
|
99
|
-
# Exit
|
|
100
|
-
# feeds the finding back to the agent.
|
|
87
|
+
# Exit 2 = a blocking self-audit finding; propagate so Claude Code feeds it back.
|
|
101
88
|
if [ ${exit_code} -eq 2 ]; then
|
|
102
89
|
exit 2
|
|
103
90
|
fi
|
|
104
91
|
|
|
105
|
-
#
|
|
106
|
-
#
|
|
92
|
+
# Any other non-zero exit is the hook breaking, not a clean pass. Report loudly
|
|
93
|
+
# and fail — a silent no-op here is exactly the failure mode this guards.
|
|
94
|
+
if [ ${exit_code} -ne 0 ]; then
|
|
95
|
+
echo "[code-auditor] HOOK BROKEN: self-audit exited ${exit_code} (neither clean nor a finding). Fix the install — do not treat this as a clean pass." >&2
|
|
96
|
+
exit 1
|
|
97
|
+
fi
|
|
98
|
+
|
|
107
99
|
exit 0
|
|
@@ -5,7 +5,7 @@ description: Audit code quality, search the codebase semantically, enforce invar
|
|
|
5
5
|
|
|
6
6
|
# Code Auditor Skill
|
|
7
7
|
|
|
8
|
-
> **Version 3.
|
|
8
|
+
> **Version 3.6.0** • Run `code-audit --version` to check your installed version.
|
|
9
9
|
> If versions differ, the CLI is authoritative — use `code-audit <command> --help` to see what your install actually supports.
|
|
10
10
|
|
|
11
11
|
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.
|
|
@@ -171,7 +171,7 @@ Use `--format dot` to generate a directed call-graph diagram (Graphviz DOT forma
|
|
|
171
171
|
|
|
172
172
|
Terminal output shows rank, function name, file path, PageRank percentile, betweenness percentile, complexity percentile, untested status, and composite risk score. JSON output fields: `functionName`, `filePath`, `pageRankPercentile`, `betweennessPercentile`, `complexityPercentile`, `untested`, `riskScore`.
|
|
173
173
|
|
|
174
|
-
> **Release checklist**:
|
|
174
|
+
> **Release checklist**: The version banner above is stamped by `npm run build:skills` from `package.json` (the single source of truth) — do not hand-edit it. Bump the version in `package.json`, run the build, and the skill copies it. `npm run verify:close` gates on test + integration + dist verification — the tag cannot move without all three green.
|
|
175
175
|
|
|
176
176
|
## Interpreting hook feedback
|
|
177
177
|
|