@yasserkhanorg/impact-gate 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +168 -0
- package/README.md +520 -0
- package/dist/adapters/cypress.d.ts +10 -0
- package/dist/adapters/cypress.d.ts.map +1 -0
- package/dist/adapters/cypress.js +86 -0
- package/dist/adapters/framework_adapter.d.ts +41 -0
- package/dist/adapters/framework_adapter.d.ts.map +1 -0
- package/dist/adapters/framework_adapter.js +152 -0
- package/dist/adapters/playwright.d.ts +10 -0
- package/dist/adapters/playwright.d.ts.map +1 -0
- package/dist/adapters/playwright.js +86 -0
- package/dist/adapters/pytest.d.ts +10 -0
- package/dist/adapters/pytest.d.ts.map +1 -0
- package/dist/adapters/pytest.js +96 -0
- package/dist/adapters/supertest.d.ts +12 -0
- package/dist/adapters/supertest.d.ts.map +1 -0
- package/dist/adapters/supertest.js +85 -0
- package/dist/agent/api_catalog.d.ts +11 -0
- package/dist/agent/api_catalog.d.ts.map +1 -0
- package/dist/agent/api_catalog.js +210 -0
- package/dist/agent/config.d.ts +193 -0
- package/dist/agent/config.d.ts.map +1 -0
- package/dist/agent/config.js +875 -0
- package/dist/agent/feedback.d.ts +91 -0
- package/dist/agent/feedback.d.ts.map +1 -0
- package/dist/agent/feedback.js +323 -0
- package/dist/agent/git.d.ts +19 -0
- package/dist/agent/git.d.ts.map +1 -0
- package/dist/agent/git.js +257 -0
- package/dist/agent/handoff.d.ts +22 -0
- package/dist/agent/handoff.d.ts.map +1 -0
- package/dist/agent/handoff.js +180 -0
- package/dist/agent/llm_agents_flow.d.ts +15 -0
- package/dist/agent/llm_agents_flow.d.ts.map +1 -0
- package/dist/agent/llm_agents_flow.js +434 -0
- package/dist/agent/native_flow.d.ts +6 -0
- package/dist/agent/native_flow.d.ts.map +1 -0
- package/dist/agent/native_flow.js +179 -0
- package/dist/agent/pipeline.d.ts +7 -0
- package/dist/agent/pipeline.d.ts.map +1 -0
- package/dist/agent/pipeline.js +260 -0
- package/dist/agent/pipeline_types.d.ts +54 -0
- package/dist/agent/pipeline_types.d.ts.map +1 -0
- package/dist/agent/pipeline_types.js +4 -0
- package/dist/agent/pipeline_utils.d.ts +12 -0
- package/dist/agent/pipeline_utils.d.ts.map +1 -0
- package/dist/agent/pipeline_utils.js +156 -0
- package/dist/agent/plan.d.ts +170 -0
- package/dist/agent/plan.d.ts.map +1 -0
- package/dist/agent/plan.js +86 -0
- package/dist/agent/playwright_report.d.ts +8 -0
- package/dist/agent/playwright_report.d.ts.map +1 -0
- package/dist/agent/playwright_report.js +126 -0
- package/dist/agent/process_runner.d.ts +10 -0
- package/dist/agent/process_runner.d.ts.map +1 -0
- package/dist/agent/process_runner.js +92 -0
- package/dist/agent/spec_generator.d.ts +5 -0
- package/dist/agent/spec_generator.d.ts.map +1 -0
- package/dist/agent/spec_generator.js +253 -0
- package/dist/agent/test_path.d.ts +2 -0
- package/dist/agent/test_path.d.ts.map +1 -0
- package/dist/agent/test_path.js +23 -0
- package/dist/agent/traceability_capture.d.ts +18 -0
- package/dist/agent/traceability_capture.d.ts.map +1 -0
- package/dist/agent/traceability_capture.js +313 -0
- package/dist/agent/traceability_ingest.d.ts +21 -0
- package/dist/agent/traceability_ingest.d.ts.map +1 -0
- package/dist/agent/traceability_ingest.js +237 -0
- package/dist/agent/types.d.ts +42 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +4 -0
- package/dist/agent/utils.d.ts +13 -0
- package/dist/agent/utils.d.ts.map +1 -0
- package/dist/agent/utils.js +152 -0
- package/dist/agent/validation_runner.d.ts +5 -0
- package/dist/agent/validation_runner.d.ts.map +1 -0
- package/dist/agent/validation_runner.js +77 -0
- package/dist/agentic/fix_loop.d.ts +26 -0
- package/dist/agentic/fix_loop.d.ts.map +1 -0
- package/dist/agentic/fix_loop.js +96 -0
- package/dist/agentic/playwright_runner.d.ts +43 -0
- package/dist/agentic/playwright_runner.d.ts.map +1 -0
- package/dist/agentic/playwright_runner.js +165 -0
- package/dist/agentic/runner.d.ts +27 -0
- package/dist/agentic/runner.d.ts.map +1 -0
- package/dist/agentic/runner.js +210 -0
- package/dist/agentic/types.d.ts +62 -0
- package/dist/agentic/types.d.ts.map +1 -0
- package/dist/agentic/types.js +4 -0
- package/dist/agents/coverage-evaluator.d.ts +8 -0
- package/dist/agents/coverage-evaluator.d.ts.map +1 -0
- package/dist/agents/coverage-evaluator.js +41 -0
- package/dist/agents/cross-impact.d.ts +13 -0
- package/dist/agents/cross-impact.d.ts.map +1 -0
- package/dist/agents/cross-impact.js +140 -0
- package/dist/agents/executor.d.ts +8 -0
- package/dist/agents/executor.d.ts.map +1 -0
- package/dist/agents/executor.js +75 -0
- package/dist/agents/explorer.d.ts +12 -0
- package/dist/agents/explorer.d.ts.map +1 -0
- package/dist/agents/explorer.js +43 -0
- package/dist/agents/generator.d.ts +8 -0
- package/dist/agents/generator.d.ts.map +1 -0
- package/dist/agents/generator.js +77 -0
- package/dist/agents/healer.d.ts +8 -0
- package/dist/agents/healer.d.ts.map +1 -0
- package/dist/agents/healer.js +31 -0
- package/dist/agents/impact-analyst.d.ts +8 -0
- package/dist/agents/impact-analyst.d.ts.map +1 -0
- package/dist/agents/impact-analyst.js +38 -0
- package/dist/agents/regression-advisor.d.ts +8 -0
- package/dist/agents/regression-advisor.d.ts.map +1 -0
- package/dist/agents/regression-advisor.js +116 -0
- package/dist/agents/strategist.d.ts +9 -0
- package/dist/agents/strategist.d.ts.map +1 -0
- package/dist/agents/strategist.js +92 -0
- package/dist/agents/test-designer.d.ts +8 -0
- package/dist/agents/test-designer.d.ts.map +1 -0
- package/dist/agents/test-designer.js +111 -0
- package/dist/anthropic_provider.d.ts +65 -0
- package/dist/anthropic_provider.d.ts.map +1 -0
- package/dist/anthropic_provider.js +334 -0
- package/dist/api.d.ts +48 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +151 -0
- package/dist/base_provider.d.ts +109 -0
- package/dist/base_provider.d.ts.map +1 -0
- package/dist/base_provider.js +203 -0
- package/dist/budget_ledger.d.ts +28 -0
- package/dist/budget_ledger.d.ts.map +1 -0
- package/dist/budget_ledger.js +62 -0
- package/dist/cache/cached_provider.d.ts +49 -0
- package/dist/cache/cached_provider.d.ts.map +1 -0
- package/dist/cache/cached_provider.js +91 -0
- package/dist/cache/response_cache.d.ts +79 -0
- package/dist/cache/response_cache.d.ts.map +1 -0
- package/dist/cache/response_cache.js +177 -0
- package/dist/cli/commands/analyze.d.ts +3 -0
- package/dist/cli/commands/analyze.d.ts.map +1 -0
- package/dist/cli/commands/analyze.js +77 -0
- package/dist/cli/commands/bootstrap.d.ts +3 -0
- package/dist/cli/commands/bootstrap.d.ts.map +1 -0
- package/dist/cli/commands/bootstrap.js +109 -0
- package/dist/cli/commands/cost_report.d.ts +3 -0
- package/dist/cli/commands/cost_report.d.ts.map +1 -0
- package/dist/cli/commands/cost_report.js +115 -0
- package/dist/cli/commands/crew.d.ts +3 -0
- package/dist/cli/commands/crew.d.ts.map +1 -0
- package/dist/cli/commands/crew.js +255 -0
- package/dist/cli/commands/feedback.d.ts +3 -0
- package/dist/cli/commands/feedback.d.ts.map +1 -0
- package/dist/cli/commands/feedback.js +39 -0
- package/dist/cli/commands/finalize.d.ts +3 -0
- package/dist/cli/commands/finalize.d.ts.map +1 -0
- package/dist/cli/commands/finalize.js +41 -0
- package/dist/cli/commands/gate.d.ts +3 -0
- package/dist/cli/commands/gate.d.ts.map +1 -0
- package/dist/cli/commands/gate.js +89 -0
- package/dist/cli/commands/generate.d.ts +4 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +108 -0
- package/dist/cli/commands/heal.d.ts +3 -0
- package/dist/cli/commands/heal.d.ts.map +1 -0
- package/dist/cli/commands/heal.js +60 -0
- package/dist/cli/commands/impact.d.ts +4 -0
- package/dist/cli/commands/impact.d.ts.map +1 -0
- package/dist/cli/commands/impact.js +33 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +169 -0
- package/dist/cli/commands/llm_health.d.ts +2 -0
- package/dist/cli/commands/llm_health.d.ts.map +1 -0
- package/dist/cli/commands/llm_health.js +22 -0
- package/dist/cli/commands/plan.d.ts +4 -0
- package/dist/cli/commands/plan.d.ts.map +1 -0
- package/dist/cli/commands/plan.js +120 -0
- package/dist/cli/commands/plan_crew.d.ts +17 -0
- package/dist/cli/commands/plan_crew.d.ts.map +1 -0
- package/dist/cli/commands/plan_crew.js +316 -0
- package/dist/cli/commands/traceability.d.ts +4 -0
- package/dist/cli/commands/traceability.d.ts.map +1 -0
- package/dist/cli/commands/traceability.js +77 -0
- package/dist/cli/commands/train.d.ts +3 -0
- package/dist/cli/commands/train.d.ts.map +1 -0
- package/dist/cli/commands/train.js +391 -0
- package/dist/cli/defaults.d.ts +35 -0
- package/dist/cli/defaults.d.ts.map +1 -0
- package/dist/cli/defaults.js +172 -0
- package/dist/cli/errors.d.ts +27 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/errors.js +57 -0
- package/dist/cli/parse_args.d.ts +6 -0
- package/dist/cli/parse_args.d.ts.map +1 -0
- package/dist/cli/parse_args.js +257 -0
- package/dist/cli/types.d.ts +87 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +4 -0
- package/dist/cli/usage.d.ts +2 -0
- package/dist/cli/usage.d.ts.map +1 -0
- package/dist/cli/usage.js +109 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +194 -0
- package/dist/crew/context.d.ts +55 -0
- package/dist/crew/context.d.ts.map +1 -0
- package/dist/crew/context.js +36 -0
- package/dist/crew/orchestrator.d.ts +50 -0
- package/dist/crew/orchestrator.d.ts.map +1 -0
- package/dist/crew/orchestrator.js +329 -0
- package/dist/crew/protocol.d.ts +46 -0
- package/dist/crew/protocol.d.ts.map +1 -0
- package/dist/crew/protocol.js +4 -0
- package/dist/crew/provider.d.ts +17 -0
- package/dist/crew/provider.d.ts.map +1 -0
- package/dist/crew/provider.js +36 -0
- package/dist/crew/sanitize.d.ts +3 -0
- package/dist/crew/sanitize.d.ts.map +1 -0
- package/dist/crew/sanitize.js +31 -0
- package/dist/crew/types.d.ts +52 -0
- package/dist/crew/types.d.ts.map +1 -0
- package/dist/crew/types.js +4 -0
- package/dist/crew/workflows.d.ts +52 -0
- package/dist/crew/workflows.d.ts.map +1 -0
- package/dist/crew/workflows.js +36 -0
- package/dist/custom_provider.d.ts +20 -0
- package/dist/custom_provider.d.ts.map +1 -0
- package/dist/custom_provider.js +277 -0
- package/dist/engine/ai_enrichment.d.ts +44 -0
- package/dist/engine/ai_enrichment.d.ts.map +1 -0
- package/dist/engine/ai_enrichment.js +267 -0
- package/dist/engine/diff_loader.d.ts +11 -0
- package/dist/engine/diff_loader.d.ts.map +1 -0
- package/dist/engine/diff_loader.js +63 -0
- package/dist/engine/impact_engine.d.ts +72 -0
- package/dist/engine/impact_engine.d.ts.map +1 -0
- package/dist/engine/impact_engine.js +298 -0
- package/dist/engine/plan_builder.d.ts +11 -0
- package/dist/engine/plan_builder.d.ts.map +1 -0
- package/dist/engine/plan_builder.js +599 -0
- package/dist/esm/adapters/cypress.js +49 -0
- package/dist/esm/adapters/framework_adapter.js +114 -0
- package/dist/esm/adapters/playwright.js +49 -0
- package/dist/esm/adapters/pytest.js +59 -0
- package/dist/esm/adapters/supertest.js +48 -0
- package/dist/esm/agent/api_catalog.js +199 -0
- package/dist/esm/agent/config.js +872 -0
- package/dist/esm/agent/feedback.js +317 -0
- package/dist/esm/agent/git.js +252 -0
- package/dist/esm/agent/handoff.js +177 -0
- package/dist/esm/agent/llm_agents_flow.js +421 -0
- package/dist/esm/agent/native_flow.js +175 -0
- package/dist/esm/agent/pipeline.js +256 -0
- package/dist/esm/agent/pipeline_types.js +3 -0
- package/dist/esm/agent/pipeline_utils.js +146 -0
- package/dist/esm/agent/plan.js +83 -0
- package/dist/esm/agent/playwright_report.js +123 -0
- package/dist/esm/agent/process_runner.js +83 -0
- package/dist/esm/agent/spec_generator.js +249 -0
- package/dist/esm/agent/test_path.js +20 -0
- package/dist/esm/agent/traceability_capture.js +310 -0
- package/dist/esm/agent/traceability_ingest.js +234 -0
- package/dist/esm/agent/types.js +3 -0
- package/dist/esm/agent/utils.js +138 -0
- package/dist/esm/agent/validation_runner.js +73 -0
- package/dist/esm/agentic/fix_loop.js +91 -0
- package/dist/esm/agentic/playwright_runner.js +161 -0
- package/dist/esm/agentic/runner.js +207 -0
- package/dist/esm/agentic/types.js +3 -0
- package/dist/esm/agents/coverage-evaluator.js +37 -0
- package/dist/esm/agents/cross-impact.js +136 -0
- package/dist/esm/agents/executor.js +71 -0
- package/dist/esm/agents/explorer.js +39 -0
- package/dist/esm/agents/generator.js +73 -0
- package/dist/esm/agents/healer.js +27 -0
- package/dist/esm/agents/impact-analyst.js +34 -0
- package/dist/esm/agents/regression-advisor.js +112 -0
- package/dist/esm/agents/strategist.js +88 -0
- package/dist/esm/agents/test-designer.js +107 -0
- package/dist/esm/anthropic_provider.js +326 -0
- package/dist/esm/api.js +143 -0
- package/dist/esm/base_provider.js +198 -0
- package/dist/esm/budget_ledger.js +58 -0
- package/dist/esm/cache/cached_provider.js +85 -0
- package/dist/esm/cache/response_cache.js +140 -0
- package/dist/esm/cli/commands/analyze.js +74 -0
- package/dist/esm/cli/commands/bootstrap.js +106 -0
- package/dist/esm/cli/commands/cost_report.js +112 -0
- package/dist/esm/cli/commands/crew.js +252 -0
- package/dist/esm/cli/commands/feedback.js +36 -0
- package/dist/esm/cli/commands/finalize.js +38 -0
- package/dist/esm/cli/commands/gate.js +86 -0
- package/dist/esm/cli/commands/generate.js +105 -0
- package/dist/esm/cli/commands/heal.js +57 -0
- package/dist/esm/cli/commands/impact.js +30 -0
- package/dist/esm/cli/commands/init.js +133 -0
- package/dist/esm/cli/commands/llm_health.js +19 -0
- package/dist/esm/cli/commands/plan.js +117 -0
- package/dist/esm/cli/commands/plan_crew.js +309 -0
- package/dist/esm/cli/commands/traceability.js +73 -0
- package/dist/esm/cli/commands/train.js +355 -0
- package/dist/esm/cli/defaults.js +165 -0
- package/dist/esm/cli/errors.js +52 -0
- package/dist/esm/cli/parse_args.js +251 -0
- package/dist/esm/cli/types.js +3 -0
- package/dist/esm/cli/usage.js +106 -0
- package/dist/esm/cli.js +192 -0
- package/dist/esm/crew/context.js +32 -0
- package/dist/esm/crew/orchestrator.js +325 -0
- package/dist/esm/crew/protocol.js +3 -0
- package/dist/esm/crew/provider.js +33 -0
- package/dist/esm/crew/sanitize.js +27 -0
- package/dist/esm/crew/types.js +3 -0
- package/dist/esm/crew/workflows.js +33 -0
- package/dist/esm/custom_provider.js +273 -0
- package/dist/esm/engine/ai_enrichment.js +264 -0
- package/dist/esm/engine/diff_loader.js +59 -0
- package/dist/esm/engine/impact_engine.js +291 -0
- package/dist/esm/engine/plan_builder.js +593 -0
- package/dist/esm/index.js +72 -0
- package/dist/esm/knowledge/api_surface.js +408 -0
- package/dist/esm/knowledge/cluster_utils.js +60 -0
- package/dist/esm/knowledge/context_loader.js +85 -0
- package/dist/esm/knowledge/failure_history.js +121 -0
- package/dist/esm/knowledge/kg_bridge.js +381 -0
- package/dist/esm/knowledge/kg_types.js +3 -0
- package/dist/esm/knowledge/route_families.js +393 -0
- package/dist/esm/knowledge/spec_index.js +122 -0
- package/dist/esm/logger.js +115 -0
- package/dist/esm/mcp-server.js +621 -0
- package/dist/esm/metrics/prometheus.js +149 -0
- package/dist/esm/model_router.js +59 -0
- package/dist/esm/ollama_provider.js +301 -0
- package/dist/esm/openai_provider.js +243 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/pipeline/orchestrator.js +228 -0
- package/dist/esm/pipeline/spec_verifier.js +75 -0
- package/dist/esm/pipeline/stage0_preprocess.js +102 -0
- package/dist/esm/pipeline/stage1_impact.js +140 -0
- package/dist/esm/pipeline/stage2_coverage.js +153 -0
- package/dist/esm/pipeline/stage3_generation.js +284 -0
- package/dist/esm/pipeline/stage4_heal.js +288 -0
- package/dist/esm/progress.js +112 -0
- package/dist/esm/prompts/coverage.js +57 -0
- package/dist/esm/prompts/cross-impact.js +53 -0
- package/dist/esm/prompts/generation.js +297 -0
- package/dist/esm/prompts/generation_profile.js +147 -0
- package/dist/esm/prompts/heal.js +91 -0
- package/dist/esm/prompts/impact.js +63 -0
- package/dist/esm/prompts/json_extract.js +36 -0
- package/dist/esm/prompts/strategist.js +61 -0
- package/dist/esm/prompts/test-designer.js +92 -0
- package/dist/esm/provider_factory.js +366 -0
- package/dist/esm/provider_interface.js +23 -0
- package/dist/esm/provider_utils.js +96 -0
- package/dist/esm/qa-agent/cli.js +205 -0
- package/dist/esm/qa-agent/orchestrator.js +120 -0
- package/dist/esm/qa-agent/phase1/runner.js +139 -0
- package/dist/esm/qa-agent/phase1/scope.js +126 -0
- package/dist/esm/qa-agent/phase2/agent_browser.js +95 -0
- package/dist/esm/qa-agent/phase2/agent_loop.js +351 -0
- package/dist/esm/qa-agent/phase2/exploration_state.js +97 -0
- package/dist/esm/qa-agent/phase2/tools.js +386 -0
- package/dist/esm/qa-agent/phase2/vision.js +75 -0
- package/dist/esm/qa-agent/phase3/feedback.js +34 -0
- package/dist/esm/qa-agent/phase3/reporter.js +145 -0
- package/dist/esm/qa-agent/phase3/spec_generator.js +62 -0
- package/dist/esm/qa-agent/phase3/verdict.js +66 -0
- package/dist/esm/qa-agent/safe_env.js +23 -0
- package/dist/esm/qa-agent/types.js +3 -0
- package/dist/esm/reporters/junit.js +86 -0
- package/dist/esm/reporters/reporter.js +3 -0
- package/dist/esm/reporters/sarif.js +132 -0
- package/dist/esm/resilience/circuit_breaker.js +78 -0
- package/dist/esm/resilience/retry.js +56 -0
- package/dist/esm/sanitize.js +66 -0
- package/dist/esm/training/enricher.js +345 -0
- package/dist/esm/training/kg_scanner.js +115 -0
- package/dist/esm/training/merger.js +204 -0
- package/dist/esm/training/scanner.js +923 -0
- package/dist/esm/training/types.js +6 -0
- package/dist/esm/training/validator.js +254 -0
- package/dist/esm/validation/guardrails.js +101 -0
- package/dist/esm/validation/output_schema.js +80 -0
- package/dist/esm/version.js +33 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +169 -0
- package/dist/knowledge/api_surface.d.ts +37 -0
- package/dist/knowledge/api_surface.d.ts.map +1 -0
- package/dist/knowledge/api_surface.js +418 -0
- package/dist/knowledge/cluster_utils.d.ts +28 -0
- package/dist/knowledge/cluster_utils.d.ts.map +1 -0
- package/dist/knowledge/cluster_utils.js +67 -0
- package/dist/knowledge/context_loader.d.ts +13 -0
- package/dist/knowledge/context_loader.d.ts.map +1 -0
- package/dist/knowledge/context_loader.js +90 -0
- package/dist/knowledge/failure_history.d.ts +39 -0
- package/dist/knowledge/failure_history.d.ts.map +1 -0
- package/dist/knowledge/failure_history.js +128 -0
- package/dist/knowledge/kg_bridge.d.ts +31 -0
- package/dist/knowledge/kg_bridge.d.ts.map +1 -0
- package/dist/knowledge/kg_bridge.js +388 -0
- package/dist/knowledge/kg_types.d.ts +75 -0
- package/dist/knowledge/kg_types.d.ts.map +1 -0
- package/dist/knowledge/kg_types.js +4 -0
- package/dist/knowledge/route_families.d.ts +98 -0
- package/dist/knowledge/route_families.d.ts.map +1 -0
- package/dist/knowledge/route_families.js +410 -0
- package/dist/knowledge/spec_index.d.ts +18 -0
- package/dist/knowledge/spec_index.d.ts.map +1 -0
- package/dist/knowledge/spec_index.js +128 -0
- package/dist/logger.d.ts +31 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +119 -0
- package/dist/mcp-server.d.ts +68 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +629 -0
- package/dist/metrics/prometheus.d.ts +37 -0
- package/dist/metrics/prometheus.d.ts.map +1 -0
- package/dist/metrics/prometheus.js +153 -0
- package/dist/model_router.d.ts +28 -0
- package/dist/model_router.d.ts.map +1 -0
- package/dist/model_router.js +63 -0
- package/dist/ollama_provider.d.ts +65 -0
- package/dist/ollama_provider.d.ts.map +1 -0
- package/dist/ollama_provider.js +309 -0
- package/dist/openai_provider.d.ts +23 -0
- package/dist/openai_provider.d.ts.map +1 -0
- package/dist/openai_provider.js +251 -0
- package/dist/pipeline/orchestrator.d.ts +33 -0
- package/dist/pipeline/orchestrator.d.ts.map +1 -0
- package/dist/pipeline/orchestrator.js +231 -0
- package/dist/pipeline/spec_verifier.d.ts +20 -0
- package/dist/pipeline/spec_verifier.d.ts.map +1 -0
- package/dist/pipeline/spec_verifier.js +79 -0
- package/dist/pipeline/stage0_preprocess.d.ts +31 -0
- package/dist/pipeline/stage0_preprocess.d.ts.map +1 -0
- package/dist/pipeline/stage0_preprocess.js +105 -0
- package/dist/pipeline/stage1_impact.d.ts +19 -0
- package/dist/pipeline/stage1_impact.d.ts.map +1 -0
- package/dist/pipeline/stage1_impact.js +143 -0
- package/dist/pipeline/stage2_coverage.d.ts +19 -0
- package/dist/pipeline/stage2_coverage.d.ts.map +1 -0
- package/dist/pipeline/stage2_coverage.js +156 -0
- package/dist/pipeline/stage3_generation.d.ts +43 -0
- package/dist/pipeline/stage3_generation.d.ts.map +1 -0
- package/dist/pipeline/stage3_generation.js +287 -0
- package/dist/pipeline/stage4_heal.d.ts +62 -0
- package/dist/pipeline/stage4_heal.d.ts.map +1 -0
- package/dist/pipeline/stage4_heal.js +294 -0
- package/dist/progress.d.ts +22 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +116 -0
- package/dist/prompts/coverage.d.ts +39 -0
- package/dist/prompts/coverage.d.ts.map +1 -0
- package/dist/prompts/coverage.js +61 -0
- package/dist/prompts/cross-impact.d.ts +23 -0
- package/dist/prompts/cross-impact.d.ts.map +1 -0
- package/dist/prompts/cross-impact.js +57 -0
- package/dist/prompts/generation.d.ts +25 -0
- package/dist/prompts/generation.d.ts.map +1 -0
- package/dist/prompts/generation.js +302 -0
- package/dist/prompts/generation_profile.d.ts +29 -0
- package/dist/prompts/generation_profile.d.ts.map +1 -0
- package/dist/prompts/generation_profile.js +151 -0
- package/dist/prompts/heal.d.ts +23 -0
- package/dist/prompts/heal.d.ts.map +1 -0
- package/dist/prompts/heal.js +95 -0
- package/dist/prompts/impact.d.ts +31 -0
- package/dist/prompts/impact.d.ts.map +1 -0
- package/dist/prompts/impact.js +67 -0
- package/dist/prompts/json_extract.d.ts +14 -0
- package/dist/prompts/json_extract.d.ts.map +1 -0
- package/dist/prompts/json_extract.js +39 -0
- package/dist/prompts/strategist.d.ts +25 -0
- package/dist/prompts/strategist.d.ts.map +1 -0
- package/dist/prompts/strategist.js +65 -0
- package/dist/prompts/test-designer.d.ts +35 -0
- package/dist/prompts/test-designer.d.ts.map +1 -0
- package/dist/prompts/test-designer.js +96 -0
- package/dist/provider_factory.d.ts +104 -0
- package/dist/provider_factory.d.ts.map +1 -0
- package/dist/provider_factory.js +371 -0
- package/dist/provider_interface.d.ts +365 -0
- package/dist/provider_interface.d.ts.map +1 -0
- package/dist/provider_interface.js +28 -0
- package/dist/provider_utils.d.ts +39 -0
- package/dist/provider_utils.d.ts.map +1 -0
- package/dist/provider_utils.js +103 -0
- package/dist/qa-agent/cli.d.ts +3 -0
- package/dist/qa-agent/cli.d.ts.map +1 -0
- package/dist/qa-agent/cli.js +207 -0
- package/dist/qa-agent/orchestrator.d.ts +3 -0
- package/dist/qa-agent/orchestrator.d.ts.map +1 -0
- package/dist/qa-agent/orchestrator.js +123 -0
- package/dist/qa-agent/phase1/runner.d.ts +3 -0
- package/dist/qa-agent/phase1/runner.d.ts.map +1 -0
- package/dist/qa-agent/phase1/runner.js +142 -0
- package/dist/qa-agent/phase1/scope.d.ts +6 -0
- package/dist/qa-agent/phase1/scope.d.ts.map +1 -0
- package/dist/qa-agent/phase1/scope.js +129 -0
- package/dist/qa-agent/phase2/agent_browser.d.ts +35 -0
- package/dist/qa-agent/phase2/agent_browser.d.ts.map +1 -0
- package/dist/qa-agent/phase2/agent_browser.js +99 -0
- package/dist/qa-agent/phase2/agent_loop.d.ts +3 -0
- package/dist/qa-agent/phase2/agent_loop.d.ts.map +1 -0
- package/dist/qa-agent/phase2/agent_loop.js +357 -0
- package/dist/qa-agent/phase2/exploration_state.d.ts +12 -0
- package/dist/qa-agent/phase2/exploration_state.d.ts.map +1 -0
- package/dist/qa-agent/phase2/exploration_state.js +109 -0
- package/dist/qa-agent/phase2/tools.d.ts +28 -0
- package/dist/qa-agent/phase2/tools.d.ts.map +1 -0
- package/dist/qa-agent/phase2/tools.js +390 -0
- package/dist/qa-agent/phase2/vision.d.ts +3 -0
- package/dist/qa-agent/phase2/vision.d.ts.map +1 -0
- package/dist/qa-agent/phase2/vision.js +78 -0
- package/dist/qa-agent/phase3/feedback.d.ts +3 -0
- package/dist/qa-agent/phase3/feedback.d.ts.map +1 -0
- package/dist/qa-agent/phase3/feedback.js +37 -0
- package/dist/qa-agent/phase3/reporter.d.ts +3 -0
- package/dist/qa-agent/phase3/reporter.d.ts.map +1 -0
- package/dist/qa-agent/phase3/reporter.js +148 -0
- package/dist/qa-agent/phase3/spec_generator.d.ts +3 -0
- package/dist/qa-agent/phase3/spec_generator.d.ts.map +1 -0
- package/dist/qa-agent/phase3/spec_generator.js +65 -0
- package/dist/qa-agent/phase3/verdict.d.ts +3 -0
- package/dist/qa-agent/phase3/verdict.d.ts.map +1 -0
- package/dist/qa-agent/phase3/verdict.js +69 -0
- package/dist/qa-agent/safe_env.d.ts +3 -0
- package/dist/qa-agent/safe_env.d.ts.map +1 -0
- package/dist/qa-agent/safe_env.js +26 -0
- package/dist/qa-agent/types.d.ts +130 -0
- package/dist/qa-agent/types.d.ts.map +1 -0
- package/dist/qa-agent/types.js +4 -0
- package/dist/reporters/junit.d.ts +6 -0
- package/dist/reporters/junit.d.ts.map +1 -0
- package/dist/reporters/junit.js +89 -0
- package/dist/reporters/reporter.d.ts +42 -0
- package/dist/reporters/reporter.d.ts.map +1 -0
- package/dist/reporters/reporter.js +4 -0
- package/dist/reporters/sarif.d.ts +7 -0
- package/dist/reporters/sarif.d.ts.map +1 -0
- package/dist/reporters/sarif.js +135 -0
- package/dist/resilience/circuit_breaker.d.ts +36 -0
- package/dist/resilience/circuit_breaker.d.ts.map +1 -0
- package/dist/resilience/circuit_breaker.js +82 -0
- package/dist/resilience/retry.d.ts +11 -0
- package/dist/resilience/retry.d.ts.map +1 -0
- package/dist/resilience/retry.js +59 -0
- package/dist/sanitize.d.ts +15 -0
- package/dist/sanitize.d.ts.map +1 -0
- package/dist/sanitize.js +71 -0
- package/dist/training/enricher.d.ts +17 -0
- package/dist/training/enricher.d.ts.map +1 -0
- package/dist/training/enricher.js +350 -0
- package/dist/training/kg_scanner.d.ts +13 -0
- package/dist/training/kg_scanner.d.ts.map +1 -0
- package/dist/training/kg_scanner.js +118 -0
- package/dist/training/merger.d.ts +15 -0
- package/dist/training/merger.d.ts.map +1 -0
- package/dist/training/merger.js +208 -0
- package/dist/training/scanner.d.ts +36 -0
- package/dist/training/scanner.d.ts.map +1 -0
- package/dist/training/scanner.js +932 -0
- package/dist/training/types.d.ts +117 -0
- package/dist/training/types.d.ts.map +1 -0
- package/dist/training/types.js +9 -0
- package/dist/training/validator.d.ts +21 -0
- package/dist/training/validator.d.ts.map +1 -0
- package/dist/training/validator.js +262 -0
- package/dist/validation/guardrails.d.ts +31 -0
- package/dist/validation/guardrails.d.ts.map +1 -0
- package/dist/validation/guardrails.js +112 -0
- package/dist/validation/output_schema.d.ts +67 -0
- package/dist/validation/output_schema.d.ts.map +1 -0
- package/dist/validation/output_schema.js +84 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +36 -0
- package/package.json +126 -0
- package/schemas/flow-decision.schema.json +83 -0
- package/schemas/gap.schema.json +18 -0
- package/schemas/impact.schema.json +455 -0
- package/schemas/plan.schema.json +491 -0
- package/schemas/route-families.schema.json +137 -0
- package/schemas/subsystem-risk-map.schema.json +62 -0
- package/schemas/traceability-input.schema.json +122 -0
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
2
|
+
// See LICENSE.txt for license information.
|
|
3
|
+
import { existsSync, readFileSync, statSync } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { logger } from '../logger.js';
|
|
6
|
+
const manifestCache = new Map();
|
|
7
|
+
export function matchesGlob(filePath, pattern) {
|
|
8
|
+
const normalized = filePath.replace(/\\/g, '/');
|
|
9
|
+
const parts = pattern.replace(/\\/g, '/').split('*');
|
|
10
|
+
if (parts.length === 1) {
|
|
11
|
+
return normalized === parts[0] || normalized.startsWith(parts[0]);
|
|
12
|
+
}
|
|
13
|
+
let pos = 0;
|
|
14
|
+
for (let i = 0; i < parts.length; i++) {
|
|
15
|
+
const part = parts[i];
|
|
16
|
+
if (part === '') {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const idx = normalized.indexOf(part, pos);
|
|
20
|
+
if (idx < 0) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (i === 0 && idx !== 0) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
pos = idx + part.length;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
export function matchesAnyPattern(filePath, patterns) {
|
|
31
|
+
return patterns.some((pattern) => matchesGlob(filePath, pattern));
|
|
32
|
+
}
|
|
33
|
+
function validateApiEndpoint(ep) {
|
|
34
|
+
if (!ep || typeof ep !== 'object')
|
|
35
|
+
return null;
|
|
36
|
+
const obj = ep;
|
|
37
|
+
if (typeof obj.method !== 'string' || typeof obj.path !== 'string')
|
|
38
|
+
return null;
|
|
39
|
+
const result = { method: obj.method, path: obj.path };
|
|
40
|
+
if (typeof obj.description === 'string')
|
|
41
|
+
result.description = obj.description;
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
function validateFamily(family) {
|
|
45
|
+
if (!family || typeof family !== 'object') {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const obj = family;
|
|
49
|
+
if (typeof obj.id !== 'string' || !obj.id.trim()) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
// When testType is 'api', routes may contain API paths like "GET /api/users"
|
|
53
|
+
const testType = (obj.testType === 'ui' || obj.testType === 'api' || obj.testType === 'both')
|
|
54
|
+
? obj.testType
|
|
55
|
+
: undefined;
|
|
56
|
+
if (!Array.isArray(obj.routes) || obj.routes.length === 0) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const routes = obj.routes.filter((r) => typeof r === 'string');
|
|
60
|
+
if (routes.length === 0) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const result = {
|
|
64
|
+
id: obj.id.trim(),
|
|
65
|
+
routes,
|
|
66
|
+
};
|
|
67
|
+
if (Array.isArray(obj.pageObjects)) {
|
|
68
|
+
result.pageObjects = obj.pageObjects.filter((v) => typeof v === 'string');
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(obj.components)) {
|
|
71
|
+
result.components = obj.components.filter((v) => typeof v === 'string');
|
|
72
|
+
}
|
|
73
|
+
if (Array.isArray(obj.webappPaths)) {
|
|
74
|
+
result.webappPaths = obj.webappPaths.filter((v) => typeof v === 'string');
|
|
75
|
+
}
|
|
76
|
+
if (Array.isArray(obj.serverPaths)) {
|
|
77
|
+
result.serverPaths = obj.serverPaths.filter((v) => typeof v === 'string');
|
|
78
|
+
}
|
|
79
|
+
if (Array.isArray(obj.specDirs)) {
|
|
80
|
+
result.specDirs = obj.specDirs.filter((v) => typeof v === 'string');
|
|
81
|
+
}
|
|
82
|
+
if (Array.isArray(obj.cypressSpecDirs)) {
|
|
83
|
+
result.cypressSpecDirs = obj.cypressSpecDirs.filter((v) => typeof v === 'string');
|
|
84
|
+
}
|
|
85
|
+
if (Array.isArray(obj.tags)) {
|
|
86
|
+
result.tags = obj.tags.filter((v) => typeof v === 'string');
|
|
87
|
+
}
|
|
88
|
+
if (obj.priority === 'P0' || obj.priority === 'P1' || obj.priority === 'P2') {
|
|
89
|
+
result.priority = obj.priority;
|
|
90
|
+
}
|
|
91
|
+
if (Array.isArray(obj.userFlows)) {
|
|
92
|
+
result.userFlows = obj.userFlows.filter((v) => typeof v === 'string');
|
|
93
|
+
}
|
|
94
|
+
if (Array.isArray(obj.features)) {
|
|
95
|
+
result.features = obj.features
|
|
96
|
+
.map((f) => validateFeature(f))
|
|
97
|
+
.filter((f) => f !== null);
|
|
98
|
+
}
|
|
99
|
+
if (Array.isArray(obj.apiEndpoints)) {
|
|
100
|
+
const endpoints = obj.apiEndpoints
|
|
101
|
+
.map((ep) => validateApiEndpoint(ep))
|
|
102
|
+
.filter((ep) => ep !== null);
|
|
103
|
+
if (endpoints.length > 0)
|
|
104
|
+
result.apiEndpoints = endpoints;
|
|
105
|
+
}
|
|
106
|
+
if (testType) {
|
|
107
|
+
result.testType = testType;
|
|
108
|
+
}
|
|
109
|
+
if (Array.isArray(obj.assertionPatterns)) {
|
|
110
|
+
result.assertionPatterns = validateAssertionPatterns(obj.assertionPatterns);
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
const VALID_ASSERTION_TYPES = [
|
|
115
|
+
'state-change', 'cross-user', 'persistence', 'negative',
|
|
116
|
+
'permission', 'data-integrity', 'error-handling',
|
|
117
|
+
];
|
|
118
|
+
function validateAssertionPatterns(patterns) {
|
|
119
|
+
return patterns
|
|
120
|
+
.filter((p) => p != null && typeof p === 'object')
|
|
121
|
+
.filter((p) => typeof p.type === 'string' && typeof p.pattern === 'string')
|
|
122
|
+
.filter((p) => VALID_ASSERTION_TYPES.includes(p.type))
|
|
123
|
+
.map((p) => ({ type: p.type, pattern: p.pattern }));
|
|
124
|
+
}
|
|
125
|
+
function validateFeature(feature) {
|
|
126
|
+
if (!feature || typeof feature !== 'object') {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
const obj = feature;
|
|
130
|
+
if (typeof obj.id !== 'string' || !obj.id.trim()) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const result = { id: obj.id.trim() };
|
|
134
|
+
if (Array.isArray(obj.routes)) {
|
|
135
|
+
result.routes = obj.routes.filter((v) => typeof v === 'string');
|
|
136
|
+
}
|
|
137
|
+
if (Array.isArray(obj.webappPaths)) {
|
|
138
|
+
result.webappPaths = obj.webappPaths.filter((v) => typeof v === 'string');
|
|
139
|
+
}
|
|
140
|
+
if (Array.isArray(obj.serverPaths)) {
|
|
141
|
+
result.serverPaths = obj.serverPaths.filter((v) => typeof v === 'string');
|
|
142
|
+
}
|
|
143
|
+
if (Array.isArray(obj.specDirs)) {
|
|
144
|
+
result.specDirs = obj.specDirs.filter((v) => typeof v === 'string');
|
|
145
|
+
}
|
|
146
|
+
if (Array.isArray(obj.cypressSpecDirs)) {
|
|
147
|
+
result.cypressSpecDirs = obj.cypressSpecDirs.filter((v) => typeof v === 'string');
|
|
148
|
+
}
|
|
149
|
+
if (Array.isArray(obj.tags)) {
|
|
150
|
+
result.tags = obj.tags.filter((v) => typeof v === 'string');
|
|
151
|
+
}
|
|
152
|
+
if (obj.priority === 'P0' || obj.priority === 'P1' || obj.priority === 'P2') {
|
|
153
|
+
result.priority = obj.priority;
|
|
154
|
+
}
|
|
155
|
+
if (Array.isArray(obj.userFlows)) {
|
|
156
|
+
result.userFlows = obj.userFlows.filter((v) => typeof v === 'string');
|
|
157
|
+
}
|
|
158
|
+
if (Array.isArray(obj.assertionPatterns)) {
|
|
159
|
+
result.assertionPatterns = validateAssertionPatterns(obj.assertionPatterns);
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
export function loadRouteFamilyManifest(testsRoot, config) {
|
|
164
|
+
const candidates = [];
|
|
165
|
+
if (config?.manifestPath) {
|
|
166
|
+
candidates.push(config.manifestPath);
|
|
167
|
+
}
|
|
168
|
+
candidates.push(join(testsRoot, '.e2e-ai-agents', 'route-families.json'));
|
|
169
|
+
for (const candidate of candidates) {
|
|
170
|
+
try {
|
|
171
|
+
if (!existsSync(candidate)) {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const mtimeMs = statSync(candidate).mtimeMs;
|
|
175
|
+
const cached = manifestCache.get(candidate);
|
|
176
|
+
if (cached && cached.mtimeMs === mtimeMs && cached.manifest) {
|
|
177
|
+
return cached.manifest;
|
|
178
|
+
}
|
|
179
|
+
const raw = JSON.parse(readFileSync(candidate, 'utf-8'));
|
|
180
|
+
if (!raw.families || !Array.isArray(raw.families)) {
|
|
181
|
+
manifestCache.set(candidate, { mtimeMs, manifest: null });
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const families = raw.families
|
|
185
|
+
.map((f) => validateFamily(f))
|
|
186
|
+
.filter((f) => f !== null);
|
|
187
|
+
if (families.length === 0) {
|
|
188
|
+
manifestCache.set(candidate, { mtimeMs, manifest: null });
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const manifest = { families, source: candidate };
|
|
192
|
+
manifestCache.set(candidate, { mtimeMs, manifest });
|
|
193
|
+
return manifest;
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (config?.strict) {
|
|
200
|
+
logger.warn('Route family manifest not found. Create .e2e-ai-agents/route-families.json to enable family-level routing hints.');
|
|
201
|
+
}
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
export function bindFilesToFamilies(changedFiles, manifest) {
|
|
205
|
+
return changedFiles.map((file) => {
|
|
206
|
+
const normalized = file.replace(/\\/g, '/');
|
|
207
|
+
const bindings = [];
|
|
208
|
+
for (const family of manifest.families) {
|
|
209
|
+
const featureBindings = [];
|
|
210
|
+
// Check feature-level first (more specific)
|
|
211
|
+
if (family.features) {
|
|
212
|
+
for (const feature of family.features) {
|
|
213
|
+
const featurePatterns = [
|
|
214
|
+
...(feature.webappPaths || []),
|
|
215
|
+
...(feature.serverPaths || []),
|
|
216
|
+
...(feature.specDirs || []),
|
|
217
|
+
];
|
|
218
|
+
if (featurePatterns.length > 0 && matchesAnyPattern(normalized, featurePatterns)) {
|
|
219
|
+
featureBindings.push({ family: family.id, feature: feature.id });
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (featureBindings.length > 0) {
|
|
224
|
+
bindings.push(...featureBindings);
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
// Fall back to family-level patterns
|
|
228
|
+
const familyPatterns = [
|
|
229
|
+
...(family.webappPaths || []),
|
|
230
|
+
...(family.serverPaths || []),
|
|
231
|
+
...(family.specDirs || []),
|
|
232
|
+
...(family.cypressSpecDirs || []),
|
|
233
|
+
];
|
|
234
|
+
if (familyPatterns.length > 0 && matchesAnyPattern(normalized, familyPatterns)) {
|
|
235
|
+
bindings.push({ family: family.id });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return { file: normalized, bindings };
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
export function getFamilyById(manifest, familyId) {
|
|
242
|
+
return manifest.families.find((f) => f.id === familyId);
|
|
243
|
+
}
|
|
244
|
+
export function getFeatureById(family, featureId) {
|
|
245
|
+
return family.features?.find((f) => f.id === featureId);
|
|
246
|
+
}
|
|
247
|
+
export function getSpecDirsForBinding(manifest, binding) {
|
|
248
|
+
const family = getFamilyById(manifest, binding.family);
|
|
249
|
+
if (!family) {
|
|
250
|
+
return [];
|
|
251
|
+
}
|
|
252
|
+
if (binding.feature) {
|
|
253
|
+
const feature = getFeatureById(family, binding.feature);
|
|
254
|
+
// An explicitly declared specDirs (even []) is intentional — don't fall back to family.
|
|
255
|
+
if (feature && feature.specDirs !== undefined) {
|
|
256
|
+
return feature.specDirs;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return family.specDirs || [];
|
|
260
|
+
}
|
|
261
|
+
export function getCypressSpecDirsForBinding(manifest, binding) {
|
|
262
|
+
const family = getFamilyById(manifest, binding.family);
|
|
263
|
+
if (!family) {
|
|
264
|
+
return [];
|
|
265
|
+
}
|
|
266
|
+
if (binding.feature) {
|
|
267
|
+
const feature = getFeatureById(family, binding.feature);
|
|
268
|
+
// An explicitly declared cypressSpecDirs (even []) is intentional — don't fall back to family.
|
|
269
|
+
if (feature && feature.cypressSpecDirs !== undefined) {
|
|
270
|
+
return feature.cypressSpecDirs;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return family.cypressSpecDirs || [];
|
|
274
|
+
}
|
|
275
|
+
export function getPriorityForBinding(manifest, binding) {
|
|
276
|
+
const family = getFamilyById(manifest, binding.family);
|
|
277
|
+
if (!family) {
|
|
278
|
+
return 'P2';
|
|
279
|
+
}
|
|
280
|
+
if (binding.feature) {
|
|
281
|
+
const feature = getFeatureById(family, binding.feature);
|
|
282
|
+
if (feature?.priority) {
|
|
283
|
+
return feature.priority;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return family.priority || 'P2';
|
|
287
|
+
}
|
|
288
|
+
export function getUserFlowsForBinding(manifest, binding) {
|
|
289
|
+
const family = getFamilyById(manifest, binding.family);
|
|
290
|
+
if (!family) {
|
|
291
|
+
return [];
|
|
292
|
+
}
|
|
293
|
+
if (binding.feature) {
|
|
294
|
+
const feature = getFeatureById(family, binding.feature);
|
|
295
|
+
if (feature?.userFlows && feature.userFlows.length > 0) {
|
|
296
|
+
return feature.userFlows;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return family.userFlows || [];
|
|
300
|
+
}
|
|
301
|
+
export function getRoutesForBinding(manifest, binding) {
|
|
302
|
+
const family = getFamilyById(manifest, binding.family);
|
|
303
|
+
if (!family) {
|
|
304
|
+
return [];
|
|
305
|
+
}
|
|
306
|
+
if (binding.feature) {
|
|
307
|
+
const feature = getFeatureById(family, binding.feature);
|
|
308
|
+
if (feature?.routes && feature.routes.length > 0) {
|
|
309
|
+
return feature.routes;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return family.routes;
|
|
313
|
+
}
|
|
314
|
+
export function getAssertionPatternsForBinding(manifest, binding) {
|
|
315
|
+
const family = getFamilyById(manifest, binding.family);
|
|
316
|
+
if (!family) {
|
|
317
|
+
return [];
|
|
318
|
+
}
|
|
319
|
+
if (binding.feature) {
|
|
320
|
+
const feature = getFeatureById(family, binding.feature);
|
|
321
|
+
if (feature?.assertionPatterns && feature.assertionPatterns.length > 0) {
|
|
322
|
+
return feature.assertionPatterns;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return family.assertionPatterns || [];
|
|
326
|
+
}
|
|
327
|
+
export function clearManifestCache() {
|
|
328
|
+
manifestCache.clear();
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Build heuristic route families from changed files when no manifest exists.
|
|
332
|
+
* Groups files by their top-level directory to create rough family groupings.
|
|
333
|
+
* Results are lower confidence but allow analysis to proceed without training.
|
|
334
|
+
*/
|
|
335
|
+
export function buildHeuristicFamilies(changedFiles, testsRoot) {
|
|
336
|
+
const dirGroups = new Map();
|
|
337
|
+
for (const file of changedFiles) {
|
|
338
|
+
const normalized = file.replace(/\\/g, '/');
|
|
339
|
+
const parts = normalized.split('/');
|
|
340
|
+
// Use the first meaningful directory segment as the family ID
|
|
341
|
+
// Skip common prefixes like 'src/', 'app/', 'lib/'
|
|
342
|
+
const skipDirs = new Set(['src', 'app', 'lib', 'packages', 'components']);
|
|
343
|
+
let familyDir = parts[0] || 'root';
|
|
344
|
+
if (skipDirs.has(familyDir) && parts.length > 1) {
|
|
345
|
+
familyDir = parts[1];
|
|
346
|
+
}
|
|
347
|
+
// Normalize to a clean family name
|
|
348
|
+
familyDir = familyDir.replace(/\.[^.]+$/, ''); // strip file extensions for single files
|
|
349
|
+
if (!dirGroups.has(familyDir)) {
|
|
350
|
+
dirGroups.set(familyDir, []);
|
|
351
|
+
}
|
|
352
|
+
dirGroups.get(familyDir).push(normalized);
|
|
353
|
+
}
|
|
354
|
+
const families = [];
|
|
355
|
+
for (const [dir, files] of dirGroups) {
|
|
356
|
+
families.push({
|
|
357
|
+
id: dir,
|
|
358
|
+
routes: [`/${dir}`],
|
|
359
|
+
webappPaths: files.map((f) => `${f}*`),
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
logger.info(`Built ${families.length} heuristic families from ${changedFiles.length} changed files (no route-families.json found)`);
|
|
363
|
+
logger.info('Tip: Run `impact-gate train` to generate a proper route-families manifest for better accuracy.');
|
|
364
|
+
return {
|
|
365
|
+
families,
|
|
366
|
+
source: 'heuristic',
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Serialize a RouteFamilyManifest to clean JSON, stripping empty optional fields.
|
|
371
|
+
*/
|
|
372
|
+
export function serializeManifest(manifest) {
|
|
373
|
+
const output = {
|
|
374
|
+
families: manifest.families.map((f) => {
|
|
375
|
+
const cleaned = { ...f };
|
|
376
|
+
const optionalArrays = [
|
|
377
|
+
'pageObjects', 'components', 'webappPaths', 'serverPaths',
|
|
378
|
+
'specDirs', 'cypressSpecDirs', 'tags', 'userFlows', 'features', 'apiEndpoints', 'assertionPatterns',
|
|
379
|
+
];
|
|
380
|
+
for (const key of optionalArrays) {
|
|
381
|
+
if (!cleaned[key] || (Array.isArray(cleaned[key]) && cleaned[key].length === 0)) {
|
|
382
|
+
delete cleaned[key];
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (!cleaned.priority)
|
|
386
|
+
delete cleaned.priority;
|
|
387
|
+
if (!cleaned.testType)
|
|
388
|
+
delete cleaned.testType;
|
|
389
|
+
return cleaned;
|
|
390
|
+
}),
|
|
391
|
+
};
|
|
392
|
+
return JSON.stringify(output, null, 2) + '\n';
|
|
393
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
2
|
+
// See LICENSE.txt for license information.
|
|
3
|
+
import { existsSync, readFileSync, readdirSync } from 'fs';
|
|
4
|
+
import { join, relative } from 'path';
|
|
5
|
+
function extractTestTitles(content) {
|
|
6
|
+
const titles = [];
|
|
7
|
+
const testRe = /\btest\s*\(\s*(['"`])((?:(?!\1).|\\.)*)\1/g;
|
|
8
|
+
let match;
|
|
9
|
+
while ((match = testRe.exec(content)) !== null) {
|
|
10
|
+
const title = match[2].trim();
|
|
11
|
+
if (title) {
|
|
12
|
+
titles.push(title);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return titles;
|
|
16
|
+
}
|
|
17
|
+
function extractTags(content) {
|
|
18
|
+
const tags = new Set();
|
|
19
|
+
const singleTagRe = /\btag:\s*['"`](@[\w-]+)['"`]/g;
|
|
20
|
+
let match;
|
|
21
|
+
while ((match = singleTagRe.exec(content)) !== null) {
|
|
22
|
+
tags.add(match[1]);
|
|
23
|
+
}
|
|
24
|
+
const arrayTagRe = /\btag:\s*\[([^\]]*)\]/g;
|
|
25
|
+
while ((match = arrayTagRe.exec(content)) !== null) {
|
|
26
|
+
const inner = match[1];
|
|
27
|
+
const tagRe = /['"`](@[\w-]+)['"`]/g;
|
|
28
|
+
let tagMatch;
|
|
29
|
+
while ((tagMatch = tagRe.exec(inner)) !== null) {
|
|
30
|
+
tags.add(tagMatch[1]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return Array.from(tags);
|
|
34
|
+
}
|
|
35
|
+
function scanSpecDir(dir, testsRoot) {
|
|
36
|
+
const entries = [];
|
|
37
|
+
if (!existsSync(dir)) {
|
|
38
|
+
return entries;
|
|
39
|
+
}
|
|
40
|
+
const items = readdirSync(dir, { withFileTypes: true });
|
|
41
|
+
for (const item of items) {
|
|
42
|
+
const fullPath = join(dir, item.name);
|
|
43
|
+
if (item.isDirectory()) {
|
|
44
|
+
entries.push(...scanSpecDir(fullPath, testsRoot));
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (!item.name.endsWith('.spec.ts') && !item.name.endsWith('.spec.tsx')) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const content = readFileSync(fullPath, 'utf-8');
|
|
52
|
+
entries.push({
|
|
53
|
+
path: fullPath,
|
|
54
|
+
relativePath: relative(testsRoot, fullPath).replace(/\\/g, '/'),
|
|
55
|
+
testTitles: extractTestTitles(content),
|
|
56
|
+
tags: extractTags(content),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return entries;
|
|
64
|
+
}
|
|
65
|
+
function bindSpecToFamily(spec, manifest) {
|
|
66
|
+
const specPath = spec.relativePath;
|
|
67
|
+
for (const family of manifest.families) {
|
|
68
|
+
if (family.features) {
|
|
69
|
+
for (const feature of family.features) {
|
|
70
|
+
if (feature.specDirs?.some((dir) => specPath.startsWith(dir))) {
|
|
71
|
+
spec.familyId = family.id;
|
|
72
|
+
spec.featureId = feature.id;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (family.specDirs?.some((dir) => specPath.startsWith(dir))) {
|
|
78
|
+
spec.familyId = family.id;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (family.tags && spec.tags.some((t) => family.tags.includes(t))) {
|
|
82
|
+
spec.familyId = family.id;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function buildSpecIndex(testsRoot, _specPatterns, manifest) {
|
|
88
|
+
const specsDir = join(testsRoot, 'specs');
|
|
89
|
+
const specs = scanSpecDir(specsDir, testsRoot);
|
|
90
|
+
if (manifest) {
|
|
91
|
+
for (const spec of specs) {
|
|
92
|
+
bindSpecToFamily(spec, manifest);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
specs,
|
|
97
|
+
indexedAt: new Date().toISOString(),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export function getSpecsForFamily(index, familyId, featureId) {
|
|
101
|
+
return index.specs.filter((s) => {
|
|
102
|
+
if (s.familyId !== familyId) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (featureId && s.featureId && s.featureId !== featureId) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
export function getSpecByPath(index, relativePath) {
|
|
112
|
+
return index.specs.find((s) => s.relativePath === relativePath);
|
|
113
|
+
}
|
|
114
|
+
export function formatSpecsForPrompt(specs) {
|
|
115
|
+
return specs
|
|
116
|
+
.map((s) => {
|
|
117
|
+
const titles = s.testTitles.map((t) => ` - ${t}`).join('\n');
|
|
118
|
+
const tagsStr = s.tags.length > 0 ? ` [${s.tags.join(', ')}]` : '';
|
|
119
|
+
return `${s.relativePath}${tagsStr}\n${titles}`;
|
|
120
|
+
})
|
|
121
|
+
.join('\n\n');
|
|
122
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
2
|
+
// See LICENSE.txt for license information.
|
|
3
|
+
/**
|
|
4
|
+
* Structured logging system.
|
|
5
|
+
* Environment variable: LOG_LEVEL (ERROR, WARN, INFO, DEBUG)
|
|
6
|
+
*/
|
|
7
|
+
export var LogLevel;
|
|
8
|
+
(function (LogLevel) {
|
|
9
|
+
LogLevel[LogLevel["ERROR"] = 0] = "ERROR";
|
|
10
|
+
LogLevel[LogLevel["WARN"] = 1] = "WARN";
|
|
11
|
+
LogLevel[LogLevel["INFO"] = 2] = "INFO";
|
|
12
|
+
LogLevel[LogLevel["DEBUG"] = 3] = "DEBUG";
|
|
13
|
+
})(LogLevel || (LogLevel = {}));
|
|
14
|
+
/**
|
|
15
|
+
* Get log level from environment variable
|
|
16
|
+
*/
|
|
17
|
+
function getLogLevelFromEnv() {
|
|
18
|
+
const level = process.env.LOG_LEVEL?.toUpperCase() || 'INFO';
|
|
19
|
+
switch (level) {
|
|
20
|
+
case 'ERROR':
|
|
21
|
+
return LogLevel.ERROR;
|
|
22
|
+
case 'WARN':
|
|
23
|
+
return LogLevel.WARN;
|
|
24
|
+
case 'INFO':
|
|
25
|
+
return LogLevel.INFO;
|
|
26
|
+
case 'DEBUG':
|
|
27
|
+
return LogLevel.DEBUG;
|
|
28
|
+
default:
|
|
29
|
+
return LogLevel.INFO;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Convert log level to string
|
|
34
|
+
*/
|
|
35
|
+
function logLevelToString(level) {
|
|
36
|
+
switch (level) {
|
|
37
|
+
case LogLevel.ERROR:
|
|
38
|
+
return 'ERROR';
|
|
39
|
+
case LogLevel.WARN:
|
|
40
|
+
return 'WARN';
|
|
41
|
+
case LogLevel.INFO:
|
|
42
|
+
return 'INFO';
|
|
43
|
+
case LogLevel.DEBUG:
|
|
44
|
+
return 'DEBUG';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export class Logger {
|
|
48
|
+
constructor(minLevel) {
|
|
49
|
+
this.level = minLevel ?? getLogLevelFromEnv();
|
|
50
|
+
this.jsonMode = process.env.LOG_FORMAT?.toLowerCase() === 'json';
|
|
51
|
+
}
|
|
52
|
+
error(message, context) {
|
|
53
|
+
if (this.level >= LogLevel.ERROR) {
|
|
54
|
+
this.log(LogLevel.ERROR, message, context);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
warn(message, context) {
|
|
58
|
+
if (this.level >= LogLevel.WARN) {
|
|
59
|
+
this.log(LogLevel.WARN, message, context);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
info(message, context) {
|
|
63
|
+
if (this.level >= LogLevel.INFO) {
|
|
64
|
+
this.log(LogLevel.INFO, message, context);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
debug(message, context) {
|
|
68
|
+
if (this.level >= LogLevel.DEBUG) {
|
|
69
|
+
this.log(LogLevel.DEBUG, message, context);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
setLevel(level) {
|
|
73
|
+
this.level = level;
|
|
74
|
+
}
|
|
75
|
+
setJsonMode(enabled) {
|
|
76
|
+
this.jsonMode = enabled;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Start a timer for measuring duration of an operation.
|
|
80
|
+
* Returns an object with `end()` that logs at DEBUG level and returns elapsed ms.
|
|
81
|
+
*/
|
|
82
|
+
timer(label) {
|
|
83
|
+
const start = performance.now();
|
|
84
|
+
return {
|
|
85
|
+
end: () => {
|
|
86
|
+
const elapsed = Math.round(performance.now() - start);
|
|
87
|
+
this.debug(`${label} completed`, { durationMs: elapsed });
|
|
88
|
+
return elapsed;
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
log(level, message, context) {
|
|
93
|
+
const timestamp = new Date().toISOString();
|
|
94
|
+
const levelStr = logLevelToString(level);
|
|
95
|
+
let output;
|
|
96
|
+
if (this.jsonMode) {
|
|
97
|
+
const entry = { ts: timestamp, level: levelStr, msg: message };
|
|
98
|
+
if (context)
|
|
99
|
+
entry.ctx = context;
|
|
100
|
+
output = JSON.stringify(entry);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const contextStr = context ? ` ${JSON.stringify(context)}` : '';
|
|
104
|
+
output = `[${timestamp}] [${levelStr}] ${message}${contextStr}`;
|
|
105
|
+
}
|
|
106
|
+
if (level <= LogLevel.WARN) {
|
|
107
|
+
console.error(output);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
console.log(output);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Global logger instance
|
|
115
|
+
export const logger = new Logger();
|