@grafema/core 0.1.0-alpha.1
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/LICENSE +190 -0
- package/README.md +76 -0
- package/dist/Orchestrator.d.ts +142 -0
- package/dist/Orchestrator.d.ts.map +1 -0
- package/dist/Orchestrator.js +481 -0
- package/dist/api/GraphAPI.d.ts +87 -0
- package/dist/api/GraphAPI.d.ts.map +1 -0
- package/dist/api/GraphAPI.js +210 -0
- package/dist/api/GuaranteeAPI.d.ts +147 -0
- package/dist/api/GuaranteeAPI.d.ts.map +1 -0
- package/dist/api/GuaranteeAPI.js +288 -0
- package/dist/core/ASTWorker.d.ts +133 -0
- package/dist/core/ASTWorker.d.ts.map +1 -0
- package/dist/core/ASTWorker.js +352 -0
- package/dist/core/ASTWorkerPool.d.ts +85 -0
- package/dist/core/ASTWorkerPool.d.ts.map +1 -0
- package/dist/core/ASTWorkerPool.js +207 -0
- package/dist/core/AnalysisQueue.d.ts +104 -0
- package/dist/core/AnalysisQueue.d.ts.map +1 -0
- package/dist/core/AnalysisQueue.js +299 -0
- package/dist/core/AnalysisWorker.d.ts +14 -0
- package/dist/core/AnalysisWorker.d.ts.map +1 -0
- package/dist/core/AnalysisWorker.js +307 -0
- package/dist/core/GraphBackend.d.ts +156 -0
- package/dist/core/GraphBackend.d.ts.map +1 -0
- package/dist/core/GraphBackend.js +85 -0
- package/dist/core/GuaranteeManager.d.ts +230 -0
- package/dist/core/GuaranteeManager.d.ts.map +1 -0
- package/dist/core/GuaranteeManager.js +352 -0
- package/dist/core/ManifestStore.d.ts +71 -0
- package/dist/core/ManifestStore.d.ts.map +1 -0
- package/dist/core/ManifestStore.js +146 -0
- package/dist/core/NodeFactory.d.ts +160 -0
- package/dist/core/NodeFactory.d.ts.map +1 -0
- package/dist/core/NodeFactory.js +137 -0
- package/dist/core/NodeId.d.ts +88 -0
- package/dist/core/NodeId.d.ts.map +1 -0
- package/dist/core/NodeId.js +170 -0
- package/dist/core/ParallelAnalyzer.d.ts +120 -0
- package/dist/core/ParallelAnalyzer.d.ts.map +1 -0
- package/dist/core/ParallelAnalyzer.js +331 -0
- package/dist/core/PriorityQueue.d.ts +106 -0
- package/dist/core/PriorityQueue.d.ts.map +1 -0
- package/dist/core/PriorityQueue.js +168 -0
- package/dist/core/Profiler.d.ts +75 -0
- package/dist/core/Profiler.d.ts.map +1 -0
- package/dist/core/Profiler.js +149 -0
- package/dist/core/QueueWorker.d.ts +12 -0
- package/dist/core/QueueWorker.d.ts.map +1 -0
- package/dist/core/QueueWorker.js +567 -0
- package/dist/core/RFDBClient.d.ts +179 -0
- package/dist/core/RFDBClient.d.ts.map +1 -0
- package/dist/core/RFDBClient.js +429 -0
- package/dist/core/Task.d.ts +56 -0
- package/dist/core/Task.d.ts.map +1 -0
- package/dist/core/Task.js +85 -0
- package/dist/core/TaskTypes.d.ts +20 -0
- package/dist/core/TaskTypes.d.ts.map +1 -0
- package/dist/core/TaskTypes.js +10 -0
- package/dist/core/VersionManager.d.ts +166 -0
- package/dist/core/VersionManager.d.ts.map +1 -0
- package/dist/core/VersionManager.js +237 -0
- package/dist/core/WorkerPool.d.ts +82 -0
- package/dist/core/WorkerPool.d.ts.map +1 -0
- package/dist/core/WorkerPool.js +109 -0
- package/dist/core/nodes/CallSiteNode.d.ts +26 -0
- package/dist/core/nodes/CallSiteNode.d.ts.map +1 -0
- package/dist/core/nodes/CallSiteNode.js +44 -0
- package/dist/core/nodes/ClassNode.d.ts +25 -0
- package/dist/core/nodes/ClassNode.d.ts.map +1 -0
- package/dist/core/nodes/ClassNode.js +40 -0
- package/dist/core/nodes/ConstantNode.d.ts +24 -0
- package/dist/core/nodes/ConstantNode.d.ts.map +1 -0
- package/dist/core/nodes/ConstantNode.js +39 -0
- package/dist/core/nodes/DatabaseQueryNode.d.ts +22 -0
- package/dist/core/nodes/DatabaseQueryNode.d.ts.map +1 -0
- package/dist/core/nodes/DatabaseQueryNode.js +37 -0
- package/dist/core/nodes/EntrypointNode.d.ts +102 -0
- package/dist/core/nodes/EntrypointNode.d.ts.map +1 -0
- package/dist/core/nodes/EntrypointNode.js +119 -0
- package/dist/core/nodes/EventListenerNode.d.ts +25 -0
- package/dist/core/nodes/EventListenerNode.d.ts.map +1 -0
- package/dist/core/nodes/EventListenerNode.js +39 -0
- package/dist/core/nodes/ExportNode.d.ts +26 -0
- package/dist/core/nodes/ExportNode.d.ts.map +1 -0
- package/dist/core/nodes/ExportNode.js +40 -0
- package/dist/core/nodes/ExternalStdioNode.d.ts +17 -0
- package/dist/core/nodes/ExternalStdioNode.d.ts.map +1 -0
- package/dist/core/nodes/ExternalStdioNode.js +26 -0
- package/dist/core/nodes/FunctionNode.d.ts +27 -0
- package/dist/core/nodes/FunctionNode.d.ts.map +1 -0
- package/dist/core/nodes/FunctionNode.js +53 -0
- package/dist/core/nodes/GuaranteeNode.d.ts +76 -0
- package/dist/core/nodes/GuaranteeNode.d.ts.map +1 -0
- package/dist/core/nodes/GuaranteeNode.js +117 -0
- package/dist/core/nodes/HttpRequestNode.d.ts +24 -0
- package/dist/core/nodes/HttpRequestNode.d.ts.map +1 -0
- package/dist/core/nodes/HttpRequestNode.js +38 -0
- package/dist/core/nodes/ImportNode.d.ts +27 -0
- package/dist/core/nodes/ImportNode.d.ts.map +1 -0
- package/dist/core/nodes/ImportNode.js +43 -0
- package/dist/core/nodes/LiteralNode.d.ts +26 -0
- package/dist/core/nodes/LiteralNode.d.ts.map +1 -0
- package/dist/core/nodes/LiteralNode.js +40 -0
- package/dist/core/nodes/MethodCallNode.d.ts +29 -0
- package/dist/core/nodes/MethodCallNode.d.ts.map +1 -0
- package/dist/core/nodes/MethodCallNode.js +47 -0
- package/dist/core/nodes/MethodNode.d.ts +29 -0
- package/dist/core/nodes/MethodNode.d.ts.map +1 -0
- package/dist/core/nodes/MethodNode.js +44 -0
- package/dist/core/nodes/ModuleNode.d.ts +29 -0
- package/dist/core/nodes/ModuleNode.d.ts.map +1 -0
- package/dist/core/nodes/ModuleNode.js +49 -0
- package/dist/core/nodes/NodeKind.d.ts +91 -0
- package/dist/core/nodes/NodeKind.d.ts.map +1 -0
- package/dist/core/nodes/NodeKind.js +146 -0
- package/dist/core/nodes/ParameterNode.d.ts +26 -0
- package/dist/core/nodes/ParameterNode.d.ts.map +1 -0
- package/dist/core/nodes/ParameterNode.js +43 -0
- package/dist/core/nodes/ScopeNode.d.ts +32 -0
- package/dist/core/nodes/ScopeNode.d.ts.map +1 -0
- package/dist/core/nodes/ScopeNode.js +47 -0
- package/dist/core/nodes/ServiceNode.d.ts +44 -0
- package/dist/core/nodes/ServiceNode.d.ts.map +1 -0
- package/dist/core/nodes/ServiceNode.js +49 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts +22 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts.map +1 -0
- package/dist/core/nodes/VariableDeclarationNode.js +38 -0
- package/dist/core/nodes/index.d.ts +25 -0
- package/dist/core/nodes/index.d.ts.map +1 -0
- package/dist/core/nodes/index.js +30 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/plugins/Plugin.d.ts +44 -0
- package/dist/plugins/Plugin.d.ts.map +1 -0
- package/dist/plugins/Plugin.js +46 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.d.ts +23 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.js +260 -0
- package/dist/plugins/analysis/ExpressAnalyzer.d.ts +19 -0
- package/dist/plugins/analysis/ExpressAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ExpressAnalyzer.js +306 -0
- package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts +17 -0
- package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ExpressRouteAnalyzer.js +308 -0
- package/dist/plugins/analysis/FetchAnalyzer.d.ts +38 -0
- package/dist/plugins/analysis/FetchAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/FetchAnalyzer.js +344 -0
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts +65 -0
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts.map +1 -0
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.js +472 -0
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts +84 -0
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/JSASTAnalyzer.js +1378 -0
- package/dist/plugins/analysis/ReactAnalyzer.d.ts +90 -0
- package/dist/plugins/analysis/ReactAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ReactAnalyzer.js +1153 -0
- package/dist/plugins/analysis/RustAnalyzer.d.ts +13 -0
- package/dist/plugins/analysis/RustAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/RustAnalyzer.js +259 -0
- package/dist/plugins/analysis/SQLiteAnalyzer.d.ts +21 -0
- package/dist/plugins/analysis/SQLiteAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/SQLiteAnalyzer.js +317 -0
- package/dist/plugins/analysis/ServiceLayerAnalyzer.d.ts +35 -0
- package/dist/plugins/analysis/ServiceLayerAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ServiceLayerAnalyzer.js +303 -0
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts +33 -0
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/SocketIOAnalyzer.js +283 -0
- package/dist/plugins/analysis/SystemDbAnalyzer.d.ts +27 -0
- package/dist/plugins/analysis/SystemDbAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/SystemDbAnalyzer.js +211 -0
- package/dist/plugins/analysis/ast/ConditionParser.d.ts +85 -0
- package/dist/plugins/analysis/ast/ConditionParser.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/ConditionParser.js +277 -0
- package/dist/plugins/analysis/ast/ExpressionEvaluator.d.ts +15 -0
- package/dist/plugins/analysis/ast/ExpressionEvaluator.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/ExpressionEvaluator.js +91 -0
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts +77 -0
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/GraphBuilder.js +1077 -0
- package/dist/plugins/analysis/ast/OxcAdapter.d.ts +41 -0
- package/dist/plugins/analysis/ast/OxcAdapter.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/OxcAdapter.js +40 -0
- package/dist/plugins/analysis/ast/types.d.ts +346 -0
- package/dist/plugins/analysis/ast/types.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/types.js +4 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts +93 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.js +24 -0
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts +77 -0
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.js +377 -0
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts +27 -0
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.js +232 -0
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts +25 -0
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.js +172 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts +29 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.js +180 -0
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts +14 -0
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.js +200 -0
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts +45 -0
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.js +150 -0
- package/dist/plugins/analysis/ast/visitors/index.d.ts +17 -0
- package/dist/plugins/analysis/ast/visitors/index.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/index.js +13 -0
- package/dist/plugins/discovery/DiscoveryPlugin.d.ts +34 -0
- package/dist/plugins/discovery/DiscoveryPlugin.d.ts.map +1 -0
- package/dist/plugins/discovery/DiscoveryPlugin.js +26 -0
- package/dist/plugins/discovery/MonorepoServiceDiscovery.d.ts +26 -0
- package/dist/plugins/discovery/MonorepoServiceDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/MonorepoServiceDiscovery.js +79 -0
- package/dist/plugins/discovery/SimpleProjectDiscovery.d.ts +14 -0
- package/dist/plugins/discovery/SimpleProjectDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/SimpleProjectDiscovery.js +65 -0
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts +19 -0
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/ZonServiceDiscovery.js +204 -0
- package/dist/plugins/enrichment/AliasTracker.d.ts +40 -0
- package/dist/plugins/enrichment/AliasTracker.d.ts.map +1 -0
- package/dist/plugins/enrichment/AliasTracker.js +290 -0
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts +30 -0
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts.map +1 -0
- package/dist/plugins/enrichment/HTTPConnectionEnricher.js +135 -0
- package/dist/plugins/enrichment/ImportExportLinker.d.ts +30 -0
- package/dist/plugins/enrichment/ImportExportLinker.d.ts.map +1 -0
- package/dist/plugins/enrichment/ImportExportLinker.js +176 -0
- package/dist/plugins/enrichment/InstanceOfResolver.d.ts +21 -0
- package/dist/plugins/enrichment/InstanceOfResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/InstanceOfResolver.js +117 -0
- package/dist/plugins/enrichment/MethodCallResolver.d.ts +41 -0
- package/dist/plugins/enrichment/MethodCallResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/MethodCallResolver.js +252 -0
- package/dist/plugins/enrichment/MountPointResolver.d.ts +26 -0
- package/dist/plugins/enrichment/MountPointResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/MountPointResolver.js +189 -0
- package/dist/plugins/enrichment/PrefixEvaluator.d.ts +89 -0
- package/dist/plugins/enrichment/PrefixEvaluator.d.ts.map +1 -0
- package/dist/plugins/enrichment/PrefixEvaluator.js +415 -0
- package/dist/plugins/enrichment/RustFFIEnricher.d.ts +25 -0
- package/dist/plugins/enrichment/RustFFIEnricher.d.ts.map +1 -0
- package/dist/plugins/enrichment/RustFFIEnricher.js +170 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts +114 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts.map +1 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.js +464 -0
- package/dist/plugins/indexing/IncrementalModuleIndexer.d.ts +27 -0
- package/dist/plugins/indexing/IncrementalModuleIndexer.d.ts.map +1 -0
- package/dist/plugins/indexing/IncrementalModuleIndexer.js +238 -0
- package/dist/plugins/indexing/JSModuleIndexer.d.ts +33 -0
- package/dist/plugins/indexing/JSModuleIndexer.d.ts.map +1 -0
- package/dist/plugins/indexing/JSModuleIndexer.js +299 -0
- package/dist/plugins/indexing/RustModuleIndexer.d.ts +28 -0
- package/dist/plugins/indexing/RustModuleIndexer.d.ts.map +1 -0
- package/dist/plugins/indexing/RustModuleIndexer.js +140 -0
- package/dist/plugins/indexing/ServiceDetector.d.ts +46 -0
- package/dist/plugins/indexing/ServiceDetector.d.ts.map +1 -0
- package/dist/plugins/indexing/ServiceDetector.js +164 -0
- package/dist/plugins/validation/CallResolverValidator.d.ts +23 -0
- package/dist/plugins/validation/CallResolverValidator.d.ts.map +1 -0
- package/dist/plugins/validation/CallResolverValidator.js +108 -0
- package/dist/plugins/validation/DataFlowValidator.d.ts +24 -0
- package/dist/plugins/validation/DataFlowValidator.d.ts.map +1 -0
- package/dist/plugins/validation/DataFlowValidator.js +148 -0
- package/dist/plugins/validation/EvalBanValidator.d.ts +25 -0
- package/dist/plugins/validation/EvalBanValidator.d.ts.map +1 -0
- package/dist/plugins/validation/EvalBanValidator.js +123 -0
- package/dist/plugins/validation/GraphConnectivityValidator.d.ts +11 -0
- package/dist/plugins/validation/GraphConnectivityValidator.d.ts.map +1 -0
- package/dist/plugins/validation/GraphConnectivityValidator.js +135 -0
- package/dist/plugins/validation/SQLInjectionValidator.d.ts +43 -0
- package/dist/plugins/validation/SQLInjectionValidator.d.ts.map +1 -0
- package/dist/plugins/validation/SQLInjectionValidator.js +251 -0
- package/dist/plugins/validation/ShadowingDetector.d.ts +26 -0
- package/dist/plugins/validation/ShadowingDetector.d.ts.map +1 -0
- package/dist/plugins/validation/ShadowingDetector.js +119 -0
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.d.ts +21 -0
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.d.ts.map +1 -0
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.js +151 -0
- package/dist/plugins/vcs/GitPlugin.d.ts +84 -0
- package/dist/plugins/vcs/GitPlugin.d.ts.map +1 -0
- package/dist/plugins/vcs/GitPlugin.js +295 -0
- package/dist/plugins/vcs/VCSPlugin.d.ts +133 -0
- package/dist/plugins/vcs/VCSPlugin.d.ts.map +1 -0
- package/dist/plugins/vcs/VCSPlugin.js +82 -0
- package/dist/plugins/vcs/index.d.ts +10 -0
- package/dist/plugins/vcs/index.d.ts.map +1 -0
- package/dist/plugins/vcs/index.js +18 -0
- package/dist/storage/backends/RFDBServerBackend.d.ts +258 -0
- package/dist/storage/backends/RFDBServerBackend.d.ts.map +1 -0
- package/dist/storage/backends/RFDBServerBackend.js +565 -0
- package/dist/storage/backends/typeValidation.d.ts +47 -0
- package/dist/storage/backends/typeValidation.d.ts.map +1 -0
- package/dist/storage/backends/typeValidation.js +137 -0
- package/dist/validation/PathValidator.d.ts +81 -0
- package/dist/validation/PathValidator.d.ts.map +1 -0
- package/dist/validation/PathValidator.js +251 -0
- package/package.json +57 -0
- package/src/.rfguard/current-session.txt +1 -0
- package/src/Orchestrator.ts +673 -0
- package/src/api/GraphAPI.ts +305 -0
- package/src/api/GuaranteeAPI.ts +401 -0
- package/src/core/ASTWorker.ts +567 -0
- package/src/core/ASTWorkerPool.ts +299 -0
- package/src/core/AnalysisQueue.ts +447 -0
- package/src/core/AnalysisWorker.ts +410 -0
- package/src/core/GraphBackend.ts +265 -0
- package/src/core/GuaranteeManager.ts +581 -0
- package/src/core/ManifestStore.ts +196 -0
- package/src/core/NodeFactory.ts +274 -0
- package/src/core/NodeId.ts +257 -0
- package/src/core/ParallelAnalyzer.ts +476 -0
- package/src/core/PriorityQueue.ts +227 -0
- package/src/core/Profiler.ts +188 -0
- package/src/core/QueueWorker.ts +780 -0
- package/src/core/Task.ts +107 -0
- package/src/core/TaskTypes.ts +40 -0
- package/src/core/VersionManager.ts +404 -0
- package/src/core/WorkerPool.ts +180 -0
- package/src/core/nodes/CallSiteNode.ts +72 -0
- package/src/core/nodes/ClassNode.ts +69 -0
- package/src/core/nodes/ConstantNode.ts +63 -0
- package/src/core/nodes/DatabaseQueryNode.ts +60 -0
- package/src/core/nodes/EntrypointNode.ts +164 -0
- package/src/core/nodes/EventListenerNode.ts +64 -0
- package/src/core/nodes/ExportNode.ts +71 -0
- package/src/core/nodes/ExternalStdioNode.ts +36 -0
- package/src/core/nodes/FunctionNode.ts +78 -0
- package/src/core/nodes/GuaranteeNode.ts +162 -0
- package/src/core/nodes/HttpRequestNode.ts +63 -0
- package/src/core/nodes/ImportNode.ts +75 -0
- package/src/core/nodes/LiteralNode.ts +67 -0
- package/src/core/nodes/MethodCallNode.ts +79 -0
- package/src/core/nodes/MethodNode.ts +78 -0
- package/src/core/nodes/ModuleNode.ts +74 -0
- package/src/core/nodes/NodeKind.ts +171 -0
- package/src/core/nodes/ParameterNode.ts +73 -0
- package/src/core/nodes/ScopeNode.ts +80 -0
- package/src/core/nodes/ServiceNode.ts +86 -0
- package/src/core/nodes/VariableDeclarationNode.ts +60 -0
- package/src/core/nodes/index.ts +49 -0
- package/src/index.ts +93 -0
- package/src/plugins/Plugin.ts +74 -0
- package/src/plugins/analysis/DatabaseAnalyzer.ts +322 -0
- package/src/plugins/analysis/ExpressAnalyzer.ts +401 -0
- package/src/plugins/analysis/ExpressRouteAnalyzer.ts +414 -0
- package/src/plugins/analysis/FetchAnalyzer.ts +441 -0
- package/src/plugins/analysis/IncrementalAnalysisPlugin.ts +686 -0
- package/src/plugins/analysis/JSASTAnalyzer.ts +1680 -0
- package/src/plugins/analysis/ReactAnalyzer.ts +1368 -0
- package/src/plugins/analysis/RustAnalyzer.ts +438 -0
- package/src/plugins/analysis/SQLiteAnalyzer.ts +388 -0
- package/src/plugins/analysis/ServiceLayerAnalyzer.ts +429 -0
- package/src/plugins/analysis/SocketIOAnalyzer.ts +395 -0
- package/src/plugins/analysis/SystemDbAnalyzer.ts +284 -0
- package/src/plugins/analysis/ast/ConditionParser.ts +333 -0
- package/src/plugins/analysis/ast/ExpressionEvaluator.ts +117 -0
- package/src/plugins/analysis/ast/GraphBuilder.ts +1371 -0
- package/src/plugins/analysis/ast/OxcAdapter.ts +63 -0
- package/src/plugins/analysis/ast/types.ts +400 -0
- package/src/plugins/analysis/ast/visitors/ASTVisitor.ts +137 -0
- package/src/plugins/analysis/ast/visitors/CallExpressionVisitor.ts +528 -0
- package/src/plugins/analysis/ast/visitors/ClassVisitor.ts +339 -0
- package/src/plugins/analysis/ast/visitors/FunctionVisitor.ts +273 -0
- package/src/plugins/analysis/ast/visitors/ImportExportVisitor.ts +259 -0
- package/src/plugins/analysis/ast/visitors/TypeScriptVisitor.ts +235 -0
- package/src/plugins/analysis/ast/visitors/VariableVisitor.ts +268 -0
- package/src/plugins/analysis/ast/visitors/index.ts +36 -0
- package/src/plugins/discovery/DiscoveryPlugin.ts +50 -0
- package/src/plugins/discovery/MonorepoServiceDiscovery.ts +117 -0
- package/src/plugins/discovery/SimpleProjectDiscovery.ts +102 -0
- package/src/plugins/enrichment/AliasTracker.ts +399 -0
- package/src/plugins/enrichment/HTTPConnectionEnricher.ts +192 -0
- package/src/plugins/enrichment/ImportExportLinker.ts +221 -0
- package/src/plugins/enrichment/InstanceOfResolver.ts +165 -0
- package/src/plugins/enrichment/MethodCallResolver.ts +333 -0
- package/src/plugins/enrichment/MountPointResolver.ts +264 -0
- package/src/plugins/enrichment/PrefixEvaluator.ts +527 -0
- package/src/plugins/enrichment/RustFFIEnricher.ts +218 -0
- package/src/plugins/enrichment/ValueDomainAnalyzer.ts +682 -0
- package/src/plugins/indexing/IncrementalModuleIndexer.ts +287 -0
- package/src/plugins/indexing/JSModuleIndexer.ts +374 -0
- package/src/plugins/indexing/RustModuleIndexer.ts +160 -0
- package/src/plugins/indexing/ServiceDetector.ts +230 -0
- package/src/plugins/validation/CallResolverValidator.ts +170 -0
- package/src/plugins/validation/DataFlowValidator.ts +233 -0
- package/src/plugins/validation/EvalBanValidator.ts +175 -0
- package/src/plugins/validation/GraphConnectivityValidator.ts +201 -0
- package/src/plugins/validation/SQLInjectionValidator.ts +363 -0
- package/src/plugins/validation/ShadowingDetector.ts +173 -0
- package/src/plugins/validation/TypeScriptDeadCodeValidator.ts +203 -0
- package/src/plugins/vcs/GitPlugin.ts +344 -0
- package/src/plugins/vcs/VCSPlugin.ts +190 -0
- package/src/plugins/vcs/index.ts +32 -0
- package/src/storage/backends/RFDBServerBackend.ts +687 -0
- package/src/storage/backends/typeValidation.ts +151 -0
- package/src/validation/PathValidator.ts +342 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IncrementalModuleIndexer - индексирует модули по требованию через очередь
|
|
3
|
+
* Стартует с entry файла, затем анализирует импорты и добавляет новые файлы в очередь
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync, existsSync } from 'fs';
|
|
6
|
+
import { join, dirname, resolve, extname, relative } from 'path';
|
|
7
|
+
import { createHash } from 'crypto';
|
|
8
|
+
import { parse } from '@babel/parser';
|
|
9
|
+
import traverseModule from '@babel/traverse';
|
|
10
|
+
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
const traverse = traverseModule.default || traverseModule;
|
|
13
|
+
export class IncrementalModuleIndexer extends Plugin {
|
|
14
|
+
get metadata() {
|
|
15
|
+
return {
|
|
16
|
+
name: 'IncrementalModuleIndexer',
|
|
17
|
+
phase: 'INDEXING',
|
|
18
|
+
priority: 90,
|
|
19
|
+
creates: {
|
|
20
|
+
nodes: ['MODULE'],
|
|
21
|
+
edges: ['CONTAINS', 'IMPORTS_FROM']
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolve module path from import
|
|
27
|
+
*/
|
|
28
|
+
resolveModule(fromFile, importPath, projectRoot) {
|
|
29
|
+
// Absolute path (starts with /)
|
|
30
|
+
if (importPath.startsWith('/')) {
|
|
31
|
+
const fullPath = join(projectRoot, importPath);
|
|
32
|
+
return this.tryResolve(fullPath);
|
|
33
|
+
}
|
|
34
|
+
// Relative path (starts with . or ..)
|
|
35
|
+
if (importPath.startsWith('.')) {
|
|
36
|
+
const fromDir = dirname(fromFile);
|
|
37
|
+
const resolved = resolve(fromDir, importPath);
|
|
38
|
+
return this.tryResolve(resolved);
|
|
39
|
+
}
|
|
40
|
+
// Bare specifier (could be alias inside monorepo, e.g. pkg/svc/...)
|
|
41
|
+
// Heuristic: if it contains a slash and not "node_modules" treat as project-root relative
|
|
42
|
+
if (importPath.includes('/') && !importPath.startsWith('node:')) {
|
|
43
|
+
const candidate = join(projectRoot, importPath);
|
|
44
|
+
const resolved = this.tryResolve(candidate);
|
|
45
|
+
if (resolved)
|
|
46
|
+
return resolved;
|
|
47
|
+
}
|
|
48
|
+
// node builtin or unresolved external - skip for incremental indexing
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Try to resolve file with different extensions
|
|
53
|
+
*/
|
|
54
|
+
tryResolve(basePath) {
|
|
55
|
+
if (existsSync(basePath)) {
|
|
56
|
+
if (!extname(basePath)) {
|
|
57
|
+
// Try as directory with index.js
|
|
58
|
+
const indexPath = join(basePath, 'index.js');
|
|
59
|
+
if (existsSync(indexPath))
|
|
60
|
+
return indexPath;
|
|
61
|
+
// Try adding .js
|
|
62
|
+
if (existsSync(basePath + '.js'))
|
|
63
|
+
return basePath + '.js';
|
|
64
|
+
}
|
|
65
|
+
return basePath;
|
|
66
|
+
}
|
|
67
|
+
// Try with .js extension
|
|
68
|
+
if (existsSync(basePath + '.js'))
|
|
69
|
+
return basePath + '.js';
|
|
70
|
+
// Try as directory
|
|
71
|
+
const indexPath = join(basePath, 'index.js');
|
|
72
|
+
if (existsSync(indexPath))
|
|
73
|
+
return indexPath;
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Calculate file hash
|
|
78
|
+
*/
|
|
79
|
+
calculateFileHash(filePath) {
|
|
80
|
+
try {
|
|
81
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
82
|
+
return createHash('sha256').update(content).digest('hex');
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Parse imports from file
|
|
90
|
+
*/
|
|
91
|
+
parseImports(filePath, projectRoot) {
|
|
92
|
+
try {
|
|
93
|
+
const code = readFileSync(filePath, 'utf-8');
|
|
94
|
+
const ast = parse(code, {
|
|
95
|
+
sourceType: 'module',
|
|
96
|
+
plugins: ['jsx', 'typescript'],
|
|
97
|
+
errorRecovery: true
|
|
98
|
+
});
|
|
99
|
+
const imports = [];
|
|
100
|
+
traverse(ast, {
|
|
101
|
+
ImportDeclaration: (path) => {
|
|
102
|
+
const importPath = path.node.source.value;
|
|
103
|
+
const resolved = this.resolveModule(filePath, importPath, projectRoot);
|
|
104
|
+
if (resolved) {
|
|
105
|
+
imports.push(resolved);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
CallExpression: (path) => {
|
|
109
|
+
if (path.node.callee.name === 'require' &&
|
|
110
|
+
path.node.arguments[0]?.type === 'StringLiteral') {
|
|
111
|
+
const importPath = path.node.arguments[0].value;
|
|
112
|
+
const resolved = this.resolveModule(filePath, importPath, projectRoot);
|
|
113
|
+
if (resolved) {
|
|
114
|
+
imports.push(resolved);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return imports;
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
console.error(` ⚠️ Failed to parse imports from ${relative(projectRoot, filePath)}: ${err.message}`);
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async execute(context) {
|
|
127
|
+
try {
|
|
128
|
+
const { manifest, graph } = context;
|
|
129
|
+
// Cast manifest to expected shape
|
|
130
|
+
const typedManifest = manifest;
|
|
131
|
+
const { projectPath, service, entryFile } = typedManifest;
|
|
132
|
+
if (!entryFile) {
|
|
133
|
+
throw new Error('IncrementalModuleIndexer requires entryFile in manifest');
|
|
134
|
+
}
|
|
135
|
+
const queue = [entryFile];
|
|
136
|
+
const processed = new Set();
|
|
137
|
+
const pendingImports = []; // Store imports to create edges after all nodes exist
|
|
138
|
+
let nodesCreated = 0;
|
|
139
|
+
let edgesCreated = 0;
|
|
140
|
+
let totalImportsParsed = 0;
|
|
141
|
+
let unresolvedImports = 0;
|
|
142
|
+
console.log(`📦 Starting incremental indexing from: ${relative(projectPath, entryFile)}\n`);
|
|
143
|
+
while (queue.length > 0) {
|
|
144
|
+
const file = queue.shift();
|
|
145
|
+
if (processed.has(file))
|
|
146
|
+
continue;
|
|
147
|
+
processed.add(file);
|
|
148
|
+
// Create MODULE node
|
|
149
|
+
const fileHash = this.calculateFileHash(file);
|
|
150
|
+
const relativePath = relative(projectPath, file);
|
|
151
|
+
const moduleNode = {
|
|
152
|
+
id: `${file}:MODULE:${file}:0`,
|
|
153
|
+
type: 'MODULE',
|
|
154
|
+
name: relativePath,
|
|
155
|
+
file: file,
|
|
156
|
+
contentHash: fileHash
|
|
157
|
+
};
|
|
158
|
+
await graph.addNode(moduleNode);
|
|
159
|
+
nodesCreated++;
|
|
160
|
+
// Link to SERVICE
|
|
161
|
+
await graph.addEdge({
|
|
162
|
+
src: service.id,
|
|
163
|
+
dst: moduleNode.id,
|
|
164
|
+
type: 'CONTAINS',
|
|
165
|
+
version: 'main'
|
|
166
|
+
});
|
|
167
|
+
edgesCreated++;
|
|
168
|
+
// Parse imports and add to queue
|
|
169
|
+
const imports = this.parseImports(file, projectPath);
|
|
170
|
+
totalImportsParsed += imports.length;
|
|
171
|
+
for (const importFile of imports) {
|
|
172
|
+
// Store for later edge creation
|
|
173
|
+
pendingImports.push({
|
|
174
|
+
src: moduleNode.id,
|
|
175
|
+
dst: `${importFile}:MODULE:${importFile}:0`
|
|
176
|
+
});
|
|
177
|
+
if (!processed.has(importFile)) {
|
|
178
|
+
queue.push(importFile);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Simple unresolved import heuristic: look for raw import strings we failed to resolve
|
|
182
|
+
// Re-parse quickly and count any that did not get resolved (debug aid)
|
|
183
|
+
try {
|
|
184
|
+
const code = readFileSync(file, 'utf-8');
|
|
185
|
+
const ast = parse(code, {
|
|
186
|
+
sourceType: 'module',
|
|
187
|
+
plugins: ['jsx', 'typescript'],
|
|
188
|
+
errorRecovery: true
|
|
189
|
+
});
|
|
190
|
+
traverse(ast, {
|
|
191
|
+
ImportDeclaration: (p) => {
|
|
192
|
+
const ip = p.node.source.value;
|
|
193
|
+
const isResolved = this.resolveModule(file, ip, projectPath);
|
|
194
|
+
if (!isResolved)
|
|
195
|
+
unresolvedImports++;
|
|
196
|
+
},
|
|
197
|
+
CallExpression: (p) => {
|
|
198
|
+
if (p.node.callee.name === 'require' &&
|
|
199
|
+
p.node.arguments[0]?.type === 'StringLiteral') {
|
|
200
|
+
const ip = p.node.arguments[0].value;
|
|
201
|
+
const isResolved = this.resolveModule(file, ip, projectPath);
|
|
202
|
+
if (!isResolved)
|
|
203
|
+
unresolvedImports++;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
// Ignore parse errors for unresolved count
|
|
210
|
+
}
|
|
211
|
+
if (processed.size % 10 === 0) {
|
|
212
|
+
process.stdout.write(`\r 📦 Indexed ${processed.size} modules (${queue.length} in queue)...`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
console.log(`\r ✅ Indexed ${processed.size} modules\n`);
|
|
216
|
+
console.log(` 📥 Parsed ${totalImportsParsed} import specifiers (unresolved: ${unresolvedImports})`);
|
|
217
|
+
console.log(` 🔗 Pending IMPORTS edges to create: ${pendingImports.length}\n`);
|
|
218
|
+
console.log(` 📊 Creating IMPORTS edges...\n`);
|
|
219
|
+
// Now create all IMPORTS edges after all MODULE nodes exist
|
|
220
|
+
for (const { src, dst } of pendingImports) {
|
|
221
|
+
await graph.addEdge({
|
|
222
|
+
src,
|
|
223
|
+
dst,
|
|
224
|
+
type: 'IMPORTS',
|
|
225
|
+
version: 'main'
|
|
226
|
+
});
|
|
227
|
+
edgesCreated++;
|
|
228
|
+
}
|
|
229
|
+
console.log(` 📊 Created ${nodesCreated} MODULE nodes and ${edgesCreated} edges`);
|
|
230
|
+
console.log(` 📈 IMPORTS edges created: ${pendingImports.length}\n`);
|
|
231
|
+
return createSuccessResult({ nodes: nodesCreated, edges: edgesCreated }, { filesScanned: processed.size });
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
console.error(`[IncrementalModuleIndexer] Error:`, error);
|
|
235
|
+
return createErrorResult(error);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSModuleIndexer - плагин для индексации JavaScript/TypeScript модулей
|
|
3
|
+
* Строит дерево зависимостей от entrypoint через DFS (как в file2host.js)
|
|
4
|
+
*/
|
|
5
|
+
import { Plugin } from '../Plugin.js';
|
|
6
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
7
|
+
export declare class JSModuleIndexer extends Plugin {
|
|
8
|
+
private walker;
|
|
9
|
+
private cache;
|
|
10
|
+
private testPatterns;
|
|
11
|
+
private markTestFiles;
|
|
12
|
+
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Check if file is a test file based on path patterns
|
|
15
|
+
*/
|
|
16
|
+
private isTestFile;
|
|
17
|
+
get metadata(): PluginMetadata;
|
|
18
|
+
private calculateFileHash;
|
|
19
|
+
/**
|
|
20
|
+
* Парсит файл и извлекает все зависимости:
|
|
21
|
+
* - require('...')
|
|
22
|
+
* - import ... from '...'
|
|
23
|
+
* - export * from '...'
|
|
24
|
+
* - export { ... } from '...'
|
|
25
|
+
*/
|
|
26
|
+
private processFile;
|
|
27
|
+
/**
|
|
28
|
+
* Резолвит путь к модулю (добавляет .js/.ts если нужно)
|
|
29
|
+
*/
|
|
30
|
+
private resolveModulePath;
|
|
31
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=JSModuleIndexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSModuleIndexer.d.ts","sourceRoot":"","sources":["../../../src/plugins/indexing/JSModuleIndexer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,MAAM,EAA0C,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA2DhF,qBAAa,eAAgB,SAAQ,MAAM;IACzC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,YAAY,CAAW;IAC/B,OAAO,CAAC,aAAa,CAAU;;IAU/B;;OAEG;IACH,OAAO,CAAC,UAAU;IAKlB,IAAI,QAAQ,IAAI,cAAc,CAU7B;IAED,OAAO,CAAC,iBAAiB;IASzB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAuEnB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAiBnB,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CAoK7D"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSModuleIndexer - плагин для индексации JavaScript/TypeScript модулей
|
|
3
|
+
* Строит дерево зависимостей от entrypoint через DFS (как в file2host.js)
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync, existsSync } from 'fs';
|
|
6
|
+
import { join, resolve, dirname } from 'path';
|
|
7
|
+
import { createHash } from 'crypto';
|
|
8
|
+
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
9
|
+
// @ts-expect-error - no type declarations for node-source-walk
|
|
10
|
+
import Walker from 'node-source-walk';
|
|
11
|
+
import { NodeFactory } from '../../core/NodeFactory.js';
|
|
12
|
+
// Test file patterns (can be overridden in config)
|
|
13
|
+
const DEFAULT_TEST_PATTERNS = [
|
|
14
|
+
/[/\\]test[/\\]/, // /test/
|
|
15
|
+
/[/\\]tests[/\\]/, // /tests/
|
|
16
|
+
/[/\\]__tests__[/\\]/, // /__tests__/
|
|
17
|
+
/[/\\]spec[/\\]/, // /spec/
|
|
18
|
+
/\.test\.[jt]sx?$/, // .test.js, .test.ts, .test.jsx, .test.tsx
|
|
19
|
+
/\.spec\.[jt]sx?$/, // .spec.js, .spec.ts, .spec.jsx, .spec.tsx
|
|
20
|
+
/_test\.[jt]sx?$/, // _test.js (Go-style)
|
|
21
|
+
/[/\\]fixtures?[/\\]/, // /fixture/ or /fixtures/
|
|
22
|
+
];
|
|
23
|
+
export class JSModuleIndexer extends Plugin {
|
|
24
|
+
walker;
|
|
25
|
+
cache;
|
|
26
|
+
testPatterns;
|
|
27
|
+
markTestFiles;
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
this.walker = new Walker();
|
|
31
|
+
this.cache = new Map(); // Кеш зависимостей файла
|
|
32
|
+
this.testPatterns = DEFAULT_TEST_PATTERNS;
|
|
33
|
+
this.markTestFiles = true; // Default: enabled
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Check if file is a test file based on path patterns
|
|
37
|
+
*/
|
|
38
|
+
isTestFile(filePath) {
|
|
39
|
+
if (!this.markTestFiles)
|
|
40
|
+
return false;
|
|
41
|
+
return this.testPatterns.some(pattern => pattern.test(filePath));
|
|
42
|
+
}
|
|
43
|
+
get metadata() {
|
|
44
|
+
return {
|
|
45
|
+
name: 'JSModuleIndexer',
|
|
46
|
+
phase: 'INDEXING',
|
|
47
|
+
priority: 90,
|
|
48
|
+
creates: {
|
|
49
|
+
nodes: ['MODULE'],
|
|
50
|
+
edges: ['CONTAINS', 'DEPENDS_ON']
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
calculateFileHash(filePath) {
|
|
55
|
+
try {
|
|
56
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
57
|
+
return createHash('sha256').update(content).digest('hex');
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Парсит файл и извлекает все зависимости:
|
|
65
|
+
* - require('...')
|
|
66
|
+
* - import ... from '...'
|
|
67
|
+
* - export * from '...'
|
|
68
|
+
* - export { ... } from '...'
|
|
69
|
+
*/
|
|
70
|
+
processFile(filePath, _projectPath) {
|
|
71
|
+
if (this.cache.has(filePath)) {
|
|
72
|
+
return this.cache.get(filePath);
|
|
73
|
+
}
|
|
74
|
+
const result = [];
|
|
75
|
+
let content;
|
|
76
|
+
let ast;
|
|
77
|
+
try {
|
|
78
|
+
if (!existsSync(filePath)) {
|
|
79
|
+
this.cache.set(filePath, new Error('ENOENT'));
|
|
80
|
+
return new Error('ENOENT');
|
|
81
|
+
}
|
|
82
|
+
content = readFileSync(filePath, 'utf-8');
|
|
83
|
+
ast = this.walker.parse(content);
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
if (filePath.endsWith('.json')) {
|
|
87
|
+
this.cache.set(filePath, []);
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
this.cache.set(filePath, new Error(e.message));
|
|
91
|
+
return new Error(e.message);
|
|
92
|
+
}
|
|
93
|
+
this.walker.traverse(ast, (node) => {
|
|
94
|
+
const isRequire = node.type === 'CallExpression' && node.callee?.name === 'require';
|
|
95
|
+
const isImport = node.type === 'ImportDeclaration';
|
|
96
|
+
// export * from './module.js'
|
|
97
|
+
const isExportAll = node.type === 'ExportAllDeclaration';
|
|
98
|
+
// export { foo } from './module.js'
|
|
99
|
+
const isExportNamed = node.type === 'ExportNamedDeclaration' && node.source;
|
|
100
|
+
if (!isRequire && !isImport && !isExportAll && !isExportNamed) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
let source;
|
|
104
|
+
if (isImport || isExportAll || isExportNamed) {
|
|
105
|
+
source = node.source;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
source = node.arguments?.[0];
|
|
109
|
+
}
|
|
110
|
+
if (!source || !['Identifier', 'StringLiteral'].includes(source.type)) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const name = source.value || source.name;
|
|
114
|
+
if (!name)
|
|
115
|
+
return;
|
|
116
|
+
// Игнорируем встроенные модули
|
|
117
|
+
if (name.startsWith('internal/')) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// Резолвим относительные пути
|
|
121
|
+
if (name.startsWith('.') || name.startsWith('/')) {
|
|
122
|
+
const dir = dirname(filePath);
|
|
123
|
+
const resolved = resolve(dir, name);
|
|
124
|
+
result.push(resolved);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
// npm пакет - помечаем специально
|
|
128
|
+
result.push(`package::${name}`);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
this.cache.set(filePath, result);
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Резолвит путь к модулю (добавляет .js/.ts если нужно)
|
|
136
|
+
*/
|
|
137
|
+
resolveModulePath(path) {
|
|
138
|
+
if (existsSync(path))
|
|
139
|
+
return path;
|
|
140
|
+
// Try JavaScript extensions
|
|
141
|
+
if (existsSync(path + '.js'))
|
|
142
|
+
return path + '.js';
|
|
143
|
+
if (existsSync(path + '.mjs'))
|
|
144
|
+
return path + '.mjs';
|
|
145
|
+
if (existsSync(path + '.jsx'))
|
|
146
|
+
return path + '.jsx';
|
|
147
|
+
// Try TypeScript extensions
|
|
148
|
+
if (existsSync(path + '.ts'))
|
|
149
|
+
return path + '.ts';
|
|
150
|
+
if (existsSync(path + '.tsx'))
|
|
151
|
+
return path + '.tsx';
|
|
152
|
+
// Try index files
|
|
153
|
+
if (existsSync(join(path, 'index.js')))
|
|
154
|
+
return join(path, 'index.js');
|
|
155
|
+
if (existsSync(join(path, 'index.ts')))
|
|
156
|
+
return join(path, 'index.ts');
|
|
157
|
+
if (existsSync(join(path, 'index.mjs')))
|
|
158
|
+
return join(path, 'index.mjs');
|
|
159
|
+
if (existsSync(join(path, 'index.tsx')))
|
|
160
|
+
return join(path, 'index.tsx');
|
|
161
|
+
return path;
|
|
162
|
+
}
|
|
163
|
+
async execute(context) {
|
|
164
|
+
try {
|
|
165
|
+
const { graph, onProgress, config } = context;
|
|
166
|
+
const manifest = context.manifest;
|
|
167
|
+
const projectPath = manifest?.projectPath ?? '';
|
|
168
|
+
const service = manifest?.service ?? { id: '', name: '', path: '' };
|
|
169
|
+
// Check config for test file marking
|
|
170
|
+
if (config?.analysis?.tests?.markTestFiles === false) {
|
|
171
|
+
this.markTestFiles = false;
|
|
172
|
+
}
|
|
173
|
+
const entrypoint = service.path;
|
|
174
|
+
// const pkgPath = join(projectPath, 'pkg');
|
|
175
|
+
// Резолвим entrypoint относительно projectPath
|
|
176
|
+
const absoluteEntrypoint = entrypoint.startsWith('/')
|
|
177
|
+
? entrypoint
|
|
178
|
+
: join(projectPath, entrypoint);
|
|
179
|
+
console.log(`[JSModuleIndexer] Building dependency tree from ${service.name}`);
|
|
180
|
+
// DFS через стек (как в file2host.js)
|
|
181
|
+
const visited = new Set();
|
|
182
|
+
const stack = [{ file: absoluteEntrypoint, depth: 0 }];
|
|
183
|
+
visited.add(absoluteEntrypoint);
|
|
184
|
+
let nodesCreated = 0;
|
|
185
|
+
let edgesCreated = 0;
|
|
186
|
+
// const skipped = 0;
|
|
187
|
+
const MAX_MODULES = 2000; // Safety limit per service
|
|
188
|
+
const MAX_DEPTH = 50; // Max dependency depth
|
|
189
|
+
// Collect DEPENDS_ON edges to create after all nodes exist
|
|
190
|
+
const pendingDependsOnEdges = [];
|
|
191
|
+
let lastProgressReport = 0;
|
|
192
|
+
const PROGRESS_INTERVAL = 10; // Report every N files
|
|
193
|
+
while (stack.length > 0 && visited.size < MAX_MODULES) {
|
|
194
|
+
const { file: currentFile, depth } = stack.pop();
|
|
195
|
+
// Report progress every PROGRESS_INTERVAL files
|
|
196
|
+
if (onProgress && visited.size - lastProgressReport >= PROGRESS_INTERVAL) {
|
|
197
|
+
onProgress({
|
|
198
|
+
phase: 'indexing',
|
|
199
|
+
currentPlugin: 'JSModuleIndexer',
|
|
200
|
+
message: `${service.name}: indexed ${visited.size} files`,
|
|
201
|
+
processedFiles: visited.size,
|
|
202
|
+
currentService: service.name
|
|
203
|
+
});
|
|
204
|
+
lastProgressReport = visited.size;
|
|
205
|
+
}
|
|
206
|
+
console.log(`[JSModuleIndexer] Processing: ${currentFile.replace(projectPath, '')} (depth ${depth})`);
|
|
207
|
+
if (depth > MAX_DEPTH) {
|
|
208
|
+
console.log(`[JSModuleIndexer] Max depth ${MAX_DEPTH} reached at ${currentFile}`);
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
// Парсим зависимости
|
|
212
|
+
const deps = this.processFile(currentFile, projectPath);
|
|
213
|
+
console.log(`[JSModuleIndexer] Found ${deps instanceof Error ? 0 : deps.length} dependencies in ${currentFile.replace(projectPath, '')}`);
|
|
214
|
+
if (deps instanceof Error) {
|
|
215
|
+
if (!deps.message.includes('ENOENT')) {
|
|
216
|
+
console.log(`[JSModuleIndexer] Error parsing ${currentFile}: ${deps.message}`);
|
|
217
|
+
}
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
// Создаём MODULE ноду для текущего файла
|
|
221
|
+
const fileHash = this.calculateFileHash(currentFile);
|
|
222
|
+
const moduleId = `MODULE:${fileHash}`; // StableID-based for deduplication
|
|
223
|
+
// Используем NodeFactory для создания MODULE ноды
|
|
224
|
+
// ВСЕГДА создаём ноду в графе (граф может быть пустой после force)
|
|
225
|
+
const isTest = this.isTestFile(currentFile);
|
|
226
|
+
const moduleNode = NodeFactory.createModule(currentFile, projectPath, {
|
|
227
|
+
contentHash: fileHash ?? undefined,
|
|
228
|
+
isTest
|
|
229
|
+
});
|
|
230
|
+
console.log(`[JSModuleIndexer] Creating MODULE node: ${moduleNode.id}`);
|
|
231
|
+
await graph.addNode(moduleNode);
|
|
232
|
+
nodesCreated++;
|
|
233
|
+
// Always create SERVICE -> CONTAINS -> MODULE edge (even if module exists)
|
|
234
|
+
await graph.addEdge({
|
|
235
|
+
src: service.id,
|
|
236
|
+
dst: moduleId,
|
|
237
|
+
type: 'CONTAINS',
|
|
238
|
+
version: 'main'
|
|
239
|
+
});
|
|
240
|
+
// Обрабатываем зависимости
|
|
241
|
+
for (const dep of deps) {
|
|
242
|
+
if (dep.startsWith('package::')) {
|
|
243
|
+
// npm пакет - игнорируем пока
|
|
244
|
+
console.log(`[JSModuleIndexer] Skipping npm package: ${dep}`);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const resolvedDep = this.resolveModulePath(dep);
|
|
248
|
+
console.log(`[JSModuleIndexer] Resolved: ${dep} -> ${resolvedDep.replace(projectPath, '')}`);
|
|
249
|
+
// Добавляем в стек если ещё не посещали
|
|
250
|
+
if (!visited.has(resolvedDep)) {
|
|
251
|
+
visited.add(resolvedDep);
|
|
252
|
+
stack.push({ file: resolvedDep, depth: depth + 1 });
|
|
253
|
+
console.log(`[JSModuleIndexer] Added to stack (depth ${depth + 1})`);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
console.log(`[JSModuleIndexer] Already visited, skipping`);
|
|
257
|
+
}
|
|
258
|
+
// Queue DEPENDS_ON edges for later (after all nodes exist)
|
|
259
|
+
const depHash = this.calculateFileHash(resolvedDep);
|
|
260
|
+
const depModuleId = `MODULE:${depHash}`;
|
|
261
|
+
pendingDependsOnEdges.push({
|
|
262
|
+
src: moduleId,
|
|
263
|
+
dst: depModuleId,
|
|
264
|
+
type: 'DEPENDS_ON',
|
|
265
|
+
version: 'main'
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// Create all DEPENDS_ON edges in one batch (faster than loop)
|
|
270
|
+
if (pendingDependsOnEdges.length > 0) {
|
|
271
|
+
await graph.addEdges(pendingDependsOnEdges);
|
|
272
|
+
edgesCreated += pendingDependsOnEdges.length;
|
|
273
|
+
}
|
|
274
|
+
// Warning if hit MAX_MODULES limit
|
|
275
|
+
if (visited.size >= MAX_MODULES) {
|
|
276
|
+
console.warn(`[JSModuleIndexer] ⚠️ ${service.name} hit MAX_MODULES limit (${MAX_MODULES})!`);
|
|
277
|
+
console.warn(`[JSModuleIndexer] This service may be pulling in too many dependencies.`);
|
|
278
|
+
console.warn(`[JSModuleIndexer] Unprocessed files in stack: ${stack.length}`);
|
|
279
|
+
}
|
|
280
|
+
// Final progress report
|
|
281
|
+
if (onProgress) {
|
|
282
|
+
onProgress({
|
|
283
|
+
phase: 'indexing',
|
|
284
|
+
currentPlugin: 'JSModuleIndexer',
|
|
285
|
+
message: `${service.name}: indexed ${visited.size} files`,
|
|
286
|
+
totalFiles: visited.size,
|
|
287
|
+
processedFiles: visited.size,
|
|
288
|
+
currentService: service.name
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
console.log(`[JSModuleIndexer] ${service.name}: ${nodesCreated} modules, ${visited.size} total in tree`);
|
|
292
|
+
return createSuccessResult({ nodes: nodesCreated, edges: edgesCreated }, { totalModules: visited.size });
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
console.error(`[JSModuleIndexer] Error:`, error);
|
|
296
|
+
return createErrorResult(error);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RustModuleIndexer - plugin for indexing Rust modules
|
|
3
|
+
* Discovers .rs files in rust-engine/src/ directory
|
|
4
|
+
*/
|
|
5
|
+
import { Plugin } from '../Plugin.js';
|
|
6
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
7
|
+
export declare class RustModuleIndexer extends Plugin {
|
|
8
|
+
private testPatterns;
|
|
9
|
+
constructor();
|
|
10
|
+
get metadata(): PluginMetadata;
|
|
11
|
+
/**
|
|
12
|
+
* Check if file is a test file based on path patterns
|
|
13
|
+
*/
|
|
14
|
+
private isTestFile;
|
|
15
|
+
/**
|
|
16
|
+
* Recursively find all .rs files in a directory
|
|
17
|
+
*/
|
|
18
|
+
private findRustFiles;
|
|
19
|
+
/**
|
|
20
|
+
* Convert file path to Rust module name
|
|
21
|
+
* src/ffi/napi_bindings.rs -> ffi::napi_bindings
|
|
22
|
+
* src/lib.rs -> crate
|
|
23
|
+
* src/ffi/mod.rs -> ffi
|
|
24
|
+
*/
|
|
25
|
+
private pathToModuleName;
|
|
26
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=RustModuleIndexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RustModuleIndexer.d.ts","sourceRoot":"","sources":["../../../src/plugins/indexing/RustModuleIndexer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,MAAM,EAAuB,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAUhF,qBAAa,iBAAkB,SAAQ,MAAM;IAC3C,OAAO,CAAC,YAAY,CAAW;;IAO/B,IAAI,QAAQ,IAAI,cAAc,CAU7B;IAED;;OAEG;IACH,OAAO,CAAC,UAAU;IAIlB;;OAEG;IACH,OAAO,CAAC,aAAa;IAyBrB;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAclB,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CAiE7D"}
|