aios-core 2.1.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/.aios-core/.session/current-session.json +14 -0
- package/.aios-core/cli/commands/generate/index.js +222 -0
- package/.aios-core/cli/commands/manifest/index.js +46 -0
- package/.aios-core/cli/commands/manifest/regenerate.js +96 -0
- package/.aios-core/cli/commands/manifest/validate.js +66 -0
- package/.aios-core/cli/commands/mcp/add.js +234 -0
- package/.aios-core/cli/commands/mcp/index.js +76 -0
- package/.aios-core/cli/commands/mcp/link.js +217 -0
- package/.aios-core/cli/commands/mcp/setup.js +164 -0
- package/.aios-core/cli/commands/mcp/status.js +183 -0
- package/.aios-core/cli/commands/metrics/cleanup.js +91 -0
- package/.aios-core/cli/commands/metrics/index.js +65 -0
- package/.aios-core/cli/commands/metrics/record.js +154 -0
- package/.aios-core/cli/commands/metrics/seed.js +126 -0
- package/.aios-core/cli/commands/metrics/show.js +209 -0
- package/.aios-core/cli/commands/migrate/analyze.js +353 -0
- package/.aios-core/cli/commands/migrate/backup.js +352 -0
- package/.aios-core/cli/commands/migrate/execute.js +292 -0
- package/.aios-core/cli/commands/migrate/index.js +441 -0
- package/.aios-core/cli/commands/migrate/rollback.js +323 -0
- package/.aios-core/cli/commands/migrate/update-imports.js +396 -0
- package/.aios-core/cli/commands/migrate/validate.js +452 -0
- package/.aios-core/cli/commands/qa/index.js +56 -0
- package/.aios-core/cli/commands/qa/run.js +163 -0
- package/.aios-core/cli/commands/qa/status.js +195 -0
- package/.aios-core/cli/commands/workers/formatters/info-formatter.js +274 -0
- package/.aios-core/cli/commands/workers/formatters/list-table.js +265 -0
- package/.aios-core/cli/commands/workers/formatters/list-tree.js +159 -0
- package/.aios-core/cli/commands/workers/index.js +56 -0
- package/.aios-core/cli/commands/workers/info.js +194 -0
- package/.aios-core/cli/commands/workers/list.js +214 -0
- package/.aios-core/cli/commands/workers/search-filters.js +185 -0
- package/.aios-core/cli/commands/workers/search-keyword.js +310 -0
- package/.aios-core/cli/commands/workers/search-semantic.js +293 -0
- package/.aios-core/cli/commands/workers/search.js +154 -0
- package/.aios-core/cli/commands/workers/utils/pagination.js +102 -0
- package/.aios-core/cli/index.js +128 -0
- package/.aios-core/cli/utils/output-formatter-cli.js +232 -0
- package/.aios-core/cli/utils/score-calculator.js +221 -0
- package/.aios-core/core/README.md +229 -0
- package/.aios-core/core/config/config-cache.js +233 -0
- package/.aios-core/core/config/config-loader.js +277 -0
- package/.aios-core/core/data/agent-config-requirements.yaml +368 -0
- package/.aios-core/core/data/aios-kb.md +924 -0
- package/.aios-core/core/data/workflow-patterns.yaml +267 -0
- package/.aios-core/core/docs/SHARD-TRANSLATION-GUIDE.md +335 -0
- package/.aios-core/core/docs/component-creation-guide.md +458 -0
- package/.aios-core/core/docs/session-update-pattern.md +307 -0
- package/.aios-core/core/docs/template-syntax.md +267 -0
- package/.aios-core/core/docs/troubleshooting-guide.md +625 -0
- package/.aios-core/core/elicitation/agent-elicitation.js +272 -0
- package/.aios-core/core/elicitation/elicitation-engine.js +479 -0
- package/.aios-core/core/elicitation/session-manager.js +320 -0
- package/.aios-core/core/elicitation/task-elicitation.js +281 -0
- package/.aios-core/core/elicitation/workflow-elicitation.js +315 -0
- package/.aios-core/core/index.esm.js +42 -0
- package/.aios-core/core/index.js +76 -0
- package/.aios-core/core/manifest/manifest-generator.js +386 -0
- package/.aios-core/core/manifest/manifest-validator.js +429 -0
- package/.aios-core/core/mcp/config-migrator.js +340 -0
- package/.aios-core/core/mcp/global-config-manager.js +369 -0
- package/.aios-core/core/mcp/index.js +34 -0
- package/.aios-core/core/mcp/os-detector.js +188 -0
- package/.aios-core/core/mcp/symlink-manager.js +413 -0
- package/.aios-core/core/migration/migration-config.yaml +83 -0
- package/.aios-core/core/migration/module-mapping.yaml +89 -0
- package/.aios-core/core/quality-gates/base-layer.js +134 -0
- package/.aios-core/core/quality-gates/checklist-generator.js +329 -0
- package/.aios-core/core/quality-gates/focus-area-recommender.js +359 -0
- package/.aios-core/core/quality-gates/human-review-orchestrator.js +529 -0
- package/.aios-core/core/quality-gates/layer1-precommit.js +336 -0
- package/.aios-core/core/quality-gates/layer2-pr-automation.js +324 -0
- package/.aios-core/core/quality-gates/layer3-human-review.js +348 -0
- package/.aios-core/core/quality-gates/notification-manager.js +550 -0
- package/.aios-core/core/quality-gates/quality-gate-config.yaml +86 -0
- package/.aios-core/core/quality-gates/quality-gate-manager.js +601 -0
- package/.aios-core/core/registry/README.md +179 -0
- package/.aios-core/core/registry/build-registry.js +452 -0
- package/.aios-core/core/registry/registry-loader.js +330 -0
- package/.aios-core/core/registry/registry-schema.json +166 -0
- package/.aios-core/core/registry/service-registry.json +6586 -0
- package/.aios-core/core/registry/validate-registry.js +340 -0
- package/.aios-core/core/session/context-detector.js +229 -0
- package/.aios-core/core/session/context-loader.js +288 -0
- package/.aios-core/core/utils/output-formatter.js +298 -0
- package/.aios-core/core/utils/security-utils.js +333 -0
- package/.aios-core/core/utils/yaml-validator.js +419 -0
- package/.aios-core/core-config.yaml +382 -0
- package/.aios-core/data/agent-config-requirements.yaml +368 -0
- package/.aios-core/data/aios-kb.md +924 -0
- package/.aios-core/data/technical-preferences.md +4 -0
- package/.aios-core/data/workflow-patterns.yaml +267 -0
- package/.aios-core/development/README.md +142 -0
- package/.aios-core/development/agent-teams/team-all.yaml +15 -0
- package/.aios-core/development/agent-teams/team-fullstack.yaml +18 -0
- package/.aios-core/development/agent-teams/team-ide-minimal.yaml +10 -0
- package/.aios-core/development/agent-teams/team-no-ui.yaml +13 -0
- package/.aios-core/development/agent-teams/team-qa-focused.yaml +155 -0
- package/.aios-core/development/agents/aios-master.md +339 -0
- package/.aios-core/development/agents/analyst.md +195 -0
- package/.aios-core/development/agents/architect.md +359 -0
- package/.aios-core/development/agents/data-engineer.md +468 -0
- package/.aios-core/development/agents/dev.md +390 -0
- package/.aios-core/development/agents/devops.md +398 -0
- package/.aios-core/development/agents/pm.md +198 -0
- package/.aios-core/development/agents/po.md +256 -0
- package/.aios-core/development/agents/qa.md +312 -0
- package/.aios-core/development/agents/sm.md +220 -0
- package/.aios-core/development/agents/ux-design-expert.md +451 -0
- package/.aios-core/development/scripts/agent-assignment-resolver.js +231 -0
- package/.aios-core/development/scripts/agent-config-loader.js +624 -0
- package/.aios-core/development/scripts/agent-exit-hooks.js +96 -0
- package/.aios-core/development/scripts/apply-inline-greeting-all-agents.js +146 -0
- package/.aios-core/development/scripts/audit-agent-config.js +380 -0
- package/.aios-core/development/scripts/backlog-manager.js +404 -0
- package/.aios-core/development/scripts/batch-update-agents-session-context.js +95 -0
- package/.aios-core/development/scripts/decision-context.js +228 -0
- package/.aios-core/development/scripts/decision-log-generator.js +293 -0
- package/.aios-core/development/scripts/decision-log-indexer.js +284 -0
- package/.aios-core/development/scripts/decision-recorder.js +168 -0
- package/.aios-core/development/scripts/dev-context-loader.js +297 -0
- package/.aios-core/development/scripts/generate-greeting.js +160 -0
- package/.aios-core/development/scripts/greeting-builder.js +866 -0
- package/.aios-core/development/scripts/greeting-config-cli.js +85 -0
- package/.aios-core/development/scripts/greeting-preference-manager.js +145 -0
- package/.aios-core/development/scripts/migrate-task-to-v2.js +377 -0
- package/.aios-core/development/scripts/story-index-generator.js +337 -0
- package/.aios-core/development/scripts/story-manager.js +375 -0
- package/.aios-core/development/scripts/story-update-hook.js +259 -0
- package/.aios-core/development/scripts/task-identifier-resolver.js +145 -0
- package/.aios-core/development/scripts/test-greeting-system.js +142 -0
- package/.aios-core/development/scripts/validate-task-v2.js +319 -0
- package/.aios-core/development/scripts/workflow-navigator.js +214 -0
- package/.aios-core/development/tasks/add-mcp.md +319 -0
- package/.aios-core/development/tasks/advanced-elicitation.md +319 -0
- package/.aios-core/development/tasks/analyst-facilitate-brainstorming.md +342 -0
- package/.aios-core/development/tasks/analyze-framework.md +697 -0
- package/.aios-core/development/tasks/analyze-performance.md +637 -0
- package/.aios-core/development/tasks/apply-qa-fixes.md +340 -0
- package/.aios-core/development/tasks/architect-analyze-impact.md +827 -0
- package/.aios-core/development/tasks/audit-codebase.md +429 -0
- package/.aios-core/development/tasks/audit-tailwind-config.md +270 -0
- package/.aios-core/development/tasks/audit-utilities.md +358 -0
- package/.aios-core/development/tasks/bootstrap-shadcn-library.md +286 -0
- package/.aios-core/development/tasks/brownfield-create-epic.md +486 -0
- package/.aios-core/development/tasks/brownfield-create-story.md +357 -0
- package/.aios-core/development/tasks/build-component.md +478 -0
- package/.aios-core/development/tasks/calculate-roi.md +455 -0
- package/.aios-core/development/tasks/ci-cd-configuration.md +764 -0
- package/.aios-core/development/tasks/cleanup-utilities.md +670 -0
- package/.aios-core/development/tasks/collaborative-edit.md +1109 -0
- package/.aios-core/development/tasks/compose-molecule.md +284 -0
- package/.aios-core/development/tasks/consolidate-patterns.md +414 -0
- package/.aios-core/development/tasks/correct-course.md +280 -0
- package/.aios-core/development/tasks/create-agent.md +322 -0
- package/.aios-core/development/tasks/create-brownfield-story.md +727 -0
- package/.aios-core/development/tasks/create-deep-research-prompt.md +499 -0
- package/.aios-core/development/tasks/create-doc.md +316 -0
- package/.aios-core/development/tasks/create-next-story.md +774 -0
- package/.aios-core/development/tasks/create-suite.md +284 -0
- package/.aios-core/development/tasks/create-task.md +372 -0
- package/.aios-core/development/tasks/create-workflow.md +371 -0
- package/.aios-core/development/tasks/db-analyze-hotpaths.md +572 -0
- package/.aios-core/development/tasks/db-apply-migration.md +381 -0
- package/.aios-core/development/tasks/db-bootstrap.md +642 -0
- package/.aios-core/development/tasks/db-domain-modeling.md +693 -0
- package/.aios-core/development/tasks/db-dry-run.md +293 -0
- package/.aios-core/development/tasks/db-env-check.md +260 -0
- package/.aios-core/development/tasks/db-expansion-pack-integration.md +663 -0
- package/.aios-core/development/tasks/db-explain.md +631 -0
- package/.aios-core/development/tasks/db-impersonate.md +495 -0
- package/.aios-core/development/tasks/db-load-csv.md +593 -0
- package/.aios-core/development/tasks/db-policy-apply.md +653 -0
- package/.aios-core/development/tasks/db-rls-audit.md +411 -0
- package/.aios-core/development/tasks/db-rollback.md +739 -0
- package/.aios-core/development/tasks/db-run-sql.md +613 -0
- package/.aios-core/development/tasks/db-schema-audit.md +1011 -0
- package/.aios-core/development/tasks/db-seed.md +390 -0
- package/.aios-core/development/tasks/db-smoke-test.md +351 -0
- package/.aios-core/development/tasks/db-snapshot.md +569 -0
- package/.aios-core/development/tasks/db-supabase-setup.md +712 -0
- package/.aios-core/development/tasks/db-verify-order.md +515 -0
- package/.aios-core/development/tasks/deprecate-component.md +957 -0
- package/.aios-core/development/tasks/dev-apply-qa-fixes.md +318 -0
- package/.aios-core/development/tasks/dev-backlog-debt.md +469 -0
- package/.aios-core/development/tasks/dev-develop-story.md +846 -0
- package/.aios-core/development/tasks/dev-improve-code-quality.md +873 -0
- package/.aios-core/development/tasks/dev-optimize-performance.md +1034 -0
- package/.aios-core/development/tasks/dev-suggest-refactoring.md +871 -0
- package/.aios-core/development/tasks/dev-validate-next-story.md +349 -0
- package/.aios-core/development/tasks/document-project.md +553 -0
- package/.aios-core/development/tasks/environment-bootstrap.md +1311 -0
- package/.aios-core/development/tasks/execute-checklist.md +301 -0
- package/.aios-core/development/tasks/export-design-tokens-dtcg.md +274 -0
- package/.aios-core/development/tasks/extend-pattern.md +269 -0
- package/.aios-core/development/tasks/extract-tokens.md +467 -0
- package/.aios-core/development/tasks/facilitate-brainstorming-session.md +518 -0
- package/.aios-core/development/tasks/generate-ai-frontend-prompt.md +261 -0
- package/.aios-core/development/tasks/generate-documentation.md +284 -0
- package/.aios-core/development/tasks/generate-migration-strategy.md +522 -0
- package/.aios-core/development/tasks/generate-shock-report.md +501 -0
- package/.aios-core/development/tasks/github-devops-github-pr-automation.md +427 -0
- package/.aios-core/development/tasks/github-devops-pre-push-quality-gate.md +733 -0
- package/.aios-core/development/tasks/github-devops-repository-cleanup.md +374 -0
- package/.aios-core/development/tasks/github-devops-version-management.md +483 -0
- package/.aios-core/development/tasks/improve-self.md +823 -0
- package/.aios-core/development/tasks/index-docs.md +388 -0
- package/.aios-core/development/tasks/init-project-status.md +506 -0
- package/.aios-core/development/tasks/integrate-expansion-pack.md +314 -0
- package/.aios-core/development/tasks/kb-mode-interaction.md +284 -0
- package/.aios-core/development/tasks/learn-patterns.md +901 -0
- package/.aios-core/development/tasks/mcp-workflow.md +437 -0
- package/.aios-core/development/tasks/modify-agent.md +382 -0
- package/.aios-core/development/tasks/modify-task.md +425 -0
- package/.aios-core/development/tasks/modify-workflow.md +466 -0
- package/.aios-core/development/tasks/po-backlog-add.md +370 -0
- package/.aios-core/development/tasks/po-manage-story-backlog.md +523 -0
- package/.aios-core/development/tasks/po-pull-story-from-clickup.md +540 -0
- package/.aios-core/development/tasks/po-pull-story.md +316 -0
- package/.aios-core/development/tasks/po-stories-index.md +351 -0
- package/.aios-core/development/tasks/po-sync-story-to-clickup.md +457 -0
- package/.aios-core/development/tasks/po-sync-story.md +303 -0
- package/.aios-core/development/tasks/pr-automation.md +701 -0
- package/.aios-core/development/tasks/propose-modification.md +843 -0
- package/.aios-core/development/tasks/qa-backlog-add-followup.md +425 -0
- package/.aios-core/development/tasks/qa-gate.md +374 -0
- package/.aios-core/development/tasks/qa-generate-tests.md +1175 -0
- package/.aios-core/development/tasks/qa-nfr-assess.md +558 -0
- package/.aios-core/development/tasks/qa-review-proposal.md +1158 -0
- package/.aios-core/development/tasks/qa-review-story.md +683 -0
- package/.aios-core/development/tasks/qa-risk-profile.md +567 -0
- package/.aios-core/development/tasks/qa-run-tests.md +277 -0
- package/.aios-core/development/tasks/qa-test-design.md +388 -0
- package/.aios-core/development/tasks/qa-trace-requirements.md +477 -0
- package/.aios-core/development/tasks/release-management.md +723 -0
- package/.aios-core/development/tasks/security-audit.md +554 -0
- package/.aios-core/development/tasks/security-scan.md +790 -0
- package/.aios-core/development/tasks/setup-database.md +741 -0
- package/.aios-core/development/tasks/setup-design-system.md +462 -0
- package/.aios-core/development/tasks/setup-github.md +874 -0
- package/.aios-core/development/tasks/setup-llm-routing.md +229 -0
- package/.aios-core/development/tasks/setup-mcp-docker.md +584 -0
- package/.aios-core/development/tasks/shard-doc.md +538 -0
- package/.aios-core/development/tasks/sm-create-next-story.md +480 -0
- package/.aios-core/development/tasks/sync-documentation.md +865 -0
- package/.aios-core/development/tasks/tailwind-upgrade.md +294 -0
- package/.aios-core/development/tasks/test-as-user.md +621 -0
- package/.aios-core/development/tasks/test-validation-task.md +171 -0
- package/.aios-core/development/tasks/undo-last.md +347 -0
- package/.aios-core/development/tasks/update-manifest.md +410 -0
- package/.aios-core/development/tasks/ux-create-wireframe.md +617 -0
- package/.aios-core/development/tasks/ux-ds-scan-artifact.md +672 -0
- package/.aios-core/development/tasks/ux-user-research.md +559 -0
- package/.aios-core/development/tasks/validate-next-story.md +423 -0
- package/.aios-core/development/tasks/validate-structure.md +243 -0
- package/.aios-core/development/workflows/README.md +84 -0
- package/.aios-core/development/workflows/brownfield-fullstack.yaml +297 -0
- package/.aios-core/development/workflows/brownfield-service.yaml +187 -0
- package/.aios-core/development/workflows/brownfield-ui.yaml +197 -0
- package/.aios-core/development/workflows/greenfield-fullstack.yaml +333 -0
- package/.aios-core/development/workflows/greenfield-service.yaml +206 -0
- package/.aios-core/development/workflows/greenfield-ui.yaml +235 -0
- package/.aios-core/docs/SHARD-TRANSLATION-GUIDE.md +335 -0
- package/.aios-core/docs/component-creation-guide.md +458 -0
- package/.aios-core/docs/session-update-pattern.md +307 -0
- package/.aios-core/docs/standards/AGENT-PERSONALIZATION-STANDARD-V1.md +572 -0
- package/.aios-core/docs/standards/AIOS-COLOR-PALETTE-QUICK-REFERENCE.md +185 -0
- package/.aios-core/docs/standards/AIOS-COLOR-PALETTE-V2.1.md +354 -0
- package/.aios-core/docs/standards/AIOS-FRAMEWORK-MASTER.md +1963 -0
- package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.1-COMPLETE.md +821 -0
- package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.1-SUMMARY.md +1190 -0
- package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.1.md +439 -0
- package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.2-SUMMARY.md +1339 -0
- package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO.md +5398 -0
- package/.aios-core/docs/standards/EXECUTOR-DECISION-TREE.md +697 -0
- package/.aios-core/docs/standards/OPEN-SOURCE-VS-SERVICE-DIFFERENCES.md +511 -0
- package/.aios-core/docs/standards/QUALITY-GATES-SPECIFICATION.md +556 -0
- package/.aios-core/docs/standards/STANDARDS-INDEX.md +210 -0
- package/.aios-core/docs/standards/STORY-TEMPLATE-V2-SPECIFICATION.md +550 -0
- package/.aios-core/docs/standards/TASK-FORMAT-SPECIFICATION-V1.md +1414 -0
- package/.aios-core/docs/standards/V3-ARCHITECTURAL-DECISIONS.md +523 -0
- package/.aios-core/docs/template-syntax.md +267 -0
- package/.aios-core/docs/troubleshooting-guide.md +625 -0
- package/.aios-core/elicitation/agent-elicitation.js +272 -0
- package/.aios-core/elicitation/task-elicitation.js +281 -0
- package/.aios-core/elicitation/workflow-elicitation.js +315 -0
- package/.aios-core/index.d.ts +8 -0
- package/.aios-core/index.esm.js +16 -0
- package/.aios-core/index.js +16 -0
- package/.aios-core/infrastructure/README.md +126 -0
- package/.aios-core/infrastructure/index.js +199 -0
- package/.aios-core/infrastructure/integrations/pm-adapters/README.md +59 -0
- package/.aios-core/infrastructure/integrations/pm-adapters/clickup-adapter.js +345 -0
- package/.aios-core/infrastructure/integrations/pm-adapters/github-adapter.js +392 -0
- package/.aios-core/infrastructure/integrations/pm-adapters/jira-adapter.js +448 -0
- package/.aios-core/infrastructure/integrations/pm-adapters/local-adapter.js +175 -0
- package/.aios-core/infrastructure/scripts/_archived/final-todo-count.js +122 -0
- package/.aios-core/infrastructure/scripts/_archived/fix-yaml-formatting.js +89 -0
- package/.aios-core/infrastructure/scripts/_archived/migration-generator.js +780 -0
- package/.aios-core/infrastructure/scripts/_archived/migration-path-generator.js +950 -0
- package/.aios-core/infrastructure/scripts/_archived/phase2-entrada-saida-errors.js +425 -0
- package/.aios-core/infrastructure/scripts/_archived/phase2-spot-check.js +132 -0
- package/.aios-core/infrastructure/scripts/_archived/phase3-tools-scripts-validation.js +381 -0
- package/.aios-core/infrastructure/scripts/_archived/phase4-metadata-performance.js +203 -0
- package/.aios-core/infrastructure/scripts/_archived/test-yaml-parsing.js +24 -0
- package/.aios-core/infrastructure/scripts/_archived/verify-yaml-fix.js +51 -0
- package/.aios-core/infrastructure/scripts/aios-validator.js +294 -0
- package/.aios-core/infrastructure/scripts/approval-workflow.js +643 -0
- package/.aios-core/infrastructure/scripts/atomic-layer-classifier.js +308 -0
- package/.aios-core/infrastructure/scripts/backup-manager.js +607 -0
- package/.aios-core/infrastructure/scripts/batch-creator.js +608 -0
- package/.aios-core/infrastructure/scripts/branch-manager.js +391 -0
- package/.aios-core/infrastructure/scripts/capability-analyzer.js +535 -0
- package/.aios-core/infrastructure/scripts/clickup-helpers.js +226 -0
- package/.aios-core/infrastructure/scripts/code-quality-improver.js +1312 -0
- package/.aios-core/infrastructure/scripts/commit-message-generator.js +850 -0
- package/.aios-core/infrastructure/scripts/component-generator.js +738 -0
- package/.aios-core/infrastructure/scripts/component-metadata.js +627 -0
- package/.aios-core/infrastructure/scripts/component-search.js +277 -0
- package/.aios-core/infrastructure/scripts/config-cache.js +322 -0
- package/.aios-core/infrastructure/scripts/config-loader.js +349 -0
- package/.aios-core/infrastructure/scripts/conflict-resolver.js +675 -0
- package/.aios-core/infrastructure/scripts/coverage-analyzer.js +882 -0
- package/.aios-core/infrastructure/scripts/dependency-analyzer.js +638 -0
- package/.aios-core/infrastructure/scripts/dependency-impact-analyzer.js +703 -0
- package/.aios-core/infrastructure/scripts/diff-generator.js +129 -0
- package/.aios-core/infrastructure/scripts/documentation-integrity/brownfield-analyzer.js +501 -0
- package/.aios-core/infrastructure/scripts/documentation-integrity/config-generator.js +329 -0
- package/.aios-core/infrastructure/scripts/documentation-integrity/deployment-config-loader.js +282 -0
- package/.aios-core/infrastructure/scripts/documentation-integrity/doc-generator.js +331 -0
- package/.aios-core/infrastructure/scripts/documentation-integrity/gitignore-generator.js +313 -0
- package/.aios-core/infrastructure/scripts/documentation-integrity/index.js +74 -0
- package/.aios-core/infrastructure/scripts/documentation-integrity/mode-detector.js +358 -0
- package/.aios-core/infrastructure/scripts/documentation-synchronizer.js +1432 -0
- package/.aios-core/infrastructure/scripts/framework-analyzer.js +746 -0
- package/.aios-core/infrastructure/scripts/git-config-detector.js +293 -0
- package/.aios-core/infrastructure/scripts/git-wrapper.js +443 -0
- package/.aios-core/infrastructure/scripts/improvement-engine.js +758 -0
- package/.aios-core/infrastructure/scripts/improvement-validator.js +710 -0
- package/.aios-core/infrastructure/scripts/llm-routing/install-llm-routing.js +267 -0
- package/.aios-core/infrastructure/scripts/llm-routing/templates/claude-free.cmd +80 -0
- package/.aios-core/infrastructure/scripts/llm-routing/templates/claude-free.sh +62 -0
- package/.aios-core/infrastructure/scripts/llm-routing/templates/claude-max.cmd +26 -0
- package/.aios-core/infrastructure/scripts/llm-routing/templates/claude-max.sh +18 -0
- package/.aios-core/infrastructure/scripts/modification-risk-assessment.js +970 -0
- package/.aios-core/infrastructure/scripts/modification-validator.js +555 -0
- package/.aios-core/infrastructure/scripts/output-formatter.js +297 -0
- package/.aios-core/infrastructure/scripts/performance-analyzer.js +758 -0
- package/.aios-core/infrastructure/scripts/performance-and-error-resolver.js +258 -0
- package/.aios-core/infrastructure/scripts/performance-optimizer.js +1902 -0
- package/.aios-core/infrastructure/scripts/performance-tracker.js +452 -0
- package/.aios-core/infrastructure/scripts/pm-adapter-factory.js +181 -0
- package/.aios-core/infrastructure/scripts/pm-adapter.js +134 -0
- package/.aios-core/infrastructure/scripts/project-status-loader.js +445 -0
- package/.aios-core/infrastructure/scripts/refactoring-suggester.js +1139 -0
- package/.aios-core/infrastructure/scripts/repository-detector.js +64 -0
- package/.aios-core/infrastructure/scripts/sandbox-tester.js +618 -0
- package/.aios-core/infrastructure/scripts/security-checker.js +359 -0
- package/.aios-core/infrastructure/scripts/source-tree-guardian/index.js +375 -0
- package/.aios-core/infrastructure/scripts/source-tree-guardian/manifest-generator.js +410 -0
- package/.aios-core/infrastructure/scripts/source-tree-guardian/rules/naming-rules.yaml +285 -0
- package/.aios-core/infrastructure/scripts/source-tree-guardian/rules/placement-rules.yaml +262 -0
- package/.aios-core/infrastructure/scripts/source-tree-guardian/validator.js +468 -0
- package/.aios-core/infrastructure/scripts/spot-check-validator.js +149 -0
- package/.aios-core/infrastructure/scripts/status-mapper.js +115 -0
- package/.aios-core/infrastructure/scripts/template-engine.js +240 -0
- package/.aios-core/infrastructure/scripts/template-validator.js +279 -0
- package/.aios-core/infrastructure/scripts/test-generator.js +844 -0
- package/.aios-core/infrastructure/scripts/test-quality-assessment.js +1081 -0
- package/.aios-core/infrastructure/scripts/test-utilities-fast.js +126 -0
- package/.aios-core/infrastructure/scripts/test-utilities.js +200 -0
- package/.aios-core/infrastructure/scripts/tool-resolver.js +360 -0
- package/.aios-core/infrastructure/scripts/transaction-manager.js +590 -0
- package/.aios-core/infrastructure/scripts/usage-analytics.js +634 -0
- package/.aios-core/infrastructure/scripts/validate-output-pattern.js +213 -0
- package/.aios-core/infrastructure/scripts/visual-impact-generator.js +1056 -0
- package/.aios-core/infrastructure/scripts/yaml-validator.js +397 -0
- package/.aios-core/infrastructure/templates/coderabbit.yaml.template +279 -0
- package/.aios-core/infrastructure/templates/core-config/core-config-brownfield.tmpl.yaml +182 -0
- package/.aios-core/infrastructure/templates/core-config/core-config-greenfield.tmpl.yaml +127 -0
- package/.aios-core/infrastructure/templates/github-workflows/README.md +109 -0
- package/.aios-core/infrastructure/templates/github-workflows/ci.yml.template +169 -0
- package/.aios-core/infrastructure/templates/github-workflows/pr-automation.yml.template +330 -0
- package/.aios-core/infrastructure/templates/github-workflows/release.yml.template +196 -0
- package/.aios-core/infrastructure/templates/gitignore/gitignore-aios-base.tmpl +63 -0
- package/.aios-core/infrastructure/templates/gitignore/gitignore-brownfield-merge.tmpl +18 -0
- package/.aios-core/infrastructure/templates/gitignore/gitignore-node.tmpl +85 -0
- package/.aios-core/infrastructure/templates/gitignore/gitignore-python.tmpl +145 -0
- package/.aios-core/infrastructure/templates/project-docs/coding-standards-tmpl.md +346 -0
- package/.aios-core/infrastructure/templates/project-docs/source-tree-tmpl.md +177 -0
- package/.aios-core/infrastructure/templates/project-docs/tech-stack-tmpl.md +267 -0
- package/.aios-core/infrastructure/tests/project-status-loader.test.js +394 -0
- package/.aios-core/infrastructure/tests/regression-suite-v2.md +621 -0
- package/.aios-core/infrastructure/tests/utilities-audit-results.json +501 -0
- package/.aios-core/infrastructure/tests/validate-module.js +97 -0
- package/.aios-core/infrastructure/tools/README.md +222 -0
- package/.aios-core/infrastructure/tools/cli/github-cli.yaml +200 -0
- package/.aios-core/infrastructure/tools/cli/llm-routing.yaml +126 -0
- package/.aios-core/infrastructure/tools/cli/railway-cli.yaml +260 -0
- package/.aios-core/infrastructure/tools/cli/supabase-cli.yaml +224 -0
- package/.aios-core/infrastructure/tools/local/ffmpeg.yaml +261 -0
- package/.aios-core/infrastructure/tools/mcp/21st-dev-magic.yaml +127 -0
- package/.aios-core/infrastructure/tools/mcp/browser.yaml +103 -0
- package/.aios-core/infrastructure/tools/mcp/clickup.yaml +534 -0
- package/.aios-core/infrastructure/tools/mcp/context7.yaml +78 -0
- package/.aios-core/infrastructure/tools/mcp/desktop-commander.yaml +180 -0
- package/.aios-core/infrastructure/tools/mcp/exa.yaml +103 -0
- package/.aios-core/infrastructure/tools/mcp/google-workspace.yaml +930 -0
- package/.aios-core/infrastructure/tools/mcp/n8n.yaml +551 -0
- package/.aios-core/infrastructure/tools/mcp/supabase.yaml +808 -0
- package/.aios-core/install-manifest.yaml +347 -0
- package/.aios-core/manifests/agents.csv +1 -0
- package/.aios-core/manifests/schema/manifest-schema.json +190 -0
- package/.aios-core/manifests/tasks.csv +121 -0
- package/.aios-core/manifests/workers.csv +204 -0
- package/.aios-core/package.json +103 -0
- package/.aios-core/product/README.md +56 -0
- package/.aios-core/product/checklists/architect-checklist.md +444 -0
- package/.aios-core/product/checklists/change-checklist.md +183 -0
- package/.aios-core/product/checklists/database-design-checklist.md +119 -0
- package/.aios-core/product/checklists/dba-predeploy-checklist.md +97 -0
- package/.aios-core/product/checklists/dba-rollback-checklist.md +99 -0
- package/.aios-core/product/checklists/pm-checklist.md +376 -0
- package/.aios-core/product/checklists/po-master-checklist.md +442 -0
- package/.aios-core/product/checklists/pre-push-checklist.md +108 -0
- package/.aios-core/product/checklists/release-checklist.md +122 -0
- package/.aios-core/product/checklists/story-dod-checklist.md +102 -0
- package/.aios-core/product/checklists/story-draft-checklist.md +216 -0
- package/.aios-core/product/data/brainstorming-techniques.md +37 -0
- package/.aios-core/product/data/elicitation-methods.md +135 -0
- package/.aios-core/product/data/mode-selection-best-practices.md +471 -0
- package/.aios-core/product/data/test-levels-framework.md +149 -0
- package/.aios-core/product/data/test-priorities-matrix.md +175 -0
- package/.aios-core/product/templates/1mcp-config.yaml +225 -0
- package/.aios-core/product/templates/activation-instructions-inline-greeting.yaml +63 -0
- package/.aios-core/product/templates/activation-instructions-template.md +258 -0
- package/.aios-core/product/templates/adr.hbs +125 -0
- package/.aios-core/product/templates/agent-template.yaml +121 -0
- package/.aios-core/product/templates/architecture-tmpl.yaml +651 -0
- package/.aios-core/product/templates/brainstorming-output-tmpl.yaml +156 -0
- package/.aios-core/product/templates/brownfield-architecture-tmpl.yaml +476 -0
- package/.aios-core/product/templates/brownfield-prd-tmpl.yaml +280 -0
- package/.aios-core/product/templates/changelog-template.md +134 -0
- package/.aios-core/product/templates/command-rationalization-matrix.md +152 -0
- package/.aios-core/product/templates/competitor-analysis-tmpl.yaml +293 -0
- package/.aios-core/product/templates/component-react-tmpl.tsx +98 -0
- package/.aios-core/product/templates/dbdr.hbs +241 -0
- package/.aios-core/product/templates/design-story-tmpl.yaml +587 -0
- package/.aios-core/product/templates/ds-artifact-analysis.md +70 -0
- package/.aios-core/product/templates/engine/elicitation.js +298 -0
- package/.aios-core/product/templates/engine/index.js +308 -0
- package/.aios-core/product/templates/engine/loader.js +231 -0
- package/.aios-core/product/templates/engine/renderer.js +343 -0
- package/.aios-core/product/templates/engine/schemas/adr.schema.json +102 -0
- package/.aios-core/product/templates/engine/schemas/dbdr.schema.json +205 -0
- package/.aios-core/product/templates/engine/schemas/epic.schema.json +175 -0
- package/.aios-core/product/templates/engine/schemas/pmdr.schema.json +175 -0
- package/.aios-core/product/templates/engine/schemas/prd-v2.schema.json +300 -0
- package/.aios-core/product/templates/engine/schemas/prd.schema.json +152 -0
- package/.aios-core/product/templates/engine/schemas/story.schema.json +222 -0
- package/.aios-core/product/templates/engine/schemas/task.schema.json +154 -0
- package/.aios-core/product/templates/engine/validator.js +294 -0
- package/.aios-core/product/templates/epic.hbs +212 -0
- package/.aios-core/product/templates/eslintrc-security.json +32 -0
- package/.aios-core/product/templates/front-end-architecture-tmpl.yaml +206 -0
- package/.aios-core/product/templates/front-end-spec-tmpl.yaml +349 -0
- package/.aios-core/product/templates/fullstack-architecture-tmpl.yaml +805 -0
- package/.aios-core/product/templates/github-actions-cd.yml +212 -0
- package/.aios-core/product/templates/github-actions-ci.yml +172 -0
- package/.aios-core/product/templates/github-pr-template.md +67 -0
- package/.aios-core/product/templates/gordon-mcp.yaml +140 -0
- package/.aios-core/product/templates/ide-rules/antigravity-rules.md +115 -0
- package/.aios-core/product/templates/ide-rules/claude-rules.md +221 -0
- package/.aios-core/product/templates/ide-rules/cline-rules.md +84 -0
- package/.aios-core/product/templates/ide-rules/copilot-rules.md +92 -0
- package/.aios-core/product/templates/ide-rules/cursor-rules.md +115 -0
- package/.aios-core/product/templates/ide-rules/gemini-rules.md +85 -0
- package/.aios-core/product/templates/ide-rules/roo-rules.md +86 -0
- package/.aios-core/product/templates/ide-rules/trae-rules.md +104 -0
- package/.aios-core/product/templates/ide-rules/windsurf-rules.md +80 -0
- package/.aios-core/product/templates/index-strategy-tmpl.yaml +53 -0
- package/.aios-core/product/templates/market-research-tmpl.yaml +252 -0
- package/.aios-core/product/templates/mcp-workflow.js +271 -0
- package/.aios-core/product/templates/migration-plan-tmpl.yaml +1022 -0
- package/.aios-core/product/templates/migration-strategy-tmpl.md +524 -0
- package/.aios-core/product/templates/personalized-agent-template.md +258 -0
- package/.aios-core/product/templates/personalized-checklist-template.md +340 -0
- package/.aios-core/product/templates/personalized-task-template-v2.md +905 -0
- package/.aios-core/product/templates/personalized-task-template.md +344 -0
- package/.aios-core/product/templates/personalized-template-file.yaml +322 -0
- package/.aios-core/product/templates/personalized-workflow-template.yaml +460 -0
- package/.aios-core/product/templates/pmdr.hbs +186 -0
- package/.aios-core/product/templates/prd-tmpl.yaml +202 -0
- package/.aios-core/product/templates/prd-v2.0.hbs +216 -0
- package/.aios-core/product/templates/prd.hbs +201 -0
- package/.aios-core/product/templates/project-brief-tmpl.yaml +221 -0
- package/.aios-core/product/templates/qa-gate-tmpl.yaml +240 -0
- package/.aios-core/product/templates/rls-policies-tmpl.yaml +1203 -0
- package/.aios-core/product/templates/schema-design-tmpl.yaml +428 -0
- package/.aios-core/product/templates/shock-report-tmpl.html +502 -0
- package/.aios-core/product/templates/state-persistence-tmpl.yaml +219 -0
- package/.aios-core/product/templates/story-tmpl.yaml +332 -0
- package/.aios-core/product/templates/story.hbs +263 -0
- package/.aios-core/product/templates/task-execution-report.md +495 -0
- package/.aios-core/product/templates/task-template.md +123 -0
- package/.aios-core/product/templates/task.hbs +170 -0
- package/.aios-core/product/templates/tmpl-comment-on-examples.sql +158 -0
- package/.aios-core/product/templates/tmpl-migration-script.sql +91 -0
- package/.aios-core/product/templates/tmpl-rls-granular-policies.sql +104 -0
- package/.aios-core/product/templates/tmpl-rls-kiss-policy.sql +10 -0
- package/.aios-core/product/templates/tmpl-rls-roles.sql +135 -0
- package/.aios-core/product/templates/tmpl-rls-simple.sql +77 -0
- package/.aios-core/product/templates/tmpl-rls-tenant.sql +152 -0
- package/.aios-core/product/templates/tmpl-rollback-script.sql +77 -0
- package/.aios-core/product/templates/tmpl-seed-data.sql +140 -0
- package/.aios-core/product/templates/tmpl-smoke-test.sql +16 -0
- package/.aios-core/product/templates/tmpl-staging-copy-merge.sql +139 -0
- package/.aios-core/product/templates/tmpl-stored-proc.sql +140 -0
- package/.aios-core/product/templates/tmpl-trigger.sql +152 -0
- package/.aios-core/product/templates/tmpl-view-materialized.sql +133 -0
- package/.aios-core/product/templates/tmpl-view.sql +177 -0
- package/.aios-core/product/templates/token-exports-css-tmpl.css +240 -0
- package/.aios-core/product/templates/token-exports-tailwind-tmpl.js +395 -0
- package/.aios-core/product/templates/tokens-schema-tmpl.yaml +305 -0
- package/.aios-core/product/templates/workflow-template.yaml +134 -0
- package/.aios-core/quality/metrics-collector.js +572 -0
- package/.aios-core/quality/metrics-hook.js +260 -0
- package/.aios-core/quality/schemas/quality-metrics.schema.json +233 -0
- package/.aios-core/quality/seed-metrics.js +336 -0
- package/.aios-core/scripts/README.md +354 -0
- package/.aios-core/scripts/aios-doc-template.md +325 -0
- package/.aios-core/scripts/batch-migrate-phase1.ps1 +36 -0
- package/.aios-core/scripts/batch-migrate-phase2.ps1 +88 -0
- package/.aios-core/scripts/batch-migrate-phase3.ps1 +45 -0
- package/.aios-core/scripts/command-execution-hook.js +201 -0
- package/.aios-core/scripts/context-detector.js +226 -0
- package/.aios-core/scripts/elicitation-engine.js +385 -0
- package/.aios-core/scripts/elicitation-session-manager.js +300 -0
- package/.aios-core/scripts/migrate-framework-docs.sh +300 -0
- package/.aios-core/scripts/session-context-loader.js +286 -0
- package/.aios-core/scripts/test-template-system.js +941 -0
- package/.aios-core/scripts/validate-phase1.ps1 +35 -0
- package/.aios-core/scripts/workflow-management.md +69 -0
- package/.aios-core/tasks/find-component.md.legacy +391 -0
- package/.aios-core/tasks/generate-commit-message.md.legacy +426 -0
- package/.aios-core/tasks/generate-migration.md.legacy +382 -0
- package/.aios-core/tasks/rollback-modification.md.legacy +307 -0
- package/.aios-core/tasks/update-tests.md.legacy +283 -0
- package/.aios-core/user-guide.md +1413 -0
- package/.aios-core/working-in-the-brownfield.md +361 -0
- package/.claude/CLAUDE.md +221 -0
- package/LICENSE +48 -0
- package/README.md +703 -0
- package/bin/aios-init-old.js +532 -0
- package/bin/aios-init-v4.js +390 -0
- package/bin/aios-init.backup-v1.1.4.js +352 -0
- package/bin/aios-init.js +736 -0
- package/bin/aios-minimal.js +26 -0
- package/bin/aios.js +279 -0
- package/bin/migrate-pm-config.js +219 -0
- package/bin/modules/env-config.js +436 -0
- package/bin/modules/mcp-installer.js +383 -0
- package/bin/utils/install-errors.js +339 -0
- package/bin/utils/install-transaction.js +445 -0
- package/index.d.ts +19 -0
- package/index.esm.js +21 -0
- package/index.js +94 -0
- package/package.json +161 -0
- package/packages/installer/package.json +39 -0
- package/packages/installer/src/config/configure-environment.js +312 -0
- package/packages/installer/src/config/templates/core-config-template.js +183 -0
- package/packages/installer/src/config/templates/env-template.js +127 -0
- package/packages/installer/src/config/validation/config-validator.js +243 -0
- package/packages/installer/src/detection/detect-project-type.js +81 -0
- package/packages/installer/src/wizard/wizard.js +244 -0
- package/packages/installer/tests/integration/environment-configuration.test.js +328 -0
- package/packages/installer/tests/integration/wizard-detection.test.js +349 -0
- package/packages/installer/tests/unit/config-validator.test.js +315 -0
- package/packages/installer/tests/unit/detection/detect-project-type.test.js +401 -0
- package/packages/installer/tests/unit/env-template.test.js +185 -0
- package/src/config/ide-configs.js +189 -0
- package/src/installer/aios-core-installer.js +319 -0
- package/src/installer/dependency-installer.js +335 -0
- package/src/utils/aios-colors.js +234 -0
- package/src/wizard/feedback.js +218 -0
- package/src/wizard/ide-config-generator.js +488 -0
- package/src/wizard/ide-selector.js +84 -0
- package/src/wizard/index.js +589 -0
- package/src/wizard/questions.js +249 -0
- package/src/wizard/validation/index.js +120 -0
- package/src/wizard/validation/report-generator.js +269 -0
- package/src/wizard/validation/troubleshooting-system.js +346 -0
- package/src/wizard/validation/validators/config-validator.js +362 -0
- package/src/wizard/validation/validators/dependency-validator.js +333 -0
- package/src/wizard/validation/validators/file-structure-validator.js +181 -0
- package/src/wizard/validation/validators/mcp-health-checker.js +310 -0
- package/src/wizard/validators.js +274 -0
- package/templates/squad/LICENSE +21 -0
- package/templates/squad/README.md +37 -0
- package/templates/squad/agents/example-agent.yaml +36 -0
- package/templates/squad/package.json +19 -0
- package/templates/squad/squad.yaml +25 -0
- package/templates/squad/tasks/example-task.yaml +46 -0
- package/templates/squad/templates/example-template.md +24 -0
- package/templates/squad/tests/example-agent.test.js +53 -0
- package/templates/squad/workflows/example-workflow.yaml +54 -0
- package/tools/package-builder.js +35 -0
|
@@ -0,0 +1,882 @@
|
|
|
1
|
+
const fs = require('fs').promises;
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Coverage analyzer for AIOS-FULLSTACK test generation
|
|
7
|
+
* Analyzes existing test coverage and identifies gaps
|
|
8
|
+
*/
|
|
9
|
+
class CoverageAnalyzer {
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
this.rootPath = options.rootPath || process.cwd();
|
|
12
|
+
this.testsDir = path.join(this.rootPath, 'tests');
|
|
13
|
+
this.coverageReportsDir = path.join(this.rootPath, 'coverage');
|
|
14
|
+
this.coverageCache = new Map();
|
|
15
|
+
this.analysisHistory = [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Initialize coverage analyzer
|
|
20
|
+
*/
|
|
21
|
+
async initialize() {
|
|
22
|
+
try {
|
|
23
|
+
// Create coverage reports directory
|
|
24
|
+
await fs.mkdir(this.coverageReportsDir, { recursive: true });
|
|
25
|
+
|
|
26
|
+
// Load existing coverage data if available
|
|
27
|
+
await this.loadExistingCoverageData();
|
|
28
|
+
|
|
29
|
+
console.log(chalk.green('✅ Coverage analyzer initialized'));
|
|
30
|
+
return true;
|
|
31
|
+
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error(chalk.red(`Failed to initialize coverage analyzer: ${error.message}`));
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Analyze test coverage for components
|
|
40
|
+
*/
|
|
41
|
+
async analyzeCoverage(components, options = {}) {
|
|
42
|
+
const analysisId = `coverage-analysis-${Date.now()}`;
|
|
43
|
+
|
|
44
|
+
console.log(chalk.blue('📊 Analyzing test coverage...'));
|
|
45
|
+
|
|
46
|
+
const analysis = {
|
|
47
|
+
analysis_id: analysisId,
|
|
48
|
+
timestamp: new Date().toISOString(),
|
|
49
|
+
components: components.length,
|
|
50
|
+
overall_coverage: {
|
|
51
|
+
lines_covered: 0,
|
|
52
|
+
lines_total: 0,
|
|
53
|
+
percentage: 0,
|
|
54
|
+
functions_covered: 0,
|
|
55
|
+
functions_total: 0,
|
|
56
|
+
function_percentage: 0,
|
|
57
|
+
branches_covered: 0,
|
|
58
|
+
branches_total: 0,
|
|
59
|
+
branch_percentage: 0,
|
|
60
|
+
},
|
|
61
|
+
component_coverage: {},
|
|
62
|
+
coverage_gaps: [],
|
|
63
|
+
recommendations: [],
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
// Analyze coverage for each component
|
|
68
|
+
for (const component of components) {
|
|
69
|
+
const componentCoverage = await this.analyzeComponentCoverage(component, options);
|
|
70
|
+
analysis.component_coverage[component.id] = componentCoverage;
|
|
71
|
+
|
|
72
|
+
// Aggregate overall coverage
|
|
73
|
+
this.aggregateCoverage(analysis.overall_coverage, componentCoverage);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Calculate final percentages
|
|
77
|
+
this.calculateCoveragePercentages(analysis.overall_coverage);
|
|
78
|
+
|
|
79
|
+
// Identify coverage gaps
|
|
80
|
+
analysis.coverage_gaps = await this.identifyCoverageGaps(analysis.component_coverage);
|
|
81
|
+
|
|
82
|
+
// Generate recommendations
|
|
83
|
+
analysis.recommendations = this.generateCoverageRecommendations(analysis);
|
|
84
|
+
|
|
85
|
+
// Cache analysis results
|
|
86
|
+
this.coverageCache.set(analysisId, analysis);
|
|
87
|
+
this.analysisHistory.push({
|
|
88
|
+
analysis_id: analysisId,
|
|
89
|
+
timestamp: analysis.timestamp,
|
|
90
|
+
overall_percentage: analysis.overall_coverage.percentage,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Save analysis report
|
|
94
|
+
await this.saveCoverageAnalysis(analysis);
|
|
95
|
+
|
|
96
|
+
console.log(chalk.green('✅ Coverage analysis completed'));
|
|
97
|
+
console.log(chalk.gray(` Overall coverage: ${analysis.overall_coverage.percentage.toFixed(1)}%`));
|
|
98
|
+
console.log(chalk.gray(` Components analyzed: ${components.length}`));
|
|
99
|
+
console.log(chalk.gray(` Coverage gaps identified: ${analysis.coverage_gaps.length}`));
|
|
100
|
+
|
|
101
|
+
return analysis;
|
|
102
|
+
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error(chalk.red(`Coverage analysis failed: ${error.message}`));
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Analyze coverage for a single component
|
|
111
|
+
*/
|
|
112
|
+
async analyzeComponentCoverage(component, options = {}) {
|
|
113
|
+
const coverage = {
|
|
114
|
+
component_id: component.id,
|
|
115
|
+
component_type: component.type,
|
|
116
|
+
has_tests: false,
|
|
117
|
+
test_files: [],
|
|
118
|
+
lines: { covered: 0, total: 0, percentage: 0 },
|
|
119
|
+
functions: { covered: 0, total: 0, percentage: 0 },
|
|
120
|
+
branches: { covered: 0, total: 0, percentage: 0 },
|
|
121
|
+
coverage_quality: 'unknown',
|
|
122
|
+
missing_tests: [],
|
|
123
|
+
untested_functions: [],
|
|
124
|
+
uncovered_branches: [],
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
// Find existing test files for component
|
|
129
|
+
coverage.test_files = await this.findTestFiles(component);
|
|
130
|
+
coverage.has_tests = coverage.test_files.length > 0;
|
|
131
|
+
|
|
132
|
+
if (coverage.has_tests) {
|
|
133
|
+
// Analyze existing coverage data
|
|
134
|
+
const existingCoverage = await this.getExistingCoverage(component);
|
|
135
|
+
if (existingCoverage) {
|
|
136
|
+
Object.assign(coverage, existingCoverage);
|
|
137
|
+
} else {
|
|
138
|
+
// Estimate coverage based on test file analysis
|
|
139
|
+
const estimatedCoverage = await this.estimateCoverage(component, coverage.test_files);
|
|
140
|
+
Object.assign(coverage, estimatedCoverage);
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
// No tests exist, analyze component to estimate required coverage
|
|
144
|
+
const componentAnalysis = await this.analyzeComponentForCoverage(component);
|
|
145
|
+
coverage.lines.total = componentAnalysis.lines || 0;
|
|
146
|
+
coverage.functions.total = componentAnalysis.functions || 0;
|
|
147
|
+
coverage.branches.total = componentAnalysis.branches || 0;
|
|
148
|
+
coverage.missing_tests = componentAnalysis.testable_elements || [];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Determine coverage quality
|
|
152
|
+
coverage.coverage_quality = this.determineCoverageQuality(coverage);
|
|
153
|
+
|
|
154
|
+
// Identify specific gaps
|
|
155
|
+
if (component.filePath) {
|
|
156
|
+
coverage.untested_functions = await this.identifyUntestedFunctions(component);
|
|
157
|
+
coverage.uncovered_branches = await this.identifyUncoveredBranches(component);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.warn(chalk.yellow(`Failed to analyze coverage for ${component.id}: ${error.message}`));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return coverage;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Find test files for a component
|
|
169
|
+
*/
|
|
170
|
+
async findTestFiles(component) {
|
|
171
|
+
const testFiles = [];
|
|
172
|
+
const possibleTestPaths = [
|
|
173
|
+
path.join(this.testsDir, 'unit', component.type, `${component.name}.test.js`),
|
|
174
|
+
path.join(this.testsDir, 'unit', component.type, `${component.name}.spec.js`),
|
|
175
|
+
path.join(this.testsDir, 'integration', component.type, `${component.name}.integration.test.js`),
|
|
176
|
+
path.join(this.testsDir, 'e2e', component.type, `${component.name}.e2e.test.js`),
|
|
177
|
+
path.join(this.rootPath, 'test', `${component.name}.test.js`),
|
|
178
|
+
path.join(this.rootPath, '__tests__', `${component.name}.test.js`),
|
|
179
|
+
];
|
|
180
|
+
|
|
181
|
+
for (const testPath of possibleTestPaths) {
|
|
182
|
+
try {
|
|
183
|
+
const stats = await fs.stat(testPath);
|
|
184
|
+
if (stats.isFile()) {
|
|
185
|
+
const testType = this.determineTestType(testPath);
|
|
186
|
+
const testAnalysis = await this.analyzeTestFile(testPath);
|
|
187
|
+
|
|
188
|
+
testFiles.push({
|
|
189
|
+
file_path: testPath,
|
|
190
|
+
test_type: testType,
|
|
191
|
+
test_count: testAnalysis.test_count,
|
|
192
|
+
assertion_count: testAnalysis.assertion_count,
|
|
193
|
+
mock_count: testAnalysis.mock_count,
|
|
194
|
+
async_tests: testAnalysis.async_tests,
|
|
195
|
+
last_modified: stats.mtime.toISOString(),
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
} catch (error) {
|
|
199
|
+
// File doesn't exist, continue
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return testFiles;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Get existing coverage data from coverage reports
|
|
208
|
+
*/
|
|
209
|
+
async getExistingCoverage(component) {
|
|
210
|
+
try {
|
|
211
|
+
// Try to find coverage data from different coverage tools
|
|
212
|
+
const coverageFiles = [
|
|
213
|
+
path.join(this.rootPath, 'coverage', 'lcov-report', 'index.html'),
|
|
214
|
+
path.join(this.rootPath, 'coverage', 'coverage-final.json'),
|
|
215
|
+
path.join(this.rootPath, 'coverage', 'clover.xml'),
|
|
216
|
+
path.join(this.rootPath, '.nyc_output', 'coverage.json'),
|
|
217
|
+
];
|
|
218
|
+
|
|
219
|
+
for (const coverageFile of coverageFiles) {
|
|
220
|
+
try {
|
|
221
|
+
const exists = await fs.access(coverageFile).then(() => true).catch(() => false);
|
|
222
|
+
if (exists) {
|
|
223
|
+
const coverageData = await this.parseCoverageFile(coverageFile, component);
|
|
224
|
+
if (coverageData) {
|
|
225
|
+
return coverageData;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
} catch (error) {
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return null;
|
|
234
|
+
|
|
235
|
+
} catch (error) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Estimate coverage based on test file analysis
|
|
242
|
+
*/
|
|
243
|
+
async estimateCoverage(component, testFiles) {
|
|
244
|
+
const coverage = {
|
|
245
|
+
lines: { covered: 0, total: 0, percentage: 0 },
|
|
246
|
+
functions: { covered: 0, total: 0, percentage: 0 },
|
|
247
|
+
branches: { covered: 0, total: 0, percentage: 0 },
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
try {
|
|
251
|
+
// Analyze component source to get totals
|
|
252
|
+
const componentAnalysis = await this.analyzeComponentForCoverage(component);
|
|
253
|
+
coverage.lines.total = componentAnalysis.lines || 0;
|
|
254
|
+
coverage.functions.total = componentAnalysis.functions || 0;
|
|
255
|
+
coverage.branches.total = componentAnalysis.branches || 0;
|
|
256
|
+
|
|
257
|
+
// Estimate coverage based on test comprehensiveness
|
|
258
|
+
let estimatedCoveragePercentage = 0;
|
|
259
|
+
let totalTestWeight = 0;
|
|
260
|
+
|
|
261
|
+
for (const testFile of testFiles) {
|
|
262
|
+
const testWeight = this.calculateTestWeight(testFile);
|
|
263
|
+
totalTestWeight += testWeight;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Convert test weight to coverage estimate
|
|
267
|
+
if (totalTestWeight > 0) {
|
|
268
|
+
estimatedCoveragePercentage = Math.min(totalTestWeight * 10, 95); // Cap at 95%
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Apply coverage percentages
|
|
272
|
+
coverage.lines.covered = Math.round(coverage.lines.total * (estimatedCoveragePercentage / 100));
|
|
273
|
+
coverage.functions.covered = Math.round(coverage.functions.total * (estimatedCoveragePercentage / 100));
|
|
274
|
+
coverage.branches.covered = Math.round(coverage.branches.total * (estimatedCoveragePercentage / 100));
|
|
275
|
+
|
|
276
|
+
this.calculateCoveragePercentages(coverage);
|
|
277
|
+
|
|
278
|
+
} catch (error) {
|
|
279
|
+
console.warn(chalk.yellow(`Failed to estimate coverage for ${component.id}: ${error.message}`));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return coverage;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Analyze component to determine coverage requirements
|
|
287
|
+
*/
|
|
288
|
+
async analyzeComponentForCoverage(component) {
|
|
289
|
+
const analysis = {
|
|
290
|
+
lines: 0,
|
|
291
|
+
functions: 0,
|
|
292
|
+
branches: 0,
|
|
293
|
+
testable_elements: [],
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
try {
|
|
297
|
+
if (!component.filePath) {
|
|
298
|
+
return analysis;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const content = await fs.readFile(component.filePath, 'utf-8');
|
|
302
|
+
|
|
303
|
+
if (component.type === 'util') {
|
|
304
|
+
// JavaScript utility analysis
|
|
305
|
+
const lines = content.split('\n').filter(line =>
|
|
306
|
+
line.trim() &&
|
|
307
|
+
!line.trim().startsWith('//') &&
|
|
308
|
+
!line.trim().startsWith('/*'),
|
|
309
|
+
);
|
|
310
|
+
analysis.lines = lines.length;
|
|
311
|
+
|
|
312
|
+
const functions = content.match(/(?:function\s+\w+|[\w\$]+\s*[=:]\s*(?:async\s+)?(?:function|\([^)]*\)\s*=>))/g) || [];
|
|
313
|
+
analysis.functions = functions.length;
|
|
314
|
+
|
|
315
|
+
const branches = content.match(/\b(?:if|else|switch|case|for|while|try|catch)\b/g) || [];
|
|
316
|
+
analysis.branches = branches.length;
|
|
317
|
+
|
|
318
|
+
// Identify testable elements
|
|
319
|
+
analysis.testable_elements = [
|
|
320
|
+
...functions.map(f => ({ type: 'function', name: this.extractFunctionName(f) })),
|
|
321
|
+
...branches.map((b, i) => ({ type: 'branch', name: `branch_${i + 1}` })),
|
|
322
|
+
];
|
|
323
|
+
|
|
324
|
+
} else if (component.type === 'agent' || component.type === 'task') {
|
|
325
|
+
// Markdown with embedded JavaScript
|
|
326
|
+
const jsBlocks = content.match(/```javascript([\s\S]*?)```/g) || [];
|
|
327
|
+
let totalLines = 0;
|
|
328
|
+
let totalFunctions = 0;
|
|
329
|
+
let totalBranches = 0;
|
|
330
|
+
|
|
331
|
+
for (const block of jsBlocks) {
|
|
332
|
+
const jsCode = block.replace(/```javascript|```/g, '');
|
|
333
|
+
const lines = jsCode.split('\n').filter(line =>
|
|
334
|
+
line.trim() &&
|
|
335
|
+
!line.trim().startsWith('//'),
|
|
336
|
+
);
|
|
337
|
+
totalLines += lines.length;
|
|
338
|
+
|
|
339
|
+
const functions = jsCode.match(/(?:function\s+\w+|[\w\$]+\s*[=:]\s*(?:async\s+)?(?:function|\([^)]*\)\s*=>))/g) || [];
|
|
340
|
+
totalFunctions += functions.length;
|
|
341
|
+
|
|
342
|
+
const branches = jsCode.match(/\b(?:if|else|switch|case|for|while|try|catch)\b/g) || [];
|
|
343
|
+
totalBranches += branches.length;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
analysis.lines = totalLines;
|
|
347
|
+
analysis.functions = totalFunctions;
|
|
348
|
+
analysis.branches = totalBranches;
|
|
349
|
+
|
|
350
|
+
// For agents/tasks, also consider configuration testing
|
|
351
|
+
analysis.testable_elements.push(
|
|
352
|
+
{ type: 'configuration', name: 'config_validation' },
|
|
353
|
+
{ type: 'execution', name: 'execute_method' },
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
} else if (component.type === 'workflow') {
|
|
357
|
+
// YAML workflow analysis
|
|
358
|
+
const steps = content.match(/^\s*-\s+name:/gm) || [];
|
|
359
|
+
analysis.lines = content.split('\n').length;
|
|
360
|
+
analysis.functions = steps.length; // Each step is like a function
|
|
361
|
+
analysis.branches = (content.match(/\bif\b/g) || []).length; // Conditional steps
|
|
362
|
+
|
|
363
|
+
analysis.testable_elements = steps.map((step, i) => ({
|
|
364
|
+
type: 'workflow_step',
|
|
365
|
+
name: `step_${i + 1}`,
|
|
366
|
+
}));
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
} catch (error) {
|
|
370
|
+
console.warn(chalk.yellow(`Failed to analyze component for coverage: ${error.message}`));
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return analysis;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Analyze test file to understand its comprehensiveness
|
|
378
|
+
*/
|
|
379
|
+
async analyzeTestFile(testFilePath) {
|
|
380
|
+
const analysis = {
|
|
381
|
+
test_count: 0,
|
|
382
|
+
assertion_count: 0,
|
|
383
|
+
mock_count: 0,
|
|
384
|
+
async_tests: 0,
|
|
385
|
+
test_types: [],
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
try {
|
|
389
|
+
const content = await fs.readFile(testFilePath, 'utf-8');
|
|
390
|
+
|
|
391
|
+
// Count test cases
|
|
392
|
+
const testCases = content.match(/\b(?:it|test|describe)\s*\(/g) || [];
|
|
393
|
+
analysis.test_count = testCases.length;
|
|
394
|
+
|
|
395
|
+
// Count assertions
|
|
396
|
+
const assertions = content.match(/\bexpect\s*\(/g) || [];
|
|
397
|
+
analysis.assertion_count = assertions.length;
|
|
398
|
+
|
|
399
|
+
// Count mocks
|
|
400
|
+
const mocks = content.match(/\b(?:mock|spy|stub|fake)\b/gi) || [];
|
|
401
|
+
analysis.mock_count = mocks.length;
|
|
402
|
+
|
|
403
|
+
// Count async tests
|
|
404
|
+
const asyncTests = content.match(/\basync\s*\([^)]*\)\s*=>/g) || [];
|
|
405
|
+
analysis.async_tests = asyncTests.length;
|
|
406
|
+
|
|
407
|
+
// Identify test types
|
|
408
|
+
if (content.includes('integration') || testFilePath.includes('integration')) {
|
|
409
|
+
analysis.test_types.push('integration');
|
|
410
|
+
}
|
|
411
|
+
if (content.includes('e2e') || testFilePath.includes('e2e')) {
|
|
412
|
+
analysis.test_types.push('e2e');
|
|
413
|
+
}
|
|
414
|
+
if (!analysis.test_types.length) {
|
|
415
|
+
analysis.test_types.push('unit');
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
} catch (error) {
|
|
419
|
+
console.warn(chalk.yellow(`Failed to analyze test file ${testFilePath}: ${error.message}`));
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return analysis;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Calculate test weight based on comprehensiveness
|
|
427
|
+
*/
|
|
428
|
+
calculateTestWeight(testFile) {
|
|
429
|
+
let weight = 0;
|
|
430
|
+
|
|
431
|
+
// Base weight from test count
|
|
432
|
+
weight += Math.min(testFile.test_count * 0.5, 5);
|
|
433
|
+
|
|
434
|
+
// Weight from assertions
|
|
435
|
+
weight += Math.min(testFile.assertion_count * 0.2, 3);
|
|
436
|
+
|
|
437
|
+
// Weight from mocks (indicates interaction testing)
|
|
438
|
+
weight += Math.min(testFile.mock_count * 0.3, 2);
|
|
439
|
+
|
|
440
|
+
// Weight from async tests
|
|
441
|
+
weight += Math.min(testFile.async_tests * 0.4, 2);
|
|
442
|
+
|
|
443
|
+
// Weight from test types
|
|
444
|
+
if (testFile.test_type === 'integration') weight += 1;
|
|
445
|
+
if (testFile.test_type === 'e2e') weight += 1.5;
|
|
446
|
+
|
|
447
|
+
return Math.min(weight, 10); // Cap at 10
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Determine test type from file path
|
|
452
|
+
*/
|
|
453
|
+
determineTestType(testPath) {
|
|
454
|
+
if (testPath.includes('integration')) return 'integration';
|
|
455
|
+
if (testPath.includes('e2e')) return 'e2e';
|
|
456
|
+
return 'unit';
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Parse coverage file to extract coverage data
|
|
461
|
+
*/
|
|
462
|
+
async parseCoverageFile(coverageFile, component) {
|
|
463
|
+
try {
|
|
464
|
+
const ext = path.extname(coverageFile);
|
|
465
|
+
|
|
466
|
+
if (ext === '.json') {
|
|
467
|
+
const data = JSON.parse(await fs.readFile(coverageFile, 'utf-8'));
|
|
468
|
+
return this.extractCoverageFromJson(data, component);
|
|
469
|
+
} else if (ext === '.xml') {
|
|
470
|
+
const data = await fs.readFile(coverageFile, 'utf-8');
|
|
471
|
+
return this.extractCoverageFromXml(data, component);
|
|
472
|
+
} else if (ext === '.html') {
|
|
473
|
+
const data = await fs.readFile(coverageFile, 'utf-8');
|
|
474
|
+
return this.extractCoverageFromHtml(data, component);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return null;
|
|
478
|
+
|
|
479
|
+
} catch (error) {
|
|
480
|
+
return null;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Extract coverage from JSON format (Istanbul/NYC)
|
|
486
|
+
*/
|
|
487
|
+
extractCoverageFromJson(data, component) {
|
|
488
|
+
// Find coverage data for this component's files
|
|
489
|
+
const componentFile = component.filePath;
|
|
490
|
+
if (!componentFile || !data[componentFile]) {
|
|
491
|
+
return null;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const fileCoverage = data[componentFile];
|
|
495
|
+
|
|
496
|
+
return {
|
|
497
|
+
lines: {
|
|
498
|
+
covered: Object.values(fileCoverage.s || {}).filter(count => count > 0).length,
|
|
499
|
+
total: Object.keys(fileCoverage.s || {}).length,
|
|
500
|
+
percentage: 0,
|
|
501
|
+
},
|
|
502
|
+
functions: {
|
|
503
|
+
covered: Object.values(fileCoverage.f || {}).filter(count => count > 0).length,
|
|
504
|
+
total: Object.keys(fileCoverage.f || {}).length,
|
|
505
|
+
percentage: 0,
|
|
506
|
+
},
|
|
507
|
+
branches: {
|
|
508
|
+
covered: Object.values(fileCoverage.b || {}).flat().filter(count => count > 0).length,
|
|
509
|
+
total: Object.values(fileCoverage.b || {}).flat().length,
|
|
510
|
+
percentage: 0,
|
|
511
|
+
},
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Extract coverage from XML format (Clover)
|
|
517
|
+
*/
|
|
518
|
+
extractCoverageFromXml(data, component) {
|
|
519
|
+
// Basic XML parsing for Clover format
|
|
520
|
+
// This is a simplified implementation
|
|
521
|
+
return null;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Extract coverage from HTML format (LCOV)
|
|
526
|
+
*/
|
|
527
|
+
extractCoverageFromHtml(data, component) {
|
|
528
|
+
// Basic HTML parsing for LCOV reports
|
|
529
|
+
// This is a simplified implementation
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Aggregate coverage data
|
|
535
|
+
*/
|
|
536
|
+
aggregateCoverage(overall, component) {
|
|
537
|
+
overall.lines_covered += component.lines.covered || 0;
|
|
538
|
+
overall.lines_total += component.lines.total || 0;
|
|
539
|
+
overall.functions_covered += component.functions.covered || 0;
|
|
540
|
+
overall.functions_total += component.functions.total || 0;
|
|
541
|
+
overall.branches_covered += component.branches.covered || 0;
|
|
542
|
+
overall.branches_total += component.branches.total || 0;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Calculate coverage percentages
|
|
547
|
+
*/
|
|
548
|
+
calculateCoveragePercentages(coverage) {
|
|
549
|
+
if (coverage.lines_total > 0) {
|
|
550
|
+
coverage.percentage = (coverage.lines_covered / coverage.lines_total) * 100;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (coverage.functions_total > 0) {
|
|
554
|
+
coverage.function_percentage = (coverage.functions_covered / coverage.functions_total) * 100;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
if (coverage.branches_total > 0) {
|
|
558
|
+
coverage.branch_percentage = (coverage.branches_covered / coverage.branches_total) * 100;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// For individual component coverage objects
|
|
562
|
+
if (coverage.lines && coverage.lines.total > 0) {
|
|
563
|
+
coverage.lines.percentage = (coverage.lines.covered / coverage.lines.total) * 100;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
if (coverage.functions && coverage.functions.total > 0) {
|
|
567
|
+
coverage.functions.percentage = (coverage.functions.covered / coverage.functions.total) * 100;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
if (coverage.branches && coverage.branches.total > 0) {
|
|
571
|
+
coverage.branches.percentage = (coverage.branches.covered / coverage.branches.total) * 100;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Identify coverage gaps
|
|
577
|
+
*/
|
|
578
|
+
async identifyCoverageGaps(componentCoverage) {
|
|
579
|
+
const gaps = [];
|
|
580
|
+
|
|
581
|
+
for (const [componentId, coverage] of Object.entries(componentCoverage)) {
|
|
582
|
+
// Components with no tests
|
|
583
|
+
if (!coverage.has_tests) {
|
|
584
|
+
gaps.push({
|
|
585
|
+
component_id: componentId,
|
|
586
|
+
gap_type: 'no_tests',
|
|
587
|
+
severity: 'high',
|
|
588
|
+
description: 'Component has no test files',
|
|
589
|
+
recommendation: 'Create comprehensive test suite',
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// Low coverage components
|
|
594
|
+
else if (coverage.lines.percentage < 50) {
|
|
595
|
+
gaps.push({
|
|
596
|
+
component_id: componentId,
|
|
597
|
+
gap_type: 'low_coverage',
|
|
598
|
+
severity: 'medium',
|
|
599
|
+
description: `Low line coverage: ${coverage.lines.percentage.toFixed(1)}%`,
|
|
600
|
+
recommendation: 'Add more test cases to improve coverage',
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// Missing function coverage
|
|
605
|
+
if (coverage.functions.total > 0 && coverage.functions.percentage < 70) {
|
|
606
|
+
gaps.push({
|
|
607
|
+
component_id: componentId,
|
|
608
|
+
gap_type: 'untested_functions',
|
|
609
|
+
severity: 'medium',
|
|
610
|
+
description: `${coverage.functions.total - coverage.functions.covered} functions not tested`,
|
|
611
|
+
recommendation: 'Add tests for untested functions',
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
// Missing branch coverage
|
|
616
|
+
if (coverage.branches.total > 0 && coverage.branches.percentage < 60) {
|
|
617
|
+
gaps.push({
|
|
618
|
+
component_id: componentId,
|
|
619
|
+
gap_type: 'untested_branches',
|
|
620
|
+
severity: 'low',
|
|
621
|
+
description: `${coverage.branches.total - coverage.branches.covered} branches not covered`,
|
|
622
|
+
recommendation: 'Add tests for edge cases and error paths',
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
return gaps;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Generate coverage recommendations
|
|
632
|
+
*/
|
|
633
|
+
generateCoverageRecommendations(analysis) {
|
|
634
|
+
const recommendations = [];
|
|
635
|
+
|
|
636
|
+
// Overall coverage recommendations
|
|
637
|
+
if (analysis.overall_coverage.percentage < 70) {
|
|
638
|
+
recommendations.push({
|
|
639
|
+
type: 'overall_coverage',
|
|
640
|
+
priority: 'high',
|
|
641
|
+
message: `Overall coverage is ${analysis.overall_coverage.percentage.toFixed(1)}% - target is 80%+`,
|
|
642
|
+
action: 'Focus on components with no tests or low coverage',
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// Function coverage recommendations
|
|
647
|
+
if (analysis.overall_coverage.function_percentage < 80) {
|
|
648
|
+
recommendations.push({
|
|
649
|
+
type: 'function_coverage',
|
|
650
|
+
priority: 'medium',
|
|
651
|
+
message: `Function coverage is ${analysis.overall_coverage.function_percentage.toFixed(1)}% - target is 90%+`,
|
|
652
|
+
action: 'Add tests for untested functions',
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// Components without tests
|
|
657
|
+
const componentsWithoutTests = Object.values(analysis.component_coverage)
|
|
658
|
+
.filter(c => !c.has_tests).length;
|
|
659
|
+
|
|
660
|
+
if (componentsWithoutTests > 0) {
|
|
661
|
+
recommendations.push({
|
|
662
|
+
type: 'missing_tests',
|
|
663
|
+
priority: 'high',
|
|
664
|
+
message: `${componentsWithoutTests} components have no tests`,
|
|
665
|
+
action: 'Create test files for untested components',
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// Test quality recommendations
|
|
670
|
+
const lowQualityTests = Object.values(analysis.component_coverage)
|
|
671
|
+
.filter(c => c.coverage_quality === 'poor').length;
|
|
672
|
+
|
|
673
|
+
if (lowQualityTests > 0) {
|
|
674
|
+
recommendations.push({
|
|
675
|
+
type: 'test_quality',
|
|
676
|
+
priority: 'medium',
|
|
677
|
+
message: `${lowQualityTests} components have poor test quality`,
|
|
678
|
+
action: 'Improve test comprehensiveness and add edge cases',
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
return recommendations;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Determine coverage quality rating
|
|
687
|
+
*/
|
|
688
|
+
determineCoverageQuality(coverage) {
|
|
689
|
+
if (!coverage.has_tests) return 'none';
|
|
690
|
+
|
|
691
|
+
const linePercentage = coverage.lines.percentage || 0;
|
|
692
|
+
const functionPercentage = coverage.functions.percentage || 0;
|
|
693
|
+
|
|
694
|
+
const averagePercentage = (linePercentage + functionPercentage) / 2;
|
|
695
|
+
|
|
696
|
+
if (averagePercentage >= 90) return 'excellent';
|
|
697
|
+
if (averagePercentage >= 80) return 'good';
|
|
698
|
+
if (averagePercentage >= 60) return 'fair';
|
|
699
|
+
if (averagePercentage >= 40) return 'poor';
|
|
700
|
+
return 'very_poor';
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Identify untested functions
|
|
705
|
+
*/
|
|
706
|
+
async identifyUntestedFunctions(component) {
|
|
707
|
+
const untestedFunctions = [];
|
|
708
|
+
|
|
709
|
+
try {
|
|
710
|
+
if (component.type === 'util' && component.filePath) {
|
|
711
|
+
const content = await fs.readFile(component.filePath, 'utf-8');
|
|
712
|
+
const functions = this.extractFunctionNames(content);
|
|
713
|
+
|
|
714
|
+
// Check if each function is tested
|
|
715
|
+
const testFiles = await this.findTestFiles(component);
|
|
716
|
+
const testContent = await this.getCombinedTestContent(testFiles);
|
|
717
|
+
|
|
718
|
+
for (const func of functions) {
|
|
719
|
+
if (!testContent.includes(func.name)) {
|
|
720
|
+
untestedFunctions.push(func);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
} catch (error) {
|
|
725
|
+
console.warn(chalk.yellow(`Failed to identify untested functions: ${error.message}`));
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
return untestedFunctions;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Identify uncovered branches
|
|
733
|
+
*/
|
|
734
|
+
async identifyUncoveredBranches(component) {
|
|
735
|
+
const uncoveredBranches = [];
|
|
736
|
+
|
|
737
|
+
// This would require more sophisticated analysis
|
|
738
|
+
// For now, return empty array
|
|
739
|
+
|
|
740
|
+
return uncoveredBranches;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// Helper methods
|
|
744
|
+
|
|
745
|
+
extractFunctionName(functionMatch) {
|
|
746
|
+
const nameMatch = functionMatch.match(/function\s+(\w+)|(\w+)\s*[=:]/);
|
|
747
|
+
return nameMatch ? (nameMatch[1] || nameMatch[2]) : 'anonymous';
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
extractFunctionNames(content) {
|
|
751
|
+
const functions = [];
|
|
752
|
+
const functionMatches = content.match(/(?:function\s+(\w+)|(\w+)\s*[=:]\s*(?:async\s+)?(?:function|\([^)]*\)\s*=>))/g) || [];
|
|
753
|
+
|
|
754
|
+
for (const match of functionMatches) {
|
|
755
|
+
const name = this.extractFunctionName(match);
|
|
756
|
+
if (name && name !== 'anonymous') {
|
|
757
|
+
functions.push({ name, match });
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
return functions;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
async getCombinedTestContent(testFiles) {
|
|
765
|
+
let combinedContent = '';
|
|
766
|
+
|
|
767
|
+
for (const testFile of testFiles) {
|
|
768
|
+
try {
|
|
769
|
+
const content = await fs.readFile(testFile.file_path, 'utf-8');
|
|
770
|
+
combinedContent += content + '\n';
|
|
771
|
+
} catch (error) {
|
|
772
|
+
continue;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
return combinedContent;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
async loadExistingCoverageData() {
|
|
780
|
+
// Load any existing coverage cache or history
|
|
781
|
+
try {
|
|
782
|
+
const historyFile = path.join(this.coverageReportsDir, 'analysis-history.json');
|
|
783
|
+
const exists = await fs.access(historyFile).then(() => true).catch(() => false);
|
|
784
|
+
|
|
785
|
+
if (exists) {
|
|
786
|
+
const data = JSON.parse(await fs.readFile(historyFile, 'utf-8'));
|
|
787
|
+
this.analysisHistory = data.analysis_history || [];
|
|
788
|
+
}
|
|
789
|
+
} catch (error) {
|
|
790
|
+
// No existing data, start fresh
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
async saveCoverageAnalysis(analysis) {
|
|
795
|
+
try {
|
|
796
|
+
// Save individual analysis
|
|
797
|
+
const analysisFile = path.join(this.coverageReportsDir, `${analysis.analysis_id}.json`);
|
|
798
|
+
await fs.writeFile(analysisFile, JSON.stringify(analysis, null, 2));
|
|
799
|
+
|
|
800
|
+
// Update history
|
|
801
|
+
const historyFile = path.join(this.coverageReportsDir, 'analysis-history.json');
|
|
802
|
+
const historyData = {
|
|
803
|
+
last_updated: new Date().toISOString(),
|
|
804
|
+
analysis_history: this.analysisHistory.slice(-10), // Keep last 10 analyses
|
|
805
|
+
};
|
|
806
|
+
await fs.writeFile(historyFile, JSON.stringify(historyData, null, 2));
|
|
807
|
+
|
|
808
|
+
console.log(chalk.gray(`Coverage analysis saved: ${analysisFile}`));
|
|
809
|
+
|
|
810
|
+
} catch (error) {
|
|
811
|
+
console.warn(chalk.yellow(`Failed to save coverage analysis: ${error.message}`));
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* Get coverage trends over time
|
|
817
|
+
*/
|
|
818
|
+
getCoverageTrends() {
|
|
819
|
+
if (this.analysisHistory.length < 2) {
|
|
820
|
+
return { trend: 'insufficient_data', message: 'Need at least 2 analyses for trend calculation' };
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
const recent = this.analysisHistory.slice(-5); // Last 5 analyses
|
|
824
|
+
const percentages = recent.map(a => a.overall_percentage);
|
|
825
|
+
|
|
826
|
+
const firstPercentage = percentages[0];
|
|
827
|
+
const lastPercentage = percentages[percentages.length - 1];
|
|
828
|
+
const difference = lastPercentage - firstPercentage;
|
|
829
|
+
|
|
830
|
+
let trend = 'stable';
|
|
831
|
+
if (difference > 5) trend = 'improving';
|
|
832
|
+
else if (difference < -5) trend = 'declining';
|
|
833
|
+
|
|
834
|
+
return {
|
|
835
|
+
trend,
|
|
836
|
+
difference: difference.toFixed(1),
|
|
837
|
+
current_percentage: lastPercentage,
|
|
838
|
+
analysis_count: recent.length,
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* Get coverage summary for reporting
|
|
844
|
+
*/
|
|
845
|
+
getCoverageSummary(analysisId) {
|
|
846
|
+
const analysis = this.coverageCache.get(analysisId);
|
|
847
|
+
|
|
848
|
+
if (!analysis) {
|
|
849
|
+
return null;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
return {
|
|
853
|
+
analysis_id: analysisId,
|
|
854
|
+
timestamp: analysis.timestamp,
|
|
855
|
+
overall_percentage: analysis.overall_coverage.percentage,
|
|
856
|
+
components_analyzed: analysis.components,
|
|
857
|
+
components_with_tests: Object.values(analysis.component_coverage)
|
|
858
|
+
.filter(c => c.has_tests).length,
|
|
859
|
+
coverage_gaps: analysis.coverage_gaps.length,
|
|
860
|
+
quality_distribution: this.calculateQualityDistribution(analysis.component_coverage),
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
calculateQualityDistribution(componentCoverage) {
|
|
865
|
+
const distribution = {
|
|
866
|
+
excellent: 0,
|
|
867
|
+
good: 0,
|
|
868
|
+
fair: 0,
|
|
869
|
+
poor: 0,
|
|
870
|
+
very_poor: 0,
|
|
871
|
+
none: 0,
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
for (const coverage of Object.values(componentCoverage)) {
|
|
875
|
+
distribution[coverage.coverage_quality]++;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
return distribution;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
module.exports = CoverageAnalyzer;
|