fivocell 1.0.0 → 1.0.2
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 +202 -98
- package/README.md +418 -180
- package/dist/cli.js +698 -80
- package/dist/cli.js.map +1 -1
- package/dist/core/__tests__/ab-test-framework.test.d.ts +2 -0
- package/dist/core/__tests__/ab-test-framework.test.d.ts.map +1 -0
- package/dist/core/__tests__/ab-test-framework.test.js +43 -0
- package/dist/core/__tests__/ab-test-framework.test.js.map +1 -0
- package/dist/core/__tests__/ai-memory.test.d.ts +2 -0
- package/dist/core/__tests__/ai-memory.test.d.ts.map +1 -0
- package/dist/core/__tests__/ai-memory.test.js +143 -0
- package/dist/core/__tests__/ai-memory.test.js.map +1 -0
- package/dist/core/__tests__/ast-extractor.test.d.ts +2 -0
- package/dist/core/__tests__/ast-extractor.test.d.ts.map +1 -0
- package/dist/core/__tests__/ast-extractor.test.js +30 -0
- package/dist/core/__tests__/ast-extractor.test.js.map +1 -0
- package/dist/core/__tests__/build-failure-predictor.test.d.ts +2 -0
- package/dist/core/__tests__/build-failure-predictor.test.d.ts.map +1 -0
- package/dist/core/__tests__/build-failure-predictor.test.js +76 -0
- package/dist/core/__tests__/build-failure-predictor.test.js.map +1 -0
- package/dist/core/__tests__/chapter3-verify.test.d.ts +2 -0
- package/dist/core/__tests__/chapter3-verify.test.d.ts.map +1 -0
- package/dist/core/__tests__/chapter3-verify.test.js +315 -0
- package/dist/core/__tests__/chapter3-verify.test.js.map +1 -0
- package/dist/core/__tests__/chapter4-hostile.test.d.ts +11 -0
- package/dist/core/__tests__/chapter4-hostile.test.d.ts.map +1 -0
- package/dist/core/__tests__/chapter4-hostile.test.js +269 -0
- package/dist/core/__tests__/chapter4-hostile.test.js.map +1 -0
- package/dist/core/__tests__/chapter4-verify.test.d.ts +2 -0
- package/dist/core/__tests__/chapter4-verify.test.d.ts.map +1 -0
- package/dist/core/__tests__/chapter4-verify.test.js +349 -0
- package/dist/core/__tests__/chapter4-verify.test.js.map +1 -0
- package/dist/core/__tests__/chapter8-hostile.test.d.ts +2 -0
- package/dist/core/__tests__/chapter8-hostile.test.d.ts.map +1 -0
- package/dist/core/__tests__/chapter8-hostile.test.js +445 -0
- package/dist/core/__tests__/chapter8-hostile.test.js.map +1 -0
- package/dist/core/__tests__/chapter9-hostile.test.d.ts +2 -0
- package/dist/core/__tests__/chapter9-hostile.test.d.ts.map +1 -0
- package/dist/core/__tests__/chapter9-hostile.test.js +783 -0
- package/dist/core/__tests__/chapter9-hostile.test.js.map +1 -0
- package/dist/core/__tests__/circular-dependency-detector.test.d.ts +2 -0
- package/dist/core/__tests__/circular-dependency-detector.test.d.ts.map +1 -0
- package/dist/core/__tests__/circular-dependency-detector.test.js +55 -0
- package/dist/core/__tests__/circular-dependency-detector.test.js.map +1 -0
- package/dist/core/__tests__/community-full.test.d.ts +2 -0
- package/dist/core/__tests__/community-full.test.d.ts.map +1 -0
- package/dist/core/__tests__/community-full.test.js +70 -0
- package/dist/core/__tests__/community-full.test.js.map +1 -0
- package/dist/core/__tests__/community-live.test.d.ts +2 -0
- package/dist/core/__tests__/community-live.test.d.ts.map +1 -0
- package/dist/core/__tests__/community-live.test.js +67 -0
- package/dist/core/__tests__/community-live.test.js.map +1 -0
- package/dist/core/__tests__/complexity-analyzer.test.d.ts +2 -0
- package/dist/core/__tests__/complexity-analyzer.test.d.ts.map +1 -0
- package/dist/core/__tests__/complexity-analyzer.test.js +54 -0
- package/dist/core/__tests__/complexity-analyzer.test.js.map +1 -0
- package/dist/core/__tests__/config-attribution.test.d.ts +2 -0
- package/dist/core/__tests__/config-attribution.test.d.ts.map +1 -0
- package/dist/core/__tests__/config-attribution.test.js +45 -0
- package/dist/core/__tests__/config-attribution.test.js.map +1 -0
- package/dist/core/__tests__/conflict-detector.test.d.ts +2 -0
- package/dist/core/__tests__/conflict-detector.test.d.ts.map +1 -0
- package/dist/core/__tests__/conflict-detector.test.js +120 -0
- package/dist/core/__tests__/conflict-detector.test.js.map +1 -0
- package/dist/core/__tests__/context-restore.test.d.ts +2 -0
- package/dist/core/__tests__/context-restore.test.d.ts.map +1 -0
- package/dist/core/__tests__/context-restore.test.js +75 -0
- package/dist/core/__tests__/context-restore.test.js.map +1 -0
- package/dist/core/__tests__/convention-detector.test.d.ts +2 -0
- package/dist/core/__tests__/convention-detector.test.d.ts.map +1 -0
- package/dist/core/__tests__/convention-detector.test.js +97 -0
- package/dist/core/__tests__/convention-detector.test.js.map +1 -0
- package/dist/core/__tests__/cost-optimizer.test.d.ts +1 -0
- package/dist/core/__tests__/cost-optimizer.test.d.ts.map +1 -0
- package/dist/core/__tests__/cost-optimizer.test.js +92 -0
- package/dist/core/__tests__/cost-optimizer.test.js.map +1 -0
- package/dist/core/__tests__/cross-domain-projections.test.d.ts +2 -0
- package/dist/core/__tests__/cross-domain-projections.test.d.ts.map +1 -0
- package/dist/core/__tests__/cross-domain-projections.test.js +36 -0
- package/dist/core/__tests__/cross-domain-projections.test.js.map +1 -0
- package/dist/core/__tests__/cross-project-sync.test.d.ts +2 -0
- package/dist/core/__tests__/cross-project-sync.test.d.ts.map +1 -0
- package/dist/core/__tests__/cross-project-sync.test.js +67 -0
- package/dist/core/__tests__/cross-project-sync.test.js.map +1 -0
- package/dist/core/__tests__/dead-code-detector.test.d.ts +2 -0
- package/dist/core/__tests__/dead-code-detector.test.d.ts.map +1 -0
- package/dist/core/__tests__/dead-code-detector.test.js +41 -0
- package/dist/core/__tests__/dead-code-detector.test.js.map +1 -0
- package/dist/core/__tests__/dependency-health-checker.test.d.ts +2 -0
- package/dist/core/__tests__/dependency-health-checker.test.d.ts.map +1 -0
- package/dist/core/__tests__/dependency-health-checker.test.js +50 -0
- package/dist/core/__tests__/dependency-health-checker.test.js.map +1 -0
- package/dist/core/__tests__/duplication-detector.test.d.ts +2 -0
- package/dist/core/__tests__/duplication-detector.test.d.ts.map +1 -0
- package/dist/core/__tests__/duplication-detector.test.js +46 -0
- package/dist/core/__tests__/duplication-detector.test.js.map +1 -0
- package/dist/core/__tests__/error-predictor.test.d.ts +2 -0
- package/dist/core/__tests__/error-predictor.test.d.ts.map +1 -0
- package/dist/core/__tests__/error-predictor.test.js +65 -0
- package/dist/core/__tests__/error-predictor.test.js.map +1 -0
- package/dist/core/__tests__/explainability.test.d.ts +2 -0
- package/dist/core/__tests__/explainability.test.d.ts.map +1 -0
- package/dist/core/__tests__/explainability.test.js +112 -0
- package/dist/core/__tests__/explainability.test.js.map +1 -0
- package/dist/core/__tests__/failure-memory.test.d.ts +2 -0
- package/dist/core/__tests__/failure-memory.test.d.ts.map +1 -0
- package/dist/core/__tests__/failure-memory.test.js +124 -0
- package/dist/core/__tests__/failure-memory.test.js.map +1 -0
- package/dist/core/__tests__/git-branch-pregenerator.test.d.ts +2 -0
- package/dist/core/__tests__/git-branch-pregenerator.test.d.ts.map +1 -0
- package/dist/core/__tests__/git-branch-pregenerator.test.js +44 -0
- package/dist/core/__tests__/git-branch-pregenerator.test.js.map +1 -0
- package/dist/core/__tests__/handoff-detector.test.d.ts +2 -0
- package/dist/core/__tests__/handoff-detector.test.d.ts.map +1 -0
- package/dist/core/__tests__/handoff-detector.test.js +71 -0
- package/dist/core/__tests__/handoff-detector.test.js.map +1 -0
- package/dist/core/__tests__/interruption-recovery.test.d.ts +2 -0
- package/dist/core/__tests__/interruption-recovery.test.d.ts.map +1 -0
- package/dist/core/__tests__/interruption-recovery.test.js +66 -0
- package/dist/core/__tests__/interruption-recovery.test.js.map +1 -0
- package/dist/core/__tests__/knowledge-graph.test.d.ts +1 -0
- package/dist/core/__tests__/knowledge-graph.test.d.ts.map +1 -0
- package/dist/core/__tests__/knowledge-graph.test.js +124 -0
- package/dist/core/__tests__/knowledge-graph.test.js.map +1 -0
- package/dist/core/__tests__/knowledge-silo-detector.test.d.ts +2 -0
- package/dist/core/__tests__/knowledge-silo-detector.test.d.ts.map +1 -0
- package/dist/core/__tests__/knowledge-silo-detector.test.js +77 -0
- package/dist/core/__tests__/knowledge-silo-detector.test.js.map +1 -0
- package/dist/core/__tests__/language-switch-assistant.test.d.ts +2 -0
- package/dist/core/__tests__/language-switch-assistant.test.d.ts.map +1 -0
- package/dist/core/__tests__/language-switch-assistant.test.js +34 -0
- package/dist/core/__tests__/language-switch-assistant.test.js.map +1 -0
- package/dist/core/__tests__/marketplace.test.d.ts +2 -0
- package/dist/core/__tests__/marketplace.test.d.ts.map +1 -0
- package/dist/core/__tests__/marketplace.test.js +96 -0
- package/dist/core/__tests__/marketplace.test.js.map +1 -0
- package/dist/core/__tests__/merge-conflict-predictor.test.d.ts +2 -0
- package/dist/core/__tests__/merge-conflict-predictor.test.d.ts.map +1 -0
- package/dist/core/__tests__/merge-conflict-predictor.test.js +36 -0
- package/dist/core/__tests__/merge-conflict-predictor.test.js.map +1 -0
- package/dist/core/__tests__/next-action-predictor.test.d.ts +2 -0
- package/dist/core/__tests__/next-action-predictor.test.d.ts.map +1 -0
- package/dist/core/__tests__/next-action-predictor.test.js +57 -0
- package/dist/core/__tests__/next-action-predictor.test.js.map +1 -0
- package/dist/core/__tests__/offline-queue.test.d.ts +2 -0
- package/dist/core/__tests__/offline-queue.test.d.ts.map +1 -0
- package/dist/core/__tests__/offline-queue.test.js +84 -0
- package/dist/core/__tests__/offline-queue.test.js.map +1 -0
- package/dist/core/__tests__/organization-memory.test.d.ts +2 -0
- package/dist/core/__tests__/organization-memory.test.d.ts.map +1 -0
- package/dist/core/__tests__/organization-memory.test.js +89 -0
- package/dist/core/__tests__/organization-memory.test.js.map +1 -0
- package/dist/core/__tests__/pattern-utils.test.d.ts +2 -0
- package/dist/core/__tests__/pattern-utils.test.d.ts.map +1 -0
- package/dist/core/__tests__/pattern-utils.test.js +52 -0
- package/dist/core/__tests__/pattern-utils.test.js.map +1 -0
- package/dist/core/__tests__/performance-predictor.test.d.ts +2 -0
- package/dist/core/__tests__/performance-predictor.test.d.ts.map +1 -0
- package/dist/core/__tests__/performance-predictor.test.js +60 -0
- package/dist/core/__tests__/performance-predictor.test.js.map +1 -0
- package/dist/core/__tests__/playbook-generator.test.d.ts +2 -0
- package/dist/core/__tests__/playbook-generator.test.d.ts.map +1 -0
- package/dist/core/__tests__/playbook-generator.test.js +94 -0
- package/dist/core/__tests__/playbook-generator.test.js.map +1 -0
- package/dist/core/__tests__/pr-review-assistant.test.d.ts +2 -0
- package/dist/core/__tests__/pr-review-assistant.test.d.ts.map +1 -0
- package/dist/core/__tests__/pr-review-assistant.test.js +35 -0
- package/dist/core/__tests__/pr-review-assistant.test.js.map +1 -0
- package/dist/core/__tests__/privacy-manager.test.d.ts +2 -0
- package/dist/core/__tests__/privacy-manager.test.d.ts.map +1 -0
- package/dist/core/__tests__/privacy-manager.test.js +97 -0
- package/dist/core/__tests__/privacy-manager.test.js.map +1 -0
- package/dist/core/__tests__/project-dna.test.d.ts +2 -0
- package/dist/core/__tests__/project-dna.test.d.ts.map +1 -0
- package/dist/core/__tests__/project-dna.test.js +135 -0
- package/dist/core/__tests__/project-dna.test.js.map +1 -0
- package/dist/core/__tests__/regex-extractor.test.d.ts +2 -0
- package/dist/core/__tests__/regex-extractor.test.d.ts.map +1 -0
- package/dist/core/__tests__/regex-extractor.test.js +49 -0
- package/dist/core/__tests__/regex-extractor.test.js.map +1 -0
- package/dist/core/__tests__/reputation.test.d.ts +2 -0
- package/dist/core/__tests__/reputation.test.d.ts.map +1 -0
- package/dist/core/__tests__/reputation.test.js +100 -0
- package/dist/core/__tests__/reputation.test.js.map +1 -0
- package/dist/core/__tests__/security-predictor.test.d.ts +2 -0
- package/dist/core/__tests__/security-predictor.test.d.ts.map +1 -0
- package/dist/core/__tests__/security-predictor.test.js +60 -0
- package/dist/core/__tests__/security-predictor.test.js.map +1 -0
- package/dist/core/__tests__/signal-capture.test.d.ts +2 -0
- package/dist/core/__tests__/signal-capture.test.d.ts.map +1 -0
- package/dist/core/__tests__/signal-capture.test.js +98 -0
- package/dist/core/__tests__/signal-capture.test.js.map +1 -0
- package/dist/core/__tests__/solution-index.test.d.ts +2 -0
- package/dist/core/__tests__/solution-index.test.d.ts.map +1 -0
- package/dist/core/__tests__/solution-index.test.js +78 -0
- package/dist/core/__tests__/solution-index.test.js.map +1 -0
- package/dist/core/__tests__/standup-generator.test.d.ts +2 -0
- package/dist/core/__tests__/standup-generator.test.d.ts.map +1 -0
- package/dist/core/__tests__/standup-generator.test.js +46 -0
- package/dist/core/__tests__/standup-generator.test.js.map +1 -0
- package/dist/core/__tests__/team-composer.test.d.ts +2 -0
- package/dist/core/__tests__/team-composer.test.d.ts.map +1 -0
- package/dist/core/__tests__/team-composer.test.js +113 -0
- package/dist/core/__tests__/team-composer.test.js.map +1 -0
- package/dist/core/__tests__/test-anticipator.test.d.ts +2 -0
- package/dist/core/__tests__/test-anticipator.test.d.ts.map +1 -0
- package/dist/core/__tests__/test-anticipator.test.js +41 -0
- package/dist/core/__tests__/test-anticipator.test.js.map +1 -0
- package/dist/core/__tests__/time-saved.test.d.ts +1 -0
- package/dist/core/__tests__/time-saved.test.d.ts.map +1 -0
- package/dist/core/__tests__/time-saved.test.js +93 -0
- package/dist/core/__tests__/time-saved.test.js.map +1 -0
- package/dist/core/__tests__/validation-run.test.d.ts +7 -0
- package/dist/core/__tests__/validation-run.test.d.ts.map +1 -0
- package/dist/core/__tests__/validation-run.test.js +510 -0
- package/dist/core/__tests__/validation-run.test.js.map +1 -0
- package/dist/core/__tests__/workflow-outcome-graph.test.d.ts +2 -0
- package/dist/core/__tests__/workflow-outcome-graph.test.d.ts.map +1 -0
- package/dist/core/__tests__/workflow-outcome-graph.test.js +89 -0
- package/dist/core/__tests__/workflow-outcome-graph.test.js.map +1 -0
- package/dist/core/ai-memory.d.ts +84 -0
- package/dist/core/ai-memory.d.ts.map +1 -0
- package/dist/core/ai-memory.js +238 -0
- package/dist/core/ai-memory.js.map +1 -0
- package/dist/core/architecture-engine.d.ts +104 -0
- package/dist/core/architecture-engine.d.ts.map +1 -0
- package/dist/core/architecture-engine.js +216 -0
- package/dist/core/architecture-engine.js.map +1 -0
- package/dist/core/ast-differ.d.ts +15 -0
- package/dist/core/ast-differ.d.ts.map +1 -0
- package/dist/core/ast-differ.js +528 -0
- package/dist/core/ast-differ.js.map +1 -0
- package/dist/core/ast-extractor.d.ts +1 -1
- package/dist/core/ast-extractor.d.ts.map +1 -1
- package/dist/core/ast-extractor.js +7 -5
- package/dist/core/ast-extractor.js.map +1 -1
- package/dist/core/backend-engine.d.ts +40 -0
- package/dist/core/backend-engine.d.ts.map +1 -0
- package/dist/core/backend-engine.js +131 -0
- package/dist/core/backend-engine.js.map +1 -0
- package/dist/core/blind-spot-engine.d.ts +29 -0
- package/dist/core/blind-spot-engine.d.ts.map +1 -0
- package/dist/core/blind-spot-engine.js +579 -0
- package/dist/core/blind-spot-engine.js.map +1 -0
- package/dist/core/build-failure-predictor.d.ts +4 -0
- package/dist/core/build-failure-predictor.d.ts.map +1 -1
- package/dist/core/build-failure-predictor.js +111 -58
- package/dist/core/build-failure-predictor.js.map +1 -1
- package/dist/core/cell-store.d.ts +72 -0
- package/dist/core/cell-store.d.ts.map +1 -0
- package/dist/core/cell-store.js +171 -0
- package/dist/core/cell-store.js.map +1 -0
- package/dist/core/community-advanced-engine.d.ts +30 -0
- package/dist/core/community-advanced-engine.d.ts.map +1 -0
- package/dist/core/community-advanced-engine.js +103 -0
- package/dist/core/community-advanced-engine.js.map +1 -0
- package/dist/core/community-engine.d.ts +62 -0
- package/dist/core/community-engine.d.ts.map +1 -0
- package/dist/core/community-engine.js +194 -0
- package/dist/core/community-engine.js.map +1 -0
- package/dist/core/community-full.d.ts +2 -3
- package/dist/core/community-full.d.ts.map +1 -1
- package/dist/core/community-full.js +2 -5
- package/dist/core/community-full.js.map +1 -1
- package/dist/core/community-intelligence.d.ts +169 -0
- package/dist/core/community-intelligence.d.ts.map +1 -0
- package/dist/core/community-intelligence.js +527 -0
- package/dist/core/community-intelligence.js.map +1 -0
- package/dist/core/community-live.d.ts +1 -0
- package/dist/core/community-live.d.ts.map +1 -1
- package/dist/core/community-live.js +9 -6
- package/dist/core/community-live.js.map +1 -1
- package/dist/core/community-prior.d.ts +1 -0
- package/dist/core/community-prior.d.ts.map +1 -1
- package/dist/core/community-prior.js +18 -10
- package/dist/core/community-prior.js.map +1 -1
- package/dist/core/confidence-engine.d.ts +2 -3
- package/dist/core/confidence-engine.d.ts.map +1 -1
- package/dist/core/confidence-engine.js +29 -32
- package/dist/core/confidence-engine.js.map +1 -1
- package/dist/core/conflict-detector.js +1 -1
- package/dist/core/conflict-detector.js.map +1 -1
- package/dist/core/convention-detector.d.ts +37 -0
- package/dist/core/convention-detector.d.ts.map +1 -0
- package/dist/core/convention-detector.js +189 -0
- package/dist/core/convention-detector.js.map +1 -0
- package/dist/core/cost-optimizer.d.ts +78 -0
- package/dist/core/cost-optimizer.d.ts.map +1 -0
- package/dist/core/cost-optimizer.js +257 -0
- package/dist/core/cost-optimizer.js.map +1 -0
- package/dist/core/cross-domain-projections.js +2 -2
- package/dist/core/cross-layer-intelligence.d.ts +375 -0
- package/dist/core/cross-layer-intelligence.d.ts.map +1 -0
- package/dist/core/cross-layer-intelligence.js +690 -0
- package/dist/core/cross-layer-intelligence.js.map +1 -0
- package/dist/core/developer-profile.d.ts +6 -0
- package/dist/core/developer-profile.d.ts.map +1 -0
- package/dist/core/developer-profile.js +78 -0
- package/dist/core/developer-profile.js.map +1 -0
- package/dist/core/error-predictor.d.ts +5 -2
- package/dist/core/error-predictor.d.ts.map +1 -1
- package/dist/core/error-predictor.js +124 -40
- package/dist/core/error-predictor.js.map +1 -1
- package/dist/core/explainability.d.ts +33 -0
- package/dist/core/explainability.d.ts.map +1 -0
- package/dist/core/explainability.js +131 -0
- package/dist/core/explainability.js.map +1 -0
- package/dist/core/extraction-cascade.d.ts +19 -5
- package/dist/core/extraction-cascade.d.ts.map +1 -1
- package/dist/core/extraction-cascade.js +86 -15
- package/dist/core/extraction-cascade.js.map +1 -1
- package/dist/core/failure-memory.d.ts +38 -0
- package/dist/core/failure-memory.d.ts.map +1 -0
- package/dist/core/failure-memory.js +113 -0
- package/dist/core/failure-memory.js.map +1 -0
- package/dist/core/frontend-engine.d.ts +40 -0
- package/dist/core/frontend-engine.d.ts.map +1 -0
- package/dist/core/frontend-engine.js +129 -0
- package/dist/core/frontend-engine.js.map +1 -0
- package/dist/core/go-extractor.d.ts +5 -0
- package/dist/core/go-extractor.d.ts.map +1 -0
- package/dist/core/go-extractor.js +68 -0
- package/dist/core/go-extractor.js.map +1 -0
- package/dist/core/identity-resolver.d.ts.map +1 -1
- package/dist/core/identity-resolver.js +16 -31
- package/dist/core/identity-resolver.js.map +1 -1
- package/dist/core/knowledge-graph-engine.d.ts +62 -0
- package/dist/core/knowledge-graph-engine.d.ts.map +1 -0
- package/dist/core/knowledge-graph-engine.js +176 -0
- package/dist/core/knowledge-graph-engine.js.map +1 -0
- package/dist/core/knowledge-graph.d.ts +229 -0
- package/dist/core/knowledge-graph.d.ts.map +1 -0
- package/dist/core/knowledge-graph.js +713 -0
- package/dist/core/knowledge-graph.js.map +1 -0
- package/dist/core/language-switch-assistant.d.ts.map +1 -1
- package/dist/core/language-switch-assistant.js +4 -1
- package/dist/core/language-switch-assistant.js.map +1 -1
- package/dist/core/learning-layer.d.ts +11 -0
- package/dist/core/learning-layer.d.ts.map +1 -0
- package/dist/core/learning-layer.js +25 -0
- package/dist/core/learning-layer.js.map +1 -0
- package/dist/core/marketplace.d.ts +43 -0
- package/dist/core/marketplace.d.ts.map +1 -0
- package/dist/core/marketplace.js +133 -0
- package/dist/core/marketplace.js.map +1 -0
- package/dist/core/memory-store.d.ts +59 -0
- package/dist/core/memory-store.d.ts.map +1 -0
- package/dist/core/memory-store.js +151 -0
- package/dist/core/memory-store.js.map +1 -0
- package/dist/core/naming-engine.d.ts +43 -0
- package/dist/core/naming-engine.d.ts.map +1 -0
- package/dist/core/naming-engine.js +120 -0
- package/dist/core/naming-engine.js.map +1 -0
- package/dist/core/org-intelligence.d.ts +151 -0
- package/dist/core/org-intelligence.d.ts.map +1 -0
- package/dist/core/org-intelligence.js +490 -0
- package/dist/core/org-intelligence.js.map +1 -0
- package/dist/core/organization-memory.d.ts +34 -0
- package/dist/core/organization-memory.d.ts.map +1 -0
- package/dist/core/organization-memory.js +148 -0
- package/dist/core/organization-memory.js.map +1 -0
- package/dist/core/outcome-engine.d.ts +21 -0
- package/dist/core/outcome-engine.d.ts.map +1 -0
- package/dist/core/outcome-engine.js +220 -0
- package/dist/core/outcome-engine.js.map +1 -0
- package/dist/core/outcome-recorder.d.ts +34 -0
- package/dist/core/outcome-recorder.d.ts.map +1 -0
- package/dist/core/outcome-recorder.js +109 -0
- package/dist/core/outcome-recorder.js.map +1 -0
- package/dist/core/outcome-store.d.ts +21 -0
- package/dist/core/outcome-store.d.ts.map +1 -0
- package/dist/core/outcome-store.js +120 -0
- package/dist/core/outcome-store.js.map +1 -0
- package/dist/core/outcome-types.d.ts +64 -0
- package/dist/core/outcome-types.d.ts.map +1 -0
- package/dist/core/outcome-types.js +20 -0
- package/dist/core/outcome-types.js.map +1 -0
- package/dist/core/pattern-classifier.d.ts +11 -0
- package/dist/core/pattern-classifier.d.ts.map +1 -0
- package/dist/core/pattern-classifier.js +82 -0
- package/dist/core/pattern-classifier.js.map +1 -0
- package/dist/core/pattern-lifecycle.d.ts +8 -0
- package/dist/core/pattern-lifecycle.d.ts.map +1 -0
- package/dist/core/pattern-lifecycle.js +25 -0
- package/dist/core/pattern-lifecycle.js.map +1 -0
- package/dist/core/pattern-quality.d.ts +6 -0
- package/dist/core/pattern-quality.d.ts.map +1 -0
- package/dist/core/pattern-quality.js +45 -0
- package/dist/core/pattern-quality.js.map +1 -0
- package/dist/core/pattern-ranking.d.ts +8 -0
- package/dist/core/pattern-ranking.d.ts.map +1 -0
- package/dist/core/pattern-ranking.js +40 -0
- package/dist/core/pattern-ranking.js.map +1 -0
- package/dist/core/pattern-relationships.d.ts +16 -0
- package/dist/core/pattern-relationships.d.ts.map +1 -0
- package/dist/core/pattern-relationships.js +66 -0
- package/dist/core/pattern-relationships.js.map +1 -0
- package/dist/core/pattern-search.d.ts +25 -0
- package/dist/core/pattern-search.d.ts.map +1 -0
- package/dist/core/pattern-search.js +82 -0
- package/dist/core/pattern-search.js.map +1 -0
- package/dist/core/pattern-store.d.ts +18 -3
- package/dist/core/pattern-store.d.ts.map +1 -1
- package/dist/core/pattern-store.js +155 -54
- package/dist/core/pattern-store.js.map +1 -1
- package/dist/core/{enterprise-features.d.ts → pattern-utils.d.ts} +2 -4
- package/dist/core/pattern-utils.d.ts.map +1 -0
- package/dist/core/{enterprise-features.js → pattern-utils.js} +4 -24
- package/dist/core/pattern-utils.js.map +1 -0
- package/dist/core/pattern-validator.d.ts +14 -0
- package/dist/core/pattern-validator.d.ts.map +1 -0
- package/dist/core/pattern-validator.js +47 -0
- package/dist/core/pattern-validator.js.map +1 -0
- package/dist/core/performance-predictor.d.ts +4 -0
- package/dist/core/performance-predictor.d.ts.map +1 -1
- package/dist/core/performance-predictor.js +143 -38
- package/dist/core/performance-predictor.js.map +1 -1
- package/dist/core/platt-calibration.d.ts.map +1 -1
- package/dist/core/platt-calibration.js +5 -3
- package/dist/core/platt-calibration.js.map +1 -1
- package/dist/core/playbook-generator.d.ts +21 -0
- package/dist/core/playbook-generator.d.ts.map +1 -0
- package/dist/core/playbook-generator.js +161 -0
- package/dist/core/playbook-generator.js.map +1 -0
- package/dist/core/privacy-manager.d.ts +43 -0
- package/dist/core/privacy-manager.d.ts.map +1 -0
- package/dist/core/privacy-manager.js +131 -0
- package/dist/core/privacy-manager.js.map +1 -0
- package/dist/core/productivity-engine.d.ts +57 -0
- package/dist/core/productivity-engine.d.ts.map +1 -0
- package/dist/core/productivity-engine.js +138 -0
- package/dist/core/productivity-engine.js.map +1 -0
- package/dist/core/project-dna-types.d.ts +150 -0
- package/dist/core/project-dna-types.d.ts.map +1 -0
- package/dist/core/project-dna-types.js +3 -0
- package/dist/core/project-dna-types.js.map +1 -0
- package/dist/core/project-dna.d.ts +122 -0
- package/dist/core/project-dna.d.ts.map +1 -0
- package/dist/core/project-dna.js +922 -0
- package/dist/core/project-dna.js.map +1 -0
- package/dist/core/python-extractor.d.ts +5 -0
- package/dist/core/python-extractor.d.ts.map +1 -0
- package/dist/core/python-extractor.js +68 -0
- package/dist/core/python-extractor.js.map +1 -0
- package/dist/core/realtime-guardian.d.ts.map +1 -1
- package/dist/core/realtime-guardian.js +1 -3
- package/dist/core/realtime-guardian.js.map +1 -1
- package/dist/core/recommendation-engine.d.ts +9 -0
- package/dist/core/recommendation-engine.d.ts.map +1 -0
- package/dist/core/recommendation-engine.js +152 -0
- package/dist/core/recommendation-engine.js.map +1 -0
- package/dist/core/recommendation-store.d.ts +21 -0
- package/dist/core/recommendation-store.d.ts.map +1 -0
- package/dist/core/recommendation-store.js +125 -0
- package/dist/core/recommendation-store.js.map +1 -0
- package/dist/core/recommendation-types.d.ts +54 -0
- package/dist/core/recommendation-types.d.ts.map +1 -0
- package/dist/core/recommendation-types.js +3 -0
- package/dist/core/recommendation-types.js.map +1 -0
- package/dist/core/regex-extractor.js +1 -1
- package/dist/core/regex-extractor.js.map +1 -1
- package/dist/core/reputation.d.ts +42 -0
- package/dist/core/reputation.d.ts.map +1 -0
- package/dist/core/reputation.js +173 -0
- package/dist/core/reputation.js.map +1 -0
- package/dist/core/scale-tester.d.ts +2 -2
- package/dist/core/scale-tester.d.ts.map +1 -1
- package/dist/core/scale-tester.js +12 -1
- package/dist/core/scale-tester.js.map +1 -1
- package/dist/core/search-engine.d.ts +37 -0
- package/dist/core/search-engine.d.ts.map +1 -0
- package/dist/core/search-engine.js +223 -0
- package/dist/core/search-engine.js.map +1 -0
- package/dist/core/security-predictor.d.ts +2 -1
- package/dist/core/security-predictor.d.ts.map +1 -1
- package/dist/core/security-predictor.js +80 -30
- package/dist/core/security-predictor.js.map +1 -1
- package/dist/core/session-recovery.js +8 -8
- package/dist/core/session-recovery.js.map +1 -1
- package/dist/core/similarity-engine.d.ts +8 -0
- package/dist/core/similarity-engine.d.ts.map +1 -0
- package/dist/core/similarity-engine.js +74 -0
- package/dist/core/similarity-engine.js.map +1 -0
- package/dist/core/structure-engine.d.ts +34 -0
- package/dist/core/structure-engine.d.ts.map +1 -0
- package/dist/core/structure-engine.js +114 -0
- package/dist/core/structure-engine.js.map +1 -0
- package/dist/core/syntax-engine.d.ts +101 -0
- package/dist/core/syntax-engine.d.ts.map +1 -0
- package/dist/core/syntax-engine.js +342 -0
- package/dist/core/syntax-engine.js.map +1 -0
- package/dist/core/team-advanced-engine.d.ts +19 -0
- package/dist/core/team-advanced-engine.d.ts.map +1 -0
- package/dist/core/team-advanced-engine.js +91 -0
- package/dist/core/team-advanced-engine.js.map +1 -0
- package/dist/core/team-engine.d.ts +59 -0
- package/dist/core/team-engine.d.ts.map +1 -0
- package/dist/core/team-engine.js +141 -0
- package/dist/core/team-engine.js.map +1 -0
- package/dist/core/time-saved.d.ts +51 -0
- package/dist/core/time-saved.d.ts.map +1 -0
- package/dist/core/time-saved.js +97 -0
- package/dist/core/time-saved.js.map +1 -0
- package/dist/core/workflow-outcome-graph.d.ts +46 -0
- package/dist/core/workflow-outcome-graph.d.ts.map +1 -0
- package/dist/core/workflow-outcome-graph.js +168 -0
- package/dist/core/workflow-outcome-graph.js.map +1 -0
- package/dist/core/workflow-tracker.d.ts +36 -0
- package/dist/core/workflow-tracker.d.ts.map +1 -0
- package/dist/core/workflow-tracker.js +99 -0
- package/dist/core/workflow-tracker.js.map +1 -0
- package/dist/core/ws-client.d.ts +24 -0
- package/dist/core/ws-client.d.ts.map +1 -0
- package/dist/core/ws-client.js +203 -0
- package/dist/core/ws-client.js.map +1 -0
- package/dist/daemon/lifecycle.d.ts.map +1 -1
- package/dist/daemon/lifecycle.js +9 -10
- package/dist/daemon/lifecycle.js.map +1 -1
- package/dist/daemon/server.d.ts +4 -2
- package/dist/daemon/server.d.ts.map +1 -1
- package/dist/daemon/server.js +886 -73
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/watchdog.js +2 -1
- package/dist/daemon/watchdog.js.map +1 -1
- package/dist/index.d.ts +21 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -4
- package/dist/index.js.map +1 -1
- package/dist/store.d.ts +4 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +47 -0
- package/dist/store.js.map +1 -0
- package/dist/types.d.ts +60 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +13 -2
- package/dist/types.js.map +1 -1
- package/dist/validation/quick-run.d.ts +7 -0
- package/dist/validation/quick-run.d.ts.map +1 -0
- package/dist/validation/quick-run.js +404 -0
- package/dist/validation/quick-run.js.map +1 -0
- package/package.json +87 -53
- package/CHANGELOG.md +0 -32
- package/CONTRIBUTING.md +0 -60
- package/dist/core/cell-pro.d.ts +0 -28
- package/dist/core/cell-pro.d.ts.map +0 -1
- package/dist/core/cell-pro.js +0 -70
- package/dist/core/cell-pro.js.map +0 -1
- package/dist/core/enterprise-features.d.ts.map +0 -1
- package/dist/core/enterprise-features.js.map +0 -1
- package/dist/core/enterprise.d.ts +0 -27
- package/dist/core/enterprise.d.ts.map +0 -1
- package/dist/core/enterprise.js +0 -41
- package/dist/core/enterprise.js.map +0 -1
- package/extensions/jetbrains/plugin.json +0 -9
- package/extensions/shell/copilot-sync.js +0 -59
- package/extensions/shell/install.sh +0 -38
- package/extensions/shell/watcher.js +0 -113
- package/extensions/vscode/.vscodeignore +0 -5
- package/extensions/vscode/dist/daemon-client.js +0 -94
- package/extensions/vscode/dist/diff-tracker.js +0 -94
- package/extensions/vscode/dist/extension.js +0 -100
- package/extensions/vscode/dist/status-bar.js +0 -70
- package/extensions/vscode/package-lock.json +0 -40
- package/extensions/vscode/package.json +0 -27
- package/packages/mcp-server/dist/server.d.ts +0 -2
- package/packages/mcp-server/dist/server.js +0 -213
- package/packages/mcp-server/package-lock.json +0 -970
- package/packages/mcp-server/package.json +0 -19
|
@@ -0,0 +1,922 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.buildProjectProfile = buildProjectProfile;
|
|
40
|
+
exports.getProjectProfile = getProjectProfile;
|
|
41
|
+
exports.listProjectProfiles = listProjectProfiles;
|
|
42
|
+
exports.deleteProjectProfile = deleteProjectProfile;
|
|
43
|
+
exports.compareProjects = compareProjects;
|
|
44
|
+
exports.getProjectsDirectory = getProjectsDirectory;
|
|
45
|
+
exports.inferArchitecture = inferArchitecture;
|
|
46
|
+
exports.detectTestingStyle = detectTestingStyle;
|
|
47
|
+
exports.generateConventions = generateConventions;
|
|
48
|
+
exports.ensureProjectDnaTable = ensureProjectDnaTable;
|
|
49
|
+
exports.recordCloudArchitecture = recordCloudArchitecture;
|
|
50
|
+
exports.getCloudArchitecture = getCloudArchitecture;
|
|
51
|
+
exports.recordCloudConvention = recordCloudConvention;
|
|
52
|
+
exports.getCloudConventions = getCloudConventions;
|
|
53
|
+
exports.scanFiles = scanFiles;
|
|
54
|
+
exports.buildLanguageProfile = buildLanguageProfile;
|
|
55
|
+
exports.buildFrameworkProfile = buildFrameworkProfile;
|
|
56
|
+
exports.buildArchitectureProfile = buildArchitectureProfile;
|
|
57
|
+
exports.buildTestingProfile = buildTestingProfile;
|
|
58
|
+
exports.buildDependencyProfile = buildDependencyProfile;
|
|
59
|
+
exports.buildComplexityProfile = buildComplexityProfile;
|
|
60
|
+
exports.buildRiskProfile = buildRiskProfile;
|
|
61
|
+
exports.buildMaturityProfile = buildMaturityProfile;
|
|
62
|
+
exports.buildDevelopmentProfile = buildDevelopmentProfile;
|
|
63
|
+
exports.buildFingerprint = buildFingerprint;
|
|
64
|
+
exports.buildProjectDNA = buildProjectDNA;
|
|
65
|
+
exports.saveDNA = saveDNA;
|
|
66
|
+
exports.getDNA = getDNA;
|
|
67
|
+
exports.listDNA = listDNA;
|
|
68
|
+
exports.deleteDNA = deleteDNA;
|
|
69
|
+
exports.getDNAHistory = getDNAHistory;
|
|
70
|
+
exports.compareDNA = compareDNA;
|
|
71
|
+
const fs = __importStar(require("fs"));
|
|
72
|
+
const path = __importStar(require("path"));
|
|
73
|
+
const os = __importStar(require("os"));
|
|
74
|
+
const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
|
|
75
|
+
const store_1 = require("../store");
|
|
76
|
+
const PROJECTS_DIR = path.join(os.homedir(), '.fivo', 'cell', 'projects');
|
|
77
|
+
const DNA_STORE_PATH = path.join(os.homedir(), '.fivo', 'cell', 'project_dna.json');
|
|
78
|
+
function ensureStoreDir() {
|
|
79
|
+
const dir = path.dirname(DNA_STORE_PATH);
|
|
80
|
+
if (!fs.existsSync(dir))
|
|
81
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
82
|
+
}
|
|
83
|
+
function ensureProjectsDir() {
|
|
84
|
+
if (!fs.existsSync(PROJECTS_DIR))
|
|
85
|
+
fs.mkdirSync(PROJECTS_DIR, { recursive: true });
|
|
86
|
+
}
|
|
87
|
+
function projectPath(projectId) {
|
|
88
|
+
return path.join(PROJECTS_DIR, `${sanitizeId(projectId)}.json`);
|
|
89
|
+
}
|
|
90
|
+
function sanitizeId(id) {
|
|
91
|
+
return id.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
92
|
+
}
|
|
93
|
+
// ─── LEGACY: Pattern-based profile functions ──────────────────────────
|
|
94
|
+
function buildProjectProfile(projectId, name, patterns) {
|
|
95
|
+
ensureProjectsDir();
|
|
96
|
+
const langMap = new Map();
|
|
97
|
+
const catMap = new Map();
|
|
98
|
+
const fwMap = new Map();
|
|
99
|
+
const seqMap = new Map();
|
|
100
|
+
const totalSignals = patterns.reduce((s, p) => s + p.signals.total, 0);
|
|
101
|
+
const totalConf = patterns.reduce((s, p) => s + p.confidence.mean, 0);
|
|
102
|
+
for (const p of patterns) {
|
|
103
|
+
for (const c of p.conditions) {
|
|
104
|
+
if (c.type === 'language')
|
|
105
|
+
langMap.set(c.value, (langMap.get(c.value) || 0) + 1);
|
|
106
|
+
if (c.type === 'framework')
|
|
107
|
+
fwMap.set(c.value, (fwMap.get(c.value) || 0) + 1);
|
|
108
|
+
}
|
|
109
|
+
catMap.set(p.category, (catMap.get(p.category) || 0) + 1);
|
|
110
|
+
const seqKey = `${p.from}|${p.to}`;
|
|
111
|
+
seqMap.set(seqKey, (seqMap.get(seqKey) || 0) + 1);
|
|
112
|
+
}
|
|
113
|
+
const total = patterns.length || 1;
|
|
114
|
+
const languages = Array.from(langMap.entries())
|
|
115
|
+
.map(([language, count]) => ({ language, count, pct: Math.round((count / total) * 100) }))
|
|
116
|
+
.sort((a, b) => b.count - a.count);
|
|
117
|
+
const categories = Array.from(catMap.entries())
|
|
118
|
+
.map(([category, count]) => ({ category, count, pct: Math.round((count / total) * 100) }))
|
|
119
|
+
.sort((a, b) => b.count - a.count);
|
|
120
|
+
const profile = {
|
|
121
|
+
projectId, name,
|
|
122
|
+
primaryLanguage: languages[0]?.language || 'unknown', languages, categories,
|
|
123
|
+
frameworks: Array.from(fwMap.entries()).map(([framework, count]) => ({ framework, count })).sort((a, b) => b.count - a.count),
|
|
124
|
+
totalPatterns: patterns.length, totalSignals,
|
|
125
|
+
topPatterns: patterns.sort((a, b) => b.signals.total - a.signals.total).slice(0, 10).map((p) => {
|
|
126
|
+
const total = p.signals.positive + p.signals.negative;
|
|
127
|
+
return { patternId: p.patternId, description: p.description, acceptRate: total > 0 ? p.signals.positive / total : 0 };
|
|
128
|
+
}),
|
|
129
|
+
patternSequences: Array.from(seqMap.entries()).map(([k, count]) => {
|
|
130
|
+
const [from, to] = k.split('|');
|
|
131
|
+
return { from, to, count };
|
|
132
|
+
}).sort((a, b) => b.count - a.count).slice(0, 20),
|
|
133
|
+
averageConfidence: patterns.length > 0 ? totalConf / patterns.length : 0,
|
|
134
|
+
createdAt: Date.now(), updatedAt: Date.now(),
|
|
135
|
+
};
|
|
136
|
+
fs.writeFileSync(projectPath(projectId), JSON.stringify(profile, null, 2), 'utf-8');
|
|
137
|
+
return profile;
|
|
138
|
+
}
|
|
139
|
+
function getProjectProfile(projectId) {
|
|
140
|
+
try {
|
|
141
|
+
const fp = projectPath(projectId);
|
|
142
|
+
if (!fs.existsSync(fp))
|
|
143
|
+
return null;
|
|
144
|
+
return JSON.parse(fs.readFileSync(fp, 'utf-8'));
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function listProjectProfiles() {
|
|
151
|
+
ensureProjectsDir();
|
|
152
|
+
try {
|
|
153
|
+
return fs.readdirSync(PROJECTS_DIR).filter((f) => f.endsWith('.json')).map((f) => f.replace('.json', ''));
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return [];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function deleteProjectProfile(projectId) {
|
|
160
|
+
try {
|
|
161
|
+
const fp = projectPath(projectId);
|
|
162
|
+
if (fs.existsSync(fp)) {
|
|
163
|
+
fs.unlinkSync(fp);
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function compareProjects(projectA, projectB) {
|
|
173
|
+
const profileA = getProjectProfile(projectA);
|
|
174
|
+
const profileB = getProjectProfile(projectB);
|
|
175
|
+
if (!profileA || !profileB) {
|
|
176
|
+
return { projectA, projectB, similarity: 0, sharedLanguages: [], sharedCategories: [], sharedPatterns: [], divergences: ['One or both projects not found'] };
|
|
177
|
+
}
|
|
178
|
+
const sharedLangs = profileA.languages.filter((l) => profileB.languages.some((lb) => lb.language === l.language)).map((l) => l.language);
|
|
179
|
+
const sharedCats = profileA.categories.filter((c) => profileB.categories.some((cb) => cb.category === c.category)).map((c) => c.category);
|
|
180
|
+
const sharedPatterns = profileA.topPatterns.filter((p) => profileB.topPatterns.some((pb) => pb.patternId === p.patternId)).map((p) => p.patternId);
|
|
181
|
+
const allLangs = new Set([...profileA.languages.map((l) => l.language), ...profileB.languages.map((l) => l.language)]);
|
|
182
|
+
const langOverlap = sharedLangs.length / (allLangs.size || 1);
|
|
183
|
+
const allCats = new Set([...profileA.categories.map((c) => c.category), ...profileB.categories.map((c) => c.category)]);
|
|
184
|
+
const catOverlap = sharedCats.length / (allCats.size || 1);
|
|
185
|
+
const similarity = Math.round(((langOverlap + catOverlap) / 2) * 100);
|
|
186
|
+
const divergences = [];
|
|
187
|
+
if (profileA.primaryLanguage !== profileB.primaryLanguage)
|
|
188
|
+
divergences.push(`Primary language differs: ${profileA.primaryLanguage} vs ${profileB.primaryLanguage}`);
|
|
189
|
+
const uniqueA = profileA.categories.filter((c) => !profileB.categories.some((cb) => cb.category === c.category));
|
|
190
|
+
const uniqueB = profileB.categories.filter((c) => !profileA.categories.some((ca) => ca.category === c.category));
|
|
191
|
+
if (uniqueA.length > 0)
|
|
192
|
+
divergences.push(`Unique categories in ${projectA}: ${uniqueA.map((c) => c.category).join(', ')}`);
|
|
193
|
+
if (uniqueB.length > 0)
|
|
194
|
+
divergences.push(`Unique categories in ${projectB}: ${uniqueB.map((c) => c.category).join(', ')}`);
|
|
195
|
+
return { projectA, projectB, similarity, sharedLanguages: sharedLangs, sharedCategories: sharedCats, sharedPatterns, divergences };
|
|
196
|
+
}
|
|
197
|
+
function getProjectsDirectory() {
|
|
198
|
+
return PROJECTS_DIR;
|
|
199
|
+
}
|
|
200
|
+
function inferArchitecture(patterns) {
|
|
201
|
+
const evidence = [];
|
|
202
|
+
const allDesc = patterns.map((p) => `${p.description} ${p.category}`.toLowerCase()).join(' ');
|
|
203
|
+
if (/model|view|controller|route/.test(allDesc))
|
|
204
|
+
evidence.push({ name: 'MVC (Model-View-Controller)', confidence: 0.7, evidence: ['Detected model/view/controller references'] });
|
|
205
|
+
if (/service|repository|usecase|dto|entity/.test(allDesc))
|
|
206
|
+
evidence.push({ name: 'Layered / Clean Architecture', confidence: 0.75, evidence: ['Detected service/repository/usecase layers'] });
|
|
207
|
+
if (/component|hook|render|jsx|tsx/.test(allDesc))
|
|
208
|
+
evidence.push({ name: 'Component-based (React/Vue)', confidence: 0.8, evidence: ['Detected components/hooks'] });
|
|
209
|
+
if (/api|endpoint|handler|middleware/.test(allDesc))
|
|
210
|
+
evidence.push({ name: 'API-first / Microservices', confidence: 0.65, evidence: ['Detected API/handler patterns'] });
|
|
211
|
+
if (/pipe|compose|reduce|map|filter|immutable|pure/.test(allDesc))
|
|
212
|
+
evidence.push({ name: 'Functional Programming', confidence: 0.6, evidence: ['Detected functional patterns'] });
|
|
213
|
+
evidence.sort((a, b) => b.confidence - a.confidence);
|
|
214
|
+
return { detectedPatterns: evidence, suggestedLabel: evidence[0]?.name || 'Unknown' };
|
|
215
|
+
}
|
|
216
|
+
function detectTestingStyle(patterns) {
|
|
217
|
+
const all = patterns.map((p) => `${p.description} ${p.from} ${p.to}`).join(' ').toLowerCase();
|
|
218
|
+
if (/describe|it\(|vitest/.test(all))
|
|
219
|
+
return { framework: 'vitest', style: 'describe/it', location: 'co-located', confidence: 0.9 };
|
|
220
|
+
if (/jest|expect\(|test\(/.test(all))
|
|
221
|
+
return { framework: 'jest', style: 'test()', location: '__tests__', confidence: 0.85 };
|
|
222
|
+
if (/mocha|assert\(/.test(all))
|
|
223
|
+
return { framework: 'mocha', style: 'describe/it', location: 'tests/', confidence: 0.7 };
|
|
224
|
+
if (/pytest|def test_/.test(all))
|
|
225
|
+
return { framework: 'pytest', style: 'test()', location: 'tests/', confidence: 0.8 };
|
|
226
|
+
return { framework: 'unknown', style: 'unknown', location: 'unknown', confidence: 0 };
|
|
227
|
+
}
|
|
228
|
+
function generateConventions(profile) {
|
|
229
|
+
const suggestions = [];
|
|
230
|
+
const lang = profile.primaryLanguage;
|
|
231
|
+
if (lang === 'typescript' || lang === 'javascript') {
|
|
232
|
+
suggestions.push({ type: 'editorconfig', content: 'root = true\n\n[*]\nindent_style = space\nindent_size = 2\nend_of_line = lf\ncharset = utf-8\ntrim_trailing_whitespace = true\ninsert_final_newline = true', description: `2-space indentation recommended for ${lang}` });
|
|
233
|
+
suggestions.push({ type: 'tsconfig', content: '{\n "compilerOptions": {\n "strict": true,\n "esModuleInterop": true,\n "skipLibCheck": true,\n "forceConsistentCasingInFileNames": true\n }\n}', description: 'Strict mode recommended based on project patterns' });
|
|
234
|
+
}
|
|
235
|
+
if (profile.languages.length > 1)
|
|
236
|
+
suggestions.push({ type: 'prettier', content: '{\n "semi": true,\n "singleQuote": true,\n "tabWidth": 2,\n "trailingComma": "all"\n}', description: 'Multi-language project — Prettier for consistent formatting' });
|
|
237
|
+
return suggestions;
|
|
238
|
+
}
|
|
239
|
+
// ─── CLOUD PROJECT DNA DB (SQLite) ────────────────────
|
|
240
|
+
function getDnaDb() {
|
|
241
|
+
const { dbPath } = (0, store_1.getStore)();
|
|
242
|
+
return new better_sqlite3_1.default(dbPath);
|
|
243
|
+
}
|
|
244
|
+
function ensureProjectDnaTable() {
|
|
245
|
+
const db = getDnaDb();
|
|
246
|
+
db.exec(`CREATE TABLE IF NOT EXISTS project_architectures (id INTEGER PRIMARY KEY AUTOINCREMENT, project_id TEXT NOT NULL, label TEXT NOT NULL, patterns TEXT NOT NULL)`);
|
|
247
|
+
db.exec(`CREATE TABLE IF NOT EXISTS project_conventions (id INTEGER PRIMARY KEY AUTOINCREMENT, project_id TEXT NOT NULL, convention_type TEXT NOT NULL, suggestion TEXT NOT NULL, description TEXT)`);
|
|
248
|
+
db.close();
|
|
249
|
+
}
|
|
250
|
+
function recordCloudArchitecture(projectId, label, patterns) {
|
|
251
|
+
const db = getDnaDb();
|
|
252
|
+
db.prepare(`INSERT INTO project_architectures (project_id, label, patterns) VALUES (?, ?, ?)`).run(projectId, label, JSON.stringify(patterns));
|
|
253
|
+
db.close();
|
|
254
|
+
}
|
|
255
|
+
function getCloudArchitecture(projectId) {
|
|
256
|
+
const db = getDnaDb();
|
|
257
|
+
const row = db.prepare(`SELECT label, patterns FROM project_architectures WHERE project_id = ? ORDER BY id DESC LIMIT 1`).get(projectId);
|
|
258
|
+
db.close();
|
|
259
|
+
if (!row)
|
|
260
|
+
return null;
|
|
261
|
+
return { label: row.label, patterns: JSON.parse(row.patterns) };
|
|
262
|
+
}
|
|
263
|
+
function recordCloudConvention(projectId, type, suggestion, description) {
|
|
264
|
+
const db = getDnaDb();
|
|
265
|
+
db.prepare(`INSERT INTO project_conventions (project_id, convention_type, suggestion, description) VALUES (?, ?, ?, ?)`).run(projectId, type, suggestion, description);
|
|
266
|
+
db.close();
|
|
267
|
+
}
|
|
268
|
+
function getCloudConventions(projectId) {
|
|
269
|
+
const db = getDnaDb();
|
|
270
|
+
const rows = db.prepare(`SELECT convention_type, suggestion FROM project_conventions WHERE project_id = ?`).all(projectId);
|
|
271
|
+
db.close();
|
|
272
|
+
return rows.map(r => ({ type: r.convention_type, suggestion: r.suggestion }));
|
|
273
|
+
}
|
|
274
|
+
// ═══════════════════════════════════════════════════════════════
|
|
275
|
+
// CHAPTER 5 — PROJECT DNA (File System based)
|
|
276
|
+
// ═══════════════════════════════════════════════════════════════
|
|
277
|
+
const EXT_TO_LANG = {
|
|
278
|
+
ts: 'typescript', tsx: 'typescript', js: 'javascript', jsx: 'javascript',
|
|
279
|
+
mjs: 'javascript', cjs: 'javascript', mts: 'typescript', cts: 'typescript',
|
|
280
|
+
py: 'python', rb: 'ruby', go: 'go', rs: 'rust',
|
|
281
|
+
java: 'java', kt: 'kotlin', scala: 'scala',
|
|
282
|
+
swift: 'swift', m: 'objective-c', h: 'c', cpp: 'cpp', c: 'c', cs: 'csharp',
|
|
283
|
+
php: 'php', vue: 'vue', svelte: 'svelte',
|
|
284
|
+
html: 'html', css: 'css', scss: 'scss', less: 'less',
|
|
285
|
+
yaml: 'yaml', yml: 'yaml', json: 'json', xml: 'xml', md: 'markdown',
|
|
286
|
+
sh: 'shell', bash: 'shell', zsh: 'shell',
|
|
287
|
+
sql: 'sql', graphql: 'graphql', prisma: 'prisma',
|
|
288
|
+
dockerfile: 'dockerfile', tf: 'terraform', toml: 'toml',
|
|
289
|
+
};
|
|
290
|
+
const SKIP_DIRS = new Set(['node_modules', '.git', '.svn', '__pycache__', '.next', 'dist', 'build', '.cache', 'coverage', '.nyc_output', 'target', 'vendor', '.tox', '.eggs', 'egg-info', '.venv', 'venv', '.idea', '.vscode', '.terrafor']);
|
|
291
|
+
function scanFiles(rootDir, maxDepth = 20) {
|
|
292
|
+
const results = [];
|
|
293
|
+
function walk(dir, depth) {
|
|
294
|
+
if (depth > maxDepth)
|
|
295
|
+
return;
|
|
296
|
+
let entries;
|
|
297
|
+
try {
|
|
298
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
for (const entry of entries) {
|
|
304
|
+
const fullPath = path.join(dir, entry.name);
|
|
305
|
+
if (entry.isDirectory()) {
|
|
306
|
+
if (SKIP_DIRS.has(entry.name))
|
|
307
|
+
continue;
|
|
308
|
+
walk(fullPath, depth + 1);
|
|
309
|
+
}
|
|
310
|
+
else if (entry.isFile()) {
|
|
311
|
+
const relPath = path.relative(rootDir, fullPath);
|
|
312
|
+
const parsed = path.parse(entry.name);
|
|
313
|
+
const ext = parsed.ext.slice(1).toLowerCase();
|
|
314
|
+
const baseName = parsed.name;
|
|
315
|
+
const language = EXT_TO_LANG[ext] || ext;
|
|
316
|
+
const normalized = relPath.replace(/\\/g, '/');
|
|
317
|
+
const isTest = /\.(test|spec|e2e|integration)\./.test(normalized) || normalized.includes('__tests__') || normalized.includes('/test/') || normalized.includes('/tests/') || normalized.startsWith('test/') || normalized.startsWith('tests/');
|
|
318
|
+
let lines = 0;
|
|
319
|
+
let size = 0;
|
|
320
|
+
try {
|
|
321
|
+
const stat = fs.statSync(fullPath);
|
|
322
|
+
size = stat.size;
|
|
323
|
+
if (size < 1024 * 1024) {
|
|
324
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
325
|
+
lines = content.split('\n').length;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
catch {
|
|
329
|
+
lines = 0;
|
|
330
|
+
}
|
|
331
|
+
results.push({ relativePath: relPath, fullPath, ext, lines, language, isTest, size });
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
walk(rootDir, 0);
|
|
336
|
+
return results;
|
|
337
|
+
}
|
|
338
|
+
// ─── SYSTEM 1: LANGUAGE PROFILE ───────────────────────
|
|
339
|
+
function buildLanguageProfile(files) {
|
|
340
|
+
const langMap = new Map();
|
|
341
|
+
for (const f of files) {
|
|
342
|
+
if (!langMap.has(f.language))
|
|
343
|
+
langMap.set(f.language, { fileCount: 0, lineCount: 0, exts: new Set() });
|
|
344
|
+
const entry = langMap.get(f.language);
|
|
345
|
+
entry.fileCount++;
|
|
346
|
+
entry.lineCount += f.lines;
|
|
347
|
+
entry.exts.add(f.ext);
|
|
348
|
+
}
|
|
349
|
+
const totalFiles = files.length || 1;
|
|
350
|
+
const languages = Array.from(langMap.entries())
|
|
351
|
+
.map(([lang, data]) => ({
|
|
352
|
+
language: lang, extensions: Array.from(data.exts), fileCount: data.fileCount,
|
|
353
|
+
lineCount: data.lineCount, percentage: Math.round((data.fileCount / totalFiles) * 100),
|
|
354
|
+
}))
|
|
355
|
+
.sort((a, b) => b.fileCount - a.fileCount);
|
|
356
|
+
const primaryLanguage = languages[0]?.language || 'unknown';
|
|
357
|
+
const languagePurity = languages[0]?.percentage || 0;
|
|
358
|
+
return { primaryLanguage, languages, languagePurity };
|
|
359
|
+
}
|
|
360
|
+
// ─── SYSTEM 2: FRAMEWORK PROFILE ──────────────────────
|
|
361
|
+
function detectFrameworkFromPackageJson(content) {
|
|
362
|
+
const results = [];
|
|
363
|
+
const frameworkKeywords = {
|
|
364
|
+
'Next.js': ['next', 'next.js', 'nextjs'],
|
|
365
|
+
'React': ['react', 'react-dom'],
|
|
366
|
+
'Vue': ['vue', 'vue-router', 'nuxt'],
|
|
367
|
+
'Angular': ['@angular/core', 'angular'],
|
|
368
|
+
'Express': ['express'],
|
|
369
|
+
'NestJS': ['@nestjs/core', 'nestjs'],
|
|
370
|
+
'Fastify': ['fastify'],
|
|
371
|
+
'Svelte': ['svelte', 'svelte-kit'],
|
|
372
|
+
'Gatsby': ['gatsby'],
|
|
373
|
+
'Nuxt': ['nuxt', 'nuxt3'],
|
|
374
|
+
'Remix': ['@remix-run/react', 'remix'],
|
|
375
|
+
'Astro': ['astro'],
|
|
376
|
+
};
|
|
377
|
+
for (const [name, keywords] of Object.entries(frameworkKeywords)) {
|
|
378
|
+
for (const kw of keywords) {
|
|
379
|
+
if (content.includes(`"${kw}"`)) {
|
|
380
|
+
results.push({ name, confidence: 0.8, evidence: [`Found dependency "${kw}"`] });
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return results;
|
|
386
|
+
}
|
|
387
|
+
function detectFrameworkFromRequirementsTxt(content) {
|
|
388
|
+
const results = [];
|
|
389
|
+
const lines = content.toLowerCase().split('\n');
|
|
390
|
+
const frameworks = {
|
|
391
|
+
'FastAPI': ['fastapi'],
|
|
392
|
+
'Django': ['django'],
|
|
393
|
+
'Flask': ['flask'],
|
|
394
|
+
'Starlette': ['starlette'],
|
|
395
|
+
'Tornado': ['tornado'],
|
|
396
|
+
'AIOHTTP': ['aiohttp'],
|
|
397
|
+
'SQLAlchemy': ['sqlalchemy'],
|
|
398
|
+
};
|
|
399
|
+
for (const [name, keywords] of Object.entries(frameworks)) {
|
|
400
|
+
for (const kw of keywords) {
|
|
401
|
+
if (lines.some(l => l.includes(kw))) {
|
|
402
|
+
results.push({ name, confidence: 0.7, evidence: [`Found dependency "${kw}" in requirements`] });
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return results;
|
|
408
|
+
}
|
|
409
|
+
function detectFrameworkFromGoMod(content) {
|
|
410
|
+
const results = [];
|
|
411
|
+
const frameworks = {
|
|
412
|
+
'Gin': ['github.com/gin-gonic/gin'],
|
|
413
|
+
'Fiber': ['github.com/gofiber/fiber'],
|
|
414
|
+
'Echo': ['github.com/labstack/echo'],
|
|
415
|
+
'Chi': ['github.com/go-chi/chi'],
|
|
416
|
+
'Mux': ['github.com/gorilla/mux'],
|
|
417
|
+
};
|
|
418
|
+
for (const [name, keywords] of Object.entries(frameworks)) {
|
|
419
|
+
for (const kw of keywords) {
|
|
420
|
+
if (content.includes(kw)) {
|
|
421
|
+
results.push({ name, confidence: 0.7, evidence: [`Found dependency "${kw}" in go.mod`] });
|
|
422
|
+
break;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return results;
|
|
427
|
+
}
|
|
428
|
+
function buildFrameworkProfile(files, rootDir) {
|
|
429
|
+
const allEvidence = [];
|
|
430
|
+
const packageJson = files.find(f => f.relativePath === 'package.json');
|
|
431
|
+
if (packageJson) {
|
|
432
|
+
try {
|
|
433
|
+
const content = fs.readFileSync(packageJson.fullPath, 'utf-8');
|
|
434
|
+
allEvidence.push(...detectFrameworkFromPackageJson(content));
|
|
435
|
+
}
|
|
436
|
+
catch { }
|
|
437
|
+
}
|
|
438
|
+
const requirementsTxt = files.find(f => f.relativePath === 'requirements.txt');
|
|
439
|
+
if (requirementsTxt) {
|
|
440
|
+
try {
|
|
441
|
+
const content = fs.readFileSync(requirementsTxt.fullPath, 'utf-8');
|
|
442
|
+
allEvidence.push(...detectFrameworkFromRequirementsTxt(content));
|
|
443
|
+
}
|
|
444
|
+
catch { }
|
|
445
|
+
}
|
|
446
|
+
const goMod = files.find(f => f.relativePath === 'go.mod');
|
|
447
|
+
if (goMod) {
|
|
448
|
+
try {
|
|
449
|
+
const content = fs.readFileSync(goMod.fullPath, 'utf-8');
|
|
450
|
+
allEvidence.push(...detectFrameworkFromGoMod(content));
|
|
451
|
+
}
|
|
452
|
+
catch { }
|
|
453
|
+
}
|
|
454
|
+
const seen = new Set();
|
|
455
|
+
const unique = [];
|
|
456
|
+
for (const ev of allEvidence) {
|
|
457
|
+
if (!seen.has(ev.name)) {
|
|
458
|
+
seen.add(ev.name);
|
|
459
|
+
unique.push(ev);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
unique.sort((a, b) => b.confidence - a.confidence);
|
|
463
|
+
const primaryFramework = unique[0]?.name || null;
|
|
464
|
+
return { frameworks: unique, primaryFramework };
|
|
465
|
+
}
|
|
466
|
+
// ─── SYSTEM 3: ARCHITECTURE PROFILE ───────────────────
|
|
467
|
+
const ARCH_SIGNATURES = [
|
|
468
|
+
{ type: 'layered', dirs: ['controllers', 'services', 'repositories', 'middleware', 'routes'], keywords: ['controller', 'service', 'repository'] },
|
|
469
|
+
{ type: 'mvc', dirs: ['models', 'views', 'controllers'], keywords: ['model', 'view', 'controller'] },
|
|
470
|
+
{ type: 'feature-based', dirs: ['features', 'modules', 'domains'], keywords: ['feature', 'module'] },
|
|
471
|
+
{ type: 'microservice', dirs: ['services', 'api-gateway', 'gateway'], keywords: ['endpoint', 'handler', 'microservice'] },
|
|
472
|
+
{ type: 'modular-monolith', dirs: ['modules', 'contexts', 'bounded-contexts'], keywords: ['module', 'context', 'bounded'] },
|
|
473
|
+
{ type: 'hexagonal', dirs: ['adapters', 'ports', 'domain', 'infrastructure'], keywords: ['adapter', 'port', 'hexagon'] },
|
|
474
|
+
{ type: 'clean-architecture', dirs: ['use-cases', 'entities', 'interface-adapters', 'frameworks-drivers'], keywords: ['usecase', 'entity', 'interface'] },
|
|
475
|
+
{ type: 'monolith', dirs: ['app', 'src', 'lib'], keywords: [] },
|
|
476
|
+
];
|
|
477
|
+
function buildArchitectureProfile(files, rootDir) {
|
|
478
|
+
const dirs = new Set();
|
|
479
|
+
for (const f of files) {
|
|
480
|
+
const parts = f.relativePath.split(/[/\\]/);
|
|
481
|
+
for (let i = 0; i < parts.length - 1; i++)
|
|
482
|
+
dirs.add(parts[i].toLowerCase());
|
|
483
|
+
}
|
|
484
|
+
const candidates = [];
|
|
485
|
+
for (const sig of ARCH_SIGNATURES) {
|
|
486
|
+
let score = 0;
|
|
487
|
+
const evidence = [];
|
|
488
|
+
for (const d of sig.dirs) {
|
|
489
|
+
if (dirs.has(d)) {
|
|
490
|
+
score += 0.25;
|
|
491
|
+
evidence.push(`Found directory: ${d}`);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
const allPaths = files.map(f => f.relativePath.toLowerCase()).join(' ');
|
|
495
|
+
for (const kw of sig.keywords) {
|
|
496
|
+
if (allPaths.includes(kw)) {
|
|
497
|
+
score += 0.15;
|
|
498
|
+
evidence.push(`Found ${kw} references in file paths`);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (evidence.length > 0) {
|
|
502
|
+
candidates.push({ type: sig.type, confidence: Math.min(score, 0.95), evidence });
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
candidates.sort((a, b) => b.confidence - a.confidence);
|
|
506
|
+
const architecture = candidates[0]?.type || 'unknown';
|
|
507
|
+
const confidence = candidates[0]?.confidence || 0;
|
|
508
|
+
const hasApiLayer = dirs.has('api') || dirs.has('routes') || dirs.has('endpoints') || files.some(f => f.relativePath.includes('/api/'));
|
|
509
|
+
const hasServiceLayer = dirs.has('services') || dirs.has('service');
|
|
510
|
+
const hasDataLayer = dirs.has('repositories') || dirs.has('data') || dirs.has('models') || dirs.has('entities');
|
|
511
|
+
return { architecture, confidence, candidates, hasApiLayer, hasServiceLayer, hasDataLayer };
|
|
512
|
+
}
|
|
513
|
+
// ─── SYSTEM 4: TESTING DNA ────────────────────────────
|
|
514
|
+
const TEST_FRAMEWORK_MAP = [
|
|
515
|
+
{ framework: 'jest', configFiles: ['jest.config.js', 'jest.config.ts', 'jest.config.json'], indicators: ['jest'] },
|
|
516
|
+
{ framework: 'vitest', configFiles: ['vitest.config.ts', 'vitest.config.js'], indicators: ['vitest'] },
|
|
517
|
+
{ framework: 'playwright', configFiles: ['playwright.config.ts', 'playwright.config.js'], indicators: ['playwright'] },
|
|
518
|
+
{ framework: 'cypress', configFiles: ['cypress.config.js', 'cypress.config.ts', 'cypress.json'], indicators: ['cypress'] },
|
|
519
|
+
{ framework: 'mocha', configFiles: ['.mocharc.js', '.mocharc.json'], indicators: ['mocha'] },
|
|
520
|
+
{ framework: 'pytest', configFiles: ['pytest.ini', 'pyproject.toml'], indicators: ['pytest'] },
|
|
521
|
+
{ framework: 'unittest', configFiles: [], indicators: ['unittest', 'test_'] },
|
|
522
|
+
{ framework: 'go-test', configFiles: ['go.mod'], indicators: ['_test.go'] },
|
|
523
|
+
];
|
|
524
|
+
function buildTestingProfile(files, rootDir) {
|
|
525
|
+
const testFiles = files.filter(f => f.isTest);
|
|
526
|
+
const sourceFiles = files.filter(f => !f.isTest && f.ext !== '' && f.ext !== 'md' && f.ext !== 'json' && f.ext !== 'yaml' && f.ext !== 'yml');
|
|
527
|
+
const testFileCount = testFiles.length;
|
|
528
|
+
const sourceFileCount = sourceFiles.length;
|
|
529
|
+
const testToSourceRatio = sourceFileCount > 0 ? Math.round((testFileCount / sourceFileCount) * 100) / 100 : 0;
|
|
530
|
+
const frameworks = [];
|
|
531
|
+
const fwSet = new Set();
|
|
532
|
+
for (const fw of TEST_FRAMEWORK_MAP) {
|
|
533
|
+
const hasConfig = fw.configFiles.some(cf => files.some(f => f.relativePath === cf));
|
|
534
|
+
let hasIndicator = false;
|
|
535
|
+
if (fw.framework === 'go-test') {
|
|
536
|
+
hasIndicator = files.some(f => f.relativePath.endsWith('_test.go'));
|
|
537
|
+
}
|
|
538
|
+
else if (fw.framework === 'pytest') {
|
|
539
|
+
hasIndicator = files.some(f => f.relativePath.endsWith('.py') && (f.relativePath.includes('test_') || f.relativePath.includes('_test')));
|
|
540
|
+
}
|
|
541
|
+
else if (fw.framework === 'unittest') {
|
|
542
|
+
hasIndicator = files.some(f => f.relativePath.includes('test_') && f.relativePath.endsWith('.py'));
|
|
543
|
+
}
|
|
544
|
+
if (hasConfig || hasIndicator) {
|
|
545
|
+
if (!fwSet.has(fw.framework)) {
|
|
546
|
+
fwSet.add(fw.framework);
|
|
547
|
+
frameworks.push(fw.framework);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
const coverageScore = Math.min(Math.round(testToSourceRatio * 100), 100);
|
|
552
|
+
const cultureScore = Math.min((testFileCount > 0 ? 30 : 0) +
|
|
553
|
+
(frameworks.length > 0 ? 20 : 0) +
|
|
554
|
+
(testToSourceRatio >= 0.3 ? 25 : testToSourceRatio >= 0.1 ? 15 : 5) +
|
|
555
|
+
(testFiles.some(f => f.lines > 20) ? 25 : 10), 100);
|
|
556
|
+
const maturity = testFileCount === 0 ? 'none' : testToSourceRatio < 0.1 ? 'minimal' : testToSourceRatio < 0.3 ? 'moderate' : testToSourceRatio < 0.5 ? 'strong' : 'comprehensive';
|
|
557
|
+
return { frameworks, testFileCount, sourceFileCount, testToSourceRatio, coverageScore, cultureScore, maturity };
|
|
558
|
+
}
|
|
559
|
+
// ─── SYSTEM 5: DEPENDENCY DNA ─────────────────────────
|
|
560
|
+
function buildDependencyProfile(files, rootDir) {
|
|
561
|
+
let depCount = 0;
|
|
562
|
+
let devDepCount = 0;
|
|
563
|
+
let hasPackageManager = false;
|
|
564
|
+
let packageManager = null;
|
|
565
|
+
const pkgJson = files.find(f => f.relativePath === 'package.json');
|
|
566
|
+
if (pkgJson) {
|
|
567
|
+
try {
|
|
568
|
+
const content = JSON.parse(fs.readFileSync(pkgJson.fullPath, 'utf-8'));
|
|
569
|
+
depCount = Object.keys(content.dependencies || {}).length;
|
|
570
|
+
devDepCount = Object.keys(content.devDependencies || {}).length;
|
|
571
|
+
hasPackageManager = true;
|
|
572
|
+
packageManager = 'npm';
|
|
573
|
+
if (files.some(f => f.relativePath === 'yarn.lock'))
|
|
574
|
+
packageManager = 'yarn';
|
|
575
|
+
else if (files.some(f => f.relativePath === 'pnpm-lock.yaml'))
|
|
576
|
+
packageManager = 'pnpm';
|
|
577
|
+
}
|
|
578
|
+
catch { }
|
|
579
|
+
}
|
|
580
|
+
const goMod = files.find(f => f.relativePath === 'go.mod');
|
|
581
|
+
if (goMod) {
|
|
582
|
+
hasPackageManager = true;
|
|
583
|
+
packageManager = packageManager || 'go-modules';
|
|
584
|
+
try {
|
|
585
|
+
const content = fs.readFileSync(goMod.fullPath, 'utf-8');
|
|
586
|
+
const requireLines = content.split('\n').filter(l => l.trim().startsWith('require') || (l.trim().startsWith('github.com') && !l.trim().startsWith('//')));
|
|
587
|
+
depCount += requireLines.length;
|
|
588
|
+
}
|
|
589
|
+
catch { }
|
|
590
|
+
}
|
|
591
|
+
const reqTxt = files.find(f => f.relativePath === 'requirements.txt');
|
|
592
|
+
if (reqTxt) {
|
|
593
|
+
hasPackageManager = true;
|
|
594
|
+
packageManager = packageManager || 'pip';
|
|
595
|
+
try {
|
|
596
|
+
const content = fs.readFileSync(reqTxt.fullPath, 'utf-8');
|
|
597
|
+
depCount += content.split('\n').filter(l => l.trim() && !l.startsWith('#') && !l.startsWith('-')).length;
|
|
598
|
+
}
|
|
599
|
+
catch { }
|
|
600
|
+
}
|
|
601
|
+
const cargoToml = files.find(f => f.relativePath === 'Cargo.toml');
|
|
602
|
+
if (cargoToml) {
|
|
603
|
+
hasPackageManager = true;
|
|
604
|
+
packageManager = packageManager || 'cargo';
|
|
605
|
+
try {
|
|
606
|
+
const content = fs.readFileSync(cargoToml.fullPath, 'utf-8');
|
|
607
|
+
const depLines = content.split('\n').filter(l => l.trim().startsWith('[') && l.includes('dependencies'));
|
|
608
|
+
depCount += depLines.length;
|
|
609
|
+
}
|
|
610
|
+
catch { }
|
|
611
|
+
}
|
|
612
|
+
const totalDeps = depCount + devDepCount;
|
|
613
|
+
const dependencyComplexity = totalDeps === 0 ? 'low' : totalDeps < 50 ? 'low' : totalDeps < 150 ? 'medium' : totalDeps < 300 ? 'high' : 'extreme';
|
|
614
|
+
const dependencyRisk = totalDeps === 0 ? 0 : Math.min(Math.round((totalDeps / 300) * 100), 100);
|
|
615
|
+
return { totalDependencies: depCount, totalDevDependencies: devDepCount, dependencyCount: totalDeps, dependencyComplexity, dependencyRisk, hasPackageManager, packageManager };
|
|
616
|
+
}
|
|
617
|
+
// ─── SYSTEM 6: COMPLEXITY DNA ─────────────────────────
|
|
618
|
+
function buildComplexityProfile(files, rootDir) {
|
|
619
|
+
const srcFiles = files.filter(f => f.ext !== '' && !f.isTest);
|
|
620
|
+
const totalFiles = srcFiles.length;
|
|
621
|
+
const totalLines = srcFiles.reduce((s, f) => s + f.lines, 0);
|
|
622
|
+
const averageFileSize = totalFiles > 0 ? Math.round(totalLines / totalFiles) : 0;
|
|
623
|
+
const largestFiles = srcFiles.sort((a, b) => b.lines - a.lines).slice(0, 10).map(f => ({ path: f.relativePath, lines: f.lines }));
|
|
624
|
+
const complexity = totalFiles === 0 ? 'low' : totalFiles < 50 ? 'low' : totalFiles < 200 ? 'medium' : totalFiles < 500 ? 'high' : 'extreme';
|
|
625
|
+
return { totalFiles, totalLines, averageFileSize, largestFiles, complexity };
|
|
626
|
+
}
|
|
627
|
+
// ─── SYSTEM 7: RISK DNA ───────────────────────────────
|
|
628
|
+
function buildRiskProfile(files, rootDir, profiles) {
|
|
629
|
+
const riskFactors = [];
|
|
630
|
+
let riskScore = 0;
|
|
631
|
+
if (profiles.testing.testFileCount === 0) {
|
|
632
|
+
riskFactors.push({ factor: 'No tests', severity: 25, description: 'Project has zero test files' });
|
|
633
|
+
riskScore += 25;
|
|
634
|
+
}
|
|
635
|
+
else if (profiles.testing.coverageScore < 10) {
|
|
636
|
+
riskFactors.push({ factor: 'Low test coverage', severity: 15, description: `Test/source ratio is ${profiles.testing.testToSourceRatio}` });
|
|
637
|
+
riskScore += 15;
|
|
638
|
+
}
|
|
639
|
+
if (profiles.dependency.dependencyRisk > 70) {
|
|
640
|
+
riskFactors.push({ factor: 'High dependency count', severity: 20, description: `${profiles.dependency.dependencyCount} dependencies` });
|
|
641
|
+
riskScore += 20;
|
|
642
|
+
}
|
|
643
|
+
else if (profiles.dependency.dependencyRisk > 40) {
|
|
644
|
+
riskFactors.push({ factor: 'Moderate dependency count', severity: 10, description: `${profiles.dependency.dependencyCount} dependencies` });
|
|
645
|
+
riskScore += 10;
|
|
646
|
+
}
|
|
647
|
+
if (profiles.maturity.hasTesting === false && profiles.testing.testFileCount === 0) {
|
|
648
|
+
riskFactors.push({ factor: 'No testing framework', severity: 15, description: 'No testing framework detected' });
|
|
649
|
+
riskScore += 15;
|
|
650
|
+
}
|
|
651
|
+
if (!profiles.maturity.hasCI) {
|
|
652
|
+
riskFactors.push({ factor: 'No CI/CD', severity: 15, description: 'No CI/CD configuration found' });
|
|
653
|
+
riskScore += 15;
|
|
654
|
+
}
|
|
655
|
+
if (!profiles.maturity.hasLinting) {
|
|
656
|
+
riskFactors.push({ factor: 'No linting', severity: 10, description: 'No linting configuration found' });
|
|
657
|
+
riskScore += 10;
|
|
658
|
+
}
|
|
659
|
+
const largeFiles = files.filter(f => f.lines > 500 && !f.isTest);
|
|
660
|
+
if (largeFiles.length > 0) {
|
|
661
|
+
const severity = Math.min(largeFiles.length * 5, 20);
|
|
662
|
+
riskFactors.push({ factor: 'Large files', severity, description: `${largeFiles.length} files exceed 500 lines` });
|
|
663
|
+
riskScore += severity;
|
|
664
|
+
}
|
|
665
|
+
riskScore = Math.min(riskScore, 100);
|
|
666
|
+
const riskLevel = riskScore <= 20 ? 'low' : riskScore <= 50 ? 'medium' : riskScore <= 75 ? 'high' : 'critical';
|
|
667
|
+
return { riskScore, riskFactors, riskLevel };
|
|
668
|
+
}
|
|
669
|
+
// ─── SYSTEM 8: MATURITY DNA ───────────────────────────
|
|
670
|
+
const CI_FILES = ['.github/workflows', '.circleci/config.yml', '.circleci/config.yaml', 'Jenkinsfile', '.gitlab-ci.yml', '.gitlab-ci.yaml', 'azure-pipelines.yml', 'bitbucket-pipelines.yml', 'buildspec.yml', '.travis.yml'];
|
|
671
|
+
const LINT_FILES = ['.eslintrc', '.eslintrc.js', '.eslintrc.json', '.eslintrc.yaml', '.eslintrc.yml', 'eslint.config.js', '.pylintrc', '.rubocop.yml', '.golangci.yml', '.golangci.yaml', 'go vet', 'tsconfig.json'];
|
|
672
|
+
const FORMAT_FILES = ['.prettierrc', '.prettierrc.js', '.prettierrc.json', '.prettierrc.yaml', '.editorconfig', '.rustfmt.toml', 'black', 'isort'];
|
|
673
|
+
const DOC_FILES = ['README.md', 'CONTRIBUTING.md', 'CHANGELOG.md', 'LICENSE', 'docs/', 'documentation/'];
|
|
674
|
+
const CONVENTION_DIRS = ['.husky', 'commitlint', '.commitlintrc.json', '.lintstagedrc'];
|
|
675
|
+
function buildMaturityProfile(files, rootDir) {
|
|
676
|
+
const paths = new Set(files.map(f => f.relativePath.replace(/\\/g, '/')));
|
|
677
|
+
const allContent = files.map(f => f.relativePath).join(' ').toLowerCase();
|
|
678
|
+
const CD_FILES = ['.github/workflows/cd.yml', '.github/workflows/deploy', 'Jenkinsfile', 'Dockerfile', 'docker-compose.yml', 'k8s/', 'deploy/', 'helm/'];
|
|
679
|
+
const hasCI = CI_FILES.some(cf => paths.has(cf) || [...paths].some(p => p.startsWith(cf)));
|
|
680
|
+
const hasCD = CD_FILES.some(cf => paths.has(cf) || [...paths].some(p => p.startsWith(cf)));
|
|
681
|
+
const hasLinting = LINT_FILES.some(lf => paths.has(lf) || allContent.includes(lf.toLowerCase()));
|
|
682
|
+
const hasFormatting = FORMAT_FILES.some(ff => paths.has(ff));
|
|
683
|
+
const hasDocumentation = DOC_FILES.some(df => paths.has(df) || [...paths].some(p => p.startsWith(df)));
|
|
684
|
+
const hasConventions = CONVENTION_DIRS.some(cd => paths.has(cd) || allContent.includes(cd));
|
|
685
|
+
const hasTesting = files.some(f => f.isTest);
|
|
686
|
+
let score = 0;
|
|
687
|
+
if (hasCI)
|
|
688
|
+
score += 20;
|
|
689
|
+
if (hasCD)
|
|
690
|
+
score += 10;
|
|
691
|
+
if (hasLinting)
|
|
692
|
+
score += 15;
|
|
693
|
+
if (hasFormatting)
|
|
694
|
+
score += 10;
|
|
695
|
+
if (hasDocumentation)
|
|
696
|
+
score += 15;
|
|
697
|
+
if (hasConventions)
|
|
698
|
+
score += 10;
|
|
699
|
+
if (hasTesting)
|
|
700
|
+
score += 20;
|
|
701
|
+
score = Math.min(score, 100);
|
|
702
|
+
const level = score <= 30 ? 'startup' : score <= 55 ? 'growing' : score <= 80 ? 'mature' : 'enterprise';
|
|
703
|
+
const details = [];
|
|
704
|
+
if (hasCI)
|
|
705
|
+
details.push('CI/CD configured');
|
|
706
|
+
if (hasLinting)
|
|
707
|
+
details.push('Linting configured');
|
|
708
|
+
if (hasFormatting)
|
|
709
|
+
details.push('Formatting configured');
|
|
710
|
+
if (hasDocumentation)
|
|
711
|
+
details.push('Documentation present');
|
|
712
|
+
if (hasConventions)
|
|
713
|
+
details.push('Conventions/commit hooks');
|
|
714
|
+
if (hasTesting)
|
|
715
|
+
details.push('Tests present');
|
|
716
|
+
if (!hasCI)
|
|
717
|
+
details.push('Missing CI/CD');
|
|
718
|
+
if (!hasTesting)
|
|
719
|
+
details.push('Missing tests');
|
|
720
|
+
return { level, score, hasCI, hasCD, hasLinting, hasFormatting, hasDocumentation, hasConventions, hasTesting, details };
|
|
721
|
+
}
|
|
722
|
+
// ─── SYSTEM 9: DEVELOPMENT DNA ────────────────────────
|
|
723
|
+
function buildDevelopmentProfile(patterns, outcomes) {
|
|
724
|
+
const totalPatterns = patterns.length;
|
|
725
|
+
let successRate = 0;
|
|
726
|
+
let failureRate = 0;
|
|
727
|
+
let acceptanceRate = 0;
|
|
728
|
+
if (outcomes.size > 0) {
|
|
729
|
+
let totalSuccess = 0;
|
|
730
|
+
let totalFailure = 0;
|
|
731
|
+
let totalAccept = 0;
|
|
732
|
+
let totalReject = 0;
|
|
733
|
+
let count = 0;
|
|
734
|
+
for (const outcome of outcomes.values()) {
|
|
735
|
+
totalSuccess += outcome.successCount || 0;
|
|
736
|
+
totalFailure += outcome.failureCount || 0;
|
|
737
|
+
totalAccept += outcome.acceptanceCount || 0;
|
|
738
|
+
totalReject += outcome.rejectionCount || 0;
|
|
739
|
+
count++;
|
|
740
|
+
}
|
|
741
|
+
const total = totalSuccess + totalFailure;
|
|
742
|
+
successRate = total > 0 ? totalSuccess / total : 0;
|
|
743
|
+
failureRate = total > 0 ? totalFailure / total : 0;
|
|
744
|
+
const totalAcceptReject = totalAccept + totalReject;
|
|
745
|
+
acceptanceRate = totalAcceptReject > 0 ? totalAccept / totalAcceptReject : 0;
|
|
746
|
+
}
|
|
747
|
+
else if (patterns.length > 0) {
|
|
748
|
+
let good = 0;
|
|
749
|
+
let bad = 0;
|
|
750
|
+
for (const p of patterns) {
|
|
751
|
+
if (p.signals) {
|
|
752
|
+
good += p.signals.positive || 0;
|
|
753
|
+
bad += p.signals.negative || 0;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
const total = good + bad;
|
|
757
|
+
successRate = total > 0 ? good / total : 0.5;
|
|
758
|
+
failureRate = total > 0 ? bad / total : 0.5;
|
|
759
|
+
acceptanceRate = 0.5;
|
|
760
|
+
}
|
|
761
|
+
let style;
|
|
762
|
+
let styleConfidence;
|
|
763
|
+
if (successRate >= 0.8 && failureRate <= 0.1) {
|
|
764
|
+
style = 'quality-driven';
|
|
765
|
+
styleConfidence = 0.8;
|
|
766
|
+
}
|
|
767
|
+
else if (acceptanceRate >= 0.7 && successRate >= 0.6) {
|
|
768
|
+
style = 'stability-driven';
|
|
769
|
+
styleConfidence = 0.7;
|
|
770
|
+
}
|
|
771
|
+
else if (successRate < 0.5 || failureRate >= 0.3) {
|
|
772
|
+
style = 'experiment-driven';
|
|
773
|
+
styleConfidence = 0.75;
|
|
774
|
+
}
|
|
775
|
+
else {
|
|
776
|
+
style = 'speed-driven';
|
|
777
|
+
styleConfidence = 0.65;
|
|
778
|
+
}
|
|
779
|
+
const iterationSpeed = failureRate > 0.3 ? 'very-fast' : failureRate > 0.15 ? 'fast' : successRate > 0.8 ? 'slow' : 'moderate';
|
|
780
|
+
return { style, styleConfidence, patternsUsed: totalPatterns, successRate, failureRate, acceptanceRate, iterationSpeed };
|
|
781
|
+
}
|
|
782
|
+
// ─── SYSTEM 10: PROJECT FINGERPRINT ───────────────────
|
|
783
|
+
function buildFingerprint(language, framework, architecture, testing, dependency, complexity, risk, maturity, development) {
|
|
784
|
+
return {
|
|
785
|
+
primaryLanguage: language.primaryLanguage,
|
|
786
|
+
framework: framework.primaryFramework,
|
|
787
|
+
architecture: architecture.architecture,
|
|
788
|
+
complexity: complexity.complexity,
|
|
789
|
+
risk: risk.riskScore,
|
|
790
|
+
maturity: maturity.level,
|
|
791
|
+
testing: testing.maturity,
|
|
792
|
+
developmentStyle: development.style,
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
// ─── DNA BUILD ─────────────────────────────────────────
|
|
796
|
+
function buildProjectDNA(projectId, projectPath, options) {
|
|
797
|
+
const files = scanFiles(projectPath);
|
|
798
|
+
const skipSystems = new Set(options?.skipSystems || []);
|
|
799
|
+
const language = skipSystems.has('language') ? buildEmptyLanguage() : buildLanguageProfile(files);
|
|
800
|
+
const framework = skipSystems.has('framework') ? { frameworks: [], primaryFramework: null } : buildFrameworkProfile(files, projectPath);
|
|
801
|
+
const architecture = skipSystems.has('architecture') ? buildEmptyArchitecture() : buildArchitectureProfile(files, projectPath);
|
|
802
|
+
const testing = skipSystems.has('testing') ? buildEmptyTesting() : buildTestingProfile(files, projectPath);
|
|
803
|
+
const dependency = skipSystems.has('dependency') ? buildEmptyDependency() : buildDependencyProfile(files, projectPath);
|
|
804
|
+
const complexity = skipSystems.has('complexity') ? buildEmptyComplexity() : buildComplexityProfile(files, projectPath);
|
|
805
|
+
const maturity = skipSystems.has('maturity') ? buildEmptyMaturity() : buildMaturityProfile(files, projectPath);
|
|
806
|
+
const risk = skipSystems.has('risk') ? buildEmptyRisk() : buildRiskProfile(files, projectPath, { testing, dependency, maturity });
|
|
807
|
+
const development = skipSystems.has('development') ? buildEmptyDevelopment() : buildDevelopmentProfile(options?.patterns || [], options?.outcomes || new Map());
|
|
808
|
+
const fingerprint = buildFingerprint(language, framework, architecture, testing, dependency, complexity, risk, maturity, development);
|
|
809
|
+
const dna = {
|
|
810
|
+
projectId, projectPath, language, framework, architecture, testing, dependency,
|
|
811
|
+
complexity, risk, maturity, development, fingerprint, builtAt: Date.now(), version: 1,
|
|
812
|
+
};
|
|
813
|
+
saveDNA(dna);
|
|
814
|
+
return dna;
|
|
815
|
+
}
|
|
816
|
+
function buildEmptyLanguage() {
|
|
817
|
+
return { primaryLanguage: 'unknown', languages: [], languagePurity: 0 };
|
|
818
|
+
}
|
|
819
|
+
function buildEmptyArchitecture() {
|
|
820
|
+
return { architecture: 'unknown', confidence: 0, candidates: [], hasApiLayer: false, hasServiceLayer: false, hasDataLayer: false };
|
|
821
|
+
}
|
|
822
|
+
function buildEmptyTesting() {
|
|
823
|
+
return { frameworks: [], testFileCount: 0, sourceFileCount: 0, testToSourceRatio: 0, coverageScore: 0, cultureScore: 0, maturity: 'none' };
|
|
824
|
+
}
|
|
825
|
+
function buildEmptyDependency() {
|
|
826
|
+
return { totalDependencies: 0, totalDevDependencies: 0, dependencyCount: 0, dependencyComplexity: 'low', dependencyRisk: 0, hasPackageManager: false, packageManager: null };
|
|
827
|
+
}
|
|
828
|
+
function buildEmptyComplexity() {
|
|
829
|
+
return { totalFiles: 0, totalLines: 0, averageFileSize: 0, largestFiles: [], complexity: 'low' };
|
|
830
|
+
}
|
|
831
|
+
function buildEmptyRisk() {
|
|
832
|
+
return { riskScore: 0, riskFactors: [], riskLevel: 'low' };
|
|
833
|
+
}
|
|
834
|
+
function buildEmptyMaturity() {
|
|
835
|
+
return { level: 'startup', score: 0, hasCI: false, hasCD: false, hasLinting: false, hasFormatting: false, hasDocumentation: false, hasConventions: false, hasTesting: false, details: [] };
|
|
836
|
+
}
|
|
837
|
+
function buildEmptyDevelopment() {
|
|
838
|
+
return { style: 'stability-driven', styleConfidence: 0, patternsUsed: 0, successRate: 0, failureRate: 0, acceptanceRate: 0, iterationSpeed: 'moderate' };
|
|
839
|
+
}
|
|
840
|
+
// ─── STORE ──────────────────────────────────────────────
|
|
841
|
+
function loadStore() {
|
|
842
|
+
ensureStoreDir();
|
|
843
|
+
try {
|
|
844
|
+
if (fs.existsSync(DNA_STORE_PATH)) {
|
|
845
|
+
return JSON.parse(fs.readFileSync(DNA_STORE_PATH, 'utf-8'));
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
catch { }
|
|
849
|
+
return { projects: {} };
|
|
850
|
+
}
|
|
851
|
+
function saveStore(data) {
|
|
852
|
+
ensureStoreDir();
|
|
853
|
+
fs.writeFileSync(DNA_STORE_PATH, JSON.stringify(data, null, 2), 'utf-8');
|
|
854
|
+
}
|
|
855
|
+
function saveDNA(dna) {
|
|
856
|
+
const store = loadStore();
|
|
857
|
+
const existing = store.projects[dna.projectId];
|
|
858
|
+
if (existing)
|
|
859
|
+
dna.version = existing.version + 1;
|
|
860
|
+
dna.builtAt = Date.now();
|
|
861
|
+
store.projects[dna.projectId] = dna;
|
|
862
|
+
saveStore(store);
|
|
863
|
+
}
|
|
864
|
+
function getDNA(projectId) {
|
|
865
|
+
const store = loadStore();
|
|
866
|
+
return store.projects[projectId] || null;
|
|
867
|
+
}
|
|
868
|
+
function listDNA() {
|
|
869
|
+
const store = loadStore();
|
|
870
|
+
return Object.values(store.projects);
|
|
871
|
+
}
|
|
872
|
+
function deleteDNA(projectId) {
|
|
873
|
+
const store = loadStore();
|
|
874
|
+
if (store.projects[projectId]) {
|
|
875
|
+
delete store.projects[projectId];
|
|
876
|
+
saveStore(store);
|
|
877
|
+
return true;
|
|
878
|
+
}
|
|
879
|
+
return false;
|
|
880
|
+
}
|
|
881
|
+
function getDNAHistory(projectId) {
|
|
882
|
+
return listDNA().filter(d => d.projectId === projectId).sort((a, b) => a.builtAt - b.builtAt);
|
|
883
|
+
}
|
|
884
|
+
// ─── COMPARISON ─────────────────────────────────────────
|
|
885
|
+
function compareDNA(projectA, projectB) {
|
|
886
|
+
const dnaA = getDNA(projectA);
|
|
887
|
+
const dnaB = getDNA(projectB);
|
|
888
|
+
if (!dnaA || !dnaB) {
|
|
889
|
+
return {
|
|
890
|
+
projectA, projectB, overallSimilarity: 0, languageSimilarity: 0, frameworkSimilarity: 0,
|
|
891
|
+
architectureDifference: 'Unknown', riskDifference: 0, complexityDifference: 'Unknown',
|
|
892
|
+
maturityDifference: 'Unknown', testingDifference: 'Unknown', details: ['One or both projects not found'],
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
const allLangs = new Set([...dnaA.language.languages.map(l => l.language), ...dnaB.language.languages.map(l => l.language)]);
|
|
896
|
+
const sharedLangs = dnaA.language.languages.filter(a => dnaB.language.languages.some(b => b.language === a.language)).length;
|
|
897
|
+
const languageSimilarity = allLangs.size > 0 ? Math.round((sharedLangs / allLangs.size) * 100) : 0;
|
|
898
|
+
const allFrameworks = new Set([...dnaA.framework.frameworks.map(f => f.name), ...dnaB.framework.frameworks.map(f => f.name)]);
|
|
899
|
+
const sharedFrameworks = dnaA.framework.frameworks.filter(a => dnaB.framework.frameworks.some(b => b.name === a.name)).length;
|
|
900
|
+
const frameworkSimilarity = allFrameworks.size > 0 ? Math.round((sharedFrameworks / allFrameworks.size) * 100) : dnaA.framework.primaryFramework === null && dnaB.framework.primaryFramework === null ? 100 : 0;
|
|
901
|
+
const architectureDifference = dnaA.architecture.architecture === dnaB.architecture.architecture ? 'Same' : `${dnaA.architecture.architecture} vs ${dnaB.architecture.architecture}`;
|
|
902
|
+
const riskDifference = Math.abs(dnaA.risk.riskScore - dnaB.risk.riskScore);
|
|
903
|
+
const complexityDifference = dnaA.complexity.complexity === dnaB.complexity.complexity ? 'Same' : `${dnaA.complexity.complexity} vs ${dnaB.complexity.complexity}`;
|
|
904
|
+
const maturityDifference = dnaA.maturity.level === dnaB.maturity.level ? 'Same' : `${dnaA.maturity.level} vs ${dnaB.maturity.level}`;
|
|
905
|
+
const testingDifference = dnaA.testing.maturity === dnaB.testing.maturity ? 'Same' : `${dnaA.testing.maturity} vs ${dnaB.testing.maturity}`;
|
|
906
|
+
const details = [];
|
|
907
|
+
if (dnaA.language.primaryLanguage !== dnaB.language.primaryLanguage)
|
|
908
|
+
details.push(`Primary language differs: ${dnaA.language.primaryLanguage} vs ${dnaB.language.primaryLanguage}`);
|
|
909
|
+
if (dnaA.framework.primaryFramework !== dnaB.framework.primaryFramework)
|
|
910
|
+
details.push(`Framework differs: ${dnaA.framework.primaryFramework || 'none'} vs ${dnaB.framework.primaryFramework || 'none'}`);
|
|
911
|
+
if (dnaA.architecture.architecture !== dnaB.architecture.architecture)
|
|
912
|
+
details.push(`Architecture differs: ${dnaA.architecture.architecture} vs ${dnaB.architecture.architecture}`);
|
|
913
|
+
details.push(`Risk: ${dnaA.risk.riskScore} vs ${dnaB.risk.riskScore}`);
|
|
914
|
+
details.push(`Maturity: ${dnaA.maturity.level} vs ${dnaB.maturity.level}`);
|
|
915
|
+
details.push(`Complexity: ${dnaA.complexity.complexity} vs ${dnaB.complexity.complexity}`);
|
|
916
|
+
const overallSimilarity = Math.round((languageSimilarity + frameworkSimilarity) / 2);
|
|
917
|
+
return {
|
|
918
|
+
projectA, projectB, overallSimilarity, languageSimilarity, frameworkSimilarity,
|
|
919
|
+
architectureDifference, riskDifference, complexityDifference, maturityDifference, testingDifference, details,
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
//# sourceMappingURL=project-dna.js.map
|