@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
|
@@ -94,6 +94,7 @@ export class PrefixEvaluator extends Plugin {
|
|
|
94
94
|
async execute(context: PluginContext): Promise<PluginResult> {
|
|
95
95
|
try {
|
|
96
96
|
const { graph } = context;
|
|
97
|
+
const logger = this.log(context);
|
|
97
98
|
const graphTyped = graph as unknown as Graph;
|
|
98
99
|
|
|
99
100
|
let mountPointsEvaluated = 0;
|
|
@@ -112,7 +113,7 @@ export class PrefixEvaluator extends Plugin {
|
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
|
|
116
|
+
logger.info('Found mount points with placeholders', { count: mountPoints.length });
|
|
116
117
|
|
|
117
118
|
// For each mount point try to evaluate prefix
|
|
118
119
|
for (const mountPoint of mountPoints) {
|
|
@@ -125,7 +126,7 @@ export class PrefixEvaluator extends Plugin {
|
|
|
125
126
|
});
|
|
126
127
|
|
|
127
128
|
if (definesEdges.length === 0) {
|
|
128
|
-
|
|
129
|
+
logger.debug('No DEFINES edge for mount point', { mountPointId: mountPoint.id });
|
|
129
130
|
continue;
|
|
130
131
|
}
|
|
131
132
|
|
|
@@ -133,7 +134,7 @@ export class PrefixEvaluator extends Plugin {
|
|
|
133
134
|
const module = (graphTyped.nodes as Map<string, NodeRecord>).get(moduleId) as ModuleNode | undefined;
|
|
134
135
|
|
|
135
136
|
if (!module || module.type !== 'MODULE') {
|
|
136
|
-
|
|
137
|
+
logger.debug('Module not found for mount point', { mountPointId: mountPoint.id });
|
|
137
138
|
continue;
|
|
138
139
|
}
|
|
139
140
|
|
|
@@ -147,7 +148,7 @@ export class PrefixEvaluator extends Plugin {
|
|
|
147
148
|
});
|
|
148
149
|
} catch (error) {
|
|
149
150
|
const err = error as Error;
|
|
150
|
-
|
|
151
|
+
logger.debug('Failed to parse file', { file: module.file, error: err.message });
|
|
151
152
|
continue;
|
|
152
153
|
}
|
|
153
154
|
|
|
@@ -163,11 +164,18 @@ export class PrefixEvaluator extends Plugin {
|
|
|
163
164
|
mountPoint.prefix = evaluatedPrefix;
|
|
164
165
|
mountPoint.evaluated = true;
|
|
165
166
|
successfulEvaluations++;
|
|
166
|
-
|
|
167
|
+
logger.debug('Resolved prefix', {
|
|
168
|
+
file: mountPoint.file,
|
|
169
|
+
line: mountPoint.line,
|
|
170
|
+
prefix: evaluatedPrefix
|
|
171
|
+
});
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
174
|
|
|
170
|
-
|
|
175
|
+
logger.info('Evaluated mount points', {
|
|
176
|
+
successful: successfulEvaluations,
|
|
177
|
+
total: mountPointsEvaluated
|
|
178
|
+
});
|
|
171
179
|
|
|
172
180
|
return createSuccessResult(
|
|
173
181
|
{ nodes: 0, edges: 0 },
|
|
@@ -175,7 +183,8 @@ export class PrefixEvaluator extends Plugin {
|
|
|
175
183
|
);
|
|
176
184
|
|
|
177
185
|
} catch (error) {
|
|
178
|
-
|
|
186
|
+
const logger = this.log(context);
|
|
187
|
+
logger.error('Error in PrefixEvaluator', { error });
|
|
179
188
|
return createErrorResult(error as Error);
|
|
180
189
|
}
|
|
181
190
|
}
|
|
@@ -40,20 +40,21 @@ export class RustFFIEnricher extends Plugin {
|
|
|
40
40
|
|
|
41
41
|
async execute(context: PluginContext): Promise<PluginResult> {
|
|
42
42
|
const { graph } = context;
|
|
43
|
+
const logger = this.log(context);
|
|
43
44
|
|
|
44
45
|
// 1. Build index of NAPI-exported Rust functions/methods
|
|
45
46
|
const napiIndex = await this.buildNapiIndex(graph);
|
|
46
47
|
|
|
47
48
|
if (napiIndex.size === 0) {
|
|
48
|
-
|
|
49
|
+
logger.info('No NAPI exports found, skipping');
|
|
49
50
|
return createSuccessResult({ nodes: 0, edges: 0 }, { skipped: true, reason: 'No NAPI exports' });
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
logger.debug('Indexed NAPI exports', { count: napiIndex.size });
|
|
53
54
|
|
|
54
55
|
// 2. Find JS CALL nodes that target Rust
|
|
55
56
|
const jsCalls = await this.findRustCallingJsCalls(graph);
|
|
56
|
-
|
|
57
|
+
logger.debug('Found candidate JS calls', { count: jsCalls.length });
|
|
57
58
|
|
|
58
59
|
// 3. Match and create FFI_CALLS edges
|
|
59
60
|
let edgesCreated = 0;
|
|
@@ -78,10 +79,10 @@ export class RustFFIEnricher extends Plugin {
|
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
if (unmatched.length > 0 && unmatched.length <= 20) {
|
|
81
|
-
|
|
82
|
+
logger.debug('Unmatched calls', { calls: unmatched.slice(0, 10) });
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
logger.info('Created FFI_CALLS edges', { count: edgesCreated, unmatched: unmatched.length });
|
|
85
86
|
return createSuccessResult({ nodes: 0, edges: edgesCreated }, { unmatched: unmatched.length });
|
|
86
87
|
}
|
|
87
88
|
|
|
@@ -65,7 +65,6 @@ interface ScopeNode {
|
|
|
65
65
|
file?: string;
|
|
66
66
|
line?: number;
|
|
67
67
|
originalId?: string;
|
|
68
|
-
stableId?: string;
|
|
69
68
|
parentScopeId?: string;
|
|
70
69
|
constraints?: Constraint[];
|
|
71
70
|
}
|
|
@@ -101,6 +100,7 @@ interface Graph {
|
|
|
101
100
|
getOutgoingEdges(nodeId: string): Promise<EdgeRecord[]>;
|
|
102
101
|
getIncomingEdges(nodeId: string): Promise<EdgeRecord[]>;
|
|
103
102
|
addEdge(edge: { src: string; dst: string; type: string; metadata?: Record<string, unknown> }): Promise<void> | void;
|
|
103
|
+
deleteEdge?(src: string, dst: string, type: string): Promise<void>; // Optional for edge updates
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
interface ProgressCallback {
|
|
@@ -154,17 +154,18 @@ export class ValueDomainAnalyzer extends Plugin {
|
|
|
154
154
|
priority: 65, // After AliasTracker (60)
|
|
155
155
|
creates: {
|
|
156
156
|
nodes: [],
|
|
157
|
-
edges: ['CALLS']
|
|
157
|
+
edges: ['CALLS', 'FLOWS_INTO'] // Added FLOWS_INTO (modifies existing)
|
|
158
158
|
}
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
async execute(context: PluginContext): Promise<PluginResult> {
|
|
163
163
|
const { graph } = context;
|
|
164
|
+
const logger = this.log(context);
|
|
164
165
|
const onProgress = (context as unknown as { onProgress?: ProgressCallback }).onProgress;
|
|
165
166
|
const graphTyped = graph as unknown as Graph;
|
|
166
167
|
|
|
167
|
-
|
|
168
|
+
logger.info('Starting value domain analysis');
|
|
168
169
|
|
|
169
170
|
let callsProcessed = 0;
|
|
170
171
|
let callsResolved = 0;
|
|
@@ -182,7 +183,7 @@ export class ValueDomainAnalyzer extends Plugin {
|
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
185
|
|
|
185
|
-
|
|
186
|
+
logger.info('Found computed member calls', { count: computedCalls.length });
|
|
186
187
|
|
|
187
188
|
// 2. For each computed call get value set
|
|
188
189
|
for (const call of computedCalls) {
|
|
@@ -249,18 +250,24 @@ export class ValueDomainAnalyzer extends Plugin {
|
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
252
|
|
|
253
|
+
// 5. Resolve computed property mutations in FLOWS_INTO edges
|
|
254
|
+
logger.debug('Resolving computed property mutations');
|
|
255
|
+
const mutationStats = await this.resolveComputedMutations(graphTyped, logger);
|
|
256
|
+
logger.debug('Mutation resolution stats', mutationStats);
|
|
257
|
+
|
|
252
258
|
const summary = {
|
|
253
259
|
callsProcessed,
|
|
254
260
|
callsResolved,
|
|
255
261
|
edgesCreated,
|
|
256
262
|
conditionalCalls,
|
|
257
|
-
partialCalls
|
|
263
|
+
partialCalls,
|
|
264
|
+
computedMutations: mutationStats
|
|
258
265
|
};
|
|
259
266
|
|
|
260
|
-
|
|
267
|
+
logger.info('Summary', summary);
|
|
261
268
|
|
|
262
269
|
return createSuccessResult(
|
|
263
|
-
{ nodes: 0, edges: edgesCreated },
|
|
270
|
+
{ nodes: 0, edges: edgesCreated + mutationStats.resolved + mutationStats.conditional },
|
|
264
271
|
summary
|
|
265
272
|
);
|
|
266
273
|
}
|
|
@@ -294,13 +301,10 @@ export class ValueDomainAnalyzer extends Plugin {
|
|
|
294
301
|
}
|
|
295
302
|
|
|
296
303
|
if (variables.length === 0) {
|
|
297
|
-
console.log(`[ValueDomainAnalyzer] No variable found for ${variableName} in ${file}`);
|
|
298
304
|
result.hasUnknown = true;
|
|
299
305
|
return result;
|
|
300
306
|
}
|
|
301
307
|
|
|
302
|
-
console.log(`[ValueDomainAnalyzer] Found ${variables.length} variable(s) for ${variableName}`);
|
|
303
|
-
|
|
304
308
|
// Trace ASSIGNED_FROM to LITERAL or nondeterministic sources
|
|
305
309
|
const visited = new Set<string>();
|
|
306
310
|
const valueSet = new Set<unknown>();
|
|
@@ -377,8 +381,7 @@ export class ValueDomainAnalyzer extends Plugin {
|
|
|
377
381
|
for await (const s of graph.queryNodes({ nodeType: 'SCOPE' })) {
|
|
378
382
|
const scopeNode = s as ScopeNode;
|
|
379
383
|
if (scopeNode.id === currentScopeId ||
|
|
380
|
-
scopeNode.originalId === currentScopeId
|
|
381
|
-
scopeNode.stableId === currentScopeId) {
|
|
384
|
+
scopeNode.originalId === currentScopeId) {
|
|
382
385
|
scope = scopeNode;
|
|
383
386
|
break;
|
|
384
387
|
}
|
|
@@ -677,6 +680,140 @@ export class ValueDomainAnalyzer extends Plugin {
|
|
|
677
680
|
|
|
678
681
|
return null;
|
|
679
682
|
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Resolve computed property names for object mutations.
|
|
686
|
+
* Finds FLOWS_INTO edges with mutationType: 'computed' and resolves
|
|
687
|
+
* the property name using value set tracing.
|
|
688
|
+
*
|
|
689
|
+
* @param graph - Graph backend with edge operations
|
|
690
|
+
* @returns Statistics about resolution
|
|
691
|
+
*/
|
|
692
|
+
async resolveComputedMutations(graph: Graph, logger: ReturnType<typeof this.log>): Promise<{
|
|
693
|
+
resolved: number;
|
|
694
|
+
conditional: number;
|
|
695
|
+
unknownParameter: number;
|
|
696
|
+
unknownRuntime: number;
|
|
697
|
+
deferredCrossFile: number;
|
|
698
|
+
total: number;
|
|
699
|
+
}> {
|
|
700
|
+
const stats = {
|
|
701
|
+
resolved: 0,
|
|
702
|
+
conditional: 0,
|
|
703
|
+
unknownParameter: 0,
|
|
704
|
+
unknownRuntime: 0,
|
|
705
|
+
deferredCrossFile: 0,
|
|
706
|
+
total: 0
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
// Process edges by finding all VARIABLE and CONSTANT nodes and checking their outgoing edges
|
|
710
|
+
const processedEdges = new Set<string>();
|
|
711
|
+
|
|
712
|
+
// Helper to process a node's outgoing edges
|
|
713
|
+
const processNodeEdges = async (node: NodeRecord): Promise<void> => {
|
|
714
|
+
const outgoing = await graph.getOutgoingEdges(node.id);
|
|
715
|
+
|
|
716
|
+
for (const edge of outgoing) {
|
|
717
|
+
const edgeType = (edge as { edgeType?: string; edge_type?: string; type?: string }).edgeType ||
|
|
718
|
+
(edge as { edge_type?: string }).edge_type ||
|
|
719
|
+
(edge as { type?: string }).type;
|
|
720
|
+
|
|
721
|
+
if (edgeType !== 'FLOWS_INTO') continue;
|
|
722
|
+
|
|
723
|
+
const edgeKey = `${edge.src}->${edge.dst}:FLOWS_INTO`;
|
|
724
|
+
if (processedEdges.has(edgeKey)) continue;
|
|
725
|
+
processedEdges.add(edgeKey);
|
|
726
|
+
|
|
727
|
+
const mutationType = (edge as { mutationType?: string }).mutationType;
|
|
728
|
+
const computedPropertyVar = (edge as { computedPropertyVar?: string }).computedPropertyVar;
|
|
729
|
+
|
|
730
|
+
if (mutationType !== 'computed' || !computedPropertyVar) continue;
|
|
731
|
+
|
|
732
|
+
stats.total++;
|
|
733
|
+
|
|
734
|
+
// Get file from source node
|
|
735
|
+
const sourceNode = await graph.getNode(edge.src);
|
|
736
|
+
const file = (sourceNode as { file?: string })?.file;
|
|
737
|
+
if (!file) continue;
|
|
738
|
+
|
|
739
|
+
// Resolve the computed property variable using existing getValueSet
|
|
740
|
+
const valueSet = await this.getValueSet(computedPropertyVar, file, graph);
|
|
741
|
+
|
|
742
|
+
// Check if the variable is a PARAMETER node
|
|
743
|
+
let isParameter = false;
|
|
744
|
+
for await (const node of graph.queryNodes({ nodeType: 'PARAMETER' })) {
|
|
745
|
+
const paramNode = node as { name?: string; file?: string; attrs?: { name?: string; file?: string } };
|
|
746
|
+
const nodeName = paramNode.name || paramNode.attrs?.name;
|
|
747
|
+
const nodeFile = paramNode.file || paramNode.attrs?.file;
|
|
748
|
+
if (nodeName === computedPropertyVar && nodeFile === file) {
|
|
749
|
+
isParameter = true;
|
|
750
|
+
break;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// Determine resolution status based on value set
|
|
755
|
+
let resolutionStatus: string;
|
|
756
|
+
let resolvedPropertyNames: string[] = [];
|
|
757
|
+
|
|
758
|
+
if (valueSet.values.length === 0 && isParameter) {
|
|
759
|
+
// Variable is a function parameter - cannot be statically resolved
|
|
760
|
+
resolutionStatus = 'UNKNOWN_PARAMETER';
|
|
761
|
+
stats.unknownParameter++;
|
|
762
|
+
} else if (valueSet.values.length === 0 && valueSet.hasUnknown) {
|
|
763
|
+
// Completely nondeterministic - runtime value (function call result, etc.)
|
|
764
|
+
resolutionStatus = 'UNKNOWN_RUNTIME';
|
|
765
|
+
stats.unknownRuntime++;
|
|
766
|
+
} else if (valueSet.values.length === 0) {
|
|
767
|
+
// No values found at all - treat as unknown
|
|
768
|
+
resolutionStatus = 'UNKNOWN_RUNTIME';
|
|
769
|
+
stats.unknownRuntime++;
|
|
770
|
+
} else if (valueSet.values.length === 1 && !valueSet.hasUnknown) {
|
|
771
|
+
// Single deterministic value
|
|
772
|
+
resolutionStatus = 'RESOLVED';
|
|
773
|
+
resolvedPropertyNames = valueSet.values.map(v => String(v));
|
|
774
|
+
stats.resolved++;
|
|
775
|
+
} else {
|
|
776
|
+
// Multiple values (conditional) or partial resolution
|
|
777
|
+
resolutionStatus = 'RESOLVED_CONDITIONAL';
|
|
778
|
+
resolvedPropertyNames = valueSet.values.map(v => String(v));
|
|
779
|
+
stats.conditional++;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// Update edge: delete old, create new with resolved data
|
|
783
|
+
// Following the same pattern as InstanceOfResolver
|
|
784
|
+
if (graph.deleteEdge) {
|
|
785
|
+
await graph.deleteEdge(edge.src, edge.dst, 'FLOWS_INTO');
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// Preserve original edge data and add resolution info
|
|
789
|
+
// For UNKNOWN cases, keep propertyName as '<computed>' and resolvedPropertyNames empty
|
|
790
|
+
await graph.addEdge({
|
|
791
|
+
src: edge.src,
|
|
792
|
+
dst: edge.dst,
|
|
793
|
+
type: 'FLOWS_INTO',
|
|
794
|
+
metadata: {
|
|
795
|
+
mutationType,
|
|
796
|
+
propertyName: resolvedPropertyNames[0] || '<computed>',
|
|
797
|
+
computedPropertyVar,
|
|
798
|
+
resolvedPropertyNames,
|
|
799
|
+
resolutionStatus
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
// Process VARIABLE nodes
|
|
806
|
+
for await (const node of graph.queryNodes({ nodeType: 'VARIABLE' })) {
|
|
807
|
+
await processNodeEdges(node);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// Process CONSTANT nodes
|
|
811
|
+
for await (const node of graph.queryNodes({ nodeType: 'CONSTANT' })) {
|
|
812
|
+
await processNodeEdges(node);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
return stats;
|
|
816
|
+
}
|
|
680
817
|
}
|
|
681
818
|
|
|
682
819
|
export default ValueDomainAnalyzer;
|
|
@@ -151,12 +151,13 @@ export class IncrementalModuleIndexer extends Plugin {
|
|
|
151
151
|
|
|
152
152
|
return imports;
|
|
153
153
|
} catch (err) {
|
|
154
|
-
|
|
154
|
+
// Parse error will be logged by execute() when it needs logger context
|
|
155
155
|
return [];
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
async execute(context: PluginContext): Promise<PluginResult> {
|
|
160
|
+
const logger = this.log(context);
|
|
160
161
|
try {
|
|
161
162
|
const { manifest, graph } = context;
|
|
162
163
|
// Cast manifest to expected shape
|
|
@@ -175,7 +176,7 @@ export class IncrementalModuleIndexer extends Plugin {
|
|
|
175
176
|
let totalImportsParsed = 0;
|
|
176
177
|
let unresolvedImports = 0;
|
|
177
178
|
|
|
178
|
-
|
|
179
|
+
logger.info('Starting incremental indexing', { entryFile: relative(projectPath, entryFile) });
|
|
179
180
|
|
|
180
181
|
while (queue.length > 0) {
|
|
181
182
|
const file = queue.shift()!;
|
|
@@ -183,12 +184,13 @@ export class IncrementalModuleIndexer extends Plugin {
|
|
|
183
184
|
if (processed.has(file)) continue;
|
|
184
185
|
processed.add(file);
|
|
185
186
|
|
|
186
|
-
// Create MODULE node
|
|
187
|
+
// Create MODULE node with semantic ID
|
|
187
188
|
const fileHash = this.calculateFileHash(file);
|
|
188
189
|
const relativePath = relative(projectPath, file);
|
|
190
|
+
const semanticId = `${relativePath}->global->MODULE->module`;
|
|
189
191
|
|
|
190
192
|
const moduleNode: NodeRecord = {
|
|
191
|
-
id:
|
|
193
|
+
id: semanticId,
|
|
192
194
|
type: 'MODULE',
|
|
193
195
|
name: relativePath,
|
|
194
196
|
file: file,
|
|
@@ -211,10 +213,12 @@ export class IncrementalModuleIndexer extends Plugin {
|
|
|
211
213
|
const imports = this.parseImports(file, projectPath);
|
|
212
214
|
totalImportsParsed += imports.length;
|
|
213
215
|
for (const importFile of imports) {
|
|
214
|
-
// Store for later edge creation
|
|
216
|
+
// Store for later edge creation with semantic ID format
|
|
217
|
+
const importRelativePath = relative(projectPath, importFile);
|
|
218
|
+
const importSemanticId = `${importRelativePath}->global->MODULE->module`;
|
|
215
219
|
pendingImports.push({
|
|
216
220
|
src: moduleNode.id,
|
|
217
|
-
dst:
|
|
221
|
+
dst: importSemanticId
|
|
218
222
|
});
|
|
219
223
|
|
|
220
224
|
if (!processed.has(importFile)) {
|
|
@@ -251,14 +255,16 @@ export class IncrementalModuleIndexer extends Plugin {
|
|
|
251
255
|
}
|
|
252
256
|
|
|
253
257
|
if (processed.size % 10 === 0) {
|
|
254
|
-
|
|
258
|
+
logger.debug('Indexing progress', { indexed: processed.size, queueLength: queue.length });
|
|
255
259
|
}
|
|
256
260
|
}
|
|
257
261
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
+
logger.info('Modules indexed', { count: processed.size });
|
|
263
|
+
logger.debug('Import statistics', {
|
|
264
|
+
totalImportsParsed,
|
|
265
|
+
unresolvedImports,
|
|
266
|
+
pendingEdges: pendingImports.length
|
|
267
|
+
});
|
|
262
268
|
|
|
263
269
|
// Now create all IMPORTS edges after all MODULE nodes exist
|
|
264
270
|
for (const { src, dst } of pendingImports) {
|
|
@@ -271,8 +277,11 @@ export class IncrementalModuleIndexer extends Plugin {
|
|
|
271
277
|
edgesCreated++;
|
|
272
278
|
}
|
|
273
279
|
|
|
274
|
-
|
|
275
|
-
|
|
280
|
+
logger.info('Indexing complete', {
|
|
281
|
+
nodesCreated,
|
|
282
|
+
edgesCreated,
|
|
283
|
+
importsEdgesCreated: pendingImports.length
|
|
284
|
+
});
|
|
276
285
|
|
|
277
286
|
return createSuccessResult(
|
|
278
287
|
{ nodes: nodesCreated, edges: edgesCreated },
|
|
@@ -280,7 +289,7 @@ export class IncrementalModuleIndexer extends Plugin {
|
|
|
280
289
|
);
|
|
281
290
|
|
|
282
291
|
} catch (error) {
|
|
283
|
-
|
|
292
|
+
logger.error('Indexing failed', { error });
|
|
284
293
|
return createErrorResult(error as Error);
|
|
285
294
|
}
|
|
286
295
|
}
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { readFileSync, existsSync } from 'fs';
|
|
7
|
-
import { join, resolve, dirname } from 'path';
|
|
7
|
+
import { join, resolve, dirname, relative, basename } from 'path';
|
|
8
8
|
import { createHash } from 'crypto';
|
|
9
|
-
import { Plugin,
|
|
9
|
+
import { Plugin, createErrorResult } from '../Plugin.js';
|
|
10
10
|
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
11
11
|
// @ts-expect-error - no type declarations for node-source-walk
|
|
12
12
|
import Walker from 'node-source-walk';
|
|
13
13
|
import { NodeFactory } from '../../core/NodeFactory.js';
|
|
14
|
+
import { LanguageError } from '../../errors/GrafemaError.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Manifest with service info
|
|
@@ -21,6 +22,10 @@ interface IndexerManifest {
|
|
|
21
22
|
id: string;
|
|
22
23
|
name: string;
|
|
23
24
|
path: string;
|
|
25
|
+
metadata?: {
|
|
26
|
+
entrypoint?: string;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
24
29
|
};
|
|
25
30
|
}
|
|
26
31
|
|
|
@@ -74,7 +79,9 @@ export class JSModuleIndexer extends Plugin {
|
|
|
74
79
|
|
|
75
80
|
constructor() {
|
|
76
81
|
super();
|
|
77
|
-
this.walker = new Walker(
|
|
82
|
+
this.walker = new Walker({
|
|
83
|
+
plugins: ['jsx', 'typescript']
|
|
84
|
+
});
|
|
78
85
|
this.cache = new Map(); // Кеш зависимостей файла
|
|
79
86
|
this.testPatterns = DEFAULT_TEST_PATTERNS;
|
|
80
87
|
this.markTestFiles = true; // Default: enabled
|
|
@@ -208,26 +215,30 @@ export class JSModuleIndexer extends Plugin {
|
|
|
208
215
|
}
|
|
209
216
|
|
|
210
217
|
async execute(context: PluginContext): Promise<PluginResult> {
|
|
218
|
+
const logger = this.log(context);
|
|
211
219
|
try {
|
|
212
220
|
const { graph, onProgress, config } = context;
|
|
213
221
|
const manifest = context.manifest as IndexerManifest | undefined;
|
|
214
222
|
const projectPath = manifest?.projectPath ?? '';
|
|
215
223
|
const service = manifest?.service ?? { id: '', name: '', path: '' };
|
|
216
224
|
|
|
225
|
+
// Collect parse errors to report (REG-147)
|
|
226
|
+
const parseErrors: Error[] = [];
|
|
227
|
+
|
|
217
228
|
// Check config for test file marking
|
|
218
229
|
if ((config as { analysis?: { tests?: { markTestFiles?: boolean } } })?.analysis?.tests?.markTestFiles === false) {
|
|
219
230
|
this.markTestFiles = false;
|
|
220
231
|
}
|
|
221
232
|
|
|
222
|
-
|
|
223
|
-
|
|
233
|
+
// Use metadata.entrypoint if available (from config services), otherwise fall back to path
|
|
234
|
+
const entrypoint = service.metadata?.entrypoint || service.path;
|
|
224
235
|
|
|
225
236
|
// Резолвим entrypoint относительно projectPath
|
|
226
237
|
const absoluteEntrypoint = entrypoint.startsWith('/')
|
|
227
238
|
? entrypoint
|
|
228
239
|
: join(projectPath, entrypoint);
|
|
229
240
|
|
|
230
|
-
|
|
241
|
+
logger.info('Building dependency tree', { service: service.name });
|
|
231
242
|
|
|
232
243
|
// DFS через стек (как в file2host.js)
|
|
233
244
|
const visited = new Set<string>();
|
|
@@ -261,37 +272,55 @@ export class JSModuleIndexer extends Plugin {
|
|
|
261
272
|
lastProgressReport = visited.size;
|
|
262
273
|
}
|
|
263
274
|
|
|
264
|
-
|
|
275
|
+
logger.debug('Processing file', { file: currentFile.replace(projectPath, ''), depth });
|
|
265
276
|
|
|
266
277
|
if (depth > MAX_DEPTH) {
|
|
267
|
-
|
|
278
|
+
logger.warn('Max depth reached', { maxDepth: MAX_DEPTH, file: currentFile });
|
|
268
279
|
continue;
|
|
269
280
|
}
|
|
270
281
|
|
|
271
282
|
// Парсим зависимости
|
|
272
283
|
const deps = this.processFile(currentFile, projectPath);
|
|
273
|
-
|
|
284
|
+
logger.debug('Found dependencies', { file: currentFile.replace(projectPath, ''), count: deps instanceof Error ? 0 : deps.length });
|
|
274
285
|
|
|
275
286
|
if (deps instanceof Error) {
|
|
276
287
|
if (!deps.message.includes('ENOENT')) {
|
|
277
|
-
|
|
288
|
+
const relativePath = relative(projectPath, currentFile) || basename(currentFile);
|
|
289
|
+
const error = new LanguageError(
|
|
290
|
+
`Failed to parse ${relativePath}: ${deps.message}`,
|
|
291
|
+
'ERR_PARSE_FAILURE',
|
|
292
|
+
{
|
|
293
|
+
filePath: currentFile,
|
|
294
|
+
phase: 'INDEXING',
|
|
295
|
+
plugin: 'JSModuleIndexer',
|
|
296
|
+
},
|
|
297
|
+
'Check file syntax or ensure the file is a supported JavaScript/TypeScript file'
|
|
298
|
+
);
|
|
299
|
+
parseErrors.push(error);
|
|
300
|
+
logger.debug('Parse error', { file: currentFile, error: deps.message });
|
|
278
301
|
}
|
|
279
302
|
continue;
|
|
280
303
|
}
|
|
281
304
|
|
|
282
|
-
// Создаём MODULE ноду для текущего файла
|
|
305
|
+
// Создаём MODULE ноду для текущего файла с semantic ID
|
|
283
306
|
const fileHash = this.calculateFileHash(currentFile);
|
|
284
|
-
const
|
|
307
|
+
const relativePath = relative(projectPath, currentFile) || basename(currentFile);
|
|
308
|
+
const semanticId = `${relativePath}->global->MODULE->module`;
|
|
285
309
|
|
|
286
|
-
//
|
|
287
|
-
// ВСЕГДА создаём ноду в графе (граф может быть пустой после force)
|
|
310
|
+
// Construct MODULE node manually to preserve absolute file path for analyzers
|
|
288
311
|
const isTest = this.isTestFile(currentFile);
|
|
289
|
-
const moduleNode =
|
|
290
|
-
|
|
312
|
+
const moduleNode = {
|
|
313
|
+
id: semanticId,
|
|
314
|
+
type: 'MODULE' as const,
|
|
315
|
+
name: relativePath,
|
|
316
|
+
file: currentFile, // Keep absolute path for file reading in analyzers
|
|
317
|
+
line: 0,
|
|
318
|
+
contentHash: fileHash || '',
|
|
291
319
|
isTest
|
|
292
|
-
}
|
|
320
|
+
};
|
|
321
|
+
const moduleId = moduleNode.id;
|
|
293
322
|
|
|
294
|
-
|
|
323
|
+
logger.debug('Creating MODULE node', { moduleId: moduleNode.id });
|
|
295
324
|
await graph.addNode(moduleNode);
|
|
296
325
|
nodesCreated++;
|
|
297
326
|
|
|
@@ -306,25 +335,26 @@ export class JSModuleIndexer extends Plugin {
|
|
|
306
335
|
for (const dep of deps) {
|
|
307
336
|
if (dep.startsWith('package::')) {
|
|
308
337
|
// npm пакет - игнорируем пока
|
|
309
|
-
|
|
338
|
+
logger.debug('Skipping npm package', { package: dep });
|
|
310
339
|
continue;
|
|
311
340
|
}
|
|
312
341
|
|
|
313
342
|
const resolvedDep = this.resolveModulePath(dep);
|
|
314
|
-
|
|
343
|
+
logger.debug('Resolved dependency', { from: dep, to: resolvedDep.replace(projectPath, '') });
|
|
315
344
|
|
|
316
345
|
// Добавляем в стек если ещё не посещали
|
|
317
346
|
if (!visited.has(resolvedDep)) {
|
|
318
347
|
visited.add(resolvedDep);
|
|
319
348
|
stack.push({ file: resolvedDep, depth: depth + 1 });
|
|
320
|
-
|
|
349
|
+
logger.debug('Added to stack', { depth: depth + 1 });
|
|
321
350
|
} else {
|
|
322
|
-
|
|
351
|
+
logger.debug('Already visited, skipping', { file: resolvedDep });
|
|
323
352
|
}
|
|
324
353
|
|
|
325
354
|
// Queue DEPENDS_ON edges for later (after all nodes exist)
|
|
326
|
-
|
|
327
|
-
const
|
|
355
|
+
// Use semantic ID format for dependency reference
|
|
356
|
+
const depRelativePath = relative(projectPath, resolvedDep) || basename(resolvedDep);
|
|
357
|
+
const depModuleId = `${depRelativePath}->global->MODULE->module`;
|
|
328
358
|
pendingDependsOnEdges.push({
|
|
329
359
|
src: moduleId,
|
|
330
360
|
dst: depModuleId,
|
|
@@ -342,9 +372,11 @@ export class JSModuleIndexer extends Plugin {
|
|
|
342
372
|
|
|
343
373
|
// Warning if hit MAX_MODULES limit
|
|
344
374
|
if (visited.size >= MAX_MODULES) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
375
|
+
logger.warn('Hit MAX_MODULES limit', {
|
|
376
|
+
service: service.name,
|
|
377
|
+
limit: MAX_MODULES,
|
|
378
|
+
unprocessedInStack: stack.length
|
|
379
|
+
});
|
|
348
380
|
}
|
|
349
381
|
|
|
350
382
|
// Final progress report
|
|
@@ -359,15 +391,23 @@ export class JSModuleIndexer extends Plugin {
|
|
|
359
391
|
});
|
|
360
392
|
}
|
|
361
393
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
394
|
+
logger.info('Indexing complete', {
|
|
395
|
+
service: service.name,
|
|
396
|
+
modulesCreated: nodesCreated,
|
|
397
|
+
totalInTree: visited.size
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
// Return result with parse errors (REG-147)
|
|
401
|
+
return {
|
|
402
|
+
success: true,
|
|
403
|
+
created: { nodes: nodesCreated, edges: edgesCreated },
|
|
404
|
+
errors: parseErrors,
|
|
405
|
+
warnings: [],
|
|
406
|
+
metadata: { totalModules: visited.size },
|
|
407
|
+
};
|
|
368
408
|
|
|
369
409
|
} catch (error) {
|
|
370
|
-
|
|
410
|
+
logger.error('Indexing failed', { error });
|
|
371
411
|
return createErrorResult(error as Error);
|
|
372
412
|
}
|
|
373
413
|
}
|