@grafema/core 0.1.0-alpha.5 → 0.1.1-alpha
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/README.md +0 -1
- package/dist/Orchestrator.d.ts +24 -2
- package/dist/Orchestrator.d.ts.map +1 -1
- package/dist/Orchestrator.js +197 -24
- package/dist/config/ConfigLoader.d.ts +72 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -0
- package/dist/config/ConfigLoader.js +187 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +4 -0
- package/dist/core/ASTWorker.d.ts +11 -36
- package/dist/core/ASTWorker.d.ts.map +1 -1
- package/dist/core/ASTWorker.js +93 -99
- package/dist/core/CoverageAnalyzer.d.ts +65 -0
- package/dist/core/CoverageAnalyzer.d.ts.map +1 -0
- package/dist/core/CoverageAnalyzer.js +198 -0
- package/dist/core/FileNodeManager.d.ts +40 -0
- package/dist/core/FileNodeManager.d.ts.map +1 -0
- package/dist/core/FileNodeManager.js +84 -0
- package/dist/core/GraphFreshnessChecker.d.ts +33 -0
- package/dist/core/GraphFreshnessChecker.d.ts.map +1 -0
- package/dist/core/GraphFreshnessChecker.js +101 -0
- package/dist/core/HashUtils.d.ts +24 -0
- package/dist/core/HashUtils.d.ts.map +1 -0
- package/dist/core/HashUtils.js +45 -0
- package/dist/core/IncrementalReanalyzer.d.ts +36 -0
- package/dist/core/IncrementalReanalyzer.d.ts.map +1 -0
- package/dist/core/IncrementalReanalyzer.js +132 -0
- package/dist/core/NodeFactory.d.ts +225 -17
- package/dist/core/NodeFactory.d.ts.map +1 -1
- package/dist/core/NodeFactory.js +208 -18
- package/dist/core/ScopeTracker.d.ts +84 -0
- package/dist/core/ScopeTracker.d.ts.map +1 -0
- package/dist/core/ScopeTracker.js +116 -0
- package/dist/core/SemanticId.d.ts +90 -0
- package/dist/core/SemanticId.d.ts.map +1 -0
- package/dist/core/SemanticId.js +115 -0
- package/dist/core/VersionManager.d.ts.map +1 -1
- package/dist/core/VersionManager.js +3 -2
- package/dist/core/nodes/ArgumentExpressionNode.d.ts +43 -0
- package/dist/core/nodes/ArgumentExpressionNode.d.ts.map +1 -0
- package/dist/core/nodes/ArgumentExpressionNode.js +60 -0
- package/dist/core/nodes/ArrayLiteralNode.d.ts +27 -0
- package/dist/core/nodes/ArrayLiteralNode.d.ts.map +1 -0
- package/dist/core/nodes/ArrayLiteralNode.js +41 -0
- package/dist/core/nodes/CallSiteNode.d.ts +28 -0
- package/dist/core/nodes/CallSiteNode.d.ts.map +1 -1
- package/dist/core/nodes/CallSiteNode.js +46 -0
- package/dist/core/nodes/ClassNode.d.ts +33 -1
- package/dist/core/nodes/ClassNode.d.ts.map +1 -1
- package/dist/core/nodes/ClassNode.js +46 -2
- package/dist/core/nodes/DecoratorNode.d.ts +42 -0
- package/dist/core/nodes/DecoratorNode.d.ts.map +1 -0
- package/dist/core/nodes/DecoratorNode.js +62 -0
- package/dist/core/nodes/EnumNode.d.ts +42 -0
- package/dist/core/nodes/EnumNode.d.ts.map +1 -0
- package/dist/core/nodes/EnumNode.js +54 -0
- package/dist/core/nodes/ExportNode.d.ts +37 -1
- package/dist/core/nodes/ExportNode.d.ts.map +1 -1
- package/dist/core/nodes/ExportNode.js +48 -2
- package/dist/core/nodes/ExpressionNode.d.ts +97 -0
- package/dist/core/nodes/ExpressionNode.d.ts.map +1 -0
- package/dist/core/nodes/ExpressionNode.js +178 -0
- package/dist/core/nodes/ExternalModuleNode.d.ts +28 -0
- package/dist/core/nodes/ExternalModuleNode.d.ts.map +1 -0
- package/dist/core/nodes/ExternalModuleNode.js +41 -0
- package/dist/core/nodes/ExternalStdioNode.d.ts +13 -6
- package/dist/core/nodes/ExternalStdioNode.d.ts.map +1 -1
- package/dist/core/nodes/ExternalStdioNode.js +15 -8
- package/dist/core/nodes/FunctionNode.d.ts +36 -0
- package/dist/core/nodes/FunctionNode.d.ts.map +1 -1
- package/dist/core/nodes/FunctionNode.js +80 -1
- package/dist/core/nodes/ImportNode.d.ts +19 -5
- package/dist/core/nodes/ImportNode.d.ts.map +1 -1
- package/dist/core/nodes/ImportNode.js +23 -5
- package/dist/core/nodes/InterfaceNode.d.ts +46 -0
- package/dist/core/nodes/InterfaceNode.d.ts.map +1 -0
- package/dist/core/nodes/InterfaceNode.js +55 -0
- package/dist/core/nodes/IssueNode.d.ts +73 -0
- package/dist/core/nodes/IssueNode.d.ts.map +1 -0
- package/dist/core/nodes/IssueNode.js +129 -0
- package/dist/core/nodes/MethodCallNode.d.ts +30 -0
- package/dist/core/nodes/MethodCallNode.d.ts.map +1 -1
- package/dist/core/nodes/MethodCallNode.js +49 -0
- package/dist/core/nodes/MethodNode.d.ts +32 -0
- package/dist/core/nodes/MethodNode.d.ts.map +1 -1
- package/dist/core/nodes/MethodNode.js +48 -0
- package/dist/core/nodes/ModuleNode.d.ts +31 -0
- package/dist/core/nodes/ModuleNode.d.ts.map +1 -1
- package/dist/core/nodes/ModuleNode.js +37 -0
- package/dist/core/nodes/NetworkRequestNode.d.ts +54 -0
- package/dist/core/nodes/NetworkRequestNode.d.ts.map +1 -0
- package/dist/core/nodes/NetworkRequestNode.js +65 -0
- package/dist/core/nodes/ObjectLiteralNode.d.ts +27 -0
- package/dist/core/nodes/ObjectLiteralNode.d.ts.map +1 -0
- package/dist/core/nodes/ObjectLiteralNode.js +41 -0
- package/dist/core/nodes/ScopeNode.d.ts +31 -0
- package/dist/core/nodes/ScopeNode.d.ts.map +1 -1
- package/dist/core/nodes/ScopeNode.js +49 -0
- package/dist/core/nodes/TypeNode.d.ts +36 -0
- package/dist/core/nodes/TypeNode.d.ts.map +1 -0
- package/dist/core/nodes/TypeNode.js +53 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts +27 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts.map +1 -1
- package/dist/core/nodes/VariableDeclarationNode.js +40 -0
- package/dist/core/nodes/index.d.ts +12 -1
- package/dist/core/nodes/index.d.ts.map +1 -1
- package/dist/core/nodes/index.js +14 -0
- package/dist/diagnostics/DiagnosticCollector.d.ts +98 -0
- package/dist/diagnostics/DiagnosticCollector.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticCollector.js +129 -0
- package/dist/diagnostics/DiagnosticReporter.d.ts +77 -0
- package/dist/diagnostics/DiagnosticReporter.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticReporter.js +159 -0
- package/dist/diagnostics/DiagnosticWriter.d.ts +31 -0
- package/dist/diagnostics/DiagnosticWriter.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticWriter.js +43 -0
- package/dist/diagnostics/index.d.ts +14 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/index.js +11 -0
- package/dist/errors/GrafemaError.d.ts +118 -0
- package/dist/errors/GrafemaError.d.ts.map +1 -0
- package/dist/errors/GrafemaError.js +131 -0
- package/dist/index.d.ts +57 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +54 -1
- package/dist/logging/Logger.d.ts +48 -0
- package/dist/logging/Logger.d.ts.map +1 -0
- package/dist/logging/Logger.js +134 -0
- package/dist/plugins/Plugin.d.ts +5 -1
- package/dist/plugins/Plugin.d.ts.map +1 -1
- package/dist/plugins/Plugin.js +33 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/DatabaseAnalyzer.js +13 -6
- package/dist/plugins/analysis/ExpressAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ExpressAnalyzer.js +27 -19
- package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ExpressRouteAnalyzer.js +21 -14
- package/dist/plugins/analysis/FetchAnalyzer.d.ts +1 -0
- package/dist/plugins/analysis/FetchAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/FetchAnalyzer.js +34 -14
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts +6 -3
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts.map +1 -1
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.js +76 -80
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts +180 -17
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/JSASTAnalyzer.js +1171 -471
- package/dist/plugins/analysis/ReactAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ReactAnalyzer.js +56 -57
- package/dist/plugins/analysis/RustAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/RustAnalyzer.js +15 -10
- package/dist/plugins/analysis/SQLiteAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SQLiteAnalyzer.js +9 -7
- package/dist/plugins/analysis/ServiceLayerAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ServiceLayerAnalyzer.js +21 -9
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SocketIOAnalyzer.js +27 -15
- package/dist/plugins/analysis/SystemDbAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SystemDbAnalyzer.js +15 -5
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts +34 -4
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/GraphBuilder.js +318 -298
- package/dist/plugins/analysis/ast/IdGenerator.d.ts +105 -0
- package/dist/plugins/analysis/ast/IdGenerator.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/IdGenerator.js +116 -0
- package/dist/plugins/analysis/ast/types.d.ts +176 -5
- package/dist/plugins/analysis/ast/types.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/utils/createParameterNodes.d.ts +33 -0
- package/dist/plugins/analysis/ast/utils/createParameterNodes.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/utils/createParameterNodes.js +89 -0
- package/dist/plugins/analysis/ast/utils/index.d.ts +6 -0
- package/dist/plugins/analysis/ast/utils/index.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/utils/index.js +5 -0
- package/dist/plugins/analysis/ast/utils/location.d.ts +87 -0
- package/dist/plugins/analysis/ast/utils/location.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/utils/location.js +78 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts +9 -4
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.js +6 -5
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts +99 -9
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.js +663 -125
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts +4 -1
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.js +72 -32
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts +4 -1
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.js +128 -63
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.js +11 -8
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts +12 -1
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.js +36 -14
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts +4 -1
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.js +17 -13
- package/dist/plugins/discovery/MonorepoServiceDiscovery.d.ts.map +1 -1
- package/dist/plugins/discovery/MonorepoServiceDiscovery.js +3 -2
- package/dist/plugins/discovery/SimpleProjectDiscovery.d.ts.map +1 -1
- package/dist/plugins/discovery/SimpleProjectDiscovery.js +5 -1
- package/dist/plugins/discovery/WorkspaceDiscovery.d.ts +22 -0
- package/dist/plugins/discovery/WorkspaceDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/WorkspaceDiscovery.js +136 -0
- package/dist/plugins/discovery/resolveSourceEntrypoint.d.ts +46 -0
- package/dist/plugins/discovery/resolveSourceEntrypoint.d.ts.map +1 -0
- package/dist/plugins/discovery/resolveSourceEntrypoint.js +86 -0
- package/dist/plugins/discovery/workspaces/detector.d.ts +21 -0
- package/dist/plugins/discovery/workspaces/detector.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/detector.js +49 -0
- package/dist/plugins/discovery/workspaces/globResolver.d.ts +35 -0
- package/dist/plugins/discovery/workspaces/globResolver.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/globResolver.js +184 -0
- package/dist/plugins/discovery/workspaces/index.d.ts +9 -0
- package/dist/plugins/discovery/workspaces/index.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/index.js +8 -0
- package/dist/plugins/discovery/workspaces/parsers.d.ts +38 -0
- package/dist/plugins/discovery/workspaces/parsers.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/parsers.js +80 -0
- package/dist/plugins/enrichment/AliasTracker.d.ts.map +1 -1
- package/dist/plugins/enrichment/AliasTracker.js +14 -8
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts.map +1 -1
- package/dist/plugins/enrichment/HTTPConnectionEnricher.js +14 -7
- package/dist/plugins/enrichment/ImportExportLinker.d.ts.map +1 -1
- package/dist/plugins/enrichment/ImportExportLinker.js +23 -6
- package/dist/plugins/enrichment/MethodCallResolver.d.ts.map +1 -1
- package/dist/plugins/enrichment/MethodCallResolver.js +18 -12
- package/dist/plugins/enrichment/MountPointResolver.d.ts.map +1 -1
- package/dist/plugins/enrichment/MountPointResolver.js +8 -3
- package/dist/plugins/enrichment/PrefixEvaluator.d.ts.map +1 -1
- package/dist/plugins/enrichment/PrefixEvaluator.js +16 -7
- package/dist/plugins/enrichment/RustFFIEnricher.d.ts.map +1 -1
- package/dist/plugins/enrichment/RustFFIEnricher.js +6 -5
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts +17 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts.map +1 -1
- package/dist/plugins/enrichment/ValueDomainAnalyzer.js +129 -10
- package/dist/plugins/indexing/IncrementalModuleIndexer.d.ts.map +1 -1
- package/dist/plugins/indexing/IncrementalModuleIndexer.js +23 -14
- package/dist/plugins/indexing/JSModuleIndexer.d.ts.map +1 -1
- package/dist/plugins/indexing/JSModuleIndexer.js +63 -31
- package/dist/plugins/indexing/RustModuleIndexer.d.ts.map +1 -1
- package/dist/plugins/indexing/RustModuleIndexer.js +5 -4
- package/dist/plugins/indexing/ServiceDetector.d.ts +10 -0
- package/dist/plugins/indexing/ServiceDetector.d.ts.map +1 -1
- package/dist/plugins/indexing/ServiceDetector.js +28 -15
- package/dist/plugins/validation/CallResolverValidator.d.ts.map +1 -1
- package/dist/plugins/validation/CallResolverValidator.js +8 -7
- package/dist/plugins/validation/DataFlowValidator.d.ts.map +1 -1
- package/dist/plugins/validation/DataFlowValidator.js +17 -12
- package/dist/plugins/validation/EvalBanValidator.d.ts.map +1 -1
- package/dist/plugins/validation/EvalBanValidator.js +17 -16
- package/dist/plugins/validation/GraphConnectivityValidator.d.ts.map +1 -1
- package/dist/plugins/validation/GraphConnectivityValidator.js +19 -23
- package/dist/plugins/validation/NodeCreationValidator.d.ts +85 -0
- package/dist/plugins/validation/NodeCreationValidator.d.ts.map +1 -0
- package/dist/plugins/validation/NodeCreationValidator.js +415 -0
- package/dist/plugins/validation/SQLInjectionValidator.d.ts.map +1 -1
- package/dist/plugins/validation/SQLInjectionValidator.js +59 -16
- package/dist/plugins/validation/ShadowingDetector.d.ts.map +1 -1
- package/dist/plugins/validation/ShadowingDetector.js +6 -5
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.d.ts.map +1 -1
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.js +12 -11
- package/dist/plugins/vcs/GitPlugin.d.ts.map +1 -1
- package/dist/plugins/vcs/GitPlugin.js +10 -12
- package/dist/plugins/vcs/VCSPlugin.d.ts +3 -2
- package/dist/plugins/vcs/VCSPlugin.d.ts.map +1 -1
- package/dist/plugins/vcs/VCSPlugin.js +5 -5
- package/dist/storage/backends/RFDBServerBackend.d.ts +10 -17
- package/dist/storage/backends/RFDBServerBackend.d.ts.map +1 -1
- package/dist/storage/backends/RFDBServerBackend.js +31 -10
- package/dist/validation/PathValidator.d.ts +1 -2
- package/dist/validation/PathValidator.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/Orchestrator.ts +237 -24
- package/src/config/ConfigLoader.ts +263 -0
- package/src/config/index.ts +5 -0
- package/src/core/ASTWorker.ts +143 -139
- package/src/core/CoverageAnalyzer.ts +243 -0
- package/src/core/FileNodeManager.ts +100 -0
- package/src/core/GraphFreshnessChecker.ts +143 -0
- package/src/core/HashUtils.ts +48 -0
- package/src/core/IncrementalReanalyzer.ts +192 -0
- package/src/core/NodeFactory.ts +401 -18
- package/src/core/ScopeTracker.ts +154 -0
- package/src/core/SemanticId.ts +192 -0
- package/src/core/VersionManager.ts +3 -2
- package/src/core/nodes/ArgumentExpressionNode.ts +89 -0
- package/src/core/nodes/ArrayLiteralNode.ts +65 -0
- package/src/core/nodes/CallSiteNode.ts +58 -0
- package/src/core/nodes/ClassNode.ts +63 -2
- package/src/core/nodes/DecoratorNode.ts +91 -0
- package/src/core/nodes/EnumNode.ts +86 -0
- package/src/core/nodes/ExportNode.ts +70 -2
- package/src/core/nodes/ExpressionNode.ts +231 -0
- package/src/core/nodes/ExternalModuleNode.ts +56 -0
- package/src/core/nodes/ExternalStdioNode.ts +17 -9
- package/src/core/nodes/FunctionNode.ts +101 -1
- package/src/core/nodes/ImportNode.ts +32 -10
- package/src/core/nodes/InterfaceNode.ts +91 -0
- package/src/core/nodes/IssueNode.ts +177 -0
- package/src/core/nodes/MethodCallNode.ts +64 -0
- package/src/core/nodes/MethodNode.ts +63 -0
- package/src/core/nodes/ModuleNode.ts +50 -0
- package/src/core/nodes/NetworkRequestNode.ts +77 -0
- package/src/core/nodes/ObjectLiteralNode.ts +65 -0
- package/src/core/nodes/ScopeNode.ts +65 -0
- package/src/core/nodes/TypeNode.ts +78 -0
- package/src/core/nodes/VariableDeclarationNode.ts +52 -0
- package/src/core/nodes/index.ts +18 -1
- package/src/diagnostics/DiagnosticCollector.ts +163 -0
- package/src/diagnostics/DiagnosticReporter.ts +204 -0
- package/src/diagnostics/DiagnosticWriter.ts +50 -0
- package/src/diagnostics/index.ts +16 -0
- package/src/errors/GrafemaError.ts +174 -0
- package/src/index.ts +148 -1
- package/src/logging/Logger.ts +152 -0
- package/src/plugins/Plugin.ts +42 -0
- package/src/plugins/analysis/DatabaseAnalyzer.ts +14 -8
- package/src/plugins/analysis/ExpressAnalyzer.ts +29 -19
- package/src/plugins/analysis/ExpressRouteAnalyzer.ts +22 -21
- package/src/plugins/analysis/FetchAnalyzer.ts +39 -16
- package/src/plugins/analysis/IncrementalAnalysisPlugin.ts +84 -101
- package/src/plugins/analysis/JSASTAnalyzer.ts +1483 -503
- package/src/plugins/analysis/ReactAnalyzer.ts +57 -57
- package/src/plugins/analysis/RustAnalyzer.ts +15 -10
- package/src/plugins/analysis/SQLiteAnalyzer.ts +10 -7
- package/src/plugins/analysis/ServiceLayerAnalyzer.ts +22 -16
- package/src/plugins/analysis/SocketIOAnalyzer.ts +31 -22
- package/src/plugins/analysis/SystemDbAnalyzer.ts +16 -11
- package/src/plugins/analysis/ast/GraphBuilder.ts +439 -327
- package/src/plugins/analysis/ast/IdGenerator.ts +177 -0
- package/src/plugins/analysis/ast/types.ts +209 -6
- package/src/plugins/analysis/ast/utils/createParameterNodes.ts +104 -0
- package/src/plugins/analysis/ast/utils/index.ts +12 -0
- package/src/plugins/analysis/ast/utils/location.ts +103 -0
- package/src/plugins/analysis/ast/visitors/ASTVisitor.ts +11 -8
- package/src/plugins/analysis/ast/visitors/CallExpressionVisitor.ts +909 -83
- package/src/plugins/analysis/ast/visitors/ClassVisitor.ts +97 -44
- package/src/plugins/analysis/ast/visitors/FunctionVisitor.ts +159 -93
- package/src/plugins/analysis/ast/visitors/ImportExportVisitor.ts +12 -8
- package/src/plugins/analysis/ast/visitors/TypeScriptVisitor.ts +41 -14
- package/src/plugins/analysis/ast/visitors/VariableVisitor.ts +37 -17
- package/src/plugins/discovery/MonorepoServiceDiscovery.ts +3 -2
- package/src/plugins/discovery/SimpleProjectDiscovery.ts +6 -1
- package/src/plugins/discovery/WorkspaceDiscovery.ts +177 -0
- package/src/plugins/discovery/resolveSourceEntrypoint.ts +103 -0
- package/src/plugins/discovery/workspaces/detector.ts +63 -0
- package/src/plugins/discovery/workspaces/globResolver.ts +229 -0
- package/src/plugins/discovery/workspaces/index.ts +23 -0
- package/src/plugins/discovery/workspaces/parsers.ts +99 -0
- package/src/plugins/enrichment/AliasTracker.ts +14 -8
- package/src/plugins/enrichment/HTTPConnectionEnricher.ts +14 -7
- package/src/plugins/enrichment/ImportExportLinker.ts +24 -6
- package/src/plugins/enrichment/MethodCallResolver.ts +18 -12
- package/src/plugins/enrichment/MountPointResolver.ts +8 -3
- package/src/plugins/enrichment/PrefixEvaluator.ts +16 -7
- package/src/plugins/enrichment/RustFFIEnricher.ts +6 -5
- package/src/plugins/enrichment/ValueDomainAnalyzer.ts +149 -12
- package/src/plugins/indexing/IncrementalModuleIndexer.ts +23 -14
- package/src/plugins/indexing/JSModuleIndexer.ts +74 -34
- package/src/plugins/indexing/RustModuleIndexer.ts +5 -4
- package/src/plugins/validation/CallResolverValidator.ts +8 -7
- package/src/plugins/validation/DataFlowValidator.ts +16 -12
- package/src/plugins/validation/EvalBanValidator.ts +17 -16
- package/src/plugins/validation/GraphConnectivityValidator.ts +19 -23
- package/src/plugins/validation/NodeCreationValidator.ts +554 -0
- package/src/plugins/validation/SQLInjectionValidator.ts +61 -15
- package/src/plugins/validation/ShadowingDetector.ts +6 -5
- package/src/plugins/validation/TypeScriptDeadCodeValidator.ts +12 -11
- package/src/plugins/vcs/GitPlugin.ts +40 -12
- package/src/plugins/vcs/VCSPlugin.ts +7 -5
- package/src/storage/backends/RFDBServerBackend.ts +43 -29
- package/src/validation/PathValidator.ts +1 -1
- package/dist/core/AnalysisWorker.d.ts +0 -14
- package/dist/core/AnalysisWorker.d.ts.map +0 -1
- package/dist/core/AnalysisWorker.js +0 -307
- package/dist/core/ParallelAnalyzer.d.ts +0 -120
- package/dist/core/ParallelAnalyzer.d.ts.map +0 -1
- package/dist/core/ParallelAnalyzer.js +0 -331
- package/dist/core/QueueWorker.d.ts +0 -12
- package/dist/core/QueueWorker.d.ts.map +0 -1
- package/dist/core/QueueWorker.js +0 -567
- package/dist/core/RFDBClient.d.ts +0 -179
- package/dist/core/RFDBClient.d.ts.map +0 -1
- package/dist/core/RFDBClient.js +0 -429
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts +0 -19
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts.map +0 -1
- package/dist/plugins/discovery/ZonServiceDiscovery.js +0 -204
- package/src/core/AnalysisWorker.ts +0 -410
- package/src/core/ParallelAnalyzer.ts +0 -476
- package/src/core/QueueWorker.ts +0 -780
- package/src/plugins/indexing/ServiceDetector.ts +0 -230
|
@@ -11,6 +11,7 @@ import { readFileSync } from 'fs';
|
|
|
11
11
|
import { parse } from '@babel/parser';
|
|
12
12
|
import traverseModule from '@babel/traverse';
|
|
13
13
|
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
14
|
+
import { getLine } from './ast/utils/location.js';
|
|
14
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
16
|
const traverse = traverseModule.default || traverseModule;
|
|
16
17
|
const HTTP_METHODS = ['get', 'post', 'put', 'patch', 'delete', 'options', 'head'];
|
|
@@ -28,11 +29,12 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
async execute(context) {
|
|
32
|
+
const logger = this.log(context);
|
|
31
33
|
try {
|
|
32
34
|
const { graph } = context;
|
|
33
35
|
// Получаем все MODULE ноды
|
|
34
36
|
const modules = await this.getModules(graph);
|
|
35
|
-
|
|
37
|
+
logger.info('Processing modules', { count: modules.length });
|
|
36
38
|
let endpointsCreated = 0;
|
|
37
39
|
let middlewareCreated = 0;
|
|
38
40
|
let edgesCreated = 0;
|
|
@@ -48,17 +50,22 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
48
50
|
if ((i + 1) % 20 === 0 || i === modules.length - 1) {
|
|
49
51
|
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
50
52
|
const avgTime = ((Date.now() - startTime) / (i + 1)).toFixed(0);
|
|
51
|
-
|
|
53
|
+
logger.debug('Progress', {
|
|
54
|
+
current: i + 1,
|
|
55
|
+
total: modules.length,
|
|
56
|
+
elapsed: `${elapsed}s`,
|
|
57
|
+
avgTime: `${avgTime}ms/module`
|
|
58
|
+
});
|
|
52
59
|
}
|
|
53
60
|
}
|
|
54
|
-
|
|
61
|
+
logger.info('Analysis complete', { endpointsCreated, middlewareCreated });
|
|
55
62
|
return createSuccessResult({
|
|
56
63
|
nodes: endpointsCreated + middlewareCreated,
|
|
57
64
|
edges: edgesCreated
|
|
58
65
|
}, { modulesAnalyzed: modules.length });
|
|
59
66
|
}
|
|
60
67
|
catch (error) {
|
|
61
|
-
|
|
68
|
+
logger.error('Analysis failed', { error });
|
|
62
69
|
return createErrorResult(error);
|
|
63
70
|
}
|
|
64
71
|
}
|
|
@@ -136,18 +143,18 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
136
143
|
// Все предыдущие - middleware
|
|
137
144
|
const middlewareHandlers = handlers.slice(0, -1);
|
|
138
145
|
// Создаём http:route
|
|
139
|
-
const endpointId = `http:route#${method.toUpperCase()}:${routePath}#${module.file}#${node
|
|
146
|
+
const endpointId = `http:route#${method.toUpperCase()}:${routePath}#${module.file}#${getLine(node)}`;
|
|
140
147
|
endpoints.push({
|
|
141
148
|
id: endpointId,
|
|
142
149
|
type: 'http:route',
|
|
143
150
|
method: method.toUpperCase(),
|
|
144
151
|
path: routePath,
|
|
145
152
|
file: module.file,
|
|
146
|
-
line: node
|
|
153
|
+
line: getLine(node),
|
|
147
154
|
routerName: objectName,
|
|
148
155
|
handlerLine: mainHandler.loc
|
|
149
|
-
? mainHandler
|
|
150
|
-
: node
|
|
156
|
+
? getLine(mainHandler)
|
|
157
|
+
: getLine(node)
|
|
151
158
|
});
|
|
152
159
|
// Обрабатываем middleware
|
|
153
160
|
middlewareHandlers.forEach((mw, index) => {
|
|
@@ -164,16 +171,16 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
164
171
|
}
|
|
165
172
|
else if (mwNode.type === 'ArrowFunctionExpression' ||
|
|
166
173
|
mwNode.type === 'FunctionExpression') {
|
|
167
|
-
middlewareName = `inline:${mwNode
|
|
174
|
+
middlewareName = `inline:${getLine(mwNode)}`;
|
|
168
175
|
}
|
|
169
176
|
if (middlewareName) {
|
|
170
|
-
const middlewareId = `express:middleware#${middlewareName}#${module.file}#${mwNode
|
|
177
|
+
const middlewareId = `express:middleware#${middlewareName}#${module.file}#${getLine(mwNode)}`;
|
|
171
178
|
middlewares.push({
|
|
172
179
|
id: middlewareId,
|
|
173
180
|
type: 'express:middleware',
|
|
174
181
|
name: middlewareName,
|
|
175
182
|
file: module.file,
|
|
176
|
-
line: mwNode.loc ? mwNode
|
|
183
|
+
line: mwNode.loc ? getLine(mwNode) : getLine(node),
|
|
177
184
|
endpointId: endpointId,
|
|
178
185
|
order: index // Порядок в цепочке
|
|
179
186
|
});
|
|
@@ -204,13 +211,13 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
204
211
|
middlewareName = middlewareArg.callee.name;
|
|
205
212
|
}
|
|
206
213
|
if (middlewareName) {
|
|
207
|
-
const middlewareId = `express:middleware#${middlewareName}#${module.file}#${node
|
|
214
|
+
const middlewareId = `express:middleware#${middlewareName}#${module.file}#${getLine(node)}`;
|
|
208
215
|
middlewares.push({
|
|
209
216
|
id: middlewareId,
|
|
210
217
|
type: 'express:middleware',
|
|
211
218
|
name: middlewareName,
|
|
212
219
|
file: module.file,
|
|
213
|
-
line: node
|
|
220
|
+
line: getLine(node),
|
|
214
221
|
mountPath: mountPath,
|
|
215
222
|
isGlobal: mountPath === '/' // Global middleware если нет path
|
|
216
223
|
});
|
|
@@ -297,7 +304,7 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
297
304
|
}
|
|
298
305
|
}
|
|
299
306
|
catch (error) {
|
|
300
|
-
|
|
307
|
+
// Silent - per-module errors shouldn't spam logs
|
|
301
308
|
}
|
|
302
309
|
return {
|
|
303
310
|
endpoints: endpointsCreated,
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { Plugin } from '../Plugin.js';
|
|
12
12
|
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
13
13
|
export declare class FetchAnalyzer extends Plugin {
|
|
14
|
+
private networkNodeCreated;
|
|
14
15
|
get metadata(): PluginMetadata;
|
|
15
16
|
execute(context: PluginContext): Promise<PluginResult>;
|
|
16
17
|
private analyzeModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/plugins/analysis/FetchAnalyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,EAAE,MAAM,EAA0C,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"FetchAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/plugins/analysis/FetchAnalyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,EAAE,MAAM,EAA0C,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA8BhF,qBAAa,aAAc,SAAQ,MAAM;IACvC,OAAO,CAAC,kBAAkB,CAAS;IAEnC,IAAI,QAAQ,IAAI,cAAc,CAW7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;YAyD9C,aAAa;IAyP3B;;OAEG;IACH,OAAO,CAAC,UAAU;IA8BlB;;OAEG;IACH,OAAO,CAAC,aAAa;IAoBrB;;OAEG;IACH,OAAO,CAAC,aAAa;IAUrB;;OAEG;IACH,OAAO,CAAC,aAAa;IASrB;;OAEG;IACH,OAAO,CAAC,aAAa;CAUtB"}
|
|
@@ -12,9 +12,12 @@ import { readFileSync } from 'fs';
|
|
|
12
12
|
import { parse } from '@babel/parser';
|
|
13
13
|
import traverseModule from '@babel/traverse';
|
|
14
14
|
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
15
|
+
import { NetworkRequestNode } from '../../core/nodes/NetworkRequestNode.js';
|
|
16
|
+
import { getLine } from './ast/utils/location.js';
|
|
15
17
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
18
|
const traverse = traverseModule.default || traverseModule;
|
|
17
19
|
export class FetchAnalyzer extends Plugin {
|
|
20
|
+
networkNodeCreated = false;
|
|
18
21
|
get metadata() {
|
|
19
22
|
return {
|
|
20
23
|
name: 'FetchAnalyzer',
|
|
@@ -28,41 +31,52 @@ export class FetchAnalyzer extends Plugin {
|
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
async execute(context) {
|
|
34
|
+
const logger = this.log(context);
|
|
31
35
|
try {
|
|
32
36
|
const { graph } = context;
|
|
37
|
+
// Create net:request singleton (GraphBackend handles deduplication)
|
|
38
|
+
const networkNode = NetworkRequestNode.create();
|
|
39
|
+
await graph.addNode(networkNode);
|
|
40
|
+
this.networkNodeCreated = true;
|
|
33
41
|
// Получаем все модули
|
|
34
42
|
const modules = await this.getModules(graph);
|
|
35
|
-
|
|
43
|
+
logger.info('Processing modules', { count: modules.length });
|
|
36
44
|
let requestsCount = 0;
|
|
37
45
|
let apisCount = 0;
|
|
38
46
|
const startTime = Date.now();
|
|
39
47
|
for (let i = 0; i < modules.length; i++) {
|
|
40
48
|
const module = modules[i];
|
|
41
|
-
const result = await this.analyzeModule(module, graph);
|
|
49
|
+
const result = await this.analyzeModule(module, graph, networkNode.id);
|
|
42
50
|
requestsCount += result.requests;
|
|
43
51
|
apisCount += result.apis;
|
|
44
52
|
// Progress every 20 modules
|
|
45
53
|
if ((i + 1) % 20 === 0 || i === modules.length - 1) {
|
|
46
54
|
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
47
55
|
const avgTime = ((Date.now() - startTime) / (i + 1)).toFixed(0);
|
|
48
|
-
|
|
56
|
+
logger.debug('Progress', {
|
|
57
|
+
current: i + 1,
|
|
58
|
+
total: modules.length,
|
|
59
|
+
elapsed: `${elapsed}s`,
|
|
60
|
+
avgTime: `${avgTime}ms/module`
|
|
61
|
+
});
|
|
49
62
|
}
|
|
50
63
|
}
|
|
51
|
-
|
|
64
|
+
logger.info('Analysis complete', { requestsCount, apisCount });
|
|
52
65
|
return createSuccessResult({
|
|
53
|
-
nodes: requestsCount + apisCount,
|
|
54
|
-
edges:
|
|
66
|
+
nodes: requestsCount + apisCount + (this.networkNodeCreated ? 1 : 0),
|
|
67
|
+
edges: requestsCount // CALLS edges from http:request to net:request
|
|
55
68
|
}, {
|
|
56
69
|
requestsCount,
|
|
57
|
-
apisCount
|
|
70
|
+
apisCount,
|
|
71
|
+
networkSingletonCreated: this.networkNodeCreated
|
|
58
72
|
});
|
|
59
73
|
}
|
|
60
74
|
catch (error) {
|
|
61
|
-
|
|
75
|
+
logger.error('Analysis failed', { error });
|
|
62
76
|
return createErrorResult(error);
|
|
63
77
|
}
|
|
64
78
|
}
|
|
65
|
-
async analyzeModule(module, graph) {
|
|
79
|
+
async analyzeModule(module, graph, networkId) {
|
|
66
80
|
try {
|
|
67
81
|
const code = readFileSync(module.file, 'utf-8');
|
|
68
82
|
const ast = parse(code, {
|
|
@@ -90,7 +104,7 @@ export class FetchAnalyzer extends Plugin {
|
|
|
90
104
|
const urlArg = node.arguments[0];
|
|
91
105
|
const url = this.extractURL(urlArg);
|
|
92
106
|
const method = this.extractMethod(node.arguments[1]) || 'GET';
|
|
93
|
-
const line = node
|
|
107
|
+
const line = getLine(node);
|
|
94
108
|
const request = {
|
|
95
109
|
id: `http:request#${method}:${url}#${module.file}#${line}`,
|
|
96
110
|
type: 'http:request',
|
|
@@ -115,7 +129,7 @@ export class FetchAnalyzer extends Plugin {
|
|
|
115
129
|
const method = callee.property.name.toUpperCase();
|
|
116
130
|
const urlArg = node.arguments[0];
|
|
117
131
|
const url = this.extractURL(urlArg);
|
|
118
|
-
const line = node
|
|
132
|
+
const line = getLine(node);
|
|
119
133
|
const request = {
|
|
120
134
|
id: `http:request#${method}:${url}#${module.file}#${line}`,
|
|
121
135
|
type: 'http:request',
|
|
@@ -148,7 +162,7 @@ export class FetchAnalyzer extends Plugin {
|
|
|
148
162
|
const method = methodProp
|
|
149
163
|
? this.extractString(methodProp.value) || 'GET'
|
|
150
164
|
: 'GET';
|
|
151
|
-
const line = node
|
|
165
|
+
const line = getLine(node);
|
|
152
166
|
const request = {
|
|
153
167
|
id: `http:request#${method.toUpperCase()}:${url}#${module.file}#${line}`,
|
|
154
168
|
type: 'http:request',
|
|
@@ -174,7 +188,7 @@ export class FetchAnalyzer extends Plugin {
|
|
|
174
188
|
const urlArg = node.arguments[0];
|
|
175
189
|
const url = this.extractURL(urlArg);
|
|
176
190
|
const method = this.extractMethod(node.arguments[1]) || 'GET';
|
|
177
|
-
const line = node
|
|
191
|
+
const line = getLine(node);
|
|
178
192
|
const request = {
|
|
179
193
|
id: `http:request#${method}:${url}#${module.file}#${line}`,
|
|
180
194
|
type: 'http:request',
|
|
@@ -202,6 +216,12 @@ export class FetchAnalyzer extends Plugin {
|
|
|
202
216
|
src: module.id,
|
|
203
217
|
dst: request.id
|
|
204
218
|
});
|
|
219
|
+
// http:request --CALLS--> net:request singleton
|
|
220
|
+
await graph.addEdge({
|
|
221
|
+
type: 'CALLS',
|
|
222
|
+
src: request.id,
|
|
223
|
+
dst: networkId
|
|
224
|
+
});
|
|
205
225
|
// Ищем FUNCTION node которая делает запрос
|
|
206
226
|
const functions = [];
|
|
207
227
|
for await (const fn of graph.queryNodes({ type: 'FUNCTION' })) {
|
|
@@ -254,7 +274,7 @@ export class FetchAnalyzer extends Plugin {
|
|
|
254
274
|
};
|
|
255
275
|
}
|
|
256
276
|
catch (error) {
|
|
257
|
-
|
|
277
|
+
// Silent - per-module errors shouldn't spam logs
|
|
258
278
|
return { requests: 0, apis: 0 };
|
|
259
279
|
}
|
|
260
280
|
}
|
|
@@ -26,11 +26,11 @@ export declare class IncrementalAnalysisPlugin extends Plugin {
|
|
|
26
26
|
initialize(context: PluginContext): Promise<void>;
|
|
27
27
|
execute(context: PluginContext): Promise<PluginResult>;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Process a single changed file
|
|
30
30
|
*/
|
|
31
31
|
private processChangedFile;
|
|
32
32
|
/**
|
|
33
|
-
* Fine-grained merge -
|
|
33
|
+
* Fine-grained merge - key function for incremental analysis
|
|
34
34
|
*/
|
|
35
35
|
private finegrainedMerge;
|
|
36
36
|
/**
|
|
@@ -42,7 +42,7 @@ export declare class IncrementalAnalysisPlugin extends Plugin {
|
|
|
42
42
|
*/
|
|
43
43
|
private isExported;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Reanalyze nodes to create CALLS/USES edges
|
|
46
46
|
*/
|
|
47
47
|
private reanalyzeNodes;
|
|
48
48
|
/**
|
|
@@ -55,6 +55,9 @@ export declare class IncrementalAnalysisPlugin extends Plugin {
|
|
|
55
55
|
private traverseFunctionBody;
|
|
56
56
|
/**
|
|
57
57
|
* Найти callee и создать CALLS edge
|
|
58
|
+
* TODO: Implement using existing graph.queryNodes() method
|
|
59
|
+
* This method was disabled as part of stableId removal (REG-140).
|
|
60
|
+
* The getNodesByStableId method never existed on GraphBackend.
|
|
58
61
|
*/
|
|
59
62
|
private findCalleeAndCreateEdge;
|
|
60
63
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IncrementalAnalysisPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/analysis/IncrementalAnalysisPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAA0C,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"IncrementalAnalysisPlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/analysis/IncrementalAnalysisPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAA0C,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAkDhF,qBAAa,yBAA0B,SAAQ,MAAM;IACnD,OAAO,CAAC,SAAS,CAA0B;IAE3C,IAAI,QAAQ,IAAI,cAAc,CAW7B;IAEK,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAejD,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAuF5D;;OAEG;YACW,kBAAkB;IAkChC;;OAEG;YACW,gBAAgB;IAuF9B;;OAEG;YACW,oBAAoB;IAiIlC;;OAEG;IACH,OAAO,CAAC,UAAU;IAmClB;;OAEG;YACW,cAAc;IAuC5B;;OAEG;YACW,oBAAoB;IA0ClC;;OAEG;YACW,oBAAoB;IA6DlC;;;;;OAKG;YAEW,uBAAuB;IAUrC;;OAEG;YAEW,mBAAmB;CASlC"}
|
|
@@ -41,125 +41,140 @@ export class IncrementalAnalysisPlugin extends Plugin {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
async initialize(context) {
|
|
44
|
-
|
|
44
|
+
const logger = this.log(context);
|
|
45
|
+
// Initialize VCS plugin
|
|
45
46
|
const manifest = context.manifest;
|
|
46
47
|
this.vcsPlugin = await VCSPluginFactory.detect({
|
|
47
48
|
rootPath: manifest?.projectPath
|
|
48
|
-
});
|
|
49
|
+
}, logger);
|
|
49
50
|
if (!this.vcsPlugin) {
|
|
50
|
-
|
|
51
|
+
logger.warn('No VCS detected, skipping incremental analysis');
|
|
51
52
|
}
|
|
52
53
|
else {
|
|
53
|
-
|
|
54
|
+
logger.info('VCS detected', { vcs: this.vcsPlugin.metadata.name });
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
async execute(context) {
|
|
58
|
+
const logger = this.log(context);
|
|
57
59
|
try {
|
|
58
60
|
const { graph } = context;
|
|
59
61
|
const manifest = context.manifest;
|
|
60
62
|
const projectPath = manifest?.projectPath ?? '';
|
|
61
|
-
//
|
|
63
|
+
// Skip if no VCS detected
|
|
62
64
|
if (!this.vcsPlugin) {
|
|
63
65
|
return createSuccessResult({ nodes: 0, edges: 0 }, {
|
|
64
66
|
skipped: true,
|
|
65
67
|
reason: 'No VCS detected'
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
|
-
//
|
|
70
|
+
// Check for uncommitted changes
|
|
69
71
|
const hasChanges = await this.vcsPlugin.hasUncommittedChanges();
|
|
70
72
|
if (!hasChanges) {
|
|
71
|
-
|
|
73
|
+
logger.info('No uncommitted changes detected');
|
|
72
74
|
return createSuccessResult({ nodes: 0, edges: 0 }, {
|
|
73
75
|
skipped: true,
|
|
74
76
|
reason: 'No uncommitted changes'
|
|
75
77
|
});
|
|
76
78
|
}
|
|
77
|
-
//
|
|
79
|
+
// Get list of changed files
|
|
78
80
|
const changedFiles = (await this.vcsPlugin.getChangedFiles());
|
|
79
|
-
|
|
81
|
+
logger.debug('Changed files detected', { count: changedFiles.length, files: changedFiles.map(f => f.path) });
|
|
80
82
|
const jsFiles = changedFiles.filter(file => file.path.endsWith('.js') || file.path.endsWith('.mjs') || file.path.endsWith('.cjs'));
|
|
81
83
|
if (jsFiles.length === 0) {
|
|
82
|
-
|
|
84
|
+
logger.info('No JavaScript files changed');
|
|
83
85
|
return createSuccessResult({ nodes: 0, edges: 0 }, {
|
|
84
86
|
skipped: true,
|
|
85
87
|
reason: 'No JS files changed'
|
|
86
88
|
});
|
|
87
89
|
}
|
|
88
|
-
|
|
90
|
+
logger.info('Processing changed JS files', { count: jsFiles.length });
|
|
91
|
+
for (const f of jsFiles) {
|
|
92
|
+
logger.debug('Changed file', { path: f.path, status: f.status });
|
|
93
|
+
}
|
|
89
94
|
let totalNodesCreated = 0;
|
|
90
95
|
let totalEdgesCreated = 0;
|
|
91
|
-
//
|
|
96
|
+
// Process each changed file
|
|
92
97
|
for (const fileInfo of jsFiles) {
|
|
93
|
-
const result = await this.processChangedFile(fileInfo, projectPath, graph);
|
|
98
|
+
const result = await this.processChangedFile(fileInfo, projectPath, graph, logger);
|
|
94
99
|
totalNodesCreated += result.nodesCreated;
|
|
95
100
|
totalEdgesCreated += result.edgesCreated;
|
|
96
101
|
}
|
|
97
|
-
|
|
102
|
+
logger.info('Incremental analysis complete', { nodesCreated: totalNodesCreated, edgesCreated: totalEdgesCreated });
|
|
98
103
|
return createSuccessResult({ nodes: totalNodesCreated, edges: totalEdgesCreated }, {
|
|
99
104
|
filesProcessed: jsFiles.length,
|
|
100
105
|
changedFiles: jsFiles.map(f => ({ path: f.path, status: f.status }))
|
|
101
106
|
});
|
|
102
107
|
}
|
|
103
108
|
catch (error) {
|
|
104
|
-
|
|
109
|
+
logger.error('Incremental analysis failed', { error: error instanceof Error ? error.message : String(error) });
|
|
105
110
|
return createErrorResult(error);
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
/**
|
|
109
|
-
*
|
|
114
|
+
* Process a single changed file
|
|
110
115
|
*/
|
|
111
|
-
async processChangedFile(fileInfo, projectPath, graph) {
|
|
116
|
+
async processChangedFile(fileInfo, projectPath, graph, logger) {
|
|
112
117
|
const { path: relativePath, status } = fileInfo;
|
|
113
|
-
// relativePath
|
|
118
|
+
// relativePath can start with / or be relative
|
|
114
119
|
const fullPath = relativePath.startsWith('/') ? relativePath : `${projectPath}/${relativePath}`;
|
|
115
|
-
|
|
116
|
-
//
|
|
120
|
+
logger.debug('Processing file', { path: relativePath, status });
|
|
121
|
+
// If file is deleted - do nothing (main version remains, no __local)
|
|
117
122
|
if (status === 'deleted') {
|
|
118
|
-
|
|
123
|
+
logger.debug('File deleted, keeping main version only');
|
|
119
124
|
return { nodesCreated: 0, edgesCreated: 0 };
|
|
120
125
|
}
|
|
121
|
-
//
|
|
122
|
-
const result = await this.finegrainedMerge(fullPath, graph);
|
|
123
|
-
|
|
126
|
+
// Execute fine-grained merge
|
|
127
|
+
const result = await this.finegrainedMerge(fullPath, graph, logger);
|
|
128
|
+
logger.debug('Merge result', {
|
|
129
|
+
added: result.added,
|
|
130
|
+
modified: result.modified,
|
|
131
|
+
unchanged: result.unchanged,
|
|
132
|
+
deleted: result.deleted
|
|
133
|
+
});
|
|
124
134
|
return {
|
|
125
135
|
nodesCreated: result.added + result.modified,
|
|
126
136
|
edgesCreated: result.edgesCreated || 0
|
|
127
137
|
};
|
|
128
138
|
}
|
|
129
139
|
/**
|
|
130
|
-
* Fine-grained merge -
|
|
140
|
+
* Fine-grained merge - key function for incremental analysis
|
|
131
141
|
*/
|
|
132
|
-
async finegrainedMerge(filePath, graph) {
|
|
133
|
-
// 1.
|
|
142
|
+
async finegrainedMerge(filePath, graph, logger) {
|
|
143
|
+
// 1. Parse new file content
|
|
134
144
|
const newContent = await readFile(filePath, 'utf-8');
|
|
135
145
|
const newNodes = await this.extractTopLevelNodes(newContent, filePath);
|
|
136
|
-
|
|
137
|
-
// 2.
|
|
146
|
+
logger.debug('Parsed new content', { nodesCount: newNodes.length });
|
|
147
|
+
// 2. Get existing main nodes for this file
|
|
138
148
|
const mainNodes = await graph.getNodesByVersion('main', {
|
|
139
149
|
file: filePath
|
|
140
150
|
});
|
|
141
151
|
const mainTopLevel = mainNodes.filter(node => ['FUNCTION', 'CLASS', 'VARIABLE_DECLARATION', 'MODULE'].includes(node.type));
|
|
142
|
-
|
|
143
|
-
// 3.
|
|
152
|
+
logger.debug('Existing main nodes', { count: mainTopLevel.length });
|
|
153
|
+
// 3. Classify changes
|
|
144
154
|
const changes = versionManager.classifyChanges(mainTopLevel, newNodes);
|
|
145
|
-
|
|
146
|
-
|
|
155
|
+
logger.debug('Change classification', {
|
|
156
|
+
added: changes.added.length,
|
|
157
|
+
modified: changes.modified.length,
|
|
158
|
+
unchanged: changes.unchanged.length,
|
|
159
|
+
deleted: changes.deleted.length
|
|
160
|
+
});
|
|
161
|
+
// 4. Create __local versions for added/modified nodes
|
|
147
162
|
let edgesCreated = 0;
|
|
148
|
-
// 4a. ADDED nodes -
|
|
163
|
+
// 4a. ADDED nodes - create with __local version
|
|
149
164
|
for (const node of changes.added) {
|
|
150
165
|
const enrichedNode = versionManager.enrichNodeWithVersion(node, '__local');
|
|
151
166
|
await graph.addNode(enrichedNode);
|
|
152
167
|
}
|
|
153
|
-
// 4b. MODIFIED nodes -
|
|
168
|
+
// 4b. MODIFIED nodes - create __local version + REPLACES edge
|
|
154
169
|
for (const { old: oldNode, new: newNode } of changes.modified) {
|
|
155
170
|
const mainNodeId = versionManager.generateVersionedId(oldNode, 'main');
|
|
156
171
|
const enrichedNode = versionManager.enrichNodeWithVersion(newNode, '__local', {
|
|
157
172
|
replacesId: mainNodeId
|
|
158
173
|
});
|
|
159
174
|
await graph.addNode(enrichedNode);
|
|
160
|
-
//
|
|
175
|
+
// Create REPLACES edge
|
|
161
176
|
const replacesEdge = versionManager.createReplacesEdge(enrichedNode.id, mainNodeId);
|
|
162
|
-
|
|
177
|
+
logger.debug('Node replacement', { name: newNode.name, from: enrichedNode.id, to: mainNodeId });
|
|
163
178
|
await graph.addEdge({
|
|
164
179
|
type: replacesEdge.type,
|
|
165
180
|
src: replacesEdge.fromId,
|
|
@@ -167,12 +182,12 @@ export class IncrementalAnalysisPlugin extends Plugin {
|
|
|
167
182
|
});
|
|
168
183
|
edgesCreated++;
|
|
169
184
|
}
|
|
170
|
-
// 4c. UNCHANGED nodes -
|
|
171
|
-
// 4d. DELETED nodes -
|
|
172
|
-
// 5.
|
|
185
|
+
// 4c. UNCHANGED nodes - no __local version (main is used)
|
|
186
|
+
// 4d. DELETED nodes - no __local version (main remains, showing what was deleted)
|
|
187
|
+
// 5. Reanalyze changed nodes to create relationships (CALLS, USES)
|
|
173
188
|
const nodesToReanalyze = [...changes.added, ...changes.modified.map(m => m.new)];
|
|
174
189
|
if (nodesToReanalyze.length > 0) {
|
|
175
|
-
const reanalyzeResult = await this.reanalyzeNodes(nodesToReanalyze, filePath, '__local', graph);
|
|
190
|
+
const reanalyzeResult = await this.reanalyzeNodes(nodesToReanalyze, filePath, '__local', graph, logger);
|
|
176
191
|
edgesCreated += reanalyzeResult.edgesCreated;
|
|
177
192
|
}
|
|
178
193
|
return {
|
|
@@ -276,8 +291,8 @@ export class IncrementalAnalysisPlugin extends Plugin {
|
|
|
276
291
|
}
|
|
277
292
|
});
|
|
278
293
|
}
|
|
279
|
-
catch
|
|
280
|
-
|
|
294
|
+
catch {
|
|
295
|
+
// Parse error - return empty nodes array
|
|
281
296
|
}
|
|
282
297
|
return nodes;
|
|
283
298
|
}
|
|
@@ -315,19 +330,19 @@ export class IncrementalAnalysisPlugin extends Plugin {
|
|
|
315
330
|
return false;
|
|
316
331
|
}
|
|
317
332
|
/**
|
|
318
|
-
*
|
|
333
|
+
* Reanalyze nodes to create CALLS/USES edges
|
|
319
334
|
*/
|
|
320
|
-
async reanalyzeNodes(nodes, filePath, version, graph) {
|
|
335
|
+
async reanalyzeNodes(nodes, filePath, version, graph, logger) {
|
|
321
336
|
let edgesCreated = 0;
|
|
322
337
|
try {
|
|
323
|
-
//
|
|
338
|
+
// Read file again
|
|
324
339
|
const content = await readFile(filePath, 'utf-8');
|
|
325
|
-
//
|
|
340
|
+
// Parse AST
|
|
326
341
|
const ast = parse(content, {
|
|
327
342
|
sourceType: 'module',
|
|
328
343
|
plugins: ['jsx', 'typescript', 'decorators-legacy']
|
|
329
344
|
});
|
|
330
|
-
//
|
|
345
|
+
// For each node, find it in AST and analyze
|
|
331
346
|
for (const node of nodes) {
|
|
332
347
|
if (node.type === 'FUNCTION') {
|
|
333
348
|
const functionEdges = await this.analyzeFunctionCalls(node, ast, version, graph);
|
|
@@ -338,11 +353,11 @@ export class IncrementalAnalysisPlugin extends Plugin {
|
|
|
338
353
|
edgesCreated += classEdges;
|
|
339
354
|
}
|
|
340
355
|
}
|
|
341
|
-
|
|
356
|
+
logger.debug('Reanalyzed nodes', { nodesCount: nodes.length, edgesCreated });
|
|
342
357
|
return { edgesCreated };
|
|
343
358
|
}
|
|
344
|
-
catch
|
|
345
|
-
|
|
359
|
+
catch {
|
|
360
|
+
// Error reanalyzing nodes - silently return empty result
|
|
346
361
|
return { edgesCreated: 0 };
|
|
347
362
|
}
|
|
348
363
|
}
|
|
@@ -419,47 +434,28 @@ export class IncrementalAnalysisPlugin extends Plugin {
|
|
|
419
434
|
// Пытаемся найти callee в графе (сначала __local, потом main)
|
|
420
435
|
const calleeName = callSite.callee.split('.')[0]; // Для method calls берём объект
|
|
421
436
|
const calleeStableId = `FUNCTION:${calleeName}:${functionNode.file}`;
|
|
422
|
-
//
|
|
437
|
+
// Find callee and create edge
|
|
423
438
|
try {
|
|
424
439
|
const created = await this.findCalleeAndCreateEdge(callerId, calleeStableId, version, graph);
|
|
425
440
|
if (created)
|
|
426
441
|
edgesCreated++;
|
|
427
442
|
}
|
|
428
|
-
catch
|
|
429
|
-
|
|
443
|
+
catch {
|
|
444
|
+
// Error creating CALLS edge - skip silently
|
|
430
445
|
}
|
|
431
446
|
}
|
|
432
447
|
return edgesCreated;
|
|
433
448
|
}
|
|
434
449
|
/**
|
|
435
450
|
* Найти callee и создать CALLS edge
|
|
451
|
+
* TODO: Implement using existing graph.queryNodes() method
|
|
452
|
+
* This method was disabled as part of stableId removal (REG-140).
|
|
453
|
+
* The getNodesByStableId method never existed on GraphBackend.
|
|
436
454
|
*/
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
if (calleeVersions.length === 0) {
|
|
442
|
-
// Callee не найден - возможно это external функция
|
|
443
|
-
return false;
|
|
444
|
-
}
|
|
445
|
-
// Предпочитаем __local версию, если есть
|
|
446
|
-
const calleeNode = calleeVersions.find(n => n.version === '__local') ||
|
|
447
|
-
calleeVersions.find(n => n.version === 'main');
|
|
448
|
-
if (!calleeNode) {
|
|
449
|
-
return false;
|
|
450
|
-
}
|
|
451
|
-
// Создаём CALLS edge
|
|
452
|
-
await graph.addEdge({
|
|
453
|
-
type: 'CALLS',
|
|
454
|
-
src: callerId,
|
|
455
|
-
dst: calleeNode.id
|
|
456
|
-
});
|
|
457
|
-
return true;
|
|
458
|
-
}
|
|
459
|
-
catch (error) {
|
|
460
|
-
console.error(`[IncrementalAnalysis] Error finding callee:`, error);
|
|
461
|
-
return false;
|
|
462
|
-
}
|
|
455
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
456
|
+
async findCalleeAndCreateEdge(_callerId, _calleeStableId, _version, _graph) {
|
|
457
|
+
// Disabled - needs implementation using graph.queryNodes()
|
|
458
|
+
return false;
|
|
463
459
|
}
|
|
464
460
|
/**
|
|
465
461
|
* Анализировать методы класса
|