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,461 +0,0 @@
|
|
|
1
|
-
package analyzer
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"fmt"
|
|
5
|
-
"go/ast"
|
|
6
|
-
"go/parser"
|
|
7
|
-
"go/token"
|
|
8
|
-
"strings"
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
// Parser handles Go AST parsing and entity extraction
|
|
12
|
-
type Parser struct {
|
|
13
|
-
fileSet *token.FileSet
|
|
14
|
-
files map[string]*ast.File
|
|
15
|
-
options AnalysisOptions
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// NewParser creates a new Go parser
|
|
19
|
-
func NewParser(options AnalysisOptions) *Parser {
|
|
20
|
-
return &Parser{
|
|
21
|
-
fileSet: token.NewFileSet(),
|
|
22
|
-
files: make(map[string]*ast.File),
|
|
23
|
-
options: options,
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// ParseFiles parses the given Go files
|
|
28
|
-
func (p *Parser) ParseFiles(filePaths []string) error {
|
|
29
|
-
for _, filePath := range filePaths {
|
|
30
|
-
if !strings.HasSuffix(filePath, ".go") {
|
|
31
|
-
continue
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
file, err := parser.ParseFile(p.fileSet, filePath, nil, parser.ParseComments)
|
|
35
|
-
if err != nil {
|
|
36
|
-
return fmt.Errorf("failed to parse %s: %w", filePath, err)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
p.files[filePath] = file
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return nil
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ParseContent parses Go source code from a string
|
|
46
|
-
func (p *Parser) ParseContent(filePath, content string) error {
|
|
47
|
-
if !strings.HasSuffix(filePath, ".go") {
|
|
48
|
-
return fmt.Errorf("not a Go file: %s", filePath)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
file, err := parser.ParseFile(p.fileSet, filePath, content, parser.ParseComments)
|
|
52
|
-
if err != nil {
|
|
53
|
-
return fmt.Errorf("failed to parse content for %s: %w", filePath, err)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
p.files[filePath] = file
|
|
57
|
-
return nil
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// ExtractFunctions extracts all functions from parsed files
|
|
61
|
-
func (p *Parser) ExtractFunctions() []Function {
|
|
62
|
-
var functions []Function
|
|
63
|
-
|
|
64
|
-
for filePath, file := range p.files {
|
|
65
|
-
ast.Inspect(file, func(n ast.Node) bool {
|
|
66
|
-
switch node := n.(type) {
|
|
67
|
-
case *ast.FuncDecl:
|
|
68
|
-
// Skip test functions (Test*/Benchmark*/Example*/Fuzz*): they are
|
|
69
|
-
// `go test` entry points, not production API. Mirrors the Go
|
|
70
|
-
// test-function convention in languages/testConventions.ts.
|
|
71
|
-
if isTestFunction(node.Name.Name) {
|
|
72
|
-
return true
|
|
73
|
-
}
|
|
74
|
-
function := p.extractFunction(node, filePath, file)
|
|
75
|
-
functions = append(functions, function)
|
|
76
|
-
}
|
|
77
|
-
return true
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return functions
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// ExtractStructs extracts all structs from parsed files
|
|
85
|
-
func (p *Parser) ExtractStructs() []Struct {
|
|
86
|
-
var structs []Struct
|
|
87
|
-
|
|
88
|
-
for filePath, file := range p.files {
|
|
89
|
-
ast.Inspect(file, func(n ast.Node) bool {
|
|
90
|
-
switch node := n.(type) {
|
|
91
|
-
case *ast.GenDecl:
|
|
92
|
-
if node.Tok == token.TYPE {
|
|
93
|
-
for _, spec := range node.Specs {
|
|
94
|
-
if typeSpec, ok := spec.(*ast.TypeSpec); ok {
|
|
95
|
-
if structType, ok := typeSpec.Type.(*ast.StructType); ok {
|
|
96
|
-
structInfo := p.extractStruct(typeSpec, structType, filePath, file)
|
|
97
|
-
structs = append(structs, structInfo)
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return true
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return structs
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// ExtractInterfaces extracts all interfaces from parsed files
|
|
111
|
-
func (p *Parser) ExtractInterfaces() []Interface {
|
|
112
|
-
var interfaces []Interface
|
|
113
|
-
|
|
114
|
-
for filePath, file := range p.files {
|
|
115
|
-
ast.Inspect(file, func(n ast.Node) bool {
|
|
116
|
-
switch node := n.(type) {
|
|
117
|
-
case *ast.GenDecl:
|
|
118
|
-
if node.Tok == token.TYPE {
|
|
119
|
-
for _, spec := range node.Specs {
|
|
120
|
-
if typeSpec, ok := spec.(*ast.TypeSpec); ok {
|
|
121
|
-
if interfaceType, ok := typeSpec.Type.(*ast.InterfaceType); ok {
|
|
122
|
-
interfaceInfo := p.extractInterface(typeSpec, interfaceType, filePath, file)
|
|
123
|
-
interfaces = append(interfaces, interfaceInfo)
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return true
|
|
130
|
-
})
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return interfaces
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// extractFunction extracts function information from AST
|
|
137
|
-
func (p *Parser) extractFunction(funcDecl *ast.FuncDecl, filePath string, file *ast.File) Function {
|
|
138
|
-
pos := p.fileSet.Position(funcDecl.Pos())
|
|
139
|
-
end := p.fileSet.Position(funcDecl.End())
|
|
140
|
-
|
|
141
|
-
function := Function{
|
|
142
|
-
EntityInfo: EntityInfo{
|
|
143
|
-
Name: funcDecl.Name.Name,
|
|
144
|
-
Type: "function",
|
|
145
|
-
File: filePath,
|
|
146
|
-
StartLine: pos.Line,
|
|
147
|
-
EndLine: end.Line,
|
|
148
|
-
Package: file.Name.Name,
|
|
149
|
-
},
|
|
150
|
-
IsMethod: funcDecl.Recv != nil,
|
|
151
|
-
IsExported: ast.IsExported(funcDecl.Name.Name),
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Extract receiver for methods
|
|
155
|
-
if funcDecl.Recv != nil && len(funcDecl.Recv.List) > 0 {
|
|
156
|
-
if field := funcDecl.Recv.List[0]; field.Type != nil {
|
|
157
|
-
function.Receiver = p.typeToString(field.Type)
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Extract parameters
|
|
162
|
-
if funcDecl.Type.Params != nil {
|
|
163
|
-
for _, param := range funcDecl.Type.Params.List {
|
|
164
|
-
paramType := p.typeToString(param.Type)
|
|
165
|
-
if len(param.Names) > 0 {
|
|
166
|
-
for _, name := range param.Names {
|
|
167
|
-
function.Parameters = append(function.Parameters, Parameter{
|
|
168
|
-
Name: name.Name,
|
|
169
|
-
Type: paramType,
|
|
170
|
-
Language: "go",
|
|
171
|
-
})
|
|
172
|
-
}
|
|
173
|
-
} else {
|
|
174
|
-
// Anonymous parameter
|
|
175
|
-
function.Parameters = append(function.Parameters, Parameter{
|
|
176
|
-
Name: "",
|
|
177
|
-
Type: paramType,
|
|
178
|
-
Language: "go",
|
|
179
|
-
})
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Extract return type
|
|
185
|
-
if funcDecl.Type.Results != nil {
|
|
186
|
-
var returnTypes []string
|
|
187
|
-
for _, result := range funcDecl.Type.Results.List {
|
|
188
|
-
returnTypes = append(returnTypes, p.typeToString(result.Type))
|
|
189
|
-
}
|
|
190
|
-
function.ReturnType = strings.Join(returnTypes, ", ")
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// Build signature
|
|
194
|
-
function.Signature = p.buildFunctionSignature(function)
|
|
195
|
-
|
|
196
|
-
// Extract purpose from comments
|
|
197
|
-
if funcDecl.Doc != nil {
|
|
198
|
-
function.Purpose = p.extractPurposeFromComments(funcDecl.Doc.Text())
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// Calculate complexity (basic implementation)
|
|
202
|
-
function.Complexity = p.calculateComplexity(funcDecl)
|
|
203
|
-
|
|
204
|
-
return function
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// extractStruct extracts struct information from AST
|
|
208
|
-
func (p *Parser) extractStruct(typeSpec *ast.TypeSpec, structType *ast.StructType, filePath string, file *ast.File) Struct {
|
|
209
|
-
pos := p.fileSet.Position(typeSpec.Pos())
|
|
210
|
-
end := p.fileSet.Position(typeSpec.End())
|
|
211
|
-
|
|
212
|
-
structInfo := Struct{
|
|
213
|
-
EntityInfo: EntityInfo{
|
|
214
|
-
Name: typeSpec.Name.Name,
|
|
215
|
-
Type: "struct",
|
|
216
|
-
File: filePath,
|
|
217
|
-
StartLine: pos.Line,
|
|
218
|
-
EndLine: end.Line,
|
|
219
|
-
Package: file.Name.Name,
|
|
220
|
-
},
|
|
221
|
-
IsExported: ast.IsExported(typeSpec.Name.Name),
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Extract fields
|
|
225
|
-
if structType.Fields != nil {
|
|
226
|
-
for _, field := range structType.Fields.List {
|
|
227
|
-
fieldType := p.typeToString(field.Type)
|
|
228
|
-
tag := ""
|
|
229
|
-
if field.Tag != nil {
|
|
230
|
-
tag = field.Tag.Value
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if len(field.Names) > 0 {
|
|
234
|
-
for _, name := range field.Names {
|
|
235
|
-
structInfo.Fields = append(structInfo.Fields, Field{
|
|
236
|
-
Name: name.Name,
|
|
237
|
-
Type: fieldType,
|
|
238
|
-
Tag: tag,
|
|
239
|
-
IsExported: ast.IsExported(name.Name),
|
|
240
|
-
})
|
|
241
|
-
}
|
|
242
|
-
} else {
|
|
243
|
-
// Embedded field
|
|
244
|
-
structInfo.Fields = append(structInfo.Fields, Field{
|
|
245
|
-
Name: fieldType, // Use type as name for embedded fields
|
|
246
|
-
Type: fieldType,
|
|
247
|
-
Tag: tag,
|
|
248
|
-
IsExported: true, // Embedded fields are typically exported
|
|
249
|
-
})
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Build signature
|
|
255
|
-
structInfo.Signature = fmt.Sprintf("type %s struct", structInfo.Name)
|
|
256
|
-
|
|
257
|
-
return structInfo
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// extractInterface extracts interface information from AST
|
|
261
|
-
func (p *Parser) extractInterface(typeSpec *ast.TypeSpec, interfaceType *ast.InterfaceType, filePath string, file *ast.File) Interface {
|
|
262
|
-
pos := p.fileSet.Position(typeSpec.Pos())
|
|
263
|
-
end := p.fileSet.Position(typeSpec.End())
|
|
264
|
-
|
|
265
|
-
interfaceInfo := Interface{
|
|
266
|
-
EntityInfo: EntityInfo{
|
|
267
|
-
Name: typeSpec.Name.Name,
|
|
268
|
-
Type: "interface",
|
|
269
|
-
File: filePath,
|
|
270
|
-
StartLine: pos.Line,
|
|
271
|
-
EndLine: end.Line,
|
|
272
|
-
Package: file.Name.Name,
|
|
273
|
-
},
|
|
274
|
-
IsExported: ast.IsExported(typeSpec.Name.Name),
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// Extract methods
|
|
278
|
-
if interfaceType.Methods != nil {
|
|
279
|
-
for _, method := range interfaceType.Methods.List {
|
|
280
|
-
if len(method.Names) > 0 {
|
|
281
|
-
// Named method
|
|
282
|
-
for _, name := range method.Names {
|
|
283
|
-
if funcType, ok := method.Type.(*ast.FuncType); ok {
|
|
284
|
-
methodInfo := Method{
|
|
285
|
-
Name: name.Name,
|
|
286
|
-
Signature: p.buildMethodSignature(name.Name, funcType),
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// Extract parameters
|
|
290
|
-
if funcType.Params != nil {
|
|
291
|
-
for _, param := range funcType.Params.List {
|
|
292
|
-
paramType := p.typeToString(param.Type)
|
|
293
|
-
if len(param.Names) > 0 {
|
|
294
|
-
for _, paramName := range param.Names {
|
|
295
|
-
methodInfo.Parameters = append(methodInfo.Parameters, Parameter{
|
|
296
|
-
Name: paramName.Name,
|
|
297
|
-
Type: paramType,
|
|
298
|
-
Language: "go",
|
|
299
|
-
})
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// Extract return type
|
|
306
|
-
if funcType.Results != nil {
|
|
307
|
-
var returnTypes []string
|
|
308
|
-
for _, result := range funcType.Results.List {
|
|
309
|
-
returnTypes = append(returnTypes, p.typeToString(result.Type))
|
|
310
|
-
}
|
|
311
|
-
methodInfo.ReturnType = strings.Join(returnTypes, ", ")
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
interfaceInfo.Methods = append(interfaceInfo.Methods, methodInfo)
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// Build signature
|
|
322
|
-
interfaceInfo.Signature = fmt.Sprintf("type %s interface", interfaceInfo.Name)
|
|
323
|
-
|
|
324
|
-
return interfaceInfo
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// typeToString converts an AST type to string representation
|
|
328
|
-
func (p *Parser) typeToString(expr ast.Expr) string {
|
|
329
|
-
switch t := expr.(type) {
|
|
330
|
-
case *ast.Ident:
|
|
331
|
-
return t.Name
|
|
332
|
-
case *ast.SelectorExpr:
|
|
333
|
-
return p.typeToString(t.X) + "." + t.Sel.Name
|
|
334
|
-
case *ast.StarExpr:
|
|
335
|
-
return "*" + p.typeToString(t.X)
|
|
336
|
-
case *ast.ArrayType:
|
|
337
|
-
if t.Len == nil {
|
|
338
|
-
return "[]" + p.typeToString(t.Elt)
|
|
339
|
-
}
|
|
340
|
-
return "[...]" + p.typeToString(t.Elt)
|
|
341
|
-
case *ast.MapType:
|
|
342
|
-
return "map[" + p.typeToString(t.Key) + "]" + p.typeToString(t.Value)
|
|
343
|
-
case *ast.ChanType:
|
|
344
|
-
dir := ""
|
|
345
|
-
switch t.Dir {
|
|
346
|
-
case ast.SEND:
|
|
347
|
-
dir = "chan<- "
|
|
348
|
-
case ast.RECV:
|
|
349
|
-
dir = "<-chan "
|
|
350
|
-
default:
|
|
351
|
-
dir = "chan "
|
|
352
|
-
}
|
|
353
|
-
return dir + p.typeToString(t.Value)
|
|
354
|
-
case *ast.FuncType:
|
|
355
|
-
return "func" // Simplified for now
|
|
356
|
-
case *ast.InterfaceType:
|
|
357
|
-
return "interface{}"
|
|
358
|
-
case *ast.StructType:
|
|
359
|
-
return "struct{}"
|
|
360
|
-
default:
|
|
361
|
-
return "unknown"
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// buildFunctionSignature builds a function signature string
|
|
366
|
-
func (p *Parser) buildFunctionSignature(function Function) string {
|
|
367
|
-
var parts []string
|
|
368
|
-
|
|
369
|
-
// Add receiver for methods
|
|
370
|
-
if function.IsMethod && function.Receiver != "" {
|
|
371
|
-
parts = append(parts, fmt.Sprintf("func (%s)", function.Receiver))
|
|
372
|
-
} else {
|
|
373
|
-
parts = append(parts, "func")
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// Add function name
|
|
377
|
-
parts = append(parts, function.Name)
|
|
378
|
-
|
|
379
|
-
// Add parameters
|
|
380
|
-
var paramStrs []string
|
|
381
|
-
for _, param := range function.Parameters {
|
|
382
|
-
if param.Name != "" {
|
|
383
|
-
paramStrs = append(paramStrs, fmt.Sprintf("%s %s", param.Name, param.Type))
|
|
384
|
-
} else {
|
|
385
|
-
paramStrs = append(paramStrs, param.Type)
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
parts = append(parts, fmt.Sprintf("(%s)", strings.Join(paramStrs, ", ")))
|
|
389
|
-
|
|
390
|
-
// Add return type
|
|
391
|
-
if function.ReturnType != "" {
|
|
392
|
-
parts = append(parts, function.ReturnType)
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
return strings.Join(parts, " ")
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// buildMethodSignature builds a method signature string for interfaces
|
|
399
|
-
func (p *Parser) buildMethodSignature(name string, funcType *ast.FuncType) string {
|
|
400
|
-
var parts []string
|
|
401
|
-
parts = append(parts, name)
|
|
402
|
-
|
|
403
|
-
// Add parameters
|
|
404
|
-
var paramStrs []string
|
|
405
|
-
if funcType.Params != nil {
|
|
406
|
-
for _, param := range funcType.Params.List {
|
|
407
|
-
paramType := p.typeToString(param.Type)
|
|
408
|
-
if len(param.Names) > 0 {
|
|
409
|
-
for _, paramName := range param.Names {
|
|
410
|
-
paramStrs = append(paramStrs, fmt.Sprintf("%s %s", paramName.Name, paramType))
|
|
411
|
-
}
|
|
412
|
-
} else {
|
|
413
|
-
paramStrs = append(paramStrs, paramType)
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
parts = append(parts, fmt.Sprintf("(%s)", strings.Join(paramStrs, ", ")))
|
|
418
|
-
|
|
419
|
-
// Add return type
|
|
420
|
-
if funcType.Results != nil {
|
|
421
|
-
var returnTypes []string
|
|
422
|
-
for _, result := range funcType.Results.List {
|
|
423
|
-
returnTypes = append(returnTypes, p.typeToString(result.Type))
|
|
424
|
-
}
|
|
425
|
-
if len(returnTypes) > 0 {
|
|
426
|
-
parts = append(parts, strings.Join(returnTypes, ", "))
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
return strings.Join(parts, " ")
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
// extractPurposeFromComments extracts purpose from Go doc comments
|
|
434
|
-
func (p *Parser) extractPurposeFromComments(docText string) string {
|
|
435
|
-
lines := strings.Split(strings.TrimSpace(docText), "\n")
|
|
436
|
-
if len(lines) > 0 {
|
|
437
|
-
// Take the first line as purpose, removing comment markers
|
|
438
|
-
purpose := strings.TrimSpace(lines[0])
|
|
439
|
-
purpose = strings.TrimPrefix(purpose, "//")
|
|
440
|
-
purpose = strings.TrimSpace(purpose)
|
|
441
|
-
return purpose
|
|
442
|
-
}
|
|
443
|
-
return ""
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// calculateComplexity calculates basic cyclomatic complexity
|
|
447
|
-
func (p *Parser) calculateComplexity(funcDecl *ast.FuncDecl) int {
|
|
448
|
-
complexity := 1 // Base complexity
|
|
449
|
-
|
|
450
|
-
ast.Inspect(funcDecl, func(n ast.Node) bool {
|
|
451
|
-
switch n.(type) {
|
|
452
|
-
case *ast.IfStmt, *ast.ForStmt, *ast.RangeStmt, *ast.SwitchStmt, *ast.TypeSwitchStmt:
|
|
453
|
-
complexity++
|
|
454
|
-
case *ast.CaseClause:
|
|
455
|
-
complexity++
|
|
456
|
-
}
|
|
457
|
-
return true
|
|
458
|
-
})
|
|
459
|
-
|
|
460
|
-
return complexity
|
|
461
|
-
}
|