code-auditor-mcp 5.0.1 → 5.2.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 +227 -3
- package/README.md +24 -2
- package/configs/hhra-compat.json +12 -118
- package/dist/analyzers/cross-language/DependencyGraphBuilder.d.ts.map +1 -1
- package/dist/analyzers/cross-language/DependencyGraphBuilder.js +11 -1
- package/dist/analyzers/cross-language/DependencyGraphBuilder.js.map +1 -1
- package/dist/analyzers/crossDomain/CrossDomainAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/crossDomain/CrossDomainAnalyzer.js +57 -52
- package/dist/analyzers/crossDomain/CrossDomainAnalyzer.js.map +1 -1
- package/dist/analyzers/handleIdentification.d.ts.map +1 -1
- package/dist/analyzers/handleIdentification.js +4 -1
- package/dist/analyzers/handleIdentification.js.map +1 -1
- package/dist/analyzers/provenance.d.ts +9 -4
- package/dist/analyzers/provenance.d.ts.map +1 -1
- package/dist/analyzers/provenance.js +8 -25
- package/dist/analyzers/provenance.js.map +1 -1
- package/dist/analyzers/reactAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/reactAnalyzer.js +0 -5
- package/dist/analyzers/reactAnalyzer.js.map +1 -1
- package/dist/analyzers/receiverRoot.d.ts +20 -0
- package/dist/analyzers/receiverRoot.d.ts.map +1 -1
- package/dist/analyzers/receiverRoot.js +42 -0
- package/dist/analyzers/receiverRoot.js.map +1 -1
- package/dist/analyzers/ruleRegistry.js +4 -4
- package/dist/analyzers/ruleRegistry.js.map +1 -1
- package/dist/analyzers/ruleTiming.d.ts +1 -1
- package/dist/analyzers/ruleTiming.js +2 -2
- package/dist/analyzers/ruleTiming.js.map +1 -1
- package/dist/analyzers/tsEcosystem.d.ts.map +1 -1
- package/dist/analyzers/tsEcosystem.js +10 -0
- package/dist/analyzers/tsEcosystem.js.map +1 -1
- package/dist/analyzers/universal/UniversalConventionsAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalConventionsAnalyzer.js +22 -26
- package/dist/analyzers/universal/UniversalConventionsAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalDataAccessAnalyzer.d.ts +32 -15
- package/dist/analyzers/universal/UniversalDataAccessAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js +189 -115
- package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalSOLIDAnalyzer.d.ts +0 -2
- package/dist/analyzers/universal/UniversalSOLIDAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js +0 -5
- package/dist/analyzers/universal/UniversalSOLIDAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/UniversalStylesAnalyzer.d.ts +2 -10
- package/dist/analyzers/universal/UniversalStylesAnalyzer.d.ts.map +1 -1
- package/dist/analyzers/universal/UniversalStylesAnalyzer.js +7 -49
- package/dist/analyzers/universal/UniversalStylesAnalyzer.js.map +1 -1
- package/dist/analyzers/universal/schema/config.d.ts.map +1 -1
- package/dist/analyzers/universal/schema/config.js +0 -2
- package/dist/analyzers/universal/schema/config.js.map +1 -1
- package/dist/analyzers/universal/schema/types.d.ts +0 -2
- package/dist/analyzers/universal/schema/types.d.ts.map +1 -1
- package/dist/analyzers/vendorSurfaces.d.ts +126 -0
- package/dist/analyzers/vendorSurfaces.d.ts.map +1 -0
- package/dist/analyzers/vendorSurfaces.js +580 -0
- package/dist/analyzers/vendorSurfaces.js.map +1 -0
- package/dist/auditRunner.d.ts +2 -0
- package/dist/auditRunner.d.ts.map +1 -1
- package/dist/auditRunner.js +159 -160
- package/dist/auditRunner.js.map +1 -1
- package/dist/churn/churnExtractor.d.ts +0 -1
- package/dist/churn/churnExtractor.d.ts.map +1 -1
- package/dist/churn/churnExtractor.js +2 -4
- package/dist/churn/churnExtractor.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +212 -29
- package/dist/cli.js.map +1 -1
- package/dist/codeIndex/migrations.d.ts.map +1 -1
- package/dist/codeIndex/migrations.js +4 -3
- package/dist/codeIndex/migrations.js.map +1 -1
- package/dist/codeIndexDB.d.ts +11 -2
- package/dist/codeIndexDB.d.ts.map +1 -1
- package/dist/codeIndexDB.js +27 -2
- package/dist/codeIndexDB.js.map +1 -1
- package/dist/config/configLoader.d.ts +60 -7
- package/dist/config/configLoader.d.ts.map +1 -1
- package/dist/config/configLoader.js +252 -60
- package/dist/config/configLoader.js.map +1 -1
- package/dist/config/defaults.d.ts +77 -18
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +105 -43
- package/dist/config/defaults.js.map +1 -1
- package/dist/constants.d.ts +2 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -0
- package/dist/constants.js.map +1 -1
- package/dist/daemon/main.d.ts +0 -1
- package/dist/daemon/main.d.ts.map +1 -1
- package/dist/daemon/main.js +31 -8
- package/dist/daemon/main.js.map +1 -1
- package/dist/dataPaths.d.ts +17 -11
- package/dist/dataPaths.d.ts.map +1 -1
- package/dist/dataPaths.js +51 -16
- package/dist/dataPaths.js.map +1 -1
- package/dist/graph/resolutionEnvironment.d.ts +61 -0
- package/dist/graph/resolutionEnvironment.d.ts.map +1 -0
- package/dist/graph/resolutionEnvironment.js +57 -0
- package/dist/graph/resolutionEnvironment.js.map +1 -0
- package/dist/hookLog.d.ts +54 -0
- package/dist/hookLog.d.ts.map +1 -0
- package/dist/hookLog.js +105 -0
- package/dist/hookLog.js.map +1 -0
- package/dist/hookLogPath.generated.d.ts +3 -0
- package/dist/hookLogPath.generated.d.ts.map +1 -0
- package/dist/hookLogPath.generated.js +8 -0
- package/dist/hookLogPath.generated.js.map +1 -0
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -7
- package/dist/index.js.map +1 -1
- package/dist/installConfig.d.ts +15 -2
- package/dist/installConfig.d.ts.map +1 -1
- package/dist/installConfig.js +17 -2
- package/dist/installConfig.js.map +1 -1
- package/dist/languages/typescript/TreeSitterTypeScriptAdapter.d.ts.map +1 -1
- package/dist/languages/typescript/TreeSitterTypeScriptAdapter.js +18 -3
- package/dist/languages/typescript/TreeSitterTypeScriptAdapter.js.map +1 -1
- package/dist/mcp-tools/workflowGuide.js +8 -8
- package/dist/mcp-tools/workflowGuide.js.map +1 -1
- package/dist/mcp-tools-shared.d.ts.map +1 -1
- package/dist/mcp-tools-shared.js +5 -2
- package/dist/mcp-tools-shared.js.map +1 -1
- package/dist/mcp-ui-simple.d.ts +5 -0
- package/dist/mcp-ui-simple.d.ts.map +1 -1
- package/dist/mcp-ui-simple.js +9 -2
- package/dist/mcp-ui-simple.js.map +1 -1
- package/dist/mcp.d.ts +0 -1
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +36 -33
- package/dist/mcp.js.map +1 -1
- package/dist/mcpAuditJobs.d.ts +10 -0
- package/dist/mcpAuditJobs.d.ts.map +1 -1
- package/dist/mcpAuditJobs.js +10 -1
- package/dist/mcpAuditJobs.js.map +1 -1
- package/dist/mcpAutoIndex.d.ts.map +1 -1
- package/dist/mcpAutoIndex.js +2 -1
- package/dist/mcpAutoIndex.js.map +1 -1
- package/dist/phase/colorMath.d.ts +18 -5
- package/dist/phase/colorMath.d.ts.map +1 -1
- package/dist/phase/colorMath.js +88 -5
- package/dist/phase/colorMath.js.map +1 -1
- package/dist/phase/dataAccessCallsCandidates.js +1 -1
- package/dist/phase/dataAccessCallsCandidates.js.map +1 -1
- package/dist/phase/goFunctionAnalysis.d.ts +2 -2
- package/dist/phase/goFunctionAnalysis.js +2 -2
- package/dist/phase/goFunctions.d.ts +2 -2
- package/dist/phase/goFunctions.js +2 -2
- package/dist/phase/goImports.d.ts +2 -2
- package/dist/phase/goImports.js +2 -2
- package/dist/phase/goSwitches.d.ts +2 -2
- package/dist/phase/goSwitches.js +2 -2
- package/dist/phase/loopQueryCandidates.js +1 -1
- package/dist/phase/loopQueryCandidates.js.map +1 -1
- package/dist/phase/phaseModel.d.ts +37 -8
- package/dist/phase/phaseModel.d.ts.map +1 -1
- package/dist/phase/phaseModel.js +94 -46
- package/dist/phase/phaseModel.js.map +1 -1
- package/dist/phase/producers.d.ts.map +1 -1
- package/dist/phase/producers.js +27 -17
- package/dist/phase/producers.js.map +1 -1
- package/dist/phase/reachability.d.ts +44 -1
- package/dist/phase/reachability.d.ts.map +1 -1
- package/dist/phase/reachability.js +79 -0
- package/dist/phase/reachability.js.map +1 -1
- package/dist/phase/receiverConsumers.d.ts +8 -1
- package/dist/phase/receiverConsumers.d.ts.map +1 -1
- package/dist/phase/receiverConsumers.js +59 -21
- package/dist/phase/receiverConsumers.js.map +1 -1
- package/dist/phase/receiverProvenance.d.ts +23 -0
- package/dist/phase/receiverProvenance.d.ts.map +1 -1
- package/dist/phase/receiverProvenance.js +40 -0
- package/dist/phase/receiverProvenance.js.map +1 -1
- package/dist/phase/rules/crossDomain.d.ts.map +1 -1
- package/dist/phase/rules/crossDomain.js +16 -6
- package/dist/phase/rules/crossDomain.js.map +1 -1
- package/dist/phase/rules/dry.d.ts.map +1 -1
- package/dist/phase/rules/dry.js +0 -1
- package/dist/phase/rules/dry.js.map +1 -1
- package/dist/phase/rules/goRules.d.ts +2 -2
- package/dist/phase/rules/goRules.js +2 -2
- package/dist/phase/rules/secrets.d.ts +22 -8
- package/dist/phase/rules/secrets.d.ts.map +1 -1
- package/dist/phase/rules/secrets.js +48 -67
- package/dist/phase/rules/secrets.js.map +1 -1
- package/dist/phase/rules/styles.d.ts +23 -9
- package/dist/phase/rules/styles.d.ts.map +1 -1
- package/dist/phase/rules/styles.js +47 -15
- package/dist/phase/rules/styles.js.map +1 -1
- package/dist/phase/rules/unreferencedModule.d.ts.map +1 -1
- package/dist/phase/rules/unreferencedModule.js +16 -5
- package/dist/phase/rules/unreferencedModule.js.map +1 -1
- package/dist/phase/runner.d.ts +16 -7
- package/dist/phase/runner.d.ts.map +1 -1
- package/dist/phase/runner.js +32 -20
- package/dist/phase/runner.js.map +1 -1
- package/dist/phase/stylesCss.d.ts.map +1 -1
- package/dist/phase/stylesCss.js +4 -0
- package/dist/phase/stylesCss.js.map +1 -1
- package/dist/phase/stylesMarkup.d.ts.map +1 -1
- package/dist/phase/stylesMarkup.js +4 -0
- package/dist/phase/stylesMarkup.js.map +1 -1
- package/dist/phase/stylesSource.d.ts.map +1 -1
- package/dist/phase/stylesSource.js +6 -0
- package/dist/phase/stylesSource.js.map +1 -1
- package/dist/phase/testProgram.d.ts +57 -0
- package/dist/phase/testProgram.d.ts.map +1 -0
- package/dist/phase/testProgram.js +244 -0
- package/dist/phase/testProgram.js.map +1 -0
- package/dist/phase/typeDeclarations.d.ts +2 -2
- package/dist/phase/typeDeclarations.js +2 -2
- package/dist/phase/types.d.ts +54 -0
- package/dist/phase/types.d.ts.map +1 -1
- package/dist/pipelineAdapters.d.ts +1 -171
- package/dist/pipelineAdapters.d.ts.map +1 -1
- package/dist/pipelineAdapters.js +47 -1281
- package/dist/pipelineAdapters.js.map +1 -1
- package/dist/reporting/csvReportGenerator.d.ts.map +1 -1
- package/dist/reporting/csvReportGenerator.js +0 -6
- package/dist/reporting/csvReportGenerator.js.map +1 -1
- package/dist/reporting/htmlReportGenerator.d.ts.map +1 -1
- package/dist/reporting/htmlReportGenerator.js +0 -4
- package/dist/reporting/htmlReportGenerator.js.map +1 -1
- package/dist/reporting/jsonReportGenerator.d.ts.map +1 -1
- package/dist/reporting/jsonReportGenerator.js +0 -1
- package/dist/reporting/jsonReportGenerator.js.map +1 -1
- package/dist/reporting/sarifReportGenerator.d.ts.map +1 -1
- package/dist/reporting/sarifReportGenerator.js +0 -7
- package/dist/reporting/sarifReportGenerator.js.map +1 -1
- package/dist/sqlite/driver.d.ts +17 -1
- package/dist/sqlite/driver.d.ts.map +1 -1
- package/dist/sqlite/driver.js +28 -5
- package/dist/sqlite/driver.js.map +1 -1
- package/dist/styles/cssInJsHarvest.d.ts +36 -0
- package/dist/styles/cssInJsHarvest.d.ts.map +1 -0
- package/dist/styles/cssInJsHarvest.js +78 -0
- package/dist/styles/cssInJsHarvest.js.map +1 -0
- package/dist/styles/definedClasses.d.ts +95 -0
- package/dist/styles/definedClasses.d.ts.map +1 -0
- package/dist/styles/definedClasses.js +129 -0
- package/dist/styles/definedClasses.js.map +1 -0
- package/dist/styles/markupStyleHarvest.d.ts +33 -0
- package/dist/styles/markupStyleHarvest.d.ts.map +1 -0
- package/dist/styles/markupStyleHarvest.js +73 -0
- package/dist/styles/markupStyleHarvest.js.map +1 -0
- package/dist/styles/styleExtractor.d.ts +37 -0
- package/dist/styles/styleExtractor.d.ts.map +1 -1
- package/dist/styles/styleExtractor.js +89 -33
- package/dist/styles/styleExtractor.js.map +1 -1
- package/dist/styles/styleIndexer.d.ts.map +1 -1
- package/dist/styles/styleIndexer.js +11 -10
- package/dist/styles/styleIndexer.js.map +1 -1
- package/dist/styles/tailwindExpander.d.ts.map +1 -1
- package/dist/styles/tailwindExpander.js +31 -10
- package/dist/styles/tailwindExpander.js.map +1 -1
- package/dist/telemetry.d.ts +67 -1
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +100 -20
- package/dist/telemetry.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 +36 -56
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -4
- package/dist/types.js.map +1 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/examples/.auditrc.example.json +7 -22
- package/examples/.auditrc.json +12 -155
- package/examples/.code-auditor.json +8 -51
- package/examples/nextjs.auditrc.json +7 -34
- package/examples/node-api.auditrc.json +6 -46
- package/examples/react.auditrc.json +8 -25
- package/examples/tolerant-solid.auditrc.json +12 -44
- package/package.json +13 -9
- package/plugin/.claude-plugin/manifest.json +10 -9
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/hooks/hooks.json +4 -4
- package/plugin/scripts/hook-audit.sh +14 -2
- package/plugin/scripts/hook-common.sh +41 -11
- package/plugin/scripts/hook-drift-check.sh +19 -6
- package/plugin/scripts/hook-log-path.sh +7 -0
- package/plugin/scripts/hook-self-audit.sh +14 -2
- package/plugin/scripts/hook-warm.sh +22 -17
- package/plugin/skills/code-auditor/SKILL.md +26 -3
- package/server.json +10 -4
- package/dist/__tests__/fixtures/spec-20/scripts/tool.d.ts +0 -6
- package/dist/__tests__/fixtures/spec-20/scripts/tool.d.ts.map +0 -1
- package/dist/__tests__/fixtures/spec-20/scripts/tool.js +0 -12
- package/dist/__tests__/fixtures/spec-20/scripts/tool.js.map +0 -1
- package/dist/__tests__/fixtures/spec-20/src/demo-module.d.ts +0 -7
- package/dist/__tests__/fixtures/spec-20/src/demo-module.d.ts.map +0 -1
- package/dist/__tests__/fixtures/spec-20/src/demo-module.js +0 -13
- package/dist/__tests__/fixtures/spec-20/src/demo-module.js.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-01-prepare-in-loop.d.ts +0 -14
- package/dist/__tests__/fixtures/spec-52/item-01-prepare-in-loop.d.ts.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-01-prepare-in-loop.js +0 -16
- package/dist/__tests__/fixtures/spec-52/item-01-prepare-in-loop.js.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-02-prepare-bind-accumulate-batch.d.ts +0 -15
- package/dist/__tests__/fixtures/spec-52/item-02-prepare-bind-accumulate-batch.d.ts.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-02-prepare-bind-accumulate-batch.js +0 -17
- package/dist/__tests__/fixtures/spec-52/item-02-prepare-bind-accumulate-batch.js.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.d.ts +0 -14
- package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.d.ts.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.js +0 -19
- package/dist/__tests__/fixtures/spec-52/item-03-exec-in-loop.js.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.d.ts +0 -18
- package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.d.ts.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.js +0 -19
- package/dist/__tests__/fixtures/spec-52/item-04-storage-sql-exec-in-loop.js.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-05-upsert-forms.d.ts +0 -19
- package/dist/__tests__/fixtures/spec-52/item-05-upsert-forms.d.ts.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-05-upsert-forms.js +0 -19
- package/dist/__tests__/fixtures/spec-52/item-05-upsert-forms.js.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.d.ts +0 -17
- package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.d.ts.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.js +0 -19
- package/dist/__tests__/fixtures/spec-52/item-06-chained-prepare-run-in-loop.js.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.d.ts +0 -25
- package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.d.ts.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.js +0 -21
- package/dist/__tests__/fixtures/spec-52/item-07-chained-prepare-bind-first-in-loop.js.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-08-promise-all-of-statements-in-loop.d.ts +0 -15
- package/dist/__tests__/fixtures/spec-52/item-08-promise-all-of-statements-in-loop.d.ts.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-08-promise-all-of-statements-in-loop.js +0 -19
- package/dist/__tests__/fixtures/spec-52/item-08-promise-all-of-statements-in-loop.js.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-09-promise-all-map-of-statements-in-loop.d.ts +0 -14
- package/dist/__tests__/fixtures/spec-52/item-09-promise-all-map-of-statements-in-loop.d.ts.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-09-promise-all-map-of-statements-in-loop.js +0 -14
- package/dist/__tests__/fixtures/spec-52/item-09-promise-all-map-of-statements-in-loop.js.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.d.ts +0 -15
- package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.d.ts.map +0 -1
- package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.js +0 -16
- package/dist/__tests__/fixtures/spec-52/item-10-promise-all-map-of-eager-all-in-loop.js.map +0 -1
- package/dist/languages/go/analyzer-darwin-amd64 +0 -0
- package/dist/languages/go/analyzer-darwin-arm64 +0 -0
- package/dist/languages/go/analyzer-linux-amd64 +0 -0
- package/dist/languages/go/analyzer-linux-arm64 +0 -0
- package/dist/languages/go/analyzer-src/analyzer.go +0 -643
- package/dist/languages/go/analyzer-src/dataaccess.go +0 -388
- package/dist/languages/go/analyzer-src/go.mod +0 -3
- package/dist/languages/go/analyzer-src/indexer.go +0 -268
- package/dist/languages/go/analyzer-src/parser.go +0 -461
- package/dist/languages/go/analyzer-src/solid.go +0 -311
- package/dist/languages/go/analyzer-src/testconventions.go +0 -25
- package/dist/languages/go/analyzer-src/types.go +0 -156
- package/dist/languages/go/analyzer-windows-amd64.exe +0 -0
- package/dist/languages/go/go.mod +0 -7
- package/dist/languages/go/main.go +0 -203
- package/dist/native/ast-grep-napi.darwin-arm64.node +0 -0
- package/dist/native/ast-grep-napi.darwin-x64.node +0 -0
- package/dist/native/ast-grep-napi.linux-arm64-gnu.node +0 -0
- package/dist/native/ast-grep-napi.linux-arm64-musl.node +0 -0
- package/dist/native/ast-grep-napi.linux-x64-gnu.node +0 -0
- package/dist/native/ast-grep-napi.linux-x64-musl.node +0 -0
- package/dist/native/ast-grep-napi.win32-x64-msvc.node +0 -0
- package/dist/native-bootstrap.d.ts +0 -15
- package/dist/native-bootstrap.d.ts.map +0 -1
- package/dist/native-bootstrap.js +0 -75
- package/dist/native-bootstrap.js.map +0 -1
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"projectRoot": ".",
|
|
3
|
-
"reportTitle": "Node.js API Audit",
|
|
4
|
-
|
|
5
2
|
"includePaths": [
|
|
6
3
|
"src/**/*.{ts,js}",
|
|
7
4
|
"lib/**/*.{ts,js}",
|
|
@@ -11,7 +8,7 @@
|
|
|
11
8
|
"services/**/*.{ts,js}",
|
|
12
9
|
"models/**/*.{ts,js}"
|
|
13
10
|
],
|
|
14
|
-
|
|
11
|
+
|
|
15
12
|
"excludePaths": [
|
|
16
13
|
"**/node_modules/**",
|
|
17
14
|
"**/dist/**",
|
|
@@ -21,55 +18,18 @@
|
|
|
21
18
|
"**/__tests__/**",
|
|
22
19
|
"**/coverage/**"
|
|
23
20
|
],
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"security": {
|
|
27
|
-
"authPatterns": ["authenticate", "authorize", "requireAuth", "passport"],
|
|
28
|
-
"rateLimitPatterns": ["rateLimit", "throttle", "limiter"],
|
|
29
|
-
"securityHeaders": [
|
|
30
|
-
"helmet",
|
|
31
|
-
"cors",
|
|
32
|
-
"Content-Security-Policy"
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
"data-access": {
|
|
36
|
-
"databasePatterns": {
|
|
37
|
-
"postgres": ["pg", "postgres"],
|
|
38
|
-
"mysql": ["mysql", "mysql2"],
|
|
39
|
-
"mongodb": ["mongodb", "mongoose"]
|
|
40
|
-
},
|
|
41
|
-
"securityPatterns": {
|
|
42
|
-
"parameterized": ["?", "$1", ":id"],
|
|
43
|
-
"sanitized": ["sanitize", "escape", "validator"]
|
|
44
|
-
},
|
|
45
|
-
"performanceThresholds": {
|
|
46
|
-
"maxJoins": 4,
|
|
47
|
-
"warnOnSelectStar": true
|
|
48
|
-
}
|
|
49
|
-
},
|
|
21
|
+
|
|
22
|
+
"analyzerConfigs": {
|
|
50
23
|
"solid": {
|
|
51
24
|
"maxMethodsPerClass": 12,
|
|
52
25
|
"maxLinesPerMethod": 60,
|
|
53
26
|
"maxParametersPerMethod": 5
|
|
54
27
|
}
|
|
55
28
|
},
|
|
56
|
-
|
|
57
|
-
"outputFormats": ["json", "html"],
|
|
58
|
-
"outputDirectory": "./audit-reports",
|
|
59
|
-
|
|
29
|
+
|
|
60
30
|
"minSeverity": "severe",
|
|
61
|
-
|
|
62
|
-
|
|
31
|
+
|
|
63
32
|
"thresholds": {
|
|
64
|
-
"maxCritical": 0,
|
|
65
|
-
"maxWarnings": 10,
|
|
66
33
|
"minHealthScore": 90
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
"integrations": {
|
|
70
|
-
"ci": {
|
|
71
|
-
"provider": "github",
|
|
72
|
-
"failOnThreshold": true
|
|
73
|
-
}
|
|
74
34
|
}
|
|
75
|
-
}
|
|
35
|
+
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"projectRoot": ".",
|
|
3
|
-
"reportTitle": "React Project Audit",
|
|
4
|
-
|
|
5
2
|
"includePaths": [
|
|
6
3
|
"src/**/*.{ts,tsx,js,jsx}"
|
|
7
4
|
],
|
|
8
|
-
|
|
5
|
+
|
|
9
6
|
"excludePaths": [
|
|
10
7
|
"**/node_modules/**",
|
|
11
8
|
"**/build/**",
|
|
@@ -16,18 +13,10 @@
|
|
|
16
13
|
"**/coverage/**",
|
|
17
14
|
"**/*.stories.{ts,tsx,js,jsx}"
|
|
18
15
|
],
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"checkPropTypes": true,
|
|
24
|
-
"maxComplexity": 12,
|
|
25
|
-
"frameworkPatterns": {
|
|
26
|
-
"react": {
|
|
27
|
-
"hooks": ["use*"],
|
|
28
|
-
"context": ["*Context", "*Provider"]
|
|
29
|
-
}
|
|
30
|
-
}
|
|
16
|
+
|
|
17
|
+
"analyzerConfigs": {
|
|
18
|
+
"react": {
|
|
19
|
+
"maxComponentComplexity": 12
|
|
31
20
|
},
|
|
32
21
|
"solid": {
|
|
33
22
|
"maxMethodsPerClass": 8,
|
|
@@ -38,16 +27,10 @@
|
|
|
38
27
|
"checkImports": true
|
|
39
28
|
}
|
|
40
29
|
},
|
|
41
|
-
|
|
42
|
-
"outputFormats": ["html", "json"],
|
|
43
|
-
"outputDirectory": "./audit-reports",
|
|
44
|
-
|
|
30
|
+
|
|
45
31
|
"minSeverity": "severe",
|
|
46
|
-
|
|
47
|
-
|
|
32
|
+
|
|
48
33
|
"thresholds": {
|
|
49
|
-
"maxCritical": 0,
|
|
50
|
-
"maxWarnings": 30,
|
|
51
34
|
"minHealthScore": 75
|
|
52
35
|
}
|
|
53
|
-
}
|
|
36
|
+
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"projectRoot": ".",
|
|
3
|
-
"reportTitle": "Project Audit with Relaxed SOLID Tolerances",
|
|
4
|
-
|
|
5
2
|
"includePaths": [
|
|
6
3
|
"src/**/*.{ts,tsx,js,jsx}"
|
|
7
4
|
],
|
|
8
|
-
|
|
5
|
+
|
|
9
6
|
"excludePaths": [
|
|
10
7
|
"**/node_modules/**",
|
|
11
8
|
"**/build/**",
|
|
@@ -13,53 +10,24 @@
|
|
|
13
10
|
"**/*.test.{ts,tsx,js,jsx}",
|
|
14
11
|
"**/*.spec.{ts,tsx,js,jsx}"
|
|
15
12
|
],
|
|
16
|
-
|
|
13
|
+
|
|
17
14
|
"analyzerConfigs": {
|
|
18
15
|
"solid": {
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"dashboard": 4,
|
|
23
|
-
"table": 3,
|
|
24
|
-
"form": 3
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
"classResponsibilityThresholds": {
|
|
28
|
-
"default": 2,
|
|
29
|
-
"repository": 2,
|
|
30
|
-
"service": 3,
|
|
31
|
-
"controller": 3,
|
|
32
|
-
"model": 3
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
"ifElseChainThreshold": 5,
|
|
36
|
-
"switchCaseThreshold": 7,
|
|
37
|
-
"classMethodThreshold": 12,
|
|
38
|
-
"interfaceMemberThreshold": 20,
|
|
39
|
-
"dependencyInjectionLimit": 6
|
|
16
|
+
"classMethodsThreshold": 40,
|
|
17
|
+
"maxInterfaceMembers": 50,
|
|
18
|
+
"maxMethodComplexity": 100
|
|
40
19
|
},
|
|
41
|
-
|
|
20
|
+
|
|
42
21
|
"dry": {
|
|
43
|
-
"minLineThreshold": 15,
|
|
44
|
-
"similarityThreshold": 0.85,
|
|
45
|
-
"checkImports": true
|
|
46
|
-
"unusedImportsConfig": {
|
|
47
|
-
"checkLevel": "function",
|
|
48
|
-
"includeTypeOnlyImports": false,
|
|
49
|
-
"ignorePatterns": ["React", "^_", "test.*"]
|
|
50
|
-
}
|
|
22
|
+
"minLineThreshold": 15,
|
|
23
|
+
"similarityThreshold": 0.85,
|
|
24
|
+
"checkImports": true
|
|
51
25
|
}
|
|
52
26
|
},
|
|
53
|
-
|
|
54
|
-
"outputFormats": ["html", "json"],
|
|
55
|
-
"outputDirectory": "./audit-reports",
|
|
56
|
-
|
|
27
|
+
|
|
57
28
|
"minSeverity": "severe",
|
|
58
|
-
|
|
59
|
-
|
|
29
|
+
|
|
60
30
|
"thresholds": {
|
|
61
|
-
"maxCritical": 5,
|
|
62
|
-
"maxWarnings": 50,
|
|
63
31
|
"minHealthScore": 70
|
|
64
32
|
}
|
|
65
|
-
}
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-auditor-mcp",
|
|
3
|
-
"version": "5.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "5.2.0",
|
|
4
|
+
"description": "Enforces architectural invariants and code quality rules inside your AI agent's edit loop.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"code-auditor-daemon": "dist/daemon/main.js"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "pnpm run build:version &&
|
|
15
|
+
"build": "pnpm run build:version && pnpm run build:hooklog && tsc && pnpm run build:grammars && pnpm run build:skills && pnpm run build:manifest",
|
|
16
16
|
"build:version": "node scripts/write-version.mjs",
|
|
17
|
-
"
|
|
17
|
+
"build:hooklog": "node scripts/write-hook-log-path.mjs",
|
|
18
18
|
"build:grammars": "mkdir -p dist/grammars && cp node_modules/tree-sitter-typescript/tree-sitter-typescript.wasm node_modules/tree-sitter-typescript/tree-sitter-tsx.wasm node_modules/tree-sitter-go/tree-sitter-go.wasm node_modules/tree-sitter-css/tree-sitter-css.wasm grammars/tree-sitter-scss.wasm dist/grammars/",
|
|
19
19
|
"build:skills": "node scripts/build-skills.mjs",
|
|
20
20
|
"build:manifest": "node scripts/build-manifest.mjs",
|
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
"verify:disk-space": "node scripts/verify-disk-space.mjs",
|
|
37
37
|
"verify:types": "tsc --noEmit",
|
|
38
38
|
"verify:dist-fresh": "node scripts/verify-dist-fresh.mjs",
|
|
39
|
+
"verify:hook-log-path": "node scripts/verify-hook-log-path.mjs",
|
|
40
|
+
"verify:version-fresh": "node scripts/verify-version-fresh.mjs",
|
|
39
41
|
"verify:clean-install": "bash scripts/verify-clean-install.sh",
|
|
40
42
|
"verify:dist": "npm pack --silent && bash scripts/verify-dist.sh && rm -f code-auditor-mcp-*.tgz",
|
|
41
43
|
"verify:self": "node scripts/verify-self.mjs && node scripts/verify-languages.mjs",
|
|
@@ -45,23 +47,26 @@
|
|
|
45
47
|
"verify:gate-budget": "node scripts/verify-gate-budget.mjs",
|
|
46
48
|
"verify:recall-value-drift": "tsx scripts/verify-recall-value-drift.ts",
|
|
47
49
|
"verify:extraction-completeness": "tsx scripts/verify-extraction-completeness.ts",
|
|
48
|
-
"verify:
|
|
50
|
+
"verify:recall-cases": "tsx scripts/verify-recall-cases.ts",
|
|
49
51
|
"verify:close": "node scripts/verify-close.mjs"
|
|
50
52
|
},
|
|
51
53
|
"keywords": [
|
|
52
54
|
"mcp",
|
|
53
55
|
"code-quality",
|
|
54
56
|
"static-analysis",
|
|
57
|
+
"ai-agent",
|
|
55
58
|
"ai-agents",
|
|
56
59
|
"claude-code",
|
|
57
|
-
"
|
|
60
|
+
"cursor",
|
|
61
|
+
"codex",
|
|
58
62
|
"sarif",
|
|
59
63
|
"tree-sitter",
|
|
60
|
-
"linter",
|
|
61
64
|
"solid",
|
|
65
|
+
"go",
|
|
62
66
|
"typescript",
|
|
63
67
|
"javascript",
|
|
64
|
-
"
|
|
68
|
+
"invariants",
|
|
69
|
+
"linter"
|
|
65
70
|
],
|
|
66
71
|
"author": "benahammond",
|
|
67
72
|
"license": "MIT",
|
|
@@ -119,7 +124,6 @@
|
|
|
119
124
|
"files": [
|
|
120
125
|
"dist/**/*",
|
|
121
126
|
"dist/grammars/",
|
|
122
|
-
"dist/native/",
|
|
123
127
|
"plugin/**/*",
|
|
124
128
|
".claude-plugin/**/*",
|
|
125
129
|
"examples/**/*",
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.0
|
|
2
|
+
"version": "5.2.0",
|
|
3
3
|
"files": {
|
|
4
|
-
".claude-plugin/plugin.json": "
|
|
4
|
+
".claude-plugin/plugin.json": "b492a180519f2991d0aa18211c3c9e45e6569c4715339e79d2032bbeec6ff44d",
|
|
5
5
|
"README.md": "6e51516ead6c7d0b4e77629e071e139b899d30a47838e8721c0d534eb733ad45",
|
|
6
|
-
"hooks/hooks.json": "
|
|
7
|
-
"scripts/hook-audit.sh": "
|
|
8
|
-
"scripts/hook-common.sh": "
|
|
9
|
-
"scripts/hook-drift-check.sh": "
|
|
10
|
-
"scripts/hook-
|
|
11
|
-
"scripts/hook-
|
|
6
|
+
"hooks/hooks.json": "f9817f337d147bbd0e175741e57c6bd0718c64352ddbff15b5ba9357272b6725",
|
|
7
|
+
"scripts/hook-audit.sh": "3fa178a87c8ac4d4d49d0cac16df308a37ccc89d778a5eda614799fc69e3e6c8",
|
|
8
|
+
"scripts/hook-common.sh": "0f29ac77e94ca7ba3f6ffe23bc91f9ce0c77f1568d9f13e29288d0cf5eef6bd8",
|
|
9
|
+
"scripts/hook-drift-check.sh": "4e6ed8e4e33d0765a5ed6adfda6fb3ecec5750d836632aa4ee6d7a6acce69665",
|
|
10
|
+
"scripts/hook-log-path.sh": "4ac27ac22dcb29fd82cbd9a936b3da7115c5182386a0e3290ed5ac9e529bc132",
|
|
11
|
+
"scripts/hook-self-audit.sh": "593926cd4714c653269791ed53675b46fbc92310074bff9194772e25665b0257",
|
|
12
|
+
"scripts/hook-warm.sh": "22d750e8e36164920515c8370f02dd48f9f09f26bfe4a21e67de91f45b5ffef9",
|
|
12
13
|
"skills/code-auditor/SKILL-RULE-KINDS.md": "be1bbe1b56b19dc112c2657c1f5984f6f704b2ac9c1c0f78a561a58b110d508a",
|
|
13
14
|
"skills/code-auditor/SKILL-SEARCH.md": "95d2df4474995bc5b18e14cc55ac55fb828024541463f109239567e2aa5ab7b0",
|
|
14
|
-
"skills/code-auditor/SKILL.md": "
|
|
15
|
+
"skills/code-auditor/SKILL.md": "0f88508c4549f4b53fdfee431e43a27c7eba2ac99e0eaad64ba55492429be41b"
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-auditor",
|
|
3
3
|
"description": "Diff-scoped code quality auditing on every edit. Indexes your codebase, enforces invariants, and feeds violations back to the agent so fixes happen inline.",
|
|
4
|
-
"version": "5.0
|
|
4
|
+
"version": "5.2.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ben Hammond",
|
|
7
7
|
"email": "ben@benhammond.tech"
|
package/plugin/hooks/hooks.json
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
"hooks": [
|
|
7
7
|
{
|
|
8
8
|
"type": "command",
|
|
9
|
-
"command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-warm.sh"
|
|
9
|
+
"command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then dir=\"${XDG_CACHE_HOME:-$HOME/.cache}/code-auditor/logs\"; mkdir -p \"$dir\" 2>/dev/null || true; echo \"[$(date -u +%Y-%m-%dT%H:%M:%SZ)] [code-auditor] HOOK NOT RUNNING: CLAUDE_PLUGIN_ROOT is unset — could not locate the plugin; the warm-up is not running.\" >> \"$dir/hook.log\" 2>/dev/null || true; exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-warm.sh"
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
12
|
"type": "command",
|
|
13
|
-
"command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-drift-check.sh"
|
|
13
|
+
"command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then dir=\"${XDG_CACHE_HOME:-$HOME/.cache}/code-auditor/logs\"; mkdir -p \"$dir\" 2>/dev/null || true; echo \"[$(date -u +%Y-%m-%dT%H:%M:%SZ)] [code-auditor] HOOK NOT RUNNING: CLAUDE_PLUGIN_ROOT is unset — could not locate the plugin; the drift check is not running.\" >> \"$dir/hook.log\" 2>/dev/null || true; exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-drift-check.sh"
|
|
14
14
|
}
|
|
15
15
|
]
|
|
16
16
|
}
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"hooks": [
|
|
22
22
|
{
|
|
23
23
|
"type": "command",
|
|
24
|
-
"command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-audit.sh"
|
|
24
|
+
"command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then dir=\"${XDG_CACHE_HOME:-$HOME/.cache}/code-auditor/logs\"; mkdir -p \"$dir\" 2>/dev/null || true; echo \"[$(date -u +%Y-%m-%dT%H:%M:%SZ)] [code-auditor] HOOK NOT RUNNING: CLAUDE_PLUGIN_ROOT is unset — could not locate the plugin; the audit is not running.\" >> \"$dir/hook.log\" 2>/dev/null || true; exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-audit.sh"
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"type": "command",
|
|
28
|
-
"command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-self-audit.sh"
|
|
28
|
+
"command": "if [ -z \"${CLAUDE_PLUGIN_ROOT}\" ]; then dir=\"${XDG_CACHE_HOME:-$HOME/.cache}/code-auditor/logs\"; mkdir -p \"$dir\" 2>/dev/null || true; echo \"[$(date -u +%Y-%m-%dT%H:%M:%SZ)] [code-auditor] HOOK NOT RUNNING: CLAUDE_PLUGIN_ROOT is unset — could not locate the plugin; the self-audit is not running.\" >> \"$dir/hook.log\" 2>/dev/null || true; exit 0; fi; \"${CLAUDE_PLUGIN_ROOT}\"/scripts/hook-self-audit.sh"
|
|
29
29
|
}
|
|
30
30
|
]
|
|
31
31
|
}
|
|
@@ -16,8 +16,11 @@
|
|
|
16
16
|
# failure surfaces on the next explicit audit, never on the edit.
|
|
17
17
|
set -euo pipefail
|
|
18
18
|
|
|
19
|
-
# Shared resolver + compatibility pinning (see hook-common.sh).
|
|
20
|
-
|
|
19
|
+
# Shared resolver + compatibility pinning (see hook-common.sh). Source it from
|
|
20
|
+
# this script's own directory — the plugin's scripts/ — never from a host
|
|
21
|
+
# environment variable.
|
|
22
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
|
23
|
+
. "${SCRIPT_DIR}/hook-common.sh"
|
|
21
24
|
|
|
22
25
|
# Read event JSON from stdin
|
|
23
26
|
event="$(cat)"
|
|
@@ -89,6 +92,15 @@ fi
|
|
|
89
92
|
exit_code=$?
|
|
90
93
|
set -e
|
|
91
94
|
|
|
95
|
+
# A completed run — clean (0) or finding (2) — is the positive "the hook is
|
|
96
|
+
# alive and enqueueing" signal. Write it so the explicit-audit reader
|
|
97
|
+
# (src/hookLog.ts) can clear a prior HOOK NOT RUNNING condition: the reader
|
|
98
|
+
# resolves a condition by newest-record order, and without this line a hook that
|
|
99
|
+
# recovered would leave the stale condition live forever.
|
|
100
|
+
if [ "${exit_code}" -eq 0 ] || [ "${exit_code}" -eq 2 ]; then
|
|
101
|
+
hook_log "[code-auditor] HOOK RAN"
|
|
102
|
+
fi
|
|
103
|
+
|
|
92
104
|
# Exit 2 = a finding read from the daemon cache; propagate so Claude Code feeds
|
|
93
105
|
# stdout back.
|
|
94
106
|
if [ ${exit_code} -eq 2 ]; then
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Shared helpers for the code-auditor PostToolUse hooks.
|
|
3
3
|
#
|
|
4
|
-
# Sourced by hook-audit.sh
|
|
5
|
-
#
|
|
6
|
-
# is
|
|
4
|
+
# Sourced by hook-audit.sh, hook-self-audit.sh, hook-warm.sh, and
|
|
5
|
+
# hook-drift-check.sh. The plugin root is derived from where THIS file lives —
|
|
6
|
+
# `<plugin>/scripts/hook-common.sh`, so the root is its grand-parent — never
|
|
7
|
+
# from a host environment variable. `CLAUDE_PLUGIN_ROOT` is honored only as a
|
|
8
|
+
# validated override (see plugin_root below), so an unset or wrong value can
|
|
9
|
+
# never decide whether the tool runs.
|
|
7
10
|
#
|
|
8
11
|
# Two rules enforced here are the fix for "the hook died quietly" (three times:
|
|
9
12
|
# unset CLAUDE_PLUGIN_ROOT, a stale global binary, a removed CLI flag):
|
|
@@ -30,6 +33,32 @@
|
|
|
30
33
|
#
|
|
31
34
|
# The sourcing hook runs with `set -euo pipefail`.
|
|
32
35
|
|
|
36
|
+
# plugin_root — the plugin's install root.
|
|
37
|
+
#
|
|
38
|
+
# This file ships at `<plugin>/scripts/hook-common.sh`, so the plugin root is the
|
|
39
|
+
# grand-parent of its own location. That fixed, known-at-build-time offset is the
|
|
40
|
+
# single source of truth: every path a hook needs (the manifest, the bundled CLI
|
|
41
|
+
# sibling) is derived from here, not read from a host variable that may be unset.
|
|
42
|
+
# `CLAUDE_PLUGIN_ROOT` is honored only when it actually points at a plugin — it
|
|
43
|
+
# must contain this same `scripts/hook-common.sh` — so a stale or wrong value
|
|
44
|
+
# never shadows the real location, and an absent one is a non-event.
|
|
45
|
+
plugin_root() {
|
|
46
|
+
local here root
|
|
47
|
+
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
|
48
|
+
root="$(dirname "${here}")"
|
|
49
|
+
if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -f "${CLAUDE_PLUGIN_ROOT}/scripts/hook-common.sh" ]; then
|
|
50
|
+
printf '%s' "${CLAUDE_PLUGIN_ROOT}"
|
|
51
|
+
return
|
|
52
|
+
fi
|
|
53
|
+
printf '%s' "${root}"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# The hook-log path tail + file name are single-sourced in hook-log-path.sh,
|
|
57
|
+
# generated by scripts/write-hook-log-path.mjs from the same source as
|
|
58
|
+
# src/hookLogPath.generated.ts (the reader's copy). Sourced here so the write
|
|
59
|
+
# half and the read half (src/hookLog.ts) can never drift apart.
|
|
60
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)/hook-log-path.sh"
|
|
61
|
+
|
|
33
62
|
# hook_log_dir / hook_log_file / hook_log — the hook's diagnostic log.
|
|
34
63
|
#
|
|
35
64
|
# The PostToolUse hook must never write stderr: the host may block on stderr
|
|
@@ -38,10 +67,10 @@
|
|
|
38
67
|
# still exits 0. A broken install therefore surfaces on the next explicit audit
|
|
39
68
|
# (and in this log), never on the edit itself.
|
|
40
69
|
hook_log_dir() {
|
|
41
|
-
printf '%s' "${XDG_CACHE_HOME:-$HOME/.cache}
|
|
70
|
+
printf '%s' "${XDG_CACHE_HOME:-$HOME/.cache}/${HOOK_LOG_DIR_TAIL}"
|
|
42
71
|
}
|
|
43
72
|
hook_log_file() {
|
|
44
|
-
printf '%s' "$(hook_log_dir)
|
|
73
|
+
printf '%s' "$(hook_log_dir)/${HOOK_LOG_FILE}"
|
|
45
74
|
}
|
|
46
75
|
hook_log() {
|
|
47
76
|
mkdir -p "$(hook_log_dir)" 2>/dev/null || return 0
|
|
@@ -55,7 +84,7 @@ hook_log() {
|
|
|
55
84
|
# manifest version. A stale candidate is warned about and skipped, so a mismatched
|
|
56
85
|
# binary no longer turns the hook into a hard failure.
|
|
57
86
|
#
|
|
58
|
-
# 1. The plugin's bundled CLI (`$
|
|
87
|
+
# 1. The plugin's bundled CLI (`$(plugin_root)/../dist/cli.js` ships in the
|
|
59
88
|
# same npm package, so it usually matches) — but a marketplace checkout has no
|
|
60
89
|
# npm-paired dist/, and a locally built one can be stale, so it is
|
|
61
90
|
# version-checked like everything else.
|
|
@@ -66,9 +95,10 @@ hook_log() {
|
|
|
66
95
|
# 3. Project-local install (consumer project's own node_modules) — if compatible.
|
|
67
96
|
# 4. Global install / PATH — if compatible.
|
|
68
97
|
resolve_code_audit() {
|
|
69
|
-
local candidate
|
|
70
|
-
|
|
71
|
-
|
|
98
|
+
local candidate root
|
|
99
|
+
root="$(plugin_root)"
|
|
100
|
+
if [ -f "${root}/../dist/cli.js" ]; then
|
|
101
|
+
candidate="${root}/../dist/cli.js"
|
|
72
102
|
if cli_is_compatible "${candidate}"; then
|
|
73
103
|
echo "${candidate}"
|
|
74
104
|
return
|
|
@@ -165,7 +195,7 @@ plugin_version() {
|
|
|
165
195
|
return
|
|
166
196
|
fi
|
|
167
197
|
__CODE_AUDITOR_PLUGIN_VERSION="$(
|
|
168
|
-
node -e
|
|
198
|
+
node -e 'const fs=require("fs");const p=process.argv[1];for(const f of [p+"/.claude-plugin/plugin.json", p+"/plugin.json"]){try{const v=JSON.parse(fs.readFileSync(f,"utf8")).version;if(v){process.stdout.write(v);break}}catch(e){}}' "$(plugin_root)" 2>/dev/null
|
|
169
199
|
)"
|
|
170
200
|
__CODE_AUDITOR_PLUGIN_VERSION_RESOLVED=1
|
|
171
201
|
printf '%s' "${__CODE_AUDITOR_PLUGIN_VERSION}"
|
|
@@ -220,7 +250,7 @@ assert_compatible() {
|
|
|
220
250
|
# bundled sibling, a project-local install, a global on PATH) are NOT
|
|
221
251
|
# path-guaranteed — the resolver's `cli_is_compatible` already version-checked
|
|
222
252
|
# them, and the full check below remains the loud backstop for any of them.
|
|
223
|
-
if [
|
|
253
|
+
if [ "${bin}" = "$(pin_dir)/node_modules/.bin/code-audit" ]; then
|
|
224
254
|
return 0
|
|
225
255
|
fi
|
|
226
256
|
pv="$(plugin_version)"
|
|
@@ -18,20 +18,30 @@
|
|
|
18
18
|
# single source of truth; the fix is to reinstall (or restore the file).
|
|
19
19
|
set -uo pipefail
|
|
20
20
|
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
|
|
21
|
+
# Source the shared resolver from this script's own directory — the plugin's
|
|
22
|
+
# scripts/ — never from a host environment variable. plugin_root() self-locates
|
|
23
|
+
# the plugin root, so an unset or wrong CLAUDE_PLUGIN_ROOT is a non-event.
|
|
24
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
|
25
|
+
. "${SCRIPT_DIR}/hook-common.sh"
|
|
26
|
+
|
|
27
|
+
ROOT="$(plugin_root)"
|
|
24
28
|
|
|
25
29
|
# The manifest ships at .claude-plugin/manifest.json; a few installs flatten the
|
|
26
30
|
# plugin.json to the plugin root, so check both locations (mirrors
|
|
27
31
|
# hook-common.sh's plugin_version).
|
|
28
32
|
manifest=""
|
|
29
|
-
for f in "${
|
|
33
|
+
for f in "${ROOT}/.claude-plugin/manifest.json" "${ROOT}/manifest.json"; do
|
|
30
34
|
if [ -f "$f" ]; then manifest="$f"; break; fi
|
|
31
35
|
done
|
|
32
|
-
[ -
|
|
36
|
+
if [ -z "${manifest}" ]; then
|
|
37
|
+
# No manifest to compare against is still a completed run — the drift check
|
|
38
|
+
# never exits non-zero, so write the success record that resolves a prior
|
|
39
|
+
# HOOK NOT RUNNING condition before the no-op exit.
|
|
40
|
+
hook_log "[code-auditor] HOOK RAN"
|
|
41
|
+
exit 0
|
|
42
|
+
fi
|
|
33
43
|
|
|
34
|
-
MANIFEST_PATH="${manifest}" PLUGIN_ROOT="${
|
|
44
|
+
MANIFEST_PATH="${manifest}" PLUGIN_ROOT="${ROOT}" node <<'NODE'
|
|
35
45
|
const fs = require('fs');
|
|
36
46
|
const crypto = require('crypto');
|
|
37
47
|
const path = require('path');
|
|
@@ -69,4 +79,7 @@ if (problems.length > 0) {
|
|
|
69
79
|
}
|
|
70
80
|
NODE
|
|
71
81
|
|
|
82
|
+
# A completed run (drift found or not) resolves a prior HOOK NOT RUNNING
|
|
83
|
+
# condition — the drift check never exits non-zero.
|
|
84
|
+
hook_log "[code-auditor] HOOK RAN"
|
|
72
85
|
exit 0
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @generated — do not edit. Written by `scripts/write-hook-log-path.mjs`.
|
|
2
|
+
#
|
|
3
|
+
# Single source of truth for the hook-log path, shared by the TS reader
|
|
4
|
+
# (src/hookLog.ts) and the bash writer (plugin/scripts/hook-common.sh).
|
|
5
|
+
# Regenerate with `npm run build:hooklog`.
|
|
6
|
+
HOOK_LOG_DIR_TAIL='code-auditor/logs'
|
|
7
|
+
HOOK_LOG_FILE='hook.log'
|
|
@@ -20,8 +20,11 @@
|
|
|
20
20
|
# the log file, not stderr, and still exits 0 (Spec 68 §hook-contract).
|
|
21
21
|
set -euo pipefail
|
|
22
22
|
|
|
23
|
-
# Shared resolver + compatibility pinning (see hook-common.sh).
|
|
24
|
-
|
|
23
|
+
# Shared resolver + compatibility pinning (see hook-common.sh). Source it from
|
|
24
|
+
# this script's own directory — the plugin's scripts/ — never from a host
|
|
25
|
+
# environment variable.
|
|
26
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
|
27
|
+
. "${SCRIPT_DIR}/hook-common.sh"
|
|
25
28
|
|
|
26
29
|
# Read event JSON from stdin
|
|
27
30
|
event="$(cat)"
|
|
@@ -89,6 +92,15 @@ fi
|
|
|
89
92
|
exit_code=$?
|
|
90
93
|
set -e
|
|
91
94
|
|
|
95
|
+
# A completed run — clean (0) or finding (2) — is the positive "the hook is
|
|
96
|
+
# alive" signal, mirroring hook-audit.sh. Write it so the reader (src/hookLog.ts)
|
|
97
|
+
# can clear a prior HOOK NOT RUNNING condition: the reader resolves by
|
|
98
|
+
# newest-record order, and without this line a recovered hook would leave the
|
|
99
|
+
# stale condition live forever.
|
|
100
|
+
if [ "${exit_code}" -eq 0 ] || [ "${exit_code}" -eq 2 ]; then
|
|
101
|
+
hook_log "[code-auditor] HOOK RAN"
|
|
102
|
+
fi
|
|
103
|
+
|
|
92
104
|
# Exit 2 = a blocking self-audit finding; propagate so Claude Code feeds it back.
|
|
93
105
|
if [ ${exit_code} -eq 2 ]; then
|
|
94
106
|
exit 2
|
|
@@ -17,28 +17,33 @@
|
|
|
17
17
|
# at all — a warm session must not re-check on every launch.
|
|
18
18
|
set -uo pipefail
|
|
19
19
|
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
. "${CLAUDE_PLUGIN_ROOT}/scripts/hook-common.sh"
|
|
20
|
+
# Source the shared resolver from this script's own directory — the plugin's
|
|
21
|
+
# scripts/ — never from a host environment variable. plugin_root() self-locates
|
|
22
|
+
# the plugin root, so an unset or wrong CLAUDE_PLUGIN_ROOT is a non-event.
|
|
23
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
|
24
|
+
. "${SCRIPT_DIR}/hook-common.sh"
|
|
26
25
|
|
|
27
26
|
# Nothing safe to warm if the manifest version can't be read: warming @latest
|
|
28
27
|
# could pin a different version than resolve_code_audit's fallback would fetch.
|
|
29
28
|
pv="$(plugin_version)"
|
|
30
|
-
[ -n "${pv}" ] || exit 0
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
if [ -n "${pv}" ]; then
|
|
31
|
+
dir="$(pin_dir)"
|
|
32
|
+
bin="${dir}/node_modules/.bin/code-audit"
|
|
34
33
|
|
|
35
|
-
# Already installed — nothing to warm. Re-running npm install here would re-check
|
|
36
|
-
# the registry on every session, which is exactly the cost this hook exists to avoid.
|
|
37
|
-
[ -x "${bin}" ]
|
|
34
|
+
# Already installed — nothing to warm. Re-running npm install here would re-check
|
|
35
|
+
# the registry on every session, which is exactly the cost this hook exists to avoid.
|
|
36
|
+
if [ ! -x "${bin}" ]; then
|
|
37
|
+
# Background the exact install the hook's last-resort path runs. Output to
|
|
38
|
+
# /dev/null (silent), stdin from /dev/null (don't hold the hook's stdin open),
|
|
39
|
+
# nohup so the install survives this hook's exit.
|
|
40
|
+
nohup npm install --prefer-offline --prefix "${dir}" "code-auditor-mcp@${pv}" \
|
|
41
|
+
--no-audit --no-fund --ignore-scripts --silent >/dev/null 2>&1 </dev/null &
|
|
42
|
+
fi
|
|
43
|
+
fi
|
|
38
44
|
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
--no-audit --no-fund --ignore-scripts --silent >/dev/null 2>&1 </dev/null &
|
|
45
|
+
# A completed run — the warm hook never exits non-zero, so every path through it
|
|
46
|
+
# is a success — writes the positive record that resolves a prior HOOK NOT RUNNING
|
|
47
|
+
# condition (CLAUDE_PLUGIN_ROOT unset) in the reader (src/hookLog.ts).
|
|
48
|
+
hook_log "[code-auditor] HOOK RAN"
|
|
44
49
|
exit 0
|