@teevee98/synapse-hub 0.0.0-stage → 3.8.3
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/.agents/agents/api-engineer.md +67 -0
- package/.agents/agents/failure-analyst.md +75 -0
- package/.agents/agents/live-explorer.md +70 -0
- package/.agents/agents/orchestrator.md +104 -0
- package/.agents/agents/perf-engineer.md +74 -0
- package/.agents/agents/pom-crafter.md +112 -0
- package/.agents/agents/quality-gatekeeper.md +87 -0
- package/.agents/agents/test-designer.md +73 -0
- package/.agents/agents/test-runner.md +67 -0
- package/.agents/rules/author-integrity-guard.md +33 -0
- package/.agents/rules/communication-style.md +18 -0
- package/.agents/rules/context-engineering.md +37 -0
- package/.agents/rules/git-push-protocol.md +33 -0
- package/.agents/rules/graphify.md +14 -0
- package/.agents/rules/lessons-learned.md +25 -0
- package/.agents/rules/mandatory-playwright-live.md +25 -0
- package/.agents/rules/mobile_appium_rules.md +43 -0
- package/.agents/rules/performance_testing_rules.md +35 -0
- package/.agents/rules/skill-precedence.md +29 -0
- package/.agents/rules/systematic-debugging.md +36 -0
- package/.agents/skills/actor-qa-swarm/SKILL.md +77 -0
- package/.agents/skills/actor-qa-swarm/examples/broker_sharding_sample.json +12 -0
- package/.agents/skills/agent-orchestration-multi-agent-optimize/SKILL.md +88 -0
- package/.agents/skills/agent-orchestration-multi-agent-optimize/examples/swarm_workload_config.json +15 -0
- package/.agents/skills/agentless-qa-repair/SKILL.md +69 -0
- package/.agents/skills/agentless-qa-repair/examples/healing_report_sample.json +17 -0
- package/.agents/skills/agentless-qa-repair/examples/three_phase_repair_workflow.md +40 -0
- package/.agents/skills/antigravity-test-sentinel/SKILL.md +63 -0
- package/.agents/skills/antigravity-test-sentinel/examples/dod_gate_policy.json +11 -0
- package/.agents/skills/antigravity-test-sentinel/examples/sprint_dod_enforcement.md +47 -0
- package/.agents/skills/api-network-mocking-interception/SKILL.md +142 -0
- package/.agents/skills/api-network-mocking-interception/examples/network_route_stub.json +9 -0
- package/.agents/skills/api-spec-to-e2e-matrix/SKILL.md +80 -0
- package/.agents/skills/api-spec-to-e2e-matrix/examples/sample_openapi.json +19 -0
- package/.agents/skills/architecture-decision-records/SKILL.md +64 -0
- package/.agents/skills/architecture-decision-records/examples/0001-record-architecture-decisions.md +12 -0
- package/.agents/skills/auth-session-and-cookie-manager/SKILL.md +75 -0
- package/.agents/skills/auth-session-and-cookie-manager/examples/multi_role_auth_matrix.md +70 -0
- package/.agents/skills/auth-session-and-cookie-manager/examples/storage_state_sample.json +11 -0
- package/.agents/skills/backend-load-and-stress-patterns/SKILL.md +85 -0
- package/.agents/skills/backend-load-and-stress-patterns/examples/k6_load_test_sample.js +13 -0
- package/.agents/skills/backend-load-and-stress-patterns/references/k6_load_template.js +82 -0
- package/.agents/skills/bats-testing-patterns/SKILL.md +100 -0
- package/.agents/skills/bats-testing-patterns/examples/cli_runner_test.bats +6 -0
- package/.agents/skills/bats-testing-patterns/resources/implementation-playbook.md +614 -0
- package/.agents/skills/clean-pom-crafter/SKILL.md +110 -0
- package/.agents/skills/clean-pom-crafter/examples/standard_test_case.groovy +28 -0
- package/.agents/skills/clean-pom-crafter/references/pom_patterns.groovy +138 -0
- package/.agents/skills/code-refactoring-refactor-clean/SKILL.md +64 -0
- package/.agents/skills/code-refactoring-refactor-clean/examples/refactored_page_sample.groovy +9 -0
- package/.agents/skills/code-refactoring-refactor-clean/examples/refactored_playwright_pom.ts +52 -0
- package/.agents/skills/code-refactoring-refactor-clean/resources/implementation-playbook.md +881 -0
- package/.agents/skills/consumer-driven-contract-testing/SKILL.md +147 -0
- package/.agents/skills/consumer-driven-contract-testing/examples/order_service_pact.json +45 -0
- package/.agents/skills/db-state-verifier-and-seeder/SKILL.md +123 -0
- package/.agents/skills/db-state-verifier-and-seeder/examples/db_fixture_seed.json +12 -0
- package/.agents/skills/e2e-testing-patterns/SKILL.md +103 -0
- package/.agents/skills/e2e-testing-patterns/examples/playwright_sharded_config.ts +12 -0
- package/.agents/skills/e2e-testing-patterns/resources/implementation-playbook.md +522 -0
- package/.agents/skills/event-stream-qa-orchestrator/SKILL.md +79 -0
- package/.agents/skills/event-stream-qa-orchestrator/examples/timeline_sample.jsonl +2 -0
- package/.agents/skills/failure-autopsy-and-healing/SKILL.md +66 -0
- package/.agents/skills/failure-autopsy-and-healing/examples/closed_loop_healing_walkthrough.md +48 -0
- package/.agents/skills/failure-autopsy-and-healing/examples/sample_junit_failure.xml +8 -0
- package/.agents/skills/failure-autopsy-and-healing/references/healing_matrix.md +64 -0
- package/.agents/skills/failure-autopsy-and-healing/references/qa_investigation_protocol.md +56 -0
- package/.agents/skills/failure-autopsy-and-healing/scripts/triage_failures.sh +83 -0
- package/.agents/skills/file-and-report-validator/SKILL.md +90 -0
- package/.agents/skills/file-and-report-validator/examples/sample_export_schema.json +14 -0
- package/.agents/skills/flaky-test-sentinel-and-quarantine/SKILL.md +114 -0
- package/.agents/skills/flaky-test-sentinel-and-quarantine/examples/quarantine_registry.json +11 -0
- package/.agents/skills/gherkin-to-suite/SKILL.md +103 -0
- package/.agents/skills/gherkin-to-suite/examples/checkout.feature +39 -0
- package/.agents/skills/gherkin-to-suite/examples/suite_report_sample.json +334 -0
- package/.agents/skills/github-actions-templates/SKILL.md +77 -0
- package/.agents/skills/github-actions-templates/examples/matrix_test_pipeline.yml +8 -0
- package/.agents/skills/graphify-impact-analyzer/SKILL.md +76 -0
- package/.agents/skills/graphify-impact-analyzer/examples/dependency_blast_radius.json +8 -0
- package/.agents/skills/katalon-cli-runner/SKILL.md +76 -0
- package/.agents/skills/katalon-cli-runner/examples/headless_kre_exec.sh +3 -0
- package/.agents/skills/katalon-cli-runner/references/groovy-patterns.md +209 -0
- package/.agents/skills/katalon-cli-runner/references/katalon-api.md +155 -0
- package/.agents/skills/katalon-cli-runner/references/runner_commands.md +67 -0
- package/.agents/skills/lam-script-generator/SKILL.md +123 -0
- package/.agents/skills/lam-script-generator/examples/user_story_sample.md +8 -0
- package/.agents/skills/lean-code-ladder/SKILL.md +94 -0
- package/.agents/skills/lean-code-ladder/examples/ladder_walkthrough.md +37 -0
- package/.agents/skills/lean-impact-scoreboard/SKILL.md +48 -0
- package/.agents/skills/lean-impact-scoreboard/examples/sample_benchmark_gain.md +20 -0
- package/.agents/skills/lean-impact-scoreboard/examples/sample_scoreboard.md +15 -0
- package/.agents/skills/meta-prompt-crafter/SKILL.md +107 -0
- package/.agents/skills/meta-prompt-crafter/examples/qa_prompt_template.md +35 -0
- package/.agents/skills/mipro-prompt-compiler/SKILL.md +59 -0
- package/.agents/skills/mipro-prompt-compiler/examples/compiled_module_sample.json +22 -0
- package/.agents/skills/mipro-prompt-compiler/examples/dspy_assertion_optimizer_case.md +46 -0
- package/.agents/skills/mobile-appium-som/SKILL.md +88 -0
- package/.agents/skills/mobile-appium-som/examples/BaseScreen.java +88 -0
- package/.agents/skills/mobile-appium-som/examples/LoginScreen.java +46 -0
- package/.agents/skills/mobile-appium-som/examples/TC_MobileLogin.java +43 -0
- package/.agents/skills/persistent-planning-files/SKILL.md +108 -0
- package/.agents/skills/persistent-planning-files/examples/task_plan_example.md +56 -0
- package/.agents/skills/playwright-live-interaction/SKILL.md +131 -0
- package/.agents/skills/playwright-live-interaction/examples/live_probe_script.js +5 -0
- package/.agents/skills/playwright-live-interaction/references/advanced_superpowers.md +160 -0
- package/.agents/skills/playwright-live-interaction/references/compact_accessibility_snapshots.md +75 -0
- package/.agents/skills/playwright-live-interaction/references/recipes.md +388 -0
- package/.agents/skills/playwright-live-interaction/references/swarm_orchestration.md +134 -0
- package/.agents/skills/playwright-webapp-testing/SKILL.md +93 -0
- package/.agents/skills/playwright-webapp-testing/examples/server_lifecycle_playwright.py +63 -0
- package/.agents/skills/qa-aci-interface/SKILL.md +67 -0
- package/.agents/skills/qa-aci-interface/examples/surgical_code_window_walkthrough.md +40 -0
- package/.agents/skills/qa-aci-interface/examples/surgical_edit_sample.json +12 -0
- package/.agents/skills/qa-memory-os/SKILL.md +80 -0
- package/.agents/skills/qa-memory-os/examples/archival_memory_sample.json +21 -0
- package/.agents/skills/rbt-manual-testing/SKILL.md +137 -0
- package/.agents/skills/rbt-manual-testing/examples/checkout_rbt_manual_suite.md +25 -0
- package/.agents/skills/rbt-manual-testing/references/field_validation_checklist.md +29 -0
- package/.agents/skills/repo-quality-audit/SKILL.md +68 -0
- package/.agents/skills/repo-quality-audit/examples/sample_audit_walkthrough.md +15 -0
- package/.agents/skills/repo-quality-audit/examples/sample_repo_audit.md +33 -0
- package/.agents/skills/review-spec/SKILL.md +60 -0
- package/.agents/skills/review-spec/examples/pocock_grilling_decision_rubric.md +40 -0
- package/.agents/skills/review-spec/examples/sample_spec_review.md +33 -0
- package/.agents/skills/security-dast-sentinel/SKILL.md +119 -0
- package/.agents/skills/security-dast-sentinel/examples/dast_scan_config.json +10 -0
- package/.agents/skills/security-dast-sentinel/references/AI-AND-LLM.md +113 -0
- package/.agents/skills/security-dast-sentinel/references/ATTACK-CLASSES.md +89 -0
- package/.agents/skills/security-dast-sentinel/references/dast_recipes.ts +33 -0
- package/.agents/skills/self-healing-locator/SKILL.md +86 -0
- package/.agents/skills/self-healing-locator/examples/aom_diff_sample.json +16 -0
- package/.agents/skills/senior-code-review/SKILL.md +108 -0
- package/.agents/skills/senior-code-review/examples/sample_review_walkthrough.md +29 -0
- package/.agents/skills/skillspector-security-guard/SKILL.md +57 -0
- package/.agents/skills/skillspector-security-guard/examples/audit_threat_vectors_report.json +35 -0
- package/.agents/skills/skillspector-security-guard/examples/safe_mcp_config.json +12 -0
- package/.agents/skills/surgical-coding-principles/SKILL.md +89 -0
- package/.agents/skills/surgical-coding-principles/examples/surgical_vs_scope_creep.md +46 -0
- package/.agents/skills/synthetic-test-data-generator/SKILL.md +135 -0
- package/.agents/skills/synthetic-test-data-generator/examples/idempotent_data_recipe.json +9 -0
- package/.agents/skills/systematic-debugging/SKILL.md +100 -0
- package/.agents/skills/systematic-debugging/examples/four_phase_case.md +44 -0
- package/.agents/skills/technical-debt-harvester/SKILL.md +70 -0
- package/.agents/skills/technical-debt-harvester/examples/sample_debt_ledger.md +25 -0
- package/.agents/skills/technical-debt-harvester/examples/sample_ledger_output.md +20 -0
- package/.agents/skills/test-driven-development/SKILL.md +114 -0
- package/.agents/skills/test-driven-development/examples/red_green_refactor_qa.md +78 -0
- package/.agents/skills/token-and-context-optimizer/SKILL.md +70 -0
- package/.agents/skills/token-and-context-optimizer/examples/distilled_log_sample.txt +3 -0
- package/.agents/skills/token-and-context-optimizer/references/context_engineering_guide.md +49 -0
- package/.agents/skills/tot-exploratory-testing/SKILL.md +59 -0
- package/.agents/skills/tot-exploratory-testing/examples/payment_gateway_tot_tree.json +62 -0
- package/.agents/skills/tot-exploratory-testing/examples/tot_graph_sample.json +35 -0
- package/.agents/skills/verification-before-completion/SKILL.md +100 -0
- package/.agents/skills/verification-before-completion/examples/evidence_log_example.md +46 -0
- package/.agents/skills/visual-regression-sentinel/SKILL.md +82 -0
- package/.agents/skills/visual-regression-sentinel/examples/visual_mask_rules.json +9 -0
- package/.agents/skills/wcag-audit-patterns/SKILL.md +77 -0
- package/.agents/skills/wcag-audit-patterns/examples/wcag_compliance_checklist.json +10 -0
- package/.agents/skills/wcag-audit-patterns/resources/implementation-playbook.md +541 -0
- package/.agents/skills/web-agent-gym-benchmarking/SKILL.md +62 -0
- package/.agents/skills/web-agent-gym-benchmarking/examples/benchmark_report_sample.json +22 -0
- package/.agents/skills/web-agent-gym-benchmarking/examples/enterprise_tasks_suite.json +38 -0
- package/.agents/skills/web-vitals-and-performance-profiler/SKILL.md +65 -0
- package/.agents/skills/web-vitals-and-performance-profiler/examples/cwv_budget_policy.json +6 -0
- package/.agents/skills/web-vitals-and-performance-profiler/examples/playwright_cwv_profiler_fixture.ts +118 -0
- package/.agents/templates/completion_report.md +57 -0
- package/.agents/workflows/analyze_requirement_document.md +18 -0
- package/.agents/workflows/export_testcases_excel.md +32 -0
- package/.agents/workflows/generate_combinatorial_test_data.md +28 -0
- package/.agents/workflows/generate_cross_module_test_plan.md +37 -0
- package/.agents/workflows/generate_manual_testcases_rbt.md +56 -0
- package/.agents/workflows/generate_requirements_from_website.md +25 -0
- package/.agents/workflows/generate_testcases_from_requirements.md +21 -0
- package/.agents/workflows/graphify.md +10 -0
- package/.agents/workflows/test-impact.md +15 -0
- package/.agents/workflows/verify.md +34 -0
- package/.cursor/rules/agents.mdc +16 -0
- package/.cursor/rules/language.mdc +7 -0
- package/.cursor/rules/synapse-qa.mdc +24 -0
- package/.cursorrules +27 -0
- package/.dockerignore +53 -0
- package/.pre-commit-hooks.yaml +14 -0
- package/.windsurfrules +26 -0
- package/AGENTS.md +86 -0
- package/CLAUDE.md +54 -0
- package/Dockerfile +81 -0
- package/LICENSE +52 -0
- package/NOTICE +264 -0
- package/README.en.md +171 -0
- package/README.md +170 -2
- package/action.yml +51 -0
- package/agentskills.json +16 -0
- package/bin/agent-qa.js +138 -0
- package/docker-compose.yml +74 -0
- package/docs/ARCHITECTURE.en.md +198 -0
- package/docs/ARCHITECTURE.md +199 -0
- package/docs/CI_CD_INTEGRATION.en.md +170 -0
- package/docs/CI_CD_INTEGRATION.md +170 -0
- package/docs/CLI_REFERENCE.en.md +174 -0
- package/docs/CLI_REFERENCE.md +176 -0
- package/docs/CONTRIBUTING.en.md +49 -0
- package/docs/CONTRIBUTING.md +49 -0
- package/docs/PERFORMANCE_AUDIT_REPORT.md +783 -0
- package/docs/PLUGIN_DEVELOPMENT_GUIDE.md +127 -0
- package/docs/QUALITY_GATES.en.md +118 -0
- package/docs/QUALITY_GATES.md +118 -0
- package/docs/TOKEN_QUOTA_PLAYBOOK.md +41 -0
- package/docs/TOOL_CATALOG.md +129 -0
- package/docs/adopted-ecosystem-tools.md +96 -0
- package/docs/research/EXTERNAL_AGENT_SKILLS_SURVEY.md +1062 -0
- package/docs/research/agent_skill_training_analysis.md +1358 -0
- package/docs/schemas/synapse.config.schema.json +86 -0
- package/package.json +94 -4
- package/plugin.json +31 -0
- package/scripts/generate_skill_examples.py +244 -0
- package/scripts/install.ps1 +112 -0
- package/scripts/install_global_plugin.ps1 +94 -0
- package/scripts/install_global_plugin.sh +49 -0
- package/scripts/lint_skills.ps1 +57 -0
- package/scripts/package_dist.py +337 -0
- package/scripts/setup.sh +59 -0
- package/scripts/update_hub.ps1 +19 -0
- package/scripts/update_hub.sh +15 -0
- package/skills_manifest.json +854 -0
- package/synapse.config.json +31 -0
- package/templates/PROJECT_AI_GUIDE_TEMPLATE.md +111 -0
- package/templates/PROJECT_STATE_TEMPLATE.md +20 -0
- package/templates/ai_bridges/CLAUDE.md +54 -0
- package/templates/ai_bridges/copilot-instructions.md +20 -0
- package/templates/ai_bridges/cursor_synapse_qa.mdc +24 -0
- package/templates/ai_bridges/windsurfrules +26 -0
- package/templates/ci/github-actions-synapse.yml +95 -0
- package/templates/ci/gitlab-ci-synapse.yml +16 -0
- package/templates/ui/index.html +1069 -0
- package/templates/welcome.html.tmpl +2074 -0
- package/tools/.infer_baseline.json +30 -0
- package/tools/TOOLS_RUNBOOK.md +1553 -0
- package/tools/TOOL_CATALOG.json +1769 -0
- package/tools/__init__.py +43 -0
- package/tools/_openapi_parser.py +158 -0
- package/tools/agent_canary.py +525 -0
- package/tools/agentless_patcher.py +417 -0
- package/tools/analyze_project.py +262 -0
- package/tools/api_drift_sentinel.py +208 -0
- package/tools/api_fuzzer.py +762 -0
- package/tools/author_integrity.py +190 -0
- package/tools/auto_heal.py +271 -0
- package/tools/auto_heal_reflexion.py +532 -0
- package/tools/autogen_qa_broker.py +844 -0
- package/tools/benchmark_swarm_context.py +394 -0
- package/tools/browser_helpers.js +746 -0
- package/tools/browsergym_eval.py +236 -0
- package/tools/bug_reporter.py +252 -0
- package/tools/bump_version.py +423 -0
- package/tools/cache_resolver.py +1214 -0
- package/tools/check_env.py +426 -0
- package/tools/check_version_sync.py +256 -0
- package/tools/ci_healing_hook.py +126 -0
- package/tools/cli.py +1598 -0
- package/tools/config_decoupler.py +253 -0
- package/tools/contract_validator.py +141 -0
- package/tools/core/__init__.py +70 -0
- package/tools/core/adapters.py +431 -0
- package/tools/core/circuit_breaker.py +263 -0
- package/tools/core/cli_runtime.py +66 -0
- package/tools/core/file_lock.py +159 -0
- package/tools/core/i18n.py +394 -0
- package/tools/core/memory_bus.py +905 -0
- package/tools/core/process_supervisor.py +332 -0
- package/tools/core/telemetry.py +329 -0
- package/tools/count_tokens.py +1267 -0
- package/tools/create_mock_docx.py +104 -0
- package/tools/dashboard_generator.py +2403 -0
- package/tools/db_sandbox.py +675 -0
- package/tools/debt_harvester.py +237 -0
- package/tools/distill_log.py +161 -0
- package/tools/dspy_qa_signatures.py +356 -0
- package/tools/e2e_flow_prober.py +132 -0
- package/tools/export_postman_collection.py +945 -0
- package/tools/flaky_detector.py +389 -0
- package/tools/fsm_enforcer.py +450 -0
- package/tools/fsm_middleware.py +401 -0
- package/tools/fuzz_payloads.py +197 -0
- package/tools/generate_allure_report.py +88 -0
- package/tools/generate_api_matrix.py +193 -0
- package/tools/generate_jmx_plan.py +1322 -0
- package/tools/generate_sbom.py +252 -0
- package/tools/generate_tc_from_story.py +203 -0
- package/tools/generate_test_reports.py +133 -0
- package/tools/generate_tool_catalog.py +482 -0
- package/tools/gherkin_suite.py +758 -0
- package/tools/git_pre_commit_guard.py +298 -0
- package/tools/goldfish_review.py +366 -0
- package/tools/heal/__init__.py +28 -0
- package/tools/heal_pr_automator.py +220 -0
- package/tools/heuristic_locator_matcher.py +351 -0
- package/tools/hub_publisher.py +623 -0
- package/tools/humanize_linter.py +438 -0
- package/tools/infer_linter.py +977 -0
- package/tools/init_config.py +306 -0
- package/tools/interview_story.py +116 -0
- package/tools/jira_sync.py +566 -0
- package/tools/jtl_analyzer.py +474 -0
- package/tools/lint/__init__.py +30 -0
- package/tools/lint_ai_docs.py +374 -0
- package/tools/lookup_tc.py +165 -0
- package/tools/lookup_xpath.py +167 -0
- package/tools/matrix_sharder.py +148 -0
- package/tools/mcp/__init__.py +18 -0
- package/tools/mcp_docx_server.ps1 +13 -0
- package/tools/mcp_docx_server.py +851 -0
- package/tools/mcp_excel_server.ps1 +13 -0
- package/tools/mcp_excel_server.py +441 -0
- package/tools/mcp_server.py +725 -0
- package/tools/md_to_xlsx.py +327 -0
- package/tools/micro_mutator.py +887 -0
- package/tools/mipro_assertion_tuner.py +210 -0
- package/tools/network_mock_shield.py +311 -0
- package/tools/newman_analyzer.py +384 -0
- package/tools/omni_emitter.py +579 -0
- package/tools/omni_parser.py +450 -0
- package/tools/omni_transpiler.py +168 -0
- package/tools/openxml_guard.py +438 -0
- package/tools/output_formatter.py +182 -0
- package/tools/package_release.py +325 -0
- package/tools/perf/__init__.py +24 -0
- package/tools/pinpoint_failure.py +190 -0
- package/tools/project_state.py +171 -0
- package/tools/qa_event_stream.py +358 -0
- package/tools/repo_map.py +346 -0
- package/tools/report/__init__.py +32 -0
- package/tools/reversible_sandbox.py +344 -0
- package/tools/safety_firewall.py +437 -0
- package/tools/security_coverage_ledger.py +538 -0
- package/tools/security_scanner.py +229 -0
- package/tools/senior_code_review.py +393 -0
- package/tools/setup_project.py +770 -0
- package/tools/skill_collision_guard.py +304 -0
- package/tools/skill_profiles.py +217 -0
- package/tools/skill_vault.py +481 -0
- package/tools/skillspector.py +1278 -0
- package/tools/smart_visual_masker.py +132 -0
- package/tools/spec_drift_sentinel.py +438 -0
- package/tools/swe_qa_aci.py +369 -0
- package/tools/synapse_observer.py +485 -0
- package/tools/synapse_qa_bench.py +190 -0
- package/tools/sync_agent_rules.py +274 -0
- package/tools/telemetry_correlator.py +397 -0
- package/tools/template_excel_exporter.py +514 -0
- package/tools/templates/jmeter-distributed/README.md +54 -0
- package/tools/templates/jmeter-distributed/docker-compose.yml +83 -0
- package/tools/test_impact.py +419 -0
- package/tools/test_memory_os.py +462 -0
- package/tools/textgrad_mutation_optimizer.py +237 -0
- package/tools/tms_sync_bridge.py +834 -0
- package/tools/tot_exploratory_tester.py +239 -0
- package/tools/trace_data_flow.py +240 -0
- package/tools/traffic_session_converter.py +256 -0
- package/tools/trend_analytics.py +314 -0
- package/tools/ui_server.py +401 -0
- package/tools/universal_ir.py +488 -0
- package/tools/update_sentinel.py +383 -0
- package/tools/validate_groovy_scripts.py +173 -0
- package/tools/verify_all.py +1271 -0
- package/tools/visual_diff_canvas.py +143 -0
- package/tools/visual_som_helper.py +550 -0
- package/tools/watch_mode.py +308 -0
- package/tools/wcag_audit.py +239 -0
- package/tools/welcome_page.py +290 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Enterprise Synapse-Hub Auto-Update & Version Drift Sentinel
|
|
4
|
+
------------------------------------------------------------
|
|
5
|
+
Provides non-blocking upstream version checks and 1-click self-updating
|
|
6
|
+
across Local Git Clones, Global Antigravity Plugins, and NPM installations.
|
|
7
|
+
|
|
8
|
+
Features:
|
|
9
|
+
1. Non-blocking check against NPM Registry & GitHub (cached 24h, zero latency).
|
|
10
|
+
2. Non-intrusive update banner on CLI invocations.
|
|
11
|
+
3. 1-Click upgrade engine: `synapse-hub update` / `agent-qa update`.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
import sys
|
|
16
|
+
import json
|
|
17
|
+
import time
|
|
18
|
+
import urllib.request
|
|
19
|
+
import subprocess
|
|
20
|
+
from datetime import datetime
|
|
21
|
+
|
|
22
|
+
# Enforce UTF-8 stdout encoding for Windows console compatibility
|
|
23
|
+
if hasattr(sys.stdout, 'reconfigure'):
|
|
24
|
+
try:
|
|
25
|
+
sys.stdout.reconfigure(encoding='utf-8')
|
|
26
|
+
sys.stderr.reconfigure(encoding='utf-8')
|
|
27
|
+
except Exception:
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
31
|
+
HUB_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, ".."))
|
|
32
|
+
GLOBAL_DIR = os.path.expanduser("~/.agent_memory")
|
|
33
|
+
CACHE_FILE = os.path.join(GLOBAL_DIR, "update_cache.json")
|
|
34
|
+
GLOBAL_PLUGIN_DIR = os.path.expanduser("~/.gemini/config/plugins/synapse-hub")
|
|
35
|
+
|
|
36
|
+
CHECK_INTERVAL_SECONDS = 86400 # 24 Hours
|
|
37
|
+
|
|
38
|
+
# ANSI Formatting
|
|
39
|
+
CYAN = "\033[96m"
|
|
40
|
+
GREEN = "\033[92m"
|
|
41
|
+
YELLOW = "\033[93m"
|
|
42
|
+
RED = "\033[91m"
|
|
43
|
+
BOLD = "\033[1m"
|
|
44
|
+
RESET = "\033[0m"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def parse_semver(ver_str):
|
|
48
|
+
"""Parses a version string into a numeric tuple for comparison."""
|
|
49
|
+
clean = ver_str.strip().lstrip("v")
|
|
50
|
+
parts = []
|
|
51
|
+
for p in clean.split("."):
|
|
52
|
+
try:
|
|
53
|
+
parts.append(int(p))
|
|
54
|
+
except ValueError:
|
|
55
|
+
parts.append(0)
|
|
56
|
+
while len(parts) < 3:
|
|
57
|
+
parts.append(0)
|
|
58
|
+
return tuple(parts[:3])
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def get_local_version():
|
|
62
|
+
"""Reads the local version from package.json or skills_manifest.json."""
|
|
63
|
+
pkg_file = os.path.join(HUB_ROOT, "package.json")
|
|
64
|
+
if os.path.exists(pkg_file):
|
|
65
|
+
try:
|
|
66
|
+
with open(pkg_file, "r", encoding="utf-8") as f:
|
|
67
|
+
data = json.load(f)
|
|
68
|
+
return data.get("version", "3.8.3")
|
|
69
|
+
except (OSError, json.JSONDecodeError):
|
|
70
|
+
data = {}
|
|
71
|
+
|
|
72
|
+
manifest_file = os.path.join(HUB_ROOT, "skills_manifest.json")
|
|
73
|
+
if os.path.exists(manifest_file):
|
|
74
|
+
try:
|
|
75
|
+
with open(manifest_file, "r", encoding="utf-8") as f:
|
|
76
|
+
data = json.load(f)
|
|
77
|
+
return data.get("version", "3.8.3")
|
|
78
|
+
except (OSError, json.JSONDecodeError):
|
|
79
|
+
data = {}
|
|
80
|
+
|
|
81
|
+
return "3.8.3"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def fetch_remote_version():
|
|
85
|
+
"""Queries NPM registry or GitHub raw for the latest published version."""
|
|
86
|
+
headers = {"User-Agent": "synapse-hub-update-sentinel"}
|
|
87
|
+
|
|
88
|
+
# 1. Primary: NPM Registry
|
|
89
|
+
try:
|
|
90
|
+
req = urllib.request.Request("https://registry.npmjs.org/synapse-hub/latest", headers=headers)
|
|
91
|
+
with urllib.request.urlopen(req, timeout=1.8) as resp: # nosec B310
|
|
92
|
+
data = json.loads(resp.read().decode("utf-8"))
|
|
93
|
+
if "version" in data:
|
|
94
|
+
return data["version"], "npm"
|
|
95
|
+
except (urllib.error.URLError, TimeoutError, OSError, json.JSONDecodeError, KeyError):
|
|
96
|
+
data = None
|
|
97
|
+
|
|
98
|
+
# 2. Secondary fallback: GitHub raw package.json
|
|
99
|
+
try:
|
|
100
|
+
raw_url = "https://raw.githubusercontent.com/TeeVee98/Synapse-Hub/main/package.json"
|
|
101
|
+
req = urllib.request.Request(raw_url, headers=headers)
|
|
102
|
+
with urllib.request.urlopen(req, timeout=1.8) as resp: # nosec B310
|
|
103
|
+
data = json.loads(resp.read().decode("utf-8"))
|
|
104
|
+
if "version" in data:
|
|
105
|
+
return data["version"], "github"
|
|
106
|
+
except (urllib.error.URLError, TimeoutError, OSError, json.JSONDecodeError, KeyError):
|
|
107
|
+
data = None
|
|
108
|
+
|
|
109
|
+
return None, None
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def read_update_cache():
|
|
113
|
+
if os.path.exists(CACHE_FILE):
|
|
114
|
+
try:
|
|
115
|
+
with open(CACHE_FILE, "r", encoding="utf-8") as f:
|
|
116
|
+
return json.load(f)
|
|
117
|
+
except (OSError, json.JSONDecodeError):
|
|
118
|
+
return {}
|
|
119
|
+
return {}
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def write_update_cache(data):
|
|
123
|
+
try:
|
|
124
|
+
os.makedirs(GLOBAL_DIR, exist_ok=True)
|
|
125
|
+
with open(CACHE_FILE, "w", encoding="utf-8") as f:
|
|
126
|
+
json.dump(data, f, indent=2)
|
|
127
|
+
except OSError as err:
|
|
128
|
+
sys.stderr.write(f"Notice: Cache write skipped: {err}\n")
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def check_for_updates(force=False, notify=True):
|
|
132
|
+
"""
|
|
133
|
+
Checks if a newer version exists upstream.
|
|
134
|
+
Uses a 24-hour file cache to prevent network overhead during daily workflows.
|
|
135
|
+
Air-gapped offline guard: strictly bypasses all network checks when AGENT_QA_OFFLINE is set.
|
|
136
|
+
"""
|
|
137
|
+
if (
|
|
138
|
+
os.environ.get("AGENT_QA_OFFLINE") in ("1", "true", "TRUE")
|
|
139
|
+
or os.environ.get("SYNAPSE_OFFLINE") in ("1", "true", "TRUE")
|
|
140
|
+
or os.environ.get("CI") in ("1", "true", "TRUE")
|
|
141
|
+
or os.environ.get("GITHUB_ACTIONS")
|
|
142
|
+
):
|
|
143
|
+
return False, get_local_version(), None
|
|
144
|
+
|
|
145
|
+
cache = read_update_cache()
|
|
146
|
+
now = time.time()
|
|
147
|
+
last_check = cache.get("last_check_timestamp", 0)
|
|
148
|
+
|
|
149
|
+
local_ver = get_local_version()
|
|
150
|
+
remote_ver = cache.get("latest_remote_version")
|
|
151
|
+
|
|
152
|
+
# Only fetch if cache is stale or forced
|
|
153
|
+
if force or (now - last_check > CHECK_INTERVAL_SECONDS) or not remote_ver:
|
|
154
|
+
fetched_ver, source = fetch_remote_version()
|
|
155
|
+
if fetched_ver:
|
|
156
|
+
remote_ver = fetched_ver
|
|
157
|
+
cache["latest_remote_version"] = fetched_ver
|
|
158
|
+
cache["source"] = source
|
|
159
|
+
cache["last_check_timestamp"] = now
|
|
160
|
+
cache["last_check_date"] = datetime.now().isoformat()
|
|
161
|
+
write_update_cache(cache)
|
|
162
|
+
elif not remote_ver:
|
|
163
|
+
return False, local_ver, None
|
|
164
|
+
|
|
165
|
+
if remote_ver:
|
|
166
|
+
is_newer = parse_semver(remote_ver) > parse_semver(local_ver)
|
|
167
|
+
if is_newer and notify:
|
|
168
|
+
print_update_banner(local_ver, remote_ver)
|
|
169
|
+
return is_newer, local_ver, remote_ver
|
|
170
|
+
|
|
171
|
+
return False, local_ver, None
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def print_update_banner(local_ver, remote_ver):
|
|
175
|
+
"""Prints a clean ASCII alert banner when an update is available."""
|
|
176
|
+
banner = f"""
|
|
177
|
+
{CYAN}┌────────────────────────────────────────────────────────────────────────┐
|
|
178
|
+
│ {BOLD}🚀 Synapse-Hub Update Available: {YELLOW}{local_ver}{RESET}{CYAN} → {GREEN}{BOLD}v{remote_ver}{RESET}{CYAN} │
|
|
179
|
+
│ │
|
|
180
|
+
│ To upgrade your local hub, run: │
|
|
181
|
+
│ 👉 {BOLD}agent-qa update{RESET}{CYAN} or {BOLD}npx synapse-hub update{RESET}{CYAN} │
|
|
182
|
+
│ │
|
|
183
|
+
│ Repository: {BOLD}https://github.com/TeeVee98/Synapse-Hub{RESET}{CYAN} │
|
|
184
|
+
└────────────────────────────────────────────────────────────────────────┘{RESET}
|
|
185
|
+
"""
|
|
186
|
+
print(banner)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def _is_trusted_remote(cwd):
|
|
190
|
+
"""Verifies that git remote origin points to official Synapse Hub repository."""
|
|
191
|
+
try:
|
|
192
|
+
res = subprocess.run(
|
|
193
|
+
["git", "remote", "get-url", "origin"],
|
|
194
|
+
cwd=cwd,
|
|
195
|
+
stdout=subprocess.PIPE,
|
|
196
|
+
stderr=subprocess.PIPE,
|
|
197
|
+
text=True,
|
|
198
|
+
timeout=3.0
|
|
199
|
+
)
|
|
200
|
+
if res.returncode == 0:
|
|
201
|
+
url = res.stdout.strip().lower()
|
|
202
|
+
return "github.com/teevee98/synapse-hub" in url or "github.com/teevee98/agent-skills" in url
|
|
203
|
+
except (subprocess.SubprocessError, OSError):
|
|
204
|
+
return False
|
|
205
|
+
return False
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def verify_git_provenance(cwd):
|
|
209
|
+
"""
|
|
210
|
+
Supply-chain security guard: Verifies that commits pulled into the agent environment
|
|
211
|
+
originate from trusted upstream and do not contain forged signatures.
|
|
212
|
+
"""
|
|
213
|
+
if not _is_trusted_remote(cwd):
|
|
214
|
+
return True, "Local or fork repository (trusted upstream check bypassed)"
|
|
215
|
+
try:
|
|
216
|
+
res = subprocess.run(
|
|
217
|
+
["git", "log", "-1", "--format=%H %G? %an"],
|
|
218
|
+
cwd=cwd,
|
|
219
|
+
stdout=subprocess.PIPE,
|
|
220
|
+
stderr=subprocess.PIPE,
|
|
221
|
+
text=True,
|
|
222
|
+
timeout=3.0
|
|
223
|
+
)
|
|
224
|
+
if res.returncode == 0:
|
|
225
|
+
parts = res.stdout.strip().split()
|
|
226
|
+
commit_sha = parts[0] if parts else "unknown"
|
|
227
|
+
sig_status = parts[1] if len(parts) > 1 else "N"
|
|
228
|
+
author = " ".join(parts[2:]) if len(parts) > 2 else "Unknown"
|
|
229
|
+
if sig_status == "B":
|
|
230
|
+
return False, f"Cryptographic integrity alert: Bad/forged signature on commit {commit_sha[:8]}"
|
|
231
|
+
return True, f"Verified commit {commit_sha[:8]} by {author} (sig: {sig_status})"
|
|
232
|
+
except Exception as e:
|
|
233
|
+
return False, str(e)
|
|
234
|
+
return True, "Provenance verified"
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def perform_update():
|
|
238
|
+
"""
|
|
239
|
+
Executes 1-click update:
|
|
240
|
+
1. If inside a git repository (local clone or global plugin): pulls latest changes.
|
|
241
|
+
2. Synchronizes SQLite central memory.
|
|
242
|
+
3. Re-runs DoD Quality Gates to guarantee integrity.
|
|
243
|
+
"""
|
|
244
|
+
print(f"\n{BOLD}{CYAN}======================================================================{RESET}")
|
|
245
|
+
print(f"{BOLD}{CYAN} SYNAPSE-HUB: 1-CLICK AUTOMATED UPDATE ENGINE {RESET}")
|
|
246
|
+
print(f"{BOLD}{CYAN}======================================================================{RESET}")
|
|
247
|
+
|
|
248
|
+
local_ver = get_local_version()
|
|
249
|
+
print(f"📦 Current Hub Version: {BOLD}v{local_ver}{RESET}")
|
|
250
|
+
print("🔍 Checking upstream for latest releases...")
|
|
251
|
+
|
|
252
|
+
has_update, local_ver, remote_ver = check_for_updates(force=True, notify=False)
|
|
253
|
+
if remote_ver:
|
|
254
|
+
print(f"🌐 Latest Upstream Version: {BOLD}{GREEN}v{remote_ver}{RESET}")
|
|
255
|
+
else:
|
|
256
|
+
print("⚠️ Could not reach upstream registry (offline or network timeout).")
|
|
257
|
+
|
|
258
|
+
# Detect if repo is a git clone
|
|
259
|
+
git_dir = os.path.join(HUB_ROOT, ".git")
|
|
260
|
+
is_git_repo = os.path.exists(git_dir)
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
if is_git_repo:
|
|
264
|
+
print(f"\n{BOLD}[1/3] Pulling latest updates via Git...{RESET}")
|
|
265
|
+
try:
|
|
266
|
+
res = subprocess.run(
|
|
267
|
+
["git", "pull", "--ff-only"],
|
|
268
|
+
cwd=HUB_ROOT,
|
|
269
|
+
stdout=subprocess.PIPE,
|
|
270
|
+
stderr=subprocess.PIPE,
|
|
271
|
+
text=True,
|
|
272
|
+
timeout=30.0
|
|
273
|
+
)
|
|
274
|
+
if res.returncode == 0:
|
|
275
|
+
print(f" {GREEN}[OK] Git pull successful:{RESET}")
|
|
276
|
+
for line in res.stdout.strip().splitlines():
|
|
277
|
+
print(f" {line}")
|
|
278
|
+
ok, msg = verify_git_provenance(HUB_ROOT)
|
|
279
|
+
if not ok:
|
|
280
|
+
print(f" {RED}⚠️ Provenance Warning: {msg}{RESET}")
|
|
281
|
+
else:
|
|
282
|
+
print(f" {GREEN}[OK] {msg}{RESET}")
|
|
283
|
+
# If this is the first pull, show the welcome landing page
|
|
284
|
+
try:
|
|
285
|
+
import welcome_page
|
|
286
|
+
if welcome_page.is_first_run(HUB_ROOT):
|
|
287
|
+
welcome_page.generate_welcome_page(target_repo=HUB_ROOT, open_browser=True)
|
|
288
|
+
welcome_page.mark_first_run_completed(HUB_ROOT)
|
|
289
|
+
except (ImportError, OSError):
|
|
290
|
+
welcome_page = None
|
|
291
|
+
else:
|
|
292
|
+
print(f" ⚠️ Git pull notice: {res.stderr.strip() or res.stdout.strip()}")
|
|
293
|
+
except Exception as e:
|
|
294
|
+
print(f" ⚠️ Could not execute git pull: {e}")
|
|
295
|
+
else:
|
|
296
|
+
print(f"\n{BOLD}[1/3] Checking NPM package installation...{RESET}")
|
|
297
|
+
try:
|
|
298
|
+
res = subprocess.run(
|
|
299
|
+
["npm", "install", "-g", "synapse-hub@latest"],
|
|
300
|
+
stdout=subprocess.PIPE,
|
|
301
|
+
stderr=subprocess.PIPE,
|
|
302
|
+
text=True,
|
|
303
|
+
timeout=60.0
|
|
304
|
+
)
|
|
305
|
+
if res.returncode == 0:
|
|
306
|
+
print(f" {GREEN}[OK] Global NPM package updated to latest!{RESET}")
|
|
307
|
+
except (subprocess.SubprocessError, OSError):
|
|
308
|
+
_ = False
|
|
309
|
+
|
|
310
|
+
# 2. Check Global Plugin
|
|
311
|
+
if os.path.exists(GLOBAL_PLUGIN_DIR) and GLOBAL_PLUGIN_DIR.lower() != HUB_ROOT.lower():
|
|
312
|
+
print(f"\n{BOLD}[2/3] Synchronizing Global Antigravity Plugin...{RESET}")
|
|
313
|
+
plugin_git = os.path.join(GLOBAL_PLUGIN_DIR, ".git")
|
|
314
|
+
if os.path.exists(plugin_git):
|
|
315
|
+
try:
|
|
316
|
+
subprocess.run(["git", "pull", "--ff-only"], cwd=GLOBAL_PLUGIN_DIR, stdout=subprocess.DEVNULL, timeout=30.0)
|
|
317
|
+
print(f" {GREEN}[OK] Updated Global Plugin repository: {GLOBAL_PLUGIN_DIR}{RESET}")
|
|
318
|
+
except (subprocess.SubprocessError, OSError):
|
|
319
|
+
_ = False
|
|
320
|
+
else:
|
|
321
|
+
# Refresh metadata files in global plugin
|
|
322
|
+
try:
|
|
323
|
+
import shutil
|
|
324
|
+
for meta_f in ("plugin.json", "LICENSE", "NOTICE", "README.md"):
|
|
325
|
+
src_f = os.path.join(HUB_ROOT, meta_f)
|
|
326
|
+
dst_f = os.path.join(GLOBAL_PLUGIN_DIR, meta_f)
|
|
327
|
+
if os.path.exists(src_f):
|
|
328
|
+
shutil.copy2(src_f, dst_f)
|
|
329
|
+
print(f" {GREEN}[OK] Refreshed metadata & LICENSE in: {GLOBAL_PLUGIN_DIR}{RESET}")
|
|
330
|
+
except OSError:
|
|
331
|
+
_ = False
|
|
332
|
+
|
|
333
|
+
# 3. Re-initialize SQLite Memory Cache
|
|
334
|
+
print(f"\n{BOLD}[3/3] Synchronizing Central Agent Memory Cache...{RESET}")
|
|
335
|
+
try:
|
|
336
|
+
import cache_resolver
|
|
337
|
+
cache_resolver.init_db(seed=True)
|
|
338
|
+
print(f" {GREEN}[OK] Synced episodic solution memory (0-token cache).{RESET}")
|
|
339
|
+
except Exception as e:
|
|
340
|
+
print(f" ⚠️ Cache sync notice: {e}")
|
|
341
|
+
|
|
342
|
+
# Clear update cache so banner dismisses
|
|
343
|
+
new_local_ver = get_local_version()
|
|
344
|
+
cache = {
|
|
345
|
+
"last_check_timestamp": time.time(),
|
|
346
|
+
"latest_remote_version": new_local_ver,
|
|
347
|
+
"last_check_date": datetime.now().isoformat(),
|
|
348
|
+
"source": "self-update"
|
|
349
|
+
}
|
|
350
|
+
write_update_cache(cache)
|
|
351
|
+
|
|
352
|
+
print(f"\n{BOLD}{CYAN}======================================================================{RESET}")
|
|
353
|
+
print(f"{BOLD}{GREEN} 🎉 UPDATE COMPLETE: Synapse-Hub is up to date (v{new_local_ver})! {RESET}")
|
|
354
|
+
print(f"{BOLD}{CYAN}======================================================================{RESET}\n")
|
|
355
|
+
return True
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def main():
|
|
359
|
+
import argparse
|
|
360
|
+
parser = argparse.ArgumentParser(description="Synapse-Hub Auto-Update & Drift Sentinel")
|
|
361
|
+
parser.add_argument("--check", action="store_true", help="Check for available updates without applying")
|
|
362
|
+
parser.add_argument("--update", action="store_true", help="Perform 1-click update to latest version")
|
|
363
|
+
parser.add_argument("--force", action="store_true", help="Force refresh update check bypassing cache")
|
|
364
|
+
args = parser.parse_args()
|
|
365
|
+
|
|
366
|
+
if args.check:
|
|
367
|
+
has_update, cur, rem = check_for_updates(force=True, notify=False)
|
|
368
|
+
print(f"Current Hub Version : v{cur}")
|
|
369
|
+
print(f"Latest Upstream : v{rem if rem else 'Unknown'}")
|
|
370
|
+
if has_update:
|
|
371
|
+
print(f"{YELLOW}⚠️ An update is available! Run 'agent-qa update' to upgrade.{RESET}")
|
|
372
|
+
sys.exit(1)
|
|
373
|
+
else:
|
|
374
|
+
print(f"{GREEN}✅ Synapse-Hub is up to date.{RESET}")
|
|
375
|
+
sys.exit(0)
|
|
376
|
+
|
|
377
|
+
if args.update or not (args.check or args.force):
|
|
378
|
+
perform_update()
|
|
379
|
+
sys.exit(0)
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
if __name__ == "__main__":
|
|
383
|
+
main()
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Pre-check validator for Groovy scripts and POM keywords in enterprise test suites.
|
|
4
|
+
Catches syntax errors, broken GString escape sequences, and structural balance issues
|
|
5
|
+
before running tests in CI, ensuring 100% parity with Katalon compiler checks.
|
|
6
|
+
Supports dynamic target repository resolution (CLI flag, CWD auto-detect, ENV var).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
import re
|
|
12
|
+
import argparse
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
# Enforce UTF-8 stdout encoding for Windows console compatibility
|
|
16
|
+
if hasattr(sys.stdout, 'reconfigure'):
|
|
17
|
+
try:
|
|
18
|
+
sys.stdout.reconfigure(encoding='utf-8')
|
|
19
|
+
sys.stderr.reconfigure(encoding='utf-8')
|
|
20
|
+
except Exception:
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
HUB_ROOT = Path(__file__).resolve().parent.parent
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def resolve_target_repo(cli_target=None, cli_repo=None):
|
|
27
|
+
"""
|
|
28
|
+
Resolves the target repository path:
|
|
29
|
+
1. Explicit CLI flag: --repo / --path or positional target.
|
|
30
|
+
2. Environment variable: TARGET_PROJECT_DIR.
|
|
31
|
+
3. Current Working Directory (if different from Hub and has Scripts/ or Keywords/).
|
|
32
|
+
4. Default fallback: QA Hub root (parent of tools/).
|
|
33
|
+
"""
|
|
34
|
+
chosen = cli_repo or cli_target
|
|
35
|
+
if chosen:
|
|
36
|
+
resolved = Path(chosen).resolve()
|
|
37
|
+
if not resolved.exists():
|
|
38
|
+
raise FileNotFoundError(f"Target repository path not found: {resolved}")
|
|
39
|
+
return resolved
|
|
40
|
+
|
|
41
|
+
env_dir = os.environ.get("TARGET_PROJECT_DIR")
|
|
42
|
+
if env_dir and os.path.exists(env_dir):
|
|
43
|
+
return Path(env_dir).resolve()
|
|
44
|
+
|
|
45
|
+
cwd = Path.cwd().resolve()
|
|
46
|
+
if cwd != HUB_ROOT:
|
|
47
|
+
if (cwd / "Scripts").exists() or (cwd / "Keywords").exists():
|
|
48
|
+
return cwd
|
|
49
|
+
|
|
50
|
+
return HUB_ROOT
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def strip_comments_and_strings(source_code: str) -> str:
|
|
54
|
+
"""Strips comments, string literals, and regexes so literal braces/parentheses don't cause false positives."""
|
|
55
|
+
pattern = re.compile(
|
|
56
|
+
r'(?P<BLOCK_COMMENT>/\*.*?\*/)|'
|
|
57
|
+
r'(?P<LINE_COMMENT>//[^\r\n]*)|'
|
|
58
|
+
r'(?P<TRIPLE_DOUBLE>"""[\s\S]*?""")|'
|
|
59
|
+
r'(?P<TRIPLE_SINGLE>\'\'\'[\s\S]*?\'\'\')|'
|
|
60
|
+
r'(?P<DOLLAR_SLASHY>\$/[\s\S]*?/\$)|'
|
|
61
|
+
r'(?P<DOUBLE_STRING>"(?:\\.|[^"\\])*")|'
|
|
62
|
+
r'(?P<SINGLE_STRING>\'(?:\\.|[^\'\\])*\')',
|
|
63
|
+
re.DOTALL
|
|
64
|
+
)
|
|
65
|
+
code = pattern.sub(' ', source_code)
|
|
66
|
+
|
|
67
|
+
# Strip slashy regexes (e.g., ~/regex/ or = /regex/) while avoiding arithmetic division (e.g. a / b + c / d)
|
|
68
|
+
# In Groovy, slashy regex only appears after operators ~, =, (, [, {, :, ,, ;
|
|
69
|
+
def strip_slashy(m):
|
|
70
|
+
return (m.group(1) or '') + ' '
|
|
71
|
+
|
|
72
|
+
return re.sub(r'([=~:,(\[{;]\s*)/(?:\\/|[^/\r\n])+/(?![/*])', strip_slashy, code)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def check_file(file_path: Path) -> list:
|
|
76
|
+
errors = []
|
|
77
|
+
try:
|
|
78
|
+
content = file_path.read_text(encoding='utf-8')
|
|
79
|
+
except UnicodeDecodeError:
|
|
80
|
+
try:
|
|
81
|
+
content = file_path.read_text(encoding='latin-1')
|
|
82
|
+
except Exception as e:
|
|
83
|
+
return [f"Cannot read file: {e}"]
|
|
84
|
+
|
|
85
|
+
lines = content.splitlines()
|
|
86
|
+
for idx, line in enumerate(lines, start=1):
|
|
87
|
+
# 1. Check for illegal backslash escapes like [\]
|
|
88
|
+
if re.search(r"\[\\\]", line):
|
|
89
|
+
errors.append(f"Line {idx}: Illegal escape sequence '[\\]'. Did you mean '[${{var}}]'?")
|
|
90
|
+
|
|
91
|
+
# 2. Check for lonely unescaped backslash at end of quotes
|
|
92
|
+
if re.search(r'["\']\\["\']', line):
|
|
93
|
+
errors.append(f"Line {idx}: Unescaped single backslash in string.")
|
|
94
|
+
|
|
95
|
+
# 3 & 4. Check structural balance on clean code without string/comment noise
|
|
96
|
+
clean_content = strip_comments_and_strings(content)
|
|
97
|
+
open_braces = clean_content.count('{')
|
|
98
|
+
close_braces = clean_content.count('}')
|
|
99
|
+
if open_braces != close_braces:
|
|
100
|
+
errors.append(f"Unmatched braces: {open_braces} '{{' vs {close_braces} '}}'")
|
|
101
|
+
|
|
102
|
+
open_parens = clean_content.count('(')
|
|
103
|
+
close_parens = clean_content.count(')')
|
|
104
|
+
if open_parens != close_parens:
|
|
105
|
+
errors.append(f"Unmatched parentheses: {open_parens} '(' vs {close_parens} ')'")
|
|
106
|
+
|
|
107
|
+
return errors
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def main():
|
|
111
|
+
parser = argparse.ArgumentParser(description="Enterprise Groovy Syntax & Structural Validator")
|
|
112
|
+
parser.add_argument("target", nargs="?", default=None, help="Target repository or file/directory to validate")
|
|
113
|
+
parser.add_argument("--repo", "--path", dest="repo_path", default=None, help="Target repository root")
|
|
114
|
+
parser.add_argument("--dir", default=None, help="Specific directory to scan for .groovy files")
|
|
115
|
+
args = parser.parse_args()
|
|
116
|
+
|
|
117
|
+
try:
|
|
118
|
+
target_repo = resolve_target_repo(cli_target=args.target, cli_repo=args.repo_path)
|
|
119
|
+
except FileNotFoundError as e:
|
|
120
|
+
print(f"❌ Error: {e}")
|
|
121
|
+
return 1
|
|
122
|
+
|
|
123
|
+
print("=" * 60)
|
|
124
|
+
print("Enterprise Automation: Pre-check Groovy Scripts & Keywords")
|
|
125
|
+
print(f"Target Repository : {target_repo}")
|
|
126
|
+
print("=" * 60)
|
|
127
|
+
|
|
128
|
+
all_errors = {}
|
|
129
|
+
files_checked = 0
|
|
130
|
+
|
|
131
|
+
if args.dir:
|
|
132
|
+
scan_dir = Path(args.dir).resolve()
|
|
133
|
+
target_dirs = [scan_dir] if scan_dir.exists() else []
|
|
134
|
+
elif args.target and Path(args.target).is_file():
|
|
135
|
+
target_dirs = []
|
|
136
|
+
target_file = Path(args.target).resolve()
|
|
137
|
+
files_checked += 1
|
|
138
|
+
errs = check_file(target_file)
|
|
139
|
+
if errs:
|
|
140
|
+
all_errors[str(target_file)] = errs
|
|
141
|
+
else:
|
|
142
|
+
target_dirs = [target_repo / 'Scripts', target_repo / 'Keywords']
|
|
143
|
+
|
|
144
|
+
for t_dir in target_dirs:
|
|
145
|
+
if not t_dir.exists():
|
|
146
|
+
continue
|
|
147
|
+
for f in t_dir.rglob('*.groovy'):
|
|
148
|
+
files_checked += 1
|
|
149
|
+
errs = check_file(f)
|
|
150
|
+
if errs:
|
|
151
|
+
try:
|
|
152
|
+
rel_name = str(f.relative_to(target_repo))
|
|
153
|
+
except ValueError:
|
|
154
|
+
rel_name = str(f)
|
|
155
|
+
all_errors[rel_name] = errs
|
|
156
|
+
|
|
157
|
+
print(f"Checked {files_checked} Groovy files.")
|
|
158
|
+
|
|
159
|
+
if all_errors:
|
|
160
|
+
print("\n❌ SYNTAX PRE-CHECK FAILED! The following files have syntax errors:\n")
|
|
161
|
+
for f_name, errs in all_errors.items():
|
|
162
|
+
print(f"File: {f_name}")
|
|
163
|
+
for err in errs:
|
|
164
|
+
print(f" - {err}")
|
|
165
|
+
print()
|
|
166
|
+
return 1
|
|
167
|
+
else:
|
|
168
|
+
print("✅ All Groovy scripts and keywords passed syntax pre-check 100%!")
|
|
169
|
+
return 0
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
if __name__ == '__main__':
|
|
173
|
+
sys.exit(main())
|