stringray-ai 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mcp.json +68 -0
- package/LICENSE +21 -0
- package/README.md +618 -0
- package/dist/agents/architect.d.ts +3 -0
- package/dist/agents/architect.d.ts.map +1 -0
- package/dist/agents/architect.js +84 -0
- package/dist/agents/architect.js.map +1 -0
- package/dist/agents/bug-triage-specialist.d.ts +3 -0
- package/dist/agents/bug-triage-specialist.d.ts.map +1 -0
- package/dist/agents/bug-triage-specialist.js +66 -0
- package/dist/agents/bug-triage-specialist.js.map +1 -0
- package/dist/agents/code-reviewer.d.ts +3 -0
- package/dist/agents/code-reviewer.d.ts.map +1 -0
- package/dist/agents/code-reviewer.js +66 -0
- package/dist/agents/code-reviewer.js.map +1 -0
- package/dist/agents/enforcer.d.ts +3 -0
- package/dist/agents/enforcer.d.ts.map +1 -0
- package/dist/agents/enforcer.js +109 -0
- package/dist/agents/enforcer.js.map +1 -0
- package/dist/agents/index.d.ts +15 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +26 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/librarian.d.ts +3 -0
- package/dist/agents/librarian.d.ts.map +1 -0
- package/dist/agents/librarian.js +70 -0
- package/dist/agents/librarian.js.map +1 -0
- package/dist/agents/log-monitor.d.ts +3 -0
- package/dist/agents/log-monitor.d.ts.map +1 -0
- package/dist/agents/log-monitor.js +102 -0
- package/dist/agents/log-monitor.js.map +1 -0
- package/dist/agents/orchestrator.d.ts +3 -0
- package/dist/agents/orchestrator.d.ts.map +1 -0
- package/dist/agents/orchestrator.js +85 -0
- package/dist/agents/orchestrator.js.map +1 -0
- package/dist/agents/refactorer.d.ts +3 -0
- package/dist/agents/refactorer.d.ts.map +1 -0
- package/dist/agents/refactorer.js +67 -0
- package/dist/agents/refactorer.js.map +1 -0
- package/dist/agents/security-auditor.d.ts +3 -0
- package/dist/agents/security-auditor.d.ts.map +1 -0
- package/dist/agents/security-auditor.js +66 -0
- package/dist/agents/security-auditor.js.map +1 -0
- package/dist/agents/sisyphus.d.ts +3 -0
- package/dist/agents/sisyphus.d.ts.map +1 -0
- package/dist/agents/sisyphus.js +53 -0
- package/dist/agents/sisyphus.js.map +1 -0
- package/dist/agents/test-architect.d.ts +3 -0
- package/dist/agents/test-architect.d.ts.map +1 -0
- package/dist/agents/test-architect.js +81 -0
- package/dist/agents/test-architect.js.map +1 -0
- package/dist/agents/types.d.ts +29 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/types.js +2 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/mcps/architect-tools.server.d.ts +40 -0
- package/dist/mcps/architect-tools.server.d.ts.map +1 -0
- package/dist/mcps/architect-tools.server.js +563 -0
- package/dist/mcps/architect-tools.server.js.map +1 -0
- package/dist/mcps/auto-format.server.d.ts +20 -0
- package/dist/mcps/auto-format.server.d.ts.map +1 -0
- package/dist/mcps/auto-format.server.js +391 -0
- package/dist/mcps/auto-format.server.js.map +1 -0
- package/dist/mcps/boot-orchestrator.server.d.ts +50 -0
- package/dist/mcps/boot-orchestrator.server.d.ts.map +1 -0
- package/dist/mcps/boot-orchestrator.server.js +871 -0
- package/dist/mcps/boot-orchestrator.server.js.map +1 -0
- package/dist/mcps/enforcer-tools.server.d.ts +26 -0
- package/dist/mcps/enforcer-tools.server.d.ts.map +1 -0
- package/dist/mcps/enforcer-tools.server.js +627 -0
- package/dist/mcps/enforcer-tools.server.js.map +1 -0
- package/dist/mcps/enhanced-orchestrator.server.d.ts +14 -0
- package/dist/mcps/enhanced-orchestrator.server.d.ts.map +1 -0
- package/dist/mcps/enhanced-orchestrator.server.js +250 -0
- package/dist/mcps/enhanced-orchestrator.server.js.map +1 -0
- package/dist/mcps/framework-compliance-audit.server.d.ts +23 -0
- package/dist/mcps/framework-compliance-audit.server.d.ts.map +1 -0
- package/dist/mcps/framework-compliance-audit.server.js +511 -0
- package/dist/mcps/framework-compliance-audit.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/api-design.server.d.ts +16 -0
- package/dist/mcps/knowledge-skills/api-design.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/api-design.server.js +120 -0
- package/dist/mcps/knowledge-skills/api-design.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/architecture-patterns.server.d.ts +16 -0
- package/dist/mcps/knowledge-skills/architecture-patterns.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/architecture-patterns.server.js +110 -0
- package/dist/mcps/knowledge-skills/architecture-patterns.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/code-review.server.d.ts +32 -0
- package/dist/mcps/knowledge-skills/code-review.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/code-review.server.js +777 -0
- package/dist/mcps/knowledge-skills/code-review.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/database-design.server.d.ts +44 -0
- package/dist/mcps/knowledge-skills/database-design.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/database-design.server.js +818 -0
- package/dist/mcps/knowledge-skills/database-design.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/devops-deployment.server.d.ts +44 -0
- package/dist/mcps/knowledge-skills/devops-deployment.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/devops-deployment.server.js +1178 -0
- package/dist/mcps/knowledge-skills/devops-deployment.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/documentation-generation.server.d.ts +48 -0
- package/dist/mcps/knowledge-skills/documentation-generation.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/documentation-generation.server.js +1188 -0
- package/dist/mcps/knowledge-skills/documentation-generation.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/git-workflow.server.d.ts +16 -0
- package/dist/mcps/knowledge-skills/git-workflow.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/git-workflow.server.js +112 -0
- package/dist/mcps/knowledge-skills/git-workflow.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/performance-optimization.server.d.ts +16 -0
- package/dist/mcps/knowledge-skills/performance-optimization.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/performance-optimization.server.js +108 -0
- package/dist/mcps/knowledge-skills/performance-optimization.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/project-analysis.server.d.ts +34 -0
- package/dist/mcps/knowledge-skills/project-analysis.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/project-analysis.server.js +710 -0
- package/dist/mcps/knowledge-skills/project-analysis.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/refactoring-strategies.server.d.ts +34 -0
- package/dist/mcps/knowledge-skills/refactoring-strategies.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +794 -0
- package/dist/mcps/knowledge-skills/refactoring-strategies.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/security-audit.server.d.ts +34 -0
- package/dist/mcps/knowledge-skills/security-audit.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/security-audit.server.js +769 -0
- package/dist/mcps/knowledge-skills/security-audit.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/testing-best-practices.server.d.ts +37 -0
- package/dist/mcps/knowledge-skills/testing-best-practices.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/testing-best-practices.server.js +865 -0
- package/dist/mcps/knowledge-skills/testing-best-practices.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/testing-strategy.server.d.ts +47 -0
- package/dist/mcps/knowledge-skills/testing-strategy.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/testing-strategy.server.js +672 -0
- package/dist/mcps/knowledge-skills/testing-strategy.server.js.map +1 -0
- package/dist/mcps/knowledge-skills/ui-ux-design.server.d.ts +42 -0
- package/dist/mcps/knowledge-skills/ui-ux-design.server.d.ts.map +1 -0
- package/dist/mcps/knowledge-skills/ui-ux-design.server.js +1016 -0
- package/dist/mcps/knowledge-skills/ui-ux-design.server.js.map +1 -0
- package/dist/mcps/lint.server.d.ts +18 -0
- package/dist/mcps/lint.server.d.ts.map +1 -0
- package/dist/mcps/lint.server.js +334 -0
- package/dist/mcps/lint.server.js.map +1 -0
- package/dist/mcps/model-health-check.server.d.ts +17 -0
- package/dist/mcps/model-health-check.server.d.ts.map +1 -0
- package/dist/mcps/model-health-check.server.js +226 -0
- package/dist/mcps/model-health-check.server.js.map +1 -0
- package/dist/mcps/orchestrator.server.d.ts +39 -0
- package/dist/mcps/orchestrator.server.d.ts.map +1 -0
- package/dist/mcps/orchestrator.server.js +908 -0
- package/dist/mcps/orchestrator.server.js.map +1 -0
- package/dist/mcps/performance-analysis.server.d.ts +28 -0
- package/dist/mcps/performance-analysis.server.d.ts.map +1 -0
- package/dist/mcps/performance-analysis.server.js +514 -0
- package/dist/mcps/performance-analysis.server.js.map +1 -0
- package/dist/mcps/processor-pipeline.server.d.ts +29 -0
- package/dist/mcps/processor-pipeline.server.d.ts.map +1 -0
- package/dist/mcps/processor-pipeline.server.js +520 -0
- package/dist/mcps/processor-pipeline.server.js.map +1 -0
- package/dist/mcps/security-scan.server.d.ts +20 -0
- package/dist/mcps/security-scan.server.d.ts.map +1 -0
- package/dist/mcps/security-scan.server.js +404 -0
- package/dist/mcps/security-scan.server.js.map +1 -0
- package/dist/mcps/state-manager.server.d.ts +29 -0
- package/dist/mcps/state-manager.server.d.ts.map +1 -0
- package/dist/mcps/state-manager.server.js +620 -0
- package/dist/mcps/state-manager.server.js.map +1 -0
- package/dist/orchestrator/enhanced-multi-agent-orchestrator.d.ts +109 -0
- package/dist/orchestrator/enhanced-multi-agent-orchestrator.d.ts.map +1 -0
- package/dist/orchestrator/enhanced-multi-agent-orchestrator.js +337 -0
- package/dist/orchestrator/enhanced-multi-agent-orchestrator.js.map +1 -0
- package/dist/orchestrator/intelligent-commit-batcher.d.ts +112 -0
- package/dist/orchestrator/intelligent-commit-batcher.d.ts.map +1 -0
- package/dist/orchestrator/intelligent-commit-batcher.js +330 -0
- package/dist/orchestrator/intelligent-commit-batcher.js.map +1 -0
- package/dist/plugin/agents/architect.d.ts +3 -0
- package/dist/plugin/agents/architect.d.ts.map +1 -0
- package/dist/plugin/agents/architect.js +84 -0
- package/dist/plugin/agents/architect.js.map +1 -0
- package/dist/plugin/agents/bug-triage-specialist.d.ts +3 -0
- package/dist/plugin/agents/bug-triage-specialist.d.ts.map +1 -0
- package/dist/plugin/agents/bug-triage-specialist.js +66 -0
- package/dist/plugin/agents/bug-triage-specialist.js.map +1 -0
- package/dist/plugin/agents/code-reviewer.d.ts +3 -0
- package/dist/plugin/agents/code-reviewer.d.ts.map +1 -0
- package/dist/plugin/agents/code-reviewer.js +66 -0
- package/dist/plugin/agents/code-reviewer.js.map +1 -0
- package/dist/plugin/agents/enforcer.d.ts +3 -0
- package/dist/plugin/agents/enforcer.d.ts.map +1 -0
- package/dist/plugin/agents/enforcer.js +109 -0
- package/dist/plugin/agents/enforcer.js.map +1 -0
- package/dist/plugin/agents/index.d.ts +15 -0
- package/dist/plugin/agents/index.d.ts.map +1 -0
- package/dist/plugin/agents/index.js +26 -0
- package/dist/plugin/agents/index.js.map +1 -0
- package/dist/plugin/agents/librarian.d.ts +3 -0
- package/dist/plugin/agents/librarian.d.ts.map +1 -0
- package/dist/plugin/agents/librarian.js +70 -0
- package/dist/plugin/agents/librarian.js.map +1 -0
- package/dist/plugin/agents/log-monitor.d.ts +3 -0
- package/dist/plugin/agents/log-monitor.d.ts.map +1 -0
- package/dist/plugin/agents/log-monitor.js +102 -0
- package/dist/plugin/agents/log-monitor.js.map +1 -0
- package/dist/plugin/agents/orchestrator.d.ts +3 -0
- package/dist/plugin/agents/orchestrator.d.ts.map +1 -0
- package/dist/plugin/agents/orchestrator.js +85 -0
- package/dist/plugin/agents/orchestrator.js.map +1 -0
- package/dist/plugin/agents/refactorer.d.ts +3 -0
- package/dist/plugin/agents/refactorer.d.ts.map +1 -0
- package/dist/plugin/agents/refactorer.js +67 -0
- package/dist/plugin/agents/refactorer.js.map +1 -0
- package/dist/plugin/agents/security-auditor.d.ts +3 -0
- package/dist/plugin/agents/security-auditor.d.ts.map +1 -0
- package/dist/plugin/agents/security-auditor.js +66 -0
- package/dist/plugin/agents/security-auditor.js.map +1 -0
- package/dist/plugin/agents/sisyphus.d.ts +3 -0
- package/dist/plugin/agents/sisyphus.d.ts.map +1 -0
- package/dist/plugin/agents/sisyphus.js +53 -0
- package/dist/plugin/agents/sisyphus.js.map +1 -0
- package/dist/plugin/agents/test-architect.d.ts +3 -0
- package/dist/plugin/agents/test-architect.d.ts.map +1 -0
- package/dist/plugin/agents/test-architect.js +81 -0
- package/dist/plugin/agents/test-architect.js.map +1 -0
- package/dist/plugin/agents/types.d.ts +29 -0
- package/dist/plugin/agents/types.d.ts.map +1 -0
- package/dist/plugin/agents/types.js +2 -0
- package/dist/plugin/agents/types.js.map +1 -0
- package/dist/plugin/config-loader.d.ts +67 -0
- package/dist/plugin/config-loader.d.ts.map +1 -0
- package/dist/plugin/config-loader.js +125 -0
- package/dist/plugin/config-loader.js.map +1 -0
- package/dist/plugin/context-loader.d.ts +122 -0
- package/dist/plugin/context-loader.d.ts.map +1 -0
- package/dist/plugin/context-loader.js +273 -0
- package/dist/plugin/context-loader.js.map +1 -0
- package/dist/plugin/delegation/agent-delegator.d.ts +217 -0
- package/dist/plugin/delegation/agent-delegator.d.ts.map +1 -0
- package/dist/plugin/delegation/agent-delegator.js +928 -0
- package/dist/plugin/delegation/agent-delegator.js.map +1 -0
- package/dist/plugin/delegation/codebase-context-analyzer.d.ts +157 -0
- package/dist/plugin/delegation/codebase-context-analyzer.d.ts.map +1 -0
- package/dist/plugin/delegation/codebase-context-analyzer.js +1029 -0
- package/dist/plugin/delegation/codebase-context-analyzer.js.map +1 -0
- package/dist/plugin/delegation/complexity-analyzer.d.ts +61 -0
- package/dist/plugin/delegation/complexity-analyzer.d.ts.map +1 -0
- package/dist/plugin/delegation/complexity-analyzer.js +253 -0
- package/dist/plugin/delegation/complexity-analyzer.js.map +1 -0
- package/dist/plugin/enforcement/enforcer-tools.d.ts +62 -0
- package/dist/plugin/enforcement/enforcer-tools.d.ts.map +1 -0
- package/dist/plugin/enforcement/enforcer-tools.js +407 -0
- package/dist/plugin/enforcement/enforcer-tools.js.map +1 -0
- package/dist/plugin/enforcement/rule-enforcer.d.ts +171 -0
- package/dist/plugin/enforcement/rule-enforcer.d.ts.map +1 -0
- package/dist/plugin/enforcement/rule-enforcer.js +1342 -0
- package/dist/plugin/enforcement/rule-enforcer.js.map +1 -0
- package/dist/plugin/enforcement/test-auto-healing.d.ts +78 -0
- package/dist/plugin/enforcement/test-auto-healing.d.ts.map +1 -0
- package/dist/plugin/enforcement/test-auto-healing.js +318 -0
- package/dist/plugin/enforcement/test-auto-healing.js.map +1 -0
- package/dist/plugin/framework-logger.d.ts +20 -0
- package/dist/plugin/framework-logger.d.ts.map +1 -0
- package/dist/plugin/framework-logger.js +79 -0
- package/dist/plugin/framework-logger.js.map +1 -0
- package/dist/plugin/logging-config.d.ts +11 -0
- package/dist/plugin/logging-config.d.ts.map +1 -0
- package/dist/plugin/logging-config.js +44 -0
- package/dist/plugin/logging-config.js.map +1 -0
- package/dist/plugin/mcps/architect-tools.server.d.ts +40 -0
- package/dist/plugin/mcps/architect-tools.server.d.ts.map +1 -0
- package/dist/plugin/mcps/architect-tools.server.js +563 -0
- package/dist/plugin/mcps/architect-tools.server.js.map +1 -0
- package/dist/plugin/mcps/auto-format.server.d.ts +20 -0
- package/dist/plugin/mcps/auto-format.server.d.ts.map +1 -0
- package/dist/plugin/mcps/auto-format.server.js +391 -0
- package/dist/plugin/mcps/auto-format.server.js.map +1 -0
- package/dist/plugin/mcps/boot-orchestrator.server.d.ts +50 -0
- package/dist/plugin/mcps/boot-orchestrator.server.d.ts.map +1 -0
- package/dist/plugin/mcps/boot-orchestrator.server.js +871 -0
- package/dist/plugin/mcps/boot-orchestrator.server.js.map +1 -0
- package/dist/plugin/mcps/enforcer-tools.server.d.ts +26 -0
- package/dist/plugin/mcps/enforcer-tools.server.d.ts.map +1 -0
- package/dist/plugin/mcps/enforcer-tools.server.js +627 -0
- package/dist/plugin/mcps/enforcer-tools.server.js.map +1 -0
- package/dist/plugin/mcps/enhanced-orchestrator.server.d.ts +14 -0
- package/dist/plugin/mcps/enhanced-orchestrator.server.d.ts.map +1 -0
- package/dist/plugin/mcps/enhanced-orchestrator.server.js +250 -0
- package/dist/plugin/mcps/enhanced-orchestrator.server.js.map +1 -0
- package/dist/plugin/mcps/framework-compliance-audit.server.d.ts +23 -0
- package/dist/plugin/mcps/framework-compliance-audit.server.d.ts.map +1 -0
- package/dist/plugin/mcps/framework-compliance-audit.server.js +511 -0
- package/dist/plugin/mcps/framework-compliance-audit.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/api-design.server.d.ts +16 -0
- package/dist/plugin/mcps/knowledge-skills/api-design.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/api-design.server.js +120 -0
- package/dist/plugin/mcps/knowledge-skills/api-design.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/architecture-patterns.server.d.ts +16 -0
- package/dist/plugin/mcps/knowledge-skills/architecture-patterns.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/architecture-patterns.server.js +110 -0
- package/dist/plugin/mcps/knowledge-skills/architecture-patterns.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/code-review.server.d.ts +32 -0
- package/dist/plugin/mcps/knowledge-skills/code-review.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/code-review.server.js +777 -0
- package/dist/plugin/mcps/knowledge-skills/code-review.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/database-design.server.d.ts +44 -0
- package/dist/plugin/mcps/knowledge-skills/database-design.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/database-design.server.js +818 -0
- package/dist/plugin/mcps/knowledge-skills/database-design.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/devops-deployment.server.d.ts +44 -0
- package/dist/plugin/mcps/knowledge-skills/devops-deployment.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/devops-deployment.server.js +1178 -0
- package/dist/plugin/mcps/knowledge-skills/devops-deployment.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/documentation-generation.server.d.ts +48 -0
- package/dist/plugin/mcps/knowledge-skills/documentation-generation.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/documentation-generation.server.js +1188 -0
- package/dist/plugin/mcps/knowledge-skills/documentation-generation.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/git-workflow.server.d.ts +16 -0
- package/dist/plugin/mcps/knowledge-skills/git-workflow.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/git-workflow.server.js +112 -0
- package/dist/plugin/mcps/knowledge-skills/git-workflow.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/performance-optimization.server.d.ts +16 -0
- package/dist/plugin/mcps/knowledge-skills/performance-optimization.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/performance-optimization.server.js +108 -0
- package/dist/plugin/mcps/knowledge-skills/performance-optimization.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/project-analysis.server.d.ts +34 -0
- package/dist/plugin/mcps/knowledge-skills/project-analysis.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/project-analysis.server.js +710 -0
- package/dist/plugin/mcps/knowledge-skills/project-analysis.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/refactoring-strategies.server.d.ts +34 -0
- package/dist/plugin/mcps/knowledge-skills/refactoring-strategies.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/refactoring-strategies.server.js +794 -0
- package/dist/plugin/mcps/knowledge-skills/refactoring-strategies.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/security-audit.server.d.ts +34 -0
- package/dist/plugin/mcps/knowledge-skills/security-audit.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/security-audit.server.js +769 -0
- package/dist/plugin/mcps/knowledge-skills/security-audit.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/testing-best-practices.server.d.ts +37 -0
- package/dist/plugin/mcps/knowledge-skills/testing-best-practices.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/testing-best-practices.server.js +865 -0
- package/dist/plugin/mcps/knowledge-skills/testing-best-practices.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/testing-strategy.server.d.ts +47 -0
- package/dist/plugin/mcps/knowledge-skills/testing-strategy.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/testing-strategy.server.js +672 -0
- package/dist/plugin/mcps/knowledge-skills/testing-strategy.server.js.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/ui-ux-design.server.d.ts +42 -0
- package/dist/plugin/mcps/knowledge-skills/ui-ux-design.server.d.ts.map +1 -0
- package/dist/plugin/mcps/knowledge-skills/ui-ux-design.server.js +1016 -0
- package/dist/plugin/mcps/knowledge-skills/ui-ux-design.server.js.map +1 -0
- package/dist/plugin/mcps/lint.server.d.ts +18 -0
- package/dist/plugin/mcps/lint.server.d.ts.map +1 -0
- package/dist/plugin/mcps/lint.server.js +334 -0
- package/dist/plugin/mcps/lint.server.js.map +1 -0
- package/dist/plugin/mcps/model-health-check.server.d.ts +17 -0
- package/dist/plugin/mcps/model-health-check.server.d.ts.map +1 -0
- package/dist/plugin/mcps/model-health-check.server.js +226 -0
- package/dist/plugin/mcps/model-health-check.server.js.map +1 -0
- package/dist/plugin/mcps/orchestrator.server.d.ts +39 -0
- package/dist/plugin/mcps/orchestrator.server.d.ts.map +1 -0
- package/dist/plugin/mcps/orchestrator.server.js +908 -0
- package/dist/plugin/mcps/orchestrator.server.js.map +1 -0
- package/dist/plugin/mcps/performance-analysis.server.d.ts +28 -0
- package/dist/plugin/mcps/performance-analysis.server.d.ts.map +1 -0
- package/dist/plugin/mcps/performance-analysis.server.js +514 -0
- package/dist/plugin/mcps/performance-analysis.server.js.map +1 -0
- package/dist/plugin/mcps/processor-pipeline.server.d.ts +29 -0
- package/dist/plugin/mcps/processor-pipeline.server.d.ts.map +1 -0
- package/dist/plugin/mcps/processor-pipeline.server.js +520 -0
- package/dist/plugin/mcps/processor-pipeline.server.js.map +1 -0
- package/dist/plugin/mcps/security-scan.server.d.ts +20 -0
- package/dist/plugin/mcps/security-scan.server.d.ts.map +1 -0
- package/dist/plugin/mcps/security-scan.server.js +404 -0
- package/dist/plugin/mcps/security-scan.server.js.map +1 -0
- package/dist/plugin/mcps/state-manager.server.d.ts +29 -0
- package/dist/plugin/mcps/state-manager.server.d.ts.map +1 -0
- package/dist/plugin/mcps/state-manager.server.js +620 -0
- package/dist/plugin/mcps/state-manager.server.js.map +1 -0
- package/dist/plugin/monitoring/advanced-profiler.d.ts +48 -0
- package/dist/plugin/monitoring/advanced-profiler.d.ts.map +1 -0
- package/dist/plugin/monitoring/advanced-profiler.js +216 -0
- package/dist/plugin/monitoring/advanced-profiler.js.map +1 -0
- package/dist/plugin/monitoring/enterprise-monitoring-system.d.ts +331 -0
- package/dist/plugin/monitoring/enterprise-monitoring-system.d.ts.map +1 -0
- package/dist/plugin/monitoring/enterprise-monitoring-system.js +797 -0
- package/dist/plugin/monitoring/enterprise-monitoring-system.js.map +1 -0
- package/dist/plugin/orchestrator/enhanced-multi-agent-orchestrator.d.ts +111 -0
- package/dist/plugin/orchestrator/enhanced-multi-agent-orchestrator.d.ts.map +1 -0
- package/dist/plugin/orchestrator/enhanced-multi-agent-orchestrator.js +339 -0
- package/dist/plugin/orchestrator/enhanced-multi-agent-orchestrator.js.map +1 -0
- package/dist/plugin/orchestrator/intelligent-commit-batcher.d.ts +112 -0
- package/dist/plugin/orchestrator/intelligent-commit-batcher.d.ts.map +1 -0
- package/dist/plugin/orchestrator/intelligent-commit-batcher.js +330 -0
- package/dist/plugin/orchestrator/intelligent-commit-batcher.js.map +1 -0
- package/dist/plugin/orchestrator.d.ts +91 -0
- package/dist/plugin/orchestrator.d.ts.map +1 -0
- package/dist/plugin/orchestrator.js +444 -0
- package/dist/plugin/orchestrator.js.map +1 -0
- package/dist/plugin/plugins/marketplace/marketplace-service.d.ts +108 -0
- package/dist/plugin/plugins/marketplace/marketplace-service.d.ts.map +1 -0
- package/dist/plugin/plugins/marketplace/marketplace-service.js +620 -0
- package/dist/plugin/plugins/marketplace/marketplace-service.js.map +1 -0
- package/dist/plugin/plugins/marketplace/marketplace-types.d.ts +468 -0
- package/dist/plugin/plugins/marketplace/marketplace-types.d.ts.map +1 -0
- package/dist/plugin/plugins/marketplace/marketplace-types.js +11 -0
- package/dist/plugin/plugins/marketplace/marketplace-types.js.map +1 -0
- package/dist/plugin/plugins/plugin-system.d.ts +152 -0
- package/dist/plugin/plugins/plugin-system.d.ts.map +1 -0
- package/dist/plugin/plugins/plugin-system.js +405 -0
- package/dist/plugin/plugins/plugin-system.js.map +1 -0
- package/dist/plugin/plugins/stringray-codex-injection.d.ts +68 -0
- package/dist/plugin/plugins/stringray-codex-injection.d.ts.map +1 -0
- package/dist/plugin/plugins/stringray-codex-injection.js +225 -0
- package/dist/plugin/plugins/stringray-codex-injection.js.map +1 -0
- package/dist/plugin/plugins/strray-codex-injection.d.ts +68 -0
- package/dist/plugin/plugins/strray-codex-injection.d.ts.map +1 -0
- package/dist/plugin/plugins/strray-codex-injection.js +225 -0
- package/dist/plugin/plugins/strray-codex-injection.js.map +1 -0
- package/dist/plugin/processors/index.d.ts +12 -0
- package/dist/plugin/processors/index.d.ts.map +1 -0
- package/dist/plugin/processors/index.js +12 -0
- package/dist/plugin/processors/index.js.map +1 -0
- package/dist/plugin/processors/processor-manager.d.ts +113 -0
- package/dist/plugin/processors/processor-manager.d.ts.map +1 -0
- package/dist/plugin/processors/processor-manager.js +498 -0
- package/dist/plugin/processors/processor-manager.js.map +1 -0
- package/dist/plugin/processors/processor-types.d.ts +50 -0
- package/dist/plugin/processors/processor-types.d.ts.map +1 -0
- package/dist/plugin/processors/processor-types.js +10 -0
- package/dist/plugin/processors/processor-types.js.map +1 -0
- package/dist/plugin/processors/refactoring-logging-processor.d.ts +61 -0
- package/dist/plugin/processors/refactoring-logging-processor.d.ts.map +1 -0
- package/dist/plugin/processors/refactoring-logging-processor.js +257 -0
- package/dist/plugin/processors/refactoring-logging-processor.js.map +1 -0
- package/dist/plugin/reporting/framework-reporting-system.d.ts +157 -0
- package/dist/plugin/reporting/framework-reporting-system.d.ts.map +1 -0
- package/dist/plugin/reporting/framework-reporting-system.js +783 -0
- package/dist/plugin/reporting/framework-reporting-system.js.map +1 -0
- package/dist/plugin/security/security-hardening-system.d.ts +220 -0
- package/dist/plugin/security/security-hardening-system.d.ts.map +1 -0
- package/dist/plugin/security/security-hardening-system.js +605 -0
- package/dist/plugin/security/security-hardening-system.js.map +1 -0
- package/dist/plugin/state/context-providers.d.ts +5 -0
- package/dist/plugin/state/context-providers.d.ts.map +1 -0
- package/dist/plugin/state/context-providers.js +2 -0
- package/dist/plugin/state/context-providers.js.map +1 -0
- package/dist/plugin/state/index.d.ts +5 -0
- package/dist/plugin/state/index.d.ts.map +1 -0
- package/dist/plugin/state/index.js +8 -0
- package/dist/plugin/state/index.js.map +1 -0
- package/dist/plugin/state/state-manager.d.ts +29 -0
- package/dist/plugin/state/state-manager.d.ts.map +1 -0
- package/dist/plugin/state/state-manager.js +153 -0
- package/dist/plugin/state/state-manager.js.map +1 -0
- package/dist/plugin/state/state-types.d.ts +6 -0
- package/dist/plugin/state/state-types.d.ts.map +1 -0
- package/dist/plugin/state/state-types.js +2 -0
- package/dist/plugin/state/state-types.js.map +1 -0
- package/dist/plugin/utils/codex-parser.d.ts +62 -0
- package/dist/plugin/utils/codex-parser.d.ts.map +1 -0
- package/dist/plugin/utils/codex-parser.js +396 -0
- package/dist/plugin/utils/codex-parser.js.map +1 -0
- package/dist/plugin/utils/command-runner.d.ts +24 -0
- package/dist/plugin/utils/command-runner.d.ts.map +1 -0
- package/dist/plugin/utils/command-runner.js +44 -0
- package/dist/plugin/utils/command-runner.js.map +1 -0
- package/dist/plugin/utils/import-resolver.d.ts +55 -0
- package/dist/plugin/utils/import-resolver.d.ts.map +1 -0
- package/dist/plugin/utils/import-resolver.js +198 -0
- package/dist/plugin/utils/import-resolver.js.map +1 -0
- package/dist/plugin/utils/memory-pool.d.ts +90 -0
- package/dist/plugin/utils/memory-pool.d.ts.map +1 -0
- package/dist/plugin/utils/memory-pool.js +245 -0
- package/dist/plugin/utils/memory-pool.js.map +1 -0
- package/dist/plugin/utils/path-resolver.d.ts +49 -0
- package/dist/plugin/utils/path-resolver.d.ts.map +1 -0
- package/dist/plugin/utils/path-resolver.js +126 -0
- package/dist/plugin/utils/path-resolver.js.map +1 -0
- package/dist/plugin/utils/test-template-generator.d.ts +26 -0
- package/dist/plugin/utils/test-template-generator.d.ts.map +1 -0
- package/dist/plugin/utils/test-template-generator.js +178 -0
- package/dist/plugin/utils/test-template-generator.js.map +1 -0
- package/dist/processors/index.d.ts +12 -0
- package/dist/processors/index.d.ts.map +1 -0
- package/dist/processors/index.js +12 -0
- package/dist/processors/index.js.map +1 -0
- package/dist/processors/processor-manager.d.ts +113 -0
- package/dist/processors/processor-manager.d.ts.map +1 -0
- package/dist/processors/processor-manager.js +498 -0
- package/dist/processors/processor-manager.js.map +1 -0
- package/dist/processors/processor-types.d.ts +50 -0
- package/dist/processors/processor-types.d.ts.map +1 -0
- package/dist/processors/processor-types.js +10 -0
- package/dist/processors/processor-types.js.map +1 -0
- package/dist/processors/refactoring-logging-processor.d.ts +61 -0
- package/dist/processors/refactoring-logging-processor.d.ts.map +1 -0
- package/dist/processors/refactoring-logging-processor.js +257 -0
- package/dist/processors/refactoring-logging-processor.js.map +1 -0
- package/dist/state/context-providers.d.ts +5 -0
- package/dist/state/context-providers.d.ts.map +1 -0
- package/dist/state/context-providers.js +2 -0
- package/dist/state/context-providers.js.map +1 -0
- package/dist/state/index.d.ts +5 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +8 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/state-manager.d.ts +29 -0
- package/dist/state/state-manager.d.ts.map +1 -0
- package/dist/state/state-manager.js +153 -0
- package/dist/state/state-manager.js.map +1 -0
- package/dist/state/state-types.d.ts +6 -0
- package/dist/state/state-types.d.ts.map +1 -0
- package/dist/state/state-types.js +2 -0
- package/dist/state/state-types.js.map +1 -0
- package/dist/utils/codex-parser.d.ts +62 -0
- package/dist/utils/codex-parser.d.ts.map +1 -0
- package/dist/utils/codex-parser.js +396 -0
- package/dist/utils/codex-parser.js.map +1 -0
- package/dist/utils/command-runner.d.ts +24 -0
- package/dist/utils/command-runner.d.ts.map +1 -0
- package/dist/utils/command-runner.js +44 -0
- package/dist/utils/command-runner.js.map +1 -0
- package/dist/utils/import-resolver.d.ts +55 -0
- package/dist/utils/import-resolver.d.ts.map +1 -0
- package/dist/utils/import-resolver.js +198 -0
- package/dist/utils/import-resolver.js.map +1 -0
- package/dist/utils/memory-pool.d.ts +90 -0
- package/dist/utils/memory-pool.d.ts.map +1 -0
- package/dist/utils/memory-pool.js +245 -0
- package/dist/utils/memory-pool.js.map +1 -0
- package/dist/utils/path-resolver.d.ts +49 -0
- package/dist/utils/path-resolver.d.ts.map +1 -0
- package/dist/utils/path-resolver.js +126 -0
- package/dist/utils/path-resolver.js.map +1 -0
- package/dist/utils/test-template-generator.d.ts +26 -0
- package/dist/utils/test-template-generator.d.ts.map +1 -0
- package/dist/utils/test-template-generator.js +178 -0
- package/dist/utils/test-template-generator.js.map +1 -0
- package/package.json +138 -0
- package/scripts/analysis/analyze-context-awareness.ts +219 -0
- package/scripts/analysis/analyze-framework-usage.ts +208 -0
- package/scripts/analysis/analyzer-agent-runner.js +328 -0
- package/scripts/analysis/context-awareness-report.ts +250 -0
- package/scripts/analyze-imports.mjs +147 -0
- package/scripts/basic-security-audit.cjs +261 -0
- package/scripts/boot-check.cjs +188 -0
- package/scripts/build/check-syntax.sh +1 -0
- package/scripts/build/check-tsc.sh +1 -0
- package/scripts/build/check-types.sh +1 -0
- package/scripts/build/compile-single.sh +1 -0
- package/scripts/build/copy-plugin.sh +1 -0
- package/scripts/build/manual-build.sh +1 -0
- package/scripts/build/run-build-after-copy.sh +1 -0
- package/scripts/build/run-build-attempt.sh +1 -0
- package/scripts/build/run-build-errors-grep.sh +1 -0
- package/scripts/build/run-build-errors.sh +1 -0
- package/scripts/build/run-build-limited.sh +1 -0
- package/scripts/build/run-build-list.sh +1 -0
- package/scripts/build/run-build.sh +1 -0
- package/scripts/build/run-limited.sh +1 -0
- package/scripts/build/run-tsc-direct.sh +1 -0
- package/scripts/build/run-type-check.sh +1 -0
- package/scripts/build/run-typecheck.sh +1 -0
- package/scripts/build/test-build.sh +1 -0
- package/scripts/check-logs.sh +62 -0
- package/scripts/debug/debug-context-enhancement.ts +116 -0
- package/scripts/debug/debug-rules.mjs +23 -0
- package/scripts/demo/demo-clickable-monitoring.mjs +116 -0
- package/scripts/demo/profiling-demo.js +108 -0
- package/scripts/demo/profiling-demo.ts +126 -0
- package/scripts/demo/reporting-demonstration.ts +184 -0
- package/scripts/demo/reporting-examples.ts +105 -0
- package/scripts/dependency-scan.cjs +111 -0
- package/scripts/deploy-stringray-plugin.sh +323 -0
- package/scripts/disable-logging.sh +20 -0
- package/scripts/extract-framework.sh +405 -0
- package/scripts/fix-mcp-capabilities.js +83 -0
- package/scripts/framework/advanced-profiling-integration.sh +384 -0
- package/scripts/framework/check-agent-orchestration-health.sh +113 -0
- package/scripts/framework/enterprise-analysis-test.sh +174 -0
- package/scripts/framework/implement-analyzer-agent.sh +393 -0
- package/scripts/framework/merge-mcp-configs.sh +201 -0
- package/scripts/framework/validate-multi-agent-orchestration.sh +195 -0
- package/scripts/framework/validate-profiling.sh +64 -0
- package/scripts/github-actions-monitor.cjs +289 -0
- package/scripts/init.ts +121 -0
- package/scripts/monitoring/initialize-monitoring-pipeline.sh +89 -0
- package/scripts/monitoring/memory-dashboard.sh +52 -0
- package/scripts/monitoring/monitoring-daemon.mjs +67 -0
- package/scripts/monitoring/monitoring-daemon.sh +190 -0
- package/scripts/monitoring/profiling-dashboard.sh +69 -0
- package/scripts/performance-report.js +56 -0
- package/scripts/postinstall.cjs +240 -0
- package/scripts/profile-performance.sh +263 -0
- package/scripts/register-mcp-servers-fixed.sh +74 -0
- package/scripts/register-mcp-servers.sh +96 -0
- package/scripts/reporting/generate-phase1-report.js +28 -0
- package/scripts/reporting/run-postprocessor.js +59 -0
- package/scripts/reporting/trigger-report.js +15 -0
- package/scripts/run-simulations.mjs +29 -0
- package/scripts/scenario-data-processor.py +122 -0
- package/scripts/scenarios/scenario-security-check.ts +60 -0
- package/scripts/scenarios/scenario-user-management.ts +123 -0
- package/scripts/setup.cjs +128 -0
- package/scripts/simulation/run-simulations.js +84 -0
- package/scripts/simulation/simulate-full-orchestrator.ts +239 -0
- package/scripts/strray-triage.sh +349 -0
- package/scripts/test/run-memory-regression.sh +45 -0
- package/scripts/test/run-test.sh +2 -0
- package/scripts/test/test-deployment.sh +552 -0
- package/scripts/test/test-enhanced-report.ts +24 -0
- package/scripts/test/test-graceful-shutdown.sh +35 -0
- package/scripts/test/test-integration.mjs +79 -0
- package/scripts/test/test-manual-orchestration.sh +168 -0
- package/scripts/test/test-max-agents.sh +70 -0
- package/scripts/test/test-memory-monitor.sh +40 -0
- package/scripts/test/test-memory-pools.sh +58 -0
- package/scripts/test/test-module.ts +1 -0
- package/scripts/test/test-multi-agent-trigger.sh +251 -0
- package/scripts/test/test-orchestrator.txt +1 -0
- package/scripts/test/test-postinstall.js +1 -0
- package/scripts/test/test-security-module.ts +27 -0
- package/scripts/test/test-session-management.js +135 -0
- package/scripts/test/test-simulation.mjs +14 -0
- package/scripts/test/test-user-service.ts +111 -0
- package/scripts/test-comprehensive-path-resolution.mjs +62 -0
- package/scripts/test-data-processor.py +51 -0
- package/scripts/test-enforcement-e2e.mjs +127 -0
- package/scripts/test-full-plugin-no-timeout.sh +30 -0
- package/scripts/test-path-resolver.mjs +32 -0
- package/scripts/test-rules.mjs +128 -0
- package/scripts/test-stringray-plugin.mjs +66 -0
- package/scripts/test-utils/smart-test-runner.mjs +609 -0
- package/scripts/test-utils/test-quarantine.mjs +246 -0
- package/scripts/validate-codex.js +60 -0
- package/scripts/validate-phase1.mjs +189 -0
- package/scripts/validation/run-validators.js +114 -0
- package/scripts/validation/validate-external-processes.js +240 -0
- package/scripts/validation/validate-mcp-connectivity.js +165 -0
- package/scripts/validation/validate-oh-my-opencode-integration.js +200 -0
- package/scripts/validation/validate-reports.ts +114 -0
- package/scripts/verify-phase1.js +144 -0
|
@@ -0,0 +1,1029 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { frameworkLogger } from "../framework-logger.js";
|
|
4
|
+
export class CodebaseContextAnalyzer {
|
|
5
|
+
projectRoot;
|
|
6
|
+
memoryConfig;
|
|
7
|
+
analysisCache = new Map();
|
|
8
|
+
ignorePatterns = [
|
|
9
|
+
/node_modules/,
|
|
10
|
+
/\.git/,
|
|
11
|
+
/dist/,
|
|
12
|
+
/build/,
|
|
13
|
+
/\.next/,
|
|
14
|
+
/\.nuxt/,
|
|
15
|
+
/\.vuepress/,
|
|
16
|
+
/\.cache/,
|
|
17
|
+
/\.temp/,
|
|
18
|
+
/coverage/,
|
|
19
|
+
/\.nyc_output/,
|
|
20
|
+
/logs/,
|
|
21
|
+
/\.DS_Store/,
|
|
22
|
+
/Thumbs\.db/,
|
|
23
|
+
];
|
|
24
|
+
supportedLanguages = {
|
|
25
|
+
".ts": "typescript",
|
|
26
|
+
".tsx": "typescript",
|
|
27
|
+
".js": "javascript",
|
|
28
|
+
".jsx": "javascript",
|
|
29
|
+
".py": "python",
|
|
30
|
+
".java": "java",
|
|
31
|
+
".cpp": "cpp",
|
|
32
|
+
".c": "c",
|
|
33
|
+
".cs": "csharp",
|
|
34
|
+
".php": "php",
|
|
35
|
+
".rb": "ruby",
|
|
36
|
+
".go": "go",
|
|
37
|
+
".rs": "rust",
|
|
38
|
+
".swift": "swift",
|
|
39
|
+
".kt": "kotlin",
|
|
40
|
+
".scala": "scala",
|
|
41
|
+
".clj": "clojure",
|
|
42
|
+
".hs": "haskell",
|
|
43
|
+
".ml": "ocaml",
|
|
44
|
+
".fs": "fsharp",
|
|
45
|
+
".elm": "elm",
|
|
46
|
+
".dart": "dart",
|
|
47
|
+
".vue": "vue",
|
|
48
|
+
".svelte": "svelte",
|
|
49
|
+
".astro": "astro",
|
|
50
|
+
};
|
|
51
|
+
constructor(projectRoot, memoryConfig) {
|
|
52
|
+
this.projectRoot = projectRoot || process.cwd();
|
|
53
|
+
// Default memory configuration for performance optimization
|
|
54
|
+
this.memoryConfig = {
|
|
55
|
+
maxFilesInMemory: 100, // Process max 100 files simultaneously
|
|
56
|
+
maxFileSizeBytes: 1024 * 1024, // 1MB max file size to load
|
|
57
|
+
enableStreaming: true, // Enable streaming for large files
|
|
58
|
+
batchSize: 20, // Process 20 files per batch
|
|
59
|
+
enableCaching: true, // Enable result caching
|
|
60
|
+
cacheTtlMs: 5 * 60 * 1000, // 5 minute cache TTL
|
|
61
|
+
enableConcurrentProcessing: true, // Enable concurrent processing
|
|
62
|
+
concurrencyLimit: 10, // Max 10 concurrent file operations
|
|
63
|
+
...memoryConfig, // Override with user config
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Perform comprehensive codebase analysis with memory optimization
|
|
68
|
+
*/
|
|
69
|
+
async analyzeCodebase() {
|
|
70
|
+
await frameworkLogger.log("codebase-context-analyzer", "analysis-start", "info", {
|
|
71
|
+
message: "Starting comprehensive codebase analysis",
|
|
72
|
+
memoryConfig: this.memoryConfig,
|
|
73
|
+
});
|
|
74
|
+
const startTime = Date.now();
|
|
75
|
+
const initialMemoryUsage = process.memoryUsage().heapUsed;
|
|
76
|
+
try {
|
|
77
|
+
const structure = await this.buildCodebaseStructure();
|
|
78
|
+
const metrics = this.calculateContextMetrics(structure);
|
|
79
|
+
const insights = this.generateInsights(structure, metrics);
|
|
80
|
+
const recommendations = this.generateRecommendations(structure, metrics);
|
|
81
|
+
const risks = this.identifyRisks(structure, metrics);
|
|
82
|
+
const analysis = {
|
|
83
|
+
structure,
|
|
84
|
+
metrics,
|
|
85
|
+
insights,
|
|
86
|
+
recommendations,
|
|
87
|
+
risks,
|
|
88
|
+
scannedAt: new Date(),
|
|
89
|
+
};
|
|
90
|
+
const endTime = Date.now();
|
|
91
|
+
const finalMemoryUsage = process.memoryUsage().heapUsed;
|
|
92
|
+
const memoryDelta = finalMemoryUsage - initialMemoryUsage;
|
|
93
|
+
await frameworkLogger.log("codebase-context-analyzer", "analysis-complete", "success", {
|
|
94
|
+
files: structure.totalFiles,
|
|
95
|
+
loc: structure.totalLinesOfCode,
|
|
96
|
+
languages: Array.from(structure.languages.keys()),
|
|
97
|
+
qualityScore: metrics.qualityScore,
|
|
98
|
+
duration: endTime - startTime,
|
|
99
|
+
memoryDeltaMB: Math.round((memoryDelta / 1024 / 1024) * 100) / 100,
|
|
100
|
+
cacheHits: this.analysisCache.size,
|
|
101
|
+
});
|
|
102
|
+
return analysis;
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
const endTime = Date.now();
|
|
106
|
+
const finalMemoryUsage = process.memoryUsage().heapUsed;
|
|
107
|
+
await frameworkLogger.log("codebase-context-analyzer", "analysis-failed", "error", {
|
|
108
|
+
error: error instanceof Error ? error.message : String(error),
|
|
109
|
+
duration: endTime - startTime,
|
|
110
|
+
finalMemoryMB: Math.round((finalMemoryUsage / 1024 / 1024) * 100) / 100,
|
|
111
|
+
});
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get cached analysis result with intelligent invalidation
|
|
117
|
+
*/
|
|
118
|
+
getCachedAnalysis(cacheKey) {
|
|
119
|
+
if (!this.memoryConfig.enableCaching)
|
|
120
|
+
return null;
|
|
121
|
+
const cached = this.analysisCache.get(cacheKey);
|
|
122
|
+
if (!cached)
|
|
123
|
+
return null;
|
|
124
|
+
// Check TTL
|
|
125
|
+
if (Date.now() - cached.timestamp > this.memoryConfig.cacheTtlMs) {
|
|
126
|
+
this.analysisCache.delete(cacheKey);
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
// Intelligent cache validation - check if file still exists and hasn't changed
|
|
130
|
+
const filePath = this.extractFilePathFromCacheKey(cacheKey);
|
|
131
|
+
if (filePath) {
|
|
132
|
+
try {
|
|
133
|
+
const currentStats = fs.statSync(filePath);
|
|
134
|
+
const cachedMtime = cached.data.lastModified?.getTime() || 0;
|
|
135
|
+
if (currentStats.mtime.getTime() !== cachedMtime) {
|
|
136
|
+
// File has changed, invalidate cache
|
|
137
|
+
this.analysisCache.delete(cacheKey);
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
// File no longer exists or inaccessible, remove from cache
|
|
143
|
+
this.analysisCache.delete(cacheKey);
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return cached.data;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Set cached analysis result with size limits
|
|
151
|
+
*/
|
|
152
|
+
setCachedAnalysis(cacheKey, data) {
|
|
153
|
+
if (!this.memoryConfig.enableCaching)
|
|
154
|
+
return;
|
|
155
|
+
// Prevent cache from growing too large (keep last 1000 entries)
|
|
156
|
+
if (this.analysisCache.size >= 1000) {
|
|
157
|
+
const oldestKey = Array.from(this.analysisCache.keys())[0];
|
|
158
|
+
if (oldestKey) {
|
|
159
|
+
this.analysisCache.delete(oldestKey);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
this.analysisCache.set(cacheKey, {
|
|
163
|
+
data,
|
|
164
|
+
timestamp: Date.now(),
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Extract file path from cache key for validation
|
|
169
|
+
*/
|
|
170
|
+
extractFilePathFromCacheKey(cacheKey) {
|
|
171
|
+
const match = cacheKey.match(/^file:(.+?:\d+)$/);
|
|
172
|
+
if (match && match[1]) {
|
|
173
|
+
const parts = match[1].split(":");
|
|
174
|
+
return parts[0] || null;
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Stream file content for large files to reduce memory usage
|
|
180
|
+
*/
|
|
181
|
+
async streamFileContent(filePath) {
|
|
182
|
+
return new Promise((resolve, reject) => {
|
|
183
|
+
let content = "";
|
|
184
|
+
const stream = fs.createReadStream(filePath, { encoding: "utf8" });
|
|
185
|
+
stream.on("data", (chunk) => {
|
|
186
|
+
content += chunk;
|
|
187
|
+
// Prevent excessive memory usage during streaming
|
|
188
|
+
if (content.length > this.memoryConfig.maxFileSizeBytes) {
|
|
189
|
+
stream.destroy();
|
|
190
|
+
reject(new Error("File too large for streaming"));
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
stream.on("end", () => resolve(content));
|
|
194
|
+
stream.on("error", reject);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Build complete codebase structure map with batching for memory efficiency
|
|
199
|
+
*/
|
|
200
|
+
async buildCodebaseStructure() {
|
|
201
|
+
const fileGraph = new Map();
|
|
202
|
+
const modules = new Map();
|
|
203
|
+
const dependencyGraph = new Map();
|
|
204
|
+
const languages = new Map();
|
|
205
|
+
const scanDirectory = async (dirPath, relativePath = "") => {
|
|
206
|
+
try {
|
|
207
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
208
|
+
// Process files in batches to control memory usage
|
|
209
|
+
const fileEntries = [];
|
|
210
|
+
const dirEntries = [];
|
|
211
|
+
// Separate files and directories for batch processing
|
|
212
|
+
for (const entry of entries) {
|
|
213
|
+
const entryPath = path.join(dirPath, entry.name);
|
|
214
|
+
const entryRelativePath = path.join(relativePath, entry.name);
|
|
215
|
+
// Skip ignored patterns
|
|
216
|
+
if (this.ignorePatterns.some((pattern) => pattern.test(entryPath))) {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (entry.isDirectory()) {
|
|
220
|
+
const isModule = this.isModuleDirectory(entryPath);
|
|
221
|
+
dirEntries.push({
|
|
222
|
+
path: entryPath,
|
|
223
|
+
relativePath: entryRelativePath,
|
|
224
|
+
isModule,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
else if (entry.isFile()) {
|
|
228
|
+
fileEntries.push({
|
|
229
|
+
path: entryPath,
|
|
230
|
+
relativePath: entryRelativePath,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// Process directories first (may contain modules)
|
|
235
|
+
for (const dirEntry of dirEntries) {
|
|
236
|
+
if (dirEntry.isModule) {
|
|
237
|
+
const moduleInfo = await this.analyzeModule(dirEntry.path, dirEntry.relativePath);
|
|
238
|
+
modules.set(dirEntry.relativePath, moduleInfo);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
await scanDirectory(dirEntry.path, dirEntry.relativePath);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// Process files with concurrent processing for better performance
|
|
245
|
+
const concurrencyLimit = this.memoryConfig.enableConcurrentProcessing
|
|
246
|
+
? Math.min(this.memoryConfig.concurrencyLimit || 10, this.memoryConfig.maxFilesInMemory)
|
|
247
|
+
: 1; // Sequential processing if concurrent disabled
|
|
248
|
+
for (let i = 0; i < fileEntries.length; i += concurrencyLimit) {
|
|
249
|
+
const batch = fileEntries.slice(i, i + concurrencyLimit);
|
|
250
|
+
// Process batch concurrently with controlled parallelism
|
|
251
|
+
const batchPromises = batch.map(async ({ path: filePath, relativePath: fileRelativePath }) => {
|
|
252
|
+
try {
|
|
253
|
+
const fileInfo = await this.analyzeFile(filePath, fileRelativePath);
|
|
254
|
+
if (fileInfo) {
|
|
255
|
+
fileGraph.set(fileRelativePath, fileInfo);
|
|
256
|
+
// Update language counts
|
|
257
|
+
const lang = fileInfo.language;
|
|
258
|
+
languages.set(lang, (languages.get(lang) || 0) + 1);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
await frameworkLogger.log("codebase-context-analyzer", "batch-file-processing-error", "info", {
|
|
263
|
+
filePath,
|
|
264
|
+
error: error instanceof Error ? error.message : String(error),
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
await Promise.all(batchPromises);
|
|
269
|
+
// Yield control periodically to prevent blocking the event loop
|
|
270
|
+
if (i + concurrencyLimit < fileEntries.length) {
|
|
271
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
await frameworkLogger.log("codebase-context-analyzer", "scan-directory-failed", "error", {
|
|
277
|
+
dirPath,
|
|
278
|
+
error: error instanceof Error ? error.message : String(error),
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
await scanDirectory(this.projectRoot);
|
|
283
|
+
// Build dependency relationships
|
|
284
|
+
await this.buildDependencyGraph(fileGraph, dependencyGraph);
|
|
285
|
+
const architecture = this.detectArchitecture(fileGraph, modules);
|
|
286
|
+
return {
|
|
287
|
+
rootPath: this.projectRoot,
|
|
288
|
+
totalFiles: fileGraph.size,
|
|
289
|
+
totalLinesOfCode: Array.from(fileGraph.values()).reduce((sum, file) => sum + file.linesOfCode, 0),
|
|
290
|
+
languages,
|
|
291
|
+
modules,
|
|
292
|
+
fileGraph,
|
|
293
|
+
dependencyGraph,
|
|
294
|
+
architecture,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Analyze individual file for structure and dependencies with memory optimization
|
|
299
|
+
*/
|
|
300
|
+
async analyzeFile(filePath, relativePath) {
|
|
301
|
+
try {
|
|
302
|
+
const stats = fs.statSync(filePath);
|
|
303
|
+
const extension = path.extname(filePath).toLowerCase();
|
|
304
|
+
const language = this.supportedLanguages[extension] || "other";
|
|
305
|
+
const isSourceCode = language !== "other";
|
|
306
|
+
if (!isSourceCode && !this.isConfigFile(relativePath)) {
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
// Memory optimization: Check file size before loading
|
|
310
|
+
if (stats.size > this.memoryConfig.maxFileSizeBytes) {
|
|
311
|
+
await frameworkLogger.log("codebase-context-analyzer", "large-file-skipped", "info", {
|
|
312
|
+
filePath,
|
|
313
|
+
size: stats.size,
|
|
314
|
+
maxSize: this.memoryConfig.maxFileSizeBytes,
|
|
315
|
+
});
|
|
316
|
+
// For large files, analyze metadata only (no content loading)
|
|
317
|
+
return {
|
|
318
|
+
path: filePath,
|
|
319
|
+
relativePath,
|
|
320
|
+
size: stats.size,
|
|
321
|
+
extension,
|
|
322
|
+
language,
|
|
323
|
+
isSourceCode,
|
|
324
|
+
linesOfCode: Math.floor(stats.size / 50), // Rough estimate
|
|
325
|
+
imports: [],
|
|
326
|
+
exports: [],
|
|
327
|
+
dependencies: [],
|
|
328
|
+
lastModified: stats.mtime,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
// Lazy load content only when needed and within memory limits
|
|
332
|
+
let content;
|
|
333
|
+
let linesOfCode = 0;
|
|
334
|
+
let imports = [];
|
|
335
|
+
let exports = [];
|
|
336
|
+
try {
|
|
337
|
+
// Check cache first for performance
|
|
338
|
+
const cacheKey = `file:${relativePath}:${stats.mtime.getTime()}`;
|
|
339
|
+
const cached = this.getCachedAnalysis(cacheKey);
|
|
340
|
+
if (cached) {
|
|
341
|
+
return {
|
|
342
|
+
path: filePath,
|
|
343
|
+
relativePath,
|
|
344
|
+
size: stats.size,
|
|
345
|
+
extension,
|
|
346
|
+
language,
|
|
347
|
+
isSourceCode,
|
|
348
|
+
linesOfCode: cached.linesOfCode,
|
|
349
|
+
imports: cached.imports,
|
|
350
|
+
exports: cached.exports,
|
|
351
|
+
dependencies: cached.imports,
|
|
352
|
+
lastModified: stats.mtime,
|
|
353
|
+
content: cached.content, // Lazy-loaded from cache
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
// Load content with streaming for large files if enabled
|
|
357
|
+
content =
|
|
358
|
+
this.memoryConfig.enableStreaming && stats.size > 100 * 1024
|
|
359
|
+
? await this.streamFileContent(filePath)
|
|
360
|
+
: fs.readFileSync(filePath, "utf8");
|
|
361
|
+
linesOfCode = content.split("\n").length;
|
|
362
|
+
const importExportData = await this.extractImportsExports(content, language);
|
|
363
|
+
imports = importExportData.imports;
|
|
364
|
+
exports = importExportData.exports;
|
|
365
|
+
// Cache the analysis result
|
|
366
|
+
if (this.memoryConfig.enableCaching) {
|
|
367
|
+
this.setCachedAnalysis(cacheKey, {
|
|
368
|
+
linesOfCode,
|
|
369
|
+
imports,
|
|
370
|
+
exports,
|
|
371
|
+
content,
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
catch (contentError) {
|
|
376
|
+
await frameworkLogger.log("codebase-context-analyzer", "content-loading-failed", "info", {
|
|
377
|
+
filePath,
|
|
378
|
+
error: contentError instanceof Error
|
|
379
|
+
? contentError.message
|
|
380
|
+
: String(contentError),
|
|
381
|
+
});
|
|
382
|
+
// Continue with metadata-only analysis
|
|
383
|
+
}
|
|
384
|
+
const result = {
|
|
385
|
+
path: filePath,
|
|
386
|
+
relativePath,
|
|
387
|
+
size: stats.size,
|
|
388
|
+
extension,
|
|
389
|
+
language,
|
|
390
|
+
isSourceCode,
|
|
391
|
+
linesOfCode,
|
|
392
|
+
imports,
|
|
393
|
+
exports,
|
|
394
|
+
dependencies: imports, // For now, imports are dependencies
|
|
395
|
+
lastModified: stats.mtime,
|
|
396
|
+
};
|
|
397
|
+
// Only set content if it was successfully loaded
|
|
398
|
+
if (content !== undefined) {
|
|
399
|
+
result.content = content;
|
|
400
|
+
}
|
|
401
|
+
return result;
|
|
402
|
+
}
|
|
403
|
+
catch (error) {
|
|
404
|
+
await frameworkLogger.log("codebase-context-analyzer", "file-analysis-failed", "error", {
|
|
405
|
+
filePath,
|
|
406
|
+
error: error instanceof Error ? error.message : String(error),
|
|
407
|
+
});
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Analyze module directory structure
|
|
413
|
+
*/
|
|
414
|
+
async analyzeModule(dirPath, relativePath) {
|
|
415
|
+
const files = [];
|
|
416
|
+
const dependencies = new Set();
|
|
417
|
+
const dependents = new Set();
|
|
418
|
+
const scanModuleFiles = async (modulePath, moduleRelativePath) => {
|
|
419
|
+
try {
|
|
420
|
+
const entries = fs.readdirSync(modulePath, { withFileTypes: true });
|
|
421
|
+
for (const entry of entries) {
|
|
422
|
+
const entryPath = path.join(modulePath, entry.name);
|
|
423
|
+
const entryRelativePath = path.join(moduleRelativePath, entry.name);
|
|
424
|
+
if (entry.isFile()) {
|
|
425
|
+
const fileInfo = await this.analyzeFile(entryPath, entryRelativePath);
|
|
426
|
+
if (fileInfo) {
|
|
427
|
+
files.push(fileInfo);
|
|
428
|
+
fileInfo.imports.forEach((dep) => dependencies.add(dep));
|
|
429
|
+
fileInfo.exports.forEach((exp) => dependents.add(exp));
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
else if (entry.isDirectory() &&
|
|
433
|
+
!this.ignorePatterns.some((pattern) => pattern.test(entry.name))) {
|
|
434
|
+
await scanModuleFiles(entryPath, entryRelativePath);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
catch (error) {
|
|
439
|
+
await frameworkLogger.log("codebase-context-analyzer", "module-scan-failed", "error", {
|
|
440
|
+
modulePath,
|
|
441
|
+
error: error instanceof Error ? error.message : String(error),
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
await scanModuleFiles(dirPath, relativePath);
|
|
446
|
+
// Determine module type
|
|
447
|
+
const moduleType = this.classifyModule(relativePath, files);
|
|
448
|
+
// Find entry point
|
|
449
|
+
const entryPoint = this.findEntryPoint(files);
|
|
450
|
+
return {
|
|
451
|
+
name: path.basename(relativePath),
|
|
452
|
+
path: dirPath,
|
|
453
|
+
files,
|
|
454
|
+
entryPoint,
|
|
455
|
+
dependencies: Array.from(dependencies),
|
|
456
|
+
dependents: Array.from(dependents),
|
|
457
|
+
type: moduleType,
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Extract imports and exports from source code
|
|
462
|
+
*/
|
|
463
|
+
async extractImportsExports(content, language) {
|
|
464
|
+
const imports = [];
|
|
465
|
+
const exports = [];
|
|
466
|
+
try {
|
|
467
|
+
switch (language) {
|
|
468
|
+
case "typescript":
|
|
469
|
+
case "javascript":
|
|
470
|
+
return this.extractJsTsImportsExports(content);
|
|
471
|
+
case "python":
|
|
472
|
+
return this.extractPythonImportsExports(content);
|
|
473
|
+
case "java":
|
|
474
|
+
return this.extractJavaImportsExports(content);
|
|
475
|
+
default:
|
|
476
|
+
return { imports: [], exports: [] };
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
await frameworkLogger.log("codebase-context-analyzer", "import-export-extraction-failed", "error", {
|
|
481
|
+
language,
|
|
482
|
+
error: error instanceof Error ? error.message : String(error),
|
|
483
|
+
});
|
|
484
|
+
return { imports: [], exports: [] };
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
extractJsTsImportsExports(content) {
|
|
488
|
+
const imports = [];
|
|
489
|
+
const exports = [];
|
|
490
|
+
// Import patterns
|
|
491
|
+
const importPatterns = [
|
|
492
|
+
/import\s+.*?\s+from\s+['"]([^'"]+)['"]/g,
|
|
493
|
+
/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,
|
|
494
|
+
/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,
|
|
495
|
+
];
|
|
496
|
+
importPatterns.forEach((pattern) => {
|
|
497
|
+
let match;
|
|
498
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
499
|
+
if (match[1]) {
|
|
500
|
+
imports.push(match[1]);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
// Export patterns
|
|
505
|
+
const exportPatterns = [
|
|
506
|
+
/export\s+(?:const|let|var|function|class|interface|type)\s+(\w+)/g,
|
|
507
|
+
/export\s+{\s*([^}]+)\s*}/g,
|
|
508
|
+
/export\s+default/g,
|
|
509
|
+
];
|
|
510
|
+
exportPatterns.forEach((pattern) => {
|
|
511
|
+
let match;
|
|
512
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
513
|
+
if (match[1]) {
|
|
514
|
+
const exportsList = match[1]
|
|
515
|
+
.split(",")
|
|
516
|
+
.map((e) => {
|
|
517
|
+
const trimmed = e.trim();
|
|
518
|
+
const asSplit = trimmed.split(" as ");
|
|
519
|
+
return asSplit[0] || trimmed;
|
|
520
|
+
})
|
|
521
|
+
.filter(Boolean);
|
|
522
|
+
exports.push(...exportsList);
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
exports.push("default");
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
return {
|
|
530
|
+
imports: Array.from(new Set(imports)),
|
|
531
|
+
exports: Array.from(new Set(exports)),
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
extractPythonImportsExports(content) {
|
|
535
|
+
const imports = [];
|
|
536
|
+
const exports = [];
|
|
537
|
+
// Import patterns
|
|
538
|
+
const importPatterns = [/from\s+([^\s]+)\s+import/g, /import\s+([^\s]+)/g];
|
|
539
|
+
importPatterns.forEach((pattern) => {
|
|
540
|
+
let match;
|
|
541
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
542
|
+
if (match[1]) {
|
|
543
|
+
imports.push(match[1]);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
// Export patterns (Python doesn't have explicit exports, but __all__ can indicate public API)
|
|
548
|
+
const allMatch = content.match(/__all__\s*=\s*\[([^\]]+)\]/);
|
|
549
|
+
if (allMatch && allMatch[1]) {
|
|
550
|
+
const exportsList = allMatch[1]
|
|
551
|
+
.split(",")
|
|
552
|
+
.map((e) => e.trim().replace(/['"]/g, ""))
|
|
553
|
+
.filter(Boolean);
|
|
554
|
+
exports.push(...exportsList);
|
|
555
|
+
}
|
|
556
|
+
return {
|
|
557
|
+
imports: Array.from(new Set(imports)),
|
|
558
|
+
exports: Array.from(new Set(exports)),
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
extractJavaImportsExports(content) {
|
|
562
|
+
const imports = [];
|
|
563
|
+
const exports = [];
|
|
564
|
+
// Import patterns
|
|
565
|
+
const importPattern = /^import\s+([^;]+);/gm;
|
|
566
|
+
let match;
|
|
567
|
+
while ((match = importPattern.exec(content)) !== null) {
|
|
568
|
+
if (match[1]) {
|
|
569
|
+
imports.push(match[1]);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
// Export patterns (public classes/interfaces)
|
|
573
|
+
const exportPattern = /(?:public\s+)?(?:class|interface|enum)\s+(\w+)/g;
|
|
574
|
+
while ((match = exportPattern.exec(content)) !== null) {
|
|
575
|
+
if (match[1]) {
|
|
576
|
+
exports.push(match[1]);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return {
|
|
580
|
+
imports: Array.from(new Set(imports)),
|
|
581
|
+
exports: Array.from(new Set(exports)),
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Build dependency graph between files
|
|
586
|
+
*/
|
|
587
|
+
async buildDependencyGraph(fileGraph, dependencyGraph) {
|
|
588
|
+
for (const [filePath, fileInfo] of Array.from(fileGraph)) {
|
|
589
|
+
const dependencies = new Set();
|
|
590
|
+
for (const importPath of fileInfo.imports) {
|
|
591
|
+
// Resolve relative imports
|
|
592
|
+
if (importPath.startsWith("./") || importPath.startsWith("../")) {
|
|
593
|
+
try {
|
|
594
|
+
const resolvedPath = path.resolve(path.dirname(fileInfo.path), importPath);
|
|
595
|
+
const resolvedRelative = path.relative(this.projectRoot, resolvedPath);
|
|
596
|
+
// Check for file extensions
|
|
597
|
+
const possibleExtensions = [
|
|
598
|
+
"",
|
|
599
|
+
".ts",
|
|
600
|
+
".tsx",
|
|
601
|
+
".js",
|
|
602
|
+
".jsx",
|
|
603
|
+
".py",
|
|
604
|
+
".java",
|
|
605
|
+
];
|
|
606
|
+
let foundFile = null;
|
|
607
|
+
for (const ext of possibleExtensions) {
|
|
608
|
+
const testPath = resolvedRelative + ext;
|
|
609
|
+
if (fileGraph.has(testPath) ||
|
|
610
|
+
fs.existsSync(path.join(this.projectRoot, testPath))) {
|
|
611
|
+
foundFile = testPath;
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
if (foundFile) {
|
|
616
|
+
dependencies.add(foundFile);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
catch (error) {
|
|
620
|
+
// Import resolution failed, skip
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
// External dependency, add to graph for tracking
|
|
625
|
+
dependencies.add(importPath);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
dependencyGraph.set(filePath, dependencies);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Detect architectural patterns and framework usage
|
|
633
|
+
*/
|
|
634
|
+
detectArchitecture(fileGraph, modules) {
|
|
635
|
+
const frameworks = [];
|
|
636
|
+
const patterns = [];
|
|
637
|
+
let structure = "monolithic";
|
|
638
|
+
const entryPoints = [];
|
|
639
|
+
// Framework detection
|
|
640
|
+
if (this.hasFramework(fileGraph, "react"))
|
|
641
|
+
frameworks.push("React");
|
|
642
|
+
if (this.hasFramework(fileGraph, "vue"))
|
|
643
|
+
frameworks.push("Vue.js");
|
|
644
|
+
if (this.hasFramework(fileGraph, "angular"))
|
|
645
|
+
frameworks.push("Angular");
|
|
646
|
+
if (this.hasFramework(fileGraph, "svelte"))
|
|
647
|
+
frameworks.push("Svelte");
|
|
648
|
+
if (this.hasFramework(fileGraph, "express"))
|
|
649
|
+
frameworks.push("Express.js");
|
|
650
|
+
if (this.hasFramework(fileGraph, "nestjs"))
|
|
651
|
+
frameworks.push("NestJS");
|
|
652
|
+
if (this.hasFramework(fileGraph, "nextjs"))
|
|
653
|
+
frameworks.push("Next.js");
|
|
654
|
+
if (this.hasFramework(fileGraph, "nuxt"))
|
|
655
|
+
frameworks.push("Nuxt.js");
|
|
656
|
+
// Pattern detection
|
|
657
|
+
if (this.detectMVCPattern(fileGraph))
|
|
658
|
+
patterns.push("MVC");
|
|
659
|
+
if (this.detectRepositoryPattern(fileGraph))
|
|
660
|
+
patterns.push("Repository");
|
|
661
|
+
if (this.detectObserverPattern(fileGraph))
|
|
662
|
+
patterns.push("Observer");
|
|
663
|
+
if (this.detectFactoryPattern(fileGraph))
|
|
664
|
+
patterns.push("Factory");
|
|
665
|
+
// Structure detection
|
|
666
|
+
if (modules.size > 5 && this.hasMicroservicesIndicators(fileGraph)) {
|
|
667
|
+
structure = "microservices";
|
|
668
|
+
}
|
|
669
|
+
else if (modules.size > 0) {
|
|
670
|
+
structure = "modular";
|
|
671
|
+
}
|
|
672
|
+
// Entry points detection
|
|
673
|
+
for (const [filePath, fileInfo] of Array.from(fileGraph)) {
|
|
674
|
+
if (this.isEntryPoint(filePath, fileInfo)) {
|
|
675
|
+
entryPoints.push(filePath);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
return {
|
|
679
|
+
framework: frameworks,
|
|
680
|
+
patterns,
|
|
681
|
+
structure,
|
|
682
|
+
entryPoints,
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Calculate comprehensive context metrics
|
|
687
|
+
*/
|
|
688
|
+
calculateContextMetrics(structure) {
|
|
689
|
+
const fileCount = structure.totalFiles;
|
|
690
|
+
const linesOfCode = structure.totalLinesOfCode;
|
|
691
|
+
const languages = Array.from(structure.languages.keys());
|
|
692
|
+
// Calculate complexity based on various factors
|
|
693
|
+
const complexity = this.calculateComplexityScore(structure);
|
|
694
|
+
// Calculate coupling (interdependencies)
|
|
695
|
+
const coupling = this.calculateCouplingScore(structure);
|
|
696
|
+
// Calculate cohesion (internal dependencies within modules)
|
|
697
|
+
const cohesion = this.calculateCohesionScore(structure);
|
|
698
|
+
// Estimate test coverage (rough heuristic)
|
|
699
|
+
const testCoverage = this.estimateTestCoverage(structure);
|
|
700
|
+
// Architectural patterns
|
|
701
|
+
const architecturalPatterns = structure.architecture.patterns;
|
|
702
|
+
// Overall quality score
|
|
703
|
+
const qualityScore = this.calculateQualityScore({
|
|
704
|
+
fileCount,
|
|
705
|
+
linesOfCode,
|
|
706
|
+
complexity,
|
|
707
|
+
coupling,
|
|
708
|
+
cohesion,
|
|
709
|
+
testCoverage,
|
|
710
|
+
patterns: architecturalPatterns.length,
|
|
711
|
+
});
|
|
712
|
+
return {
|
|
713
|
+
fileCount,
|
|
714
|
+
linesOfCode,
|
|
715
|
+
languages,
|
|
716
|
+
complexity,
|
|
717
|
+
coupling,
|
|
718
|
+
cohesion,
|
|
719
|
+
testCoverage,
|
|
720
|
+
architecturalPatterns,
|
|
721
|
+
qualityScore,
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
calculateComplexityScore(structure) {
|
|
725
|
+
let score = 0;
|
|
726
|
+
// File count factor
|
|
727
|
+
score += Math.min(structure.totalFiles / 10, 20);
|
|
728
|
+
// Language diversity factor
|
|
729
|
+
score += Math.min(structure.languages.size * 5, 15);
|
|
730
|
+
// Module complexity
|
|
731
|
+
score += Math.min(structure.modules.size * 2, 20);
|
|
732
|
+
// Dependency complexity
|
|
733
|
+
const totalDeps = Array.from(structure.dependencyGraph.values()).reduce((sum, deps) => sum + deps.size, 0);
|
|
734
|
+
score += Math.min(totalDeps / 20, 25);
|
|
735
|
+
// Framework complexity
|
|
736
|
+
score += Math.min(structure.architecture.framework.length * 10, 20);
|
|
737
|
+
return Math.min(Math.max(score, 0), 100);
|
|
738
|
+
}
|
|
739
|
+
calculateCouplingScore(structure) {
|
|
740
|
+
const totalDeps = Array.from(structure.dependencyGraph.values()).reduce((sum, deps) => sum + deps.size, 0);
|
|
741
|
+
const avgDeps = totalDeps / structure.totalFiles;
|
|
742
|
+
// Normalize to 0-100 scale (higher coupling = higher score)
|
|
743
|
+
return Math.min(avgDeps * 20, 100);
|
|
744
|
+
}
|
|
745
|
+
calculateCohesionScore(structure) {
|
|
746
|
+
let totalCohesion = 0;
|
|
747
|
+
let moduleCount = 0;
|
|
748
|
+
for (const module of Array.from(structure.modules.values())) {
|
|
749
|
+
if (module.files.length > 1) {
|
|
750
|
+
// Calculate internal dependencies within module
|
|
751
|
+
const internalDeps = module.files.reduce((sum, file) => {
|
|
752
|
+
const fileDeps = structure.dependencyGraph.get(file.relativePath) || new Set();
|
|
753
|
+
const internalCount = Array.from(fileDeps).filter((dep) => module.files.some((f) => f.relativePath === dep)).length;
|
|
754
|
+
return sum + internalCount;
|
|
755
|
+
}, 0);
|
|
756
|
+
const cohesion = internalDeps / (module.files.length * (module.files.length - 1));
|
|
757
|
+
totalCohesion += Math.min(cohesion, 1);
|
|
758
|
+
moduleCount++;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
return moduleCount > 0 ? (totalCohesion / moduleCount) * 100 : 50;
|
|
762
|
+
}
|
|
763
|
+
estimateTestCoverage(structure) {
|
|
764
|
+
const testFiles = Array.from(structure.fileGraph.values()).filter((file) => file.relativePath.includes("test") ||
|
|
765
|
+
file.relativePath.includes("spec")).length;
|
|
766
|
+
const srcFiles = Array.from(structure.fileGraph.values()).filter((file) => file.isSourceCode &&
|
|
767
|
+
!file.relativePath.includes("test") &&
|
|
768
|
+
!file.relativePath.includes("spec")).length;
|
|
769
|
+
if (srcFiles === 0)
|
|
770
|
+
return 0;
|
|
771
|
+
// Rough heuristic: assume 1 test file covers 3-5 source files
|
|
772
|
+
const estimatedCoverage = Math.min(((testFiles * 4) / srcFiles) * 100, 100);
|
|
773
|
+
return Math.round(estimatedCoverage);
|
|
774
|
+
}
|
|
775
|
+
calculateQualityScore(metrics) {
|
|
776
|
+
// Weighted scoring system
|
|
777
|
+
const weights = {
|
|
778
|
+
complexity: -0.2, // Lower complexity is better
|
|
779
|
+
coupling: -0.25, // Lower coupling is better
|
|
780
|
+
cohesion: 0.2, // Higher cohesion is better
|
|
781
|
+
testCoverage: 0.25, // Higher coverage is better
|
|
782
|
+
patterns: 0.1, // More patterns is better
|
|
783
|
+
};
|
|
784
|
+
let score = 50; // Base score
|
|
785
|
+
score += weights.complexity * Math.min(metrics.complexity, 50);
|
|
786
|
+
score += weights.coupling * (100 - metrics.coupling);
|
|
787
|
+
score += weights.cohesion * metrics.cohesion;
|
|
788
|
+
score += weights.testCoverage * metrics.testCoverage;
|
|
789
|
+
score += weights.patterns * Math.min(metrics.patterns * 10, 20);
|
|
790
|
+
return Math.min(Math.max(Math.round(score), 0), 100);
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Generate insights based on analysis
|
|
794
|
+
*/
|
|
795
|
+
generateInsights(structure, metrics) {
|
|
796
|
+
const insights = [];
|
|
797
|
+
// Size insights
|
|
798
|
+
if (structure.totalFiles > 1000) {
|
|
799
|
+
insights.push(`Large codebase with ${structure.totalFiles} files - consider modularization`);
|
|
800
|
+
}
|
|
801
|
+
else if (structure.totalFiles < 10) {
|
|
802
|
+
insights.push("Small codebase - good candidate for rapid development");
|
|
803
|
+
}
|
|
804
|
+
// Language insights
|
|
805
|
+
if (structure.languages.size > 3) {
|
|
806
|
+
insights.push(`Polyglot codebase with ${structure.languages.size} languages`);
|
|
807
|
+
}
|
|
808
|
+
else if (structure.languages.size === 1) {
|
|
809
|
+
insights.push("Single-language codebase - easier maintenance but potential skill limitations");
|
|
810
|
+
}
|
|
811
|
+
// Architecture insights
|
|
812
|
+
if (structure.architecture.framework.length > 0) {
|
|
813
|
+
insights.push(`Uses ${structure.architecture.framework.join(", ")} framework(s)`);
|
|
814
|
+
}
|
|
815
|
+
if (structure.architecture.patterns.length > 0) {
|
|
816
|
+
insights.push(`Follows ${structure.architecture.patterns.join(", ")} architectural pattern(s)`);
|
|
817
|
+
}
|
|
818
|
+
// Quality insights
|
|
819
|
+
if (metrics.qualityScore > 80) {
|
|
820
|
+
insights.push("High-quality codebase with strong architectural foundations");
|
|
821
|
+
}
|
|
822
|
+
else if (metrics.qualityScore < 40) {
|
|
823
|
+
insights.push("Codebase may benefit from refactoring and quality improvements");
|
|
824
|
+
}
|
|
825
|
+
if (metrics.testCoverage > 80) {
|
|
826
|
+
insights.push("Excellent test coverage provides strong confidence in changes");
|
|
827
|
+
}
|
|
828
|
+
else if (metrics.testCoverage < 20) {
|
|
829
|
+
insights.push("Low test coverage increases risk of undetected regressions");
|
|
830
|
+
}
|
|
831
|
+
return insights;
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Generate recommendations for improvement
|
|
835
|
+
*/
|
|
836
|
+
generateRecommendations(structure, metrics) {
|
|
837
|
+
const recommendations = [];
|
|
838
|
+
if (metrics.testCoverage < 70) {
|
|
839
|
+
recommendations.push("Increase test coverage to reduce regression risk");
|
|
840
|
+
}
|
|
841
|
+
if (metrics.coupling > 70) {
|
|
842
|
+
recommendations.push("Reduce coupling through better separation of concerns");
|
|
843
|
+
}
|
|
844
|
+
if (metrics.cohesion < 30) {
|
|
845
|
+
recommendations.push("Improve cohesion by grouping related functionality");
|
|
846
|
+
}
|
|
847
|
+
if (structure.modules.size === 0 && structure.totalFiles > 50) {
|
|
848
|
+
recommendations.push("Consider modularizing the codebase for better maintainability");
|
|
849
|
+
}
|
|
850
|
+
if (structure.architecture.framework.length === 0 &&
|
|
851
|
+
structure.totalFiles > 20) {
|
|
852
|
+
recommendations.push("Consider adopting a framework to standardize development patterns");
|
|
853
|
+
}
|
|
854
|
+
if (metrics.complexity > 80) {
|
|
855
|
+
recommendations.push("Consider breaking down complex components into smaller, focused units");
|
|
856
|
+
}
|
|
857
|
+
return recommendations;
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Identify potential risks and issues
|
|
861
|
+
*/
|
|
862
|
+
identifyRisks(structure, metrics) {
|
|
863
|
+
const risks = [];
|
|
864
|
+
if (metrics.coupling > 80) {
|
|
865
|
+
risks.push("High coupling increases change risk and maintenance complexity");
|
|
866
|
+
}
|
|
867
|
+
if (metrics.testCoverage < 30) {
|
|
868
|
+
risks.push("Low test coverage poses significant risk for safe refactoring");
|
|
869
|
+
}
|
|
870
|
+
if (structure.dependencyGraph.size > 0) {
|
|
871
|
+
// Check for circular dependencies (simplified check)
|
|
872
|
+
const circularDeps = this.detectCircularDependencies(structure.dependencyGraph);
|
|
873
|
+
if (circularDeps.length > 0) {
|
|
874
|
+
risks.push(`${circularDeps.length} potential circular dependencies detected`);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
if (structure.languages.size > 5) {
|
|
878
|
+
risks.push("High language diversity may complicate team composition and maintenance");
|
|
879
|
+
}
|
|
880
|
+
if (metrics.complexity > 90) {
|
|
881
|
+
risks.push("Very high complexity indicates potential maintainability issues");
|
|
882
|
+
}
|
|
883
|
+
return risks;
|
|
884
|
+
}
|
|
885
|
+
// Helper methods
|
|
886
|
+
isModuleDirectory(dirPath) {
|
|
887
|
+
try {
|
|
888
|
+
const entries = fs.readdirSync(dirPath);
|
|
889
|
+
return (entries.some((entry) => {
|
|
890
|
+
const ext = path.extname(entry);
|
|
891
|
+
return this.supportedLanguages[ext];
|
|
892
|
+
}) &&
|
|
893
|
+
entries.some((entry) => entry === "package.json" ||
|
|
894
|
+
entry === "index.ts" ||
|
|
895
|
+
entry === "index.js"));
|
|
896
|
+
}
|
|
897
|
+
catch {
|
|
898
|
+
return false;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
isConfigFile(filePath) {
|
|
902
|
+
const configPatterns = [
|
|
903
|
+
/package\.json$/,
|
|
904
|
+
/tsconfig\.json$/,
|
|
905
|
+
/webpack\.config\./,
|
|
906
|
+
/\.eslintrc/,
|
|
907
|
+
/\.prettierrc/,
|
|
908
|
+
/Dockerfile/,
|
|
909
|
+
/docker-compose\.yml/,
|
|
910
|
+
/\.env/,
|
|
911
|
+
];
|
|
912
|
+
return configPatterns.some((pattern) => pattern.test(filePath));
|
|
913
|
+
}
|
|
914
|
+
classifyModule(relativePath, files) {
|
|
915
|
+
if (relativePath.includes("test") || relativePath.includes("spec")) {
|
|
916
|
+
return "test";
|
|
917
|
+
}
|
|
918
|
+
if (relativePath.includes("docs") ||
|
|
919
|
+
files.some((f) => f.extension === ".md")) {
|
|
920
|
+
return "docs";
|
|
921
|
+
}
|
|
922
|
+
if (files.some((f) => ["package.json", "Dockerfile", "docker-compose.yml"].includes(path.basename(f.relativePath)))) {
|
|
923
|
+
return "infrastructure";
|
|
924
|
+
}
|
|
925
|
+
if (files.some((f) => f.relativePath.includes("config") || f.relativePath.includes(".env"))) {
|
|
926
|
+
return "config";
|
|
927
|
+
}
|
|
928
|
+
return "source";
|
|
929
|
+
}
|
|
930
|
+
findEntryPoint(files) {
|
|
931
|
+
const entryCandidates = [
|
|
932
|
+
"index.ts",
|
|
933
|
+
"index.js",
|
|
934
|
+
"main.ts",
|
|
935
|
+
"main.js",
|
|
936
|
+
"app.ts",
|
|
937
|
+
"app.js",
|
|
938
|
+
];
|
|
939
|
+
for (const candidate of entryCandidates) {
|
|
940
|
+
const file = files.find((f) => path.basename(f.relativePath) === candidate);
|
|
941
|
+
if (file)
|
|
942
|
+
return file.relativePath;
|
|
943
|
+
}
|
|
944
|
+
// Fallback to first source file
|
|
945
|
+
const sourceFile = files.find((f) => f.isSourceCode);
|
|
946
|
+
return sourceFile?.relativePath;
|
|
947
|
+
}
|
|
948
|
+
hasFramework(fileGraph, framework) {
|
|
949
|
+
for (const file of Array.from(fileGraph.values())) {
|
|
950
|
+
if (file.content?.toLowerCase().includes(framework.toLowerCase())) {
|
|
951
|
+
return true;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
return false;
|
|
955
|
+
}
|
|
956
|
+
detectMVCPattern(fileGraph) {
|
|
957
|
+
const hasControllers = Array.from(fileGraph.keys()).some((path) => path.includes("controller"));
|
|
958
|
+
const hasModels = Array.from(fileGraph.keys()).some((path) => path.includes("model"));
|
|
959
|
+
const hasViews = Array.from(fileGraph.keys()).some((path) => path.includes("view"));
|
|
960
|
+
return hasControllers && hasModels && hasViews;
|
|
961
|
+
}
|
|
962
|
+
detectRepositoryPattern(fileGraph) {
|
|
963
|
+
return Array.from(fileGraph.keys()).some((path) => path.includes("repository"));
|
|
964
|
+
}
|
|
965
|
+
detectObserverPattern(fileGraph) {
|
|
966
|
+
return Array.from(fileGraph.values()).some((file) => file.content?.includes("subscribe") ||
|
|
967
|
+
file.content?.includes("observe"));
|
|
968
|
+
}
|
|
969
|
+
detectFactoryPattern(fileGraph) {
|
|
970
|
+
return Array.from(fileGraph.keys()).some((path) => path.includes("factory"));
|
|
971
|
+
}
|
|
972
|
+
hasMicroservicesIndicators(fileGraph) {
|
|
973
|
+
return Array.from(fileGraph.keys()).some((path) => path.includes("docker") ||
|
|
974
|
+
path.includes("kubernetes") ||
|
|
975
|
+
path.includes("service"));
|
|
976
|
+
}
|
|
977
|
+
isEntryPoint(filePath, fileInfo) {
|
|
978
|
+
const entryIndicators = [
|
|
979
|
+
"index.ts",
|
|
980
|
+
"index.js",
|
|
981
|
+
"main.ts",
|
|
982
|
+
"main.js",
|
|
983
|
+
"app.ts",
|
|
984
|
+
"app.js",
|
|
985
|
+
"server.ts",
|
|
986
|
+
"server.js",
|
|
987
|
+
"cli.ts",
|
|
988
|
+
"cli.js",
|
|
989
|
+
];
|
|
990
|
+
return (entryIndicators.includes(path.basename(filePath)) ||
|
|
991
|
+
Boolean(fileInfo.content?.includes("#!/usr/bin/env")) ||
|
|
992
|
+
Boolean(fileInfo.content?.includes("process.argv")));
|
|
993
|
+
}
|
|
994
|
+
detectCircularDependencies(dependencyGraph) {
|
|
995
|
+
const circularDeps = [];
|
|
996
|
+
const visited = new Set();
|
|
997
|
+
const recursionStack = new Set();
|
|
998
|
+
const dfs = (node) => {
|
|
999
|
+
visited.add(node);
|
|
1000
|
+
recursionStack.add(node);
|
|
1001
|
+
const dependencies = dependencyGraph.get(node) || new Set();
|
|
1002
|
+
for (const dep of Array.from(dependencies)) {
|
|
1003
|
+
if (!visited.has(dep)) {
|
|
1004
|
+
if (dfs(dep)) {
|
|
1005
|
+
circularDeps.push(`${node} -> ${dep}`);
|
|
1006
|
+
return true;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
else if (recursionStack.has(dep)) {
|
|
1010
|
+
circularDeps.push(`${node} -> ${dep}`);
|
|
1011
|
+
return true;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
recursionStack.delete(node);
|
|
1015
|
+
return false;
|
|
1016
|
+
};
|
|
1017
|
+
for (const node of Array.from(dependencyGraph.keys())) {
|
|
1018
|
+
if (!visited.has(node)) {
|
|
1019
|
+
dfs(node);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
return circularDeps;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
// Export factory function for optimized analyzers
|
|
1026
|
+
export const createCodebaseContextAnalyzer = (projectRoot, memoryConfig) => {
|
|
1027
|
+
return new CodebaseContextAnalyzer(projectRoot, memoryConfig);
|
|
1028
|
+
};
|
|
1029
|
+
//# sourceMappingURL=codebase-context-analyzer.js.map
|