@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.
Files changed (369) hide show
  1. package/.agents/agents/api-engineer.md +67 -0
  2. package/.agents/agents/failure-analyst.md +75 -0
  3. package/.agents/agents/live-explorer.md +70 -0
  4. package/.agents/agents/orchestrator.md +104 -0
  5. package/.agents/agents/perf-engineer.md +74 -0
  6. package/.agents/agents/pom-crafter.md +112 -0
  7. package/.agents/agents/quality-gatekeeper.md +87 -0
  8. package/.agents/agents/test-designer.md +73 -0
  9. package/.agents/agents/test-runner.md +67 -0
  10. package/.agents/rules/author-integrity-guard.md +33 -0
  11. package/.agents/rules/communication-style.md +18 -0
  12. package/.agents/rules/context-engineering.md +37 -0
  13. package/.agents/rules/git-push-protocol.md +33 -0
  14. package/.agents/rules/graphify.md +14 -0
  15. package/.agents/rules/lessons-learned.md +25 -0
  16. package/.agents/rules/mandatory-playwright-live.md +25 -0
  17. package/.agents/rules/mobile_appium_rules.md +43 -0
  18. package/.agents/rules/performance_testing_rules.md +35 -0
  19. package/.agents/rules/skill-precedence.md +29 -0
  20. package/.agents/rules/systematic-debugging.md +36 -0
  21. package/.agents/skills/actor-qa-swarm/SKILL.md +77 -0
  22. package/.agents/skills/actor-qa-swarm/examples/broker_sharding_sample.json +12 -0
  23. package/.agents/skills/agent-orchestration-multi-agent-optimize/SKILL.md +88 -0
  24. package/.agents/skills/agent-orchestration-multi-agent-optimize/examples/swarm_workload_config.json +15 -0
  25. package/.agents/skills/agentless-qa-repair/SKILL.md +69 -0
  26. package/.agents/skills/agentless-qa-repair/examples/healing_report_sample.json +17 -0
  27. package/.agents/skills/agentless-qa-repair/examples/three_phase_repair_workflow.md +40 -0
  28. package/.agents/skills/antigravity-test-sentinel/SKILL.md +63 -0
  29. package/.agents/skills/antigravity-test-sentinel/examples/dod_gate_policy.json +11 -0
  30. package/.agents/skills/antigravity-test-sentinel/examples/sprint_dod_enforcement.md +47 -0
  31. package/.agents/skills/api-network-mocking-interception/SKILL.md +142 -0
  32. package/.agents/skills/api-network-mocking-interception/examples/network_route_stub.json +9 -0
  33. package/.agents/skills/api-spec-to-e2e-matrix/SKILL.md +80 -0
  34. package/.agents/skills/api-spec-to-e2e-matrix/examples/sample_openapi.json +19 -0
  35. package/.agents/skills/architecture-decision-records/SKILL.md +64 -0
  36. package/.agents/skills/architecture-decision-records/examples/0001-record-architecture-decisions.md +12 -0
  37. package/.agents/skills/auth-session-and-cookie-manager/SKILL.md +75 -0
  38. package/.agents/skills/auth-session-and-cookie-manager/examples/multi_role_auth_matrix.md +70 -0
  39. package/.agents/skills/auth-session-and-cookie-manager/examples/storage_state_sample.json +11 -0
  40. package/.agents/skills/backend-load-and-stress-patterns/SKILL.md +85 -0
  41. package/.agents/skills/backend-load-and-stress-patterns/examples/k6_load_test_sample.js +13 -0
  42. package/.agents/skills/backend-load-and-stress-patterns/references/k6_load_template.js +82 -0
  43. package/.agents/skills/bats-testing-patterns/SKILL.md +100 -0
  44. package/.agents/skills/bats-testing-patterns/examples/cli_runner_test.bats +6 -0
  45. package/.agents/skills/bats-testing-patterns/resources/implementation-playbook.md +614 -0
  46. package/.agents/skills/clean-pom-crafter/SKILL.md +110 -0
  47. package/.agents/skills/clean-pom-crafter/examples/standard_test_case.groovy +28 -0
  48. package/.agents/skills/clean-pom-crafter/references/pom_patterns.groovy +138 -0
  49. package/.agents/skills/code-refactoring-refactor-clean/SKILL.md +64 -0
  50. package/.agents/skills/code-refactoring-refactor-clean/examples/refactored_page_sample.groovy +9 -0
  51. package/.agents/skills/code-refactoring-refactor-clean/examples/refactored_playwright_pom.ts +52 -0
  52. package/.agents/skills/code-refactoring-refactor-clean/resources/implementation-playbook.md +881 -0
  53. package/.agents/skills/consumer-driven-contract-testing/SKILL.md +147 -0
  54. package/.agents/skills/consumer-driven-contract-testing/examples/order_service_pact.json +45 -0
  55. package/.agents/skills/db-state-verifier-and-seeder/SKILL.md +123 -0
  56. package/.agents/skills/db-state-verifier-and-seeder/examples/db_fixture_seed.json +12 -0
  57. package/.agents/skills/e2e-testing-patterns/SKILL.md +103 -0
  58. package/.agents/skills/e2e-testing-patterns/examples/playwright_sharded_config.ts +12 -0
  59. package/.agents/skills/e2e-testing-patterns/resources/implementation-playbook.md +522 -0
  60. package/.agents/skills/event-stream-qa-orchestrator/SKILL.md +79 -0
  61. package/.agents/skills/event-stream-qa-orchestrator/examples/timeline_sample.jsonl +2 -0
  62. package/.agents/skills/failure-autopsy-and-healing/SKILL.md +66 -0
  63. package/.agents/skills/failure-autopsy-and-healing/examples/closed_loop_healing_walkthrough.md +48 -0
  64. package/.agents/skills/failure-autopsy-and-healing/examples/sample_junit_failure.xml +8 -0
  65. package/.agents/skills/failure-autopsy-and-healing/references/healing_matrix.md +64 -0
  66. package/.agents/skills/failure-autopsy-and-healing/references/qa_investigation_protocol.md +56 -0
  67. package/.agents/skills/failure-autopsy-and-healing/scripts/triage_failures.sh +83 -0
  68. package/.agents/skills/file-and-report-validator/SKILL.md +90 -0
  69. package/.agents/skills/file-and-report-validator/examples/sample_export_schema.json +14 -0
  70. package/.agents/skills/flaky-test-sentinel-and-quarantine/SKILL.md +114 -0
  71. package/.agents/skills/flaky-test-sentinel-and-quarantine/examples/quarantine_registry.json +11 -0
  72. package/.agents/skills/gherkin-to-suite/SKILL.md +103 -0
  73. package/.agents/skills/gherkin-to-suite/examples/checkout.feature +39 -0
  74. package/.agents/skills/gherkin-to-suite/examples/suite_report_sample.json +334 -0
  75. package/.agents/skills/github-actions-templates/SKILL.md +77 -0
  76. package/.agents/skills/github-actions-templates/examples/matrix_test_pipeline.yml +8 -0
  77. package/.agents/skills/graphify-impact-analyzer/SKILL.md +76 -0
  78. package/.agents/skills/graphify-impact-analyzer/examples/dependency_blast_radius.json +8 -0
  79. package/.agents/skills/katalon-cli-runner/SKILL.md +76 -0
  80. package/.agents/skills/katalon-cli-runner/examples/headless_kre_exec.sh +3 -0
  81. package/.agents/skills/katalon-cli-runner/references/groovy-patterns.md +209 -0
  82. package/.agents/skills/katalon-cli-runner/references/katalon-api.md +155 -0
  83. package/.agents/skills/katalon-cli-runner/references/runner_commands.md +67 -0
  84. package/.agents/skills/lam-script-generator/SKILL.md +123 -0
  85. package/.agents/skills/lam-script-generator/examples/user_story_sample.md +8 -0
  86. package/.agents/skills/lean-code-ladder/SKILL.md +94 -0
  87. package/.agents/skills/lean-code-ladder/examples/ladder_walkthrough.md +37 -0
  88. package/.agents/skills/lean-impact-scoreboard/SKILL.md +48 -0
  89. package/.agents/skills/lean-impact-scoreboard/examples/sample_benchmark_gain.md +20 -0
  90. package/.agents/skills/lean-impact-scoreboard/examples/sample_scoreboard.md +15 -0
  91. package/.agents/skills/meta-prompt-crafter/SKILL.md +107 -0
  92. package/.agents/skills/meta-prompt-crafter/examples/qa_prompt_template.md +35 -0
  93. package/.agents/skills/mipro-prompt-compiler/SKILL.md +59 -0
  94. package/.agents/skills/mipro-prompt-compiler/examples/compiled_module_sample.json +22 -0
  95. package/.agents/skills/mipro-prompt-compiler/examples/dspy_assertion_optimizer_case.md +46 -0
  96. package/.agents/skills/mobile-appium-som/SKILL.md +88 -0
  97. package/.agents/skills/mobile-appium-som/examples/BaseScreen.java +88 -0
  98. package/.agents/skills/mobile-appium-som/examples/LoginScreen.java +46 -0
  99. package/.agents/skills/mobile-appium-som/examples/TC_MobileLogin.java +43 -0
  100. package/.agents/skills/persistent-planning-files/SKILL.md +108 -0
  101. package/.agents/skills/persistent-planning-files/examples/task_plan_example.md +56 -0
  102. package/.agents/skills/playwright-live-interaction/SKILL.md +131 -0
  103. package/.agents/skills/playwright-live-interaction/examples/live_probe_script.js +5 -0
  104. package/.agents/skills/playwright-live-interaction/references/advanced_superpowers.md +160 -0
  105. package/.agents/skills/playwright-live-interaction/references/compact_accessibility_snapshots.md +75 -0
  106. package/.agents/skills/playwright-live-interaction/references/recipes.md +388 -0
  107. package/.agents/skills/playwright-live-interaction/references/swarm_orchestration.md +134 -0
  108. package/.agents/skills/playwright-webapp-testing/SKILL.md +93 -0
  109. package/.agents/skills/playwright-webapp-testing/examples/server_lifecycle_playwright.py +63 -0
  110. package/.agents/skills/qa-aci-interface/SKILL.md +67 -0
  111. package/.agents/skills/qa-aci-interface/examples/surgical_code_window_walkthrough.md +40 -0
  112. package/.agents/skills/qa-aci-interface/examples/surgical_edit_sample.json +12 -0
  113. package/.agents/skills/qa-memory-os/SKILL.md +80 -0
  114. package/.agents/skills/qa-memory-os/examples/archival_memory_sample.json +21 -0
  115. package/.agents/skills/rbt-manual-testing/SKILL.md +137 -0
  116. package/.agents/skills/rbt-manual-testing/examples/checkout_rbt_manual_suite.md +25 -0
  117. package/.agents/skills/rbt-manual-testing/references/field_validation_checklist.md +29 -0
  118. package/.agents/skills/repo-quality-audit/SKILL.md +68 -0
  119. package/.agents/skills/repo-quality-audit/examples/sample_audit_walkthrough.md +15 -0
  120. package/.agents/skills/repo-quality-audit/examples/sample_repo_audit.md +33 -0
  121. package/.agents/skills/review-spec/SKILL.md +60 -0
  122. package/.agents/skills/review-spec/examples/pocock_grilling_decision_rubric.md +40 -0
  123. package/.agents/skills/review-spec/examples/sample_spec_review.md +33 -0
  124. package/.agents/skills/security-dast-sentinel/SKILL.md +119 -0
  125. package/.agents/skills/security-dast-sentinel/examples/dast_scan_config.json +10 -0
  126. package/.agents/skills/security-dast-sentinel/references/AI-AND-LLM.md +113 -0
  127. package/.agents/skills/security-dast-sentinel/references/ATTACK-CLASSES.md +89 -0
  128. package/.agents/skills/security-dast-sentinel/references/dast_recipes.ts +33 -0
  129. package/.agents/skills/self-healing-locator/SKILL.md +86 -0
  130. package/.agents/skills/self-healing-locator/examples/aom_diff_sample.json +16 -0
  131. package/.agents/skills/senior-code-review/SKILL.md +108 -0
  132. package/.agents/skills/senior-code-review/examples/sample_review_walkthrough.md +29 -0
  133. package/.agents/skills/skillspector-security-guard/SKILL.md +57 -0
  134. package/.agents/skills/skillspector-security-guard/examples/audit_threat_vectors_report.json +35 -0
  135. package/.agents/skills/skillspector-security-guard/examples/safe_mcp_config.json +12 -0
  136. package/.agents/skills/surgical-coding-principles/SKILL.md +89 -0
  137. package/.agents/skills/surgical-coding-principles/examples/surgical_vs_scope_creep.md +46 -0
  138. package/.agents/skills/synthetic-test-data-generator/SKILL.md +135 -0
  139. package/.agents/skills/synthetic-test-data-generator/examples/idempotent_data_recipe.json +9 -0
  140. package/.agents/skills/systematic-debugging/SKILL.md +100 -0
  141. package/.agents/skills/systematic-debugging/examples/four_phase_case.md +44 -0
  142. package/.agents/skills/technical-debt-harvester/SKILL.md +70 -0
  143. package/.agents/skills/technical-debt-harvester/examples/sample_debt_ledger.md +25 -0
  144. package/.agents/skills/technical-debt-harvester/examples/sample_ledger_output.md +20 -0
  145. package/.agents/skills/test-driven-development/SKILL.md +114 -0
  146. package/.agents/skills/test-driven-development/examples/red_green_refactor_qa.md +78 -0
  147. package/.agents/skills/token-and-context-optimizer/SKILL.md +70 -0
  148. package/.agents/skills/token-and-context-optimizer/examples/distilled_log_sample.txt +3 -0
  149. package/.agents/skills/token-and-context-optimizer/references/context_engineering_guide.md +49 -0
  150. package/.agents/skills/tot-exploratory-testing/SKILL.md +59 -0
  151. package/.agents/skills/tot-exploratory-testing/examples/payment_gateway_tot_tree.json +62 -0
  152. package/.agents/skills/tot-exploratory-testing/examples/tot_graph_sample.json +35 -0
  153. package/.agents/skills/verification-before-completion/SKILL.md +100 -0
  154. package/.agents/skills/verification-before-completion/examples/evidence_log_example.md +46 -0
  155. package/.agents/skills/visual-regression-sentinel/SKILL.md +82 -0
  156. package/.agents/skills/visual-regression-sentinel/examples/visual_mask_rules.json +9 -0
  157. package/.agents/skills/wcag-audit-patterns/SKILL.md +77 -0
  158. package/.agents/skills/wcag-audit-patterns/examples/wcag_compliance_checklist.json +10 -0
  159. package/.agents/skills/wcag-audit-patterns/resources/implementation-playbook.md +541 -0
  160. package/.agents/skills/web-agent-gym-benchmarking/SKILL.md +62 -0
  161. package/.agents/skills/web-agent-gym-benchmarking/examples/benchmark_report_sample.json +22 -0
  162. package/.agents/skills/web-agent-gym-benchmarking/examples/enterprise_tasks_suite.json +38 -0
  163. package/.agents/skills/web-vitals-and-performance-profiler/SKILL.md +65 -0
  164. package/.agents/skills/web-vitals-and-performance-profiler/examples/cwv_budget_policy.json +6 -0
  165. package/.agents/skills/web-vitals-and-performance-profiler/examples/playwright_cwv_profiler_fixture.ts +118 -0
  166. package/.agents/templates/completion_report.md +57 -0
  167. package/.agents/workflows/analyze_requirement_document.md +18 -0
  168. package/.agents/workflows/export_testcases_excel.md +32 -0
  169. package/.agents/workflows/generate_combinatorial_test_data.md +28 -0
  170. package/.agents/workflows/generate_cross_module_test_plan.md +37 -0
  171. package/.agents/workflows/generate_manual_testcases_rbt.md +56 -0
  172. package/.agents/workflows/generate_requirements_from_website.md +25 -0
  173. package/.agents/workflows/generate_testcases_from_requirements.md +21 -0
  174. package/.agents/workflows/graphify.md +10 -0
  175. package/.agents/workflows/test-impact.md +15 -0
  176. package/.agents/workflows/verify.md +34 -0
  177. package/.cursor/rules/agents.mdc +16 -0
  178. package/.cursor/rules/language.mdc +7 -0
  179. package/.cursor/rules/synapse-qa.mdc +24 -0
  180. package/.cursorrules +27 -0
  181. package/.dockerignore +53 -0
  182. package/.pre-commit-hooks.yaml +14 -0
  183. package/.windsurfrules +26 -0
  184. package/AGENTS.md +86 -0
  185. package/CLAUDE.md +54 -0
  186. package/Dockerfile +81 -0
  187. package/LICENSE +52 -0
  188. package/NOTICE +264 -0
  189. package/README.en.md +171 -0
  190. package/README.md +170 -2
  191. package/action.yml +51 -0
  192. package/agentskills.json +16 -0
  193. package/bin/agent-qa.js +138 -0
  194. package/docker-compose.yml +74 -0
  195. package/docs/ARCHITECTURE.en.md +198 -0
  196. package/docs/ARCHITECTURE.md +199 -0
  197. package/docs/CI_CD_INTEGRATION.en.md +170 -0
  198. package/docs/CI_CD_INTEGRATION.md +170 -0
  199. package/docs/CLI_REFERENCE.en.md +174 -0
  200. package/docs/CLI_REFERENCE.md +176 -0
  201. package/docs/CONTRIBUTING.en.md +49 -0
  202. package/docs/CONTRIBUTING.md +49 -0
  203. package/docs/PERFORMANCE_AUDIT_REPORT.md +783 -0
  204. package/docs/PLUGIN_DEVELOPMENT_GUIDE.md +127 -0
  205. package/docs/QUALITY_GATES.en.md +118 -0
  206. package/docs/QUALITY_GATES.md +118 -0
  207. package/docs/TOKEN_QUOTA_PLAYBOOK.md +41 -0
  208. package/docs/TOOL_CATALOG.md +129 -0
  209. package/docs/adopted-ecosystem-tools.md +96 -0
  210. package/docs/research/EXTERNAL_AGENT_SKILLS_SURVEY.md +1062 -0
  211. package/docs/research/agent_skill_training_analysis.md +1358 -0
  212. package/docs/schemas/synapse.config.schema.json +86 -0
  213. package/package.json +94 -4
  214. package/plugin.json +31 -0
  215. package/scripts/generate_skill_examples.py +244 -0
  216. package/scripts/install.ps1 +112 -0
  217. package/scripts/install_global_plugin.ps1 +94 -0
  218. package/scripts/install_global_plugin.sh +49 -0
  219. package/scripts/lint_skills.ps1 +57 -0
  220. package/scripts/package_dist.py +337 -0
  221. package/scripts/setup.sh +59 -0
  222. package/scripts/update_hub.ps1 +19 -0
  223. package/scripts/update_hub.sh +15 -0
  224. package/skills_manifest.json +854 -0
  225. package/synapse.config.json +31 -0
  226. package/templates/PROJECT_AI_GUIDE_TEMPLATE.md +111 -0
  227. package/templates/PROJECT_STATE_TEMPLATE.md +20 -0
  228. package/templates/ai_bridges/CLAUDE.md +54 -0
  229. package/templates/ai_bridges/copilot-instructions.md +20 -0
  230. package/templates/ai_bridges/cursor_synapse_qa.mdc +24 -0
  231. package/templates/ai_bridges/windsurfrules +26 -0
  232. package/templates/ci/github-actions-synapse.yml +95 -0
  233. package/templates/ci/gitlab-ci-synapse.yml +16 -0
  234. package/templates/ui/index.html +1069 -0
  235. package/templates/welcome.html.tmpl +2074 -0
  236. package/tools/.infer_baseline.json +30 -0
  237. package/tools/TOOLS_RUNBOOK.md +1553 -0
  238. package/tools/TOOL_CATALOG.json +1769 -0
  239. package/tools/__init__.py +43 -0
  240. package/tools/_openapi_parser.py +158 -0
  241. package/tools/agent_canary.py +525 -0
  242. package/tools/agentless_patcher.py +417 -0
  243. package/tools/analyze_project.py +262 -0
  244. package/tools/api_drift_sentinel.py +208 -0
  245. package/tools/api_fuzzer.py +762 -0
  246. package/tools/author_integrity.py +190 -0
  247. package/tools/auto_heal.py +271 -0
  248. package/tools/auto_heal_reflexion.py +532 -0
  249. package/tools/autogen_qa_broker.py +844 -0
  250. package/tools/benchmark_swarm_context.py +394 -0
  251. package/tools/browser_helpers.js +746 -0
  252. package/tools/browsergym_eval.py +236 -0
  253. package/tools/bug_reporter.py +252 -0
  254. package/tools/bump_version.py +423 -0
  255. package/tools/cache_resolver.py +1214 -0
  256. package/tools/check_env.py +426 -0
  257. package/tools/check_version_sync.py +256 -0
  258. package/tools/ci_healing_hook.py +126 -0
  259. package/tools/cli.py +1598 -0
  260. package/tools/config_decoupler.py +253 -0
  261. package/tools/contract_validator.py +141 -0
  262. package/tools/core/__init__.py +70 -0
  263. package/tools/core/adapters.py +431 -0
  264. package/tools/core/circuit_breaker.py +263 -0
  265. package/tools/core/cli_runtime.py +66 -0
  266. package/tools/core/file_lock.py +159 -0
  267. package/tools/core/i18n.py +394 -0
  268. package/tools/core/memory_bus.py +905 -0
  269. package/tools/core/process_supervisor.py +332 -0
  270. package/tools/core/telemetry.py +329 -0
  271. package/tools/count_tokens.py +1267 -0
  272. package/tools/create_mock_docx.py +104 -0
  273. package/tools/dashboard_generator.py +2403 -0
  274. package/tools/db_sandbox.py +675 -0
  275. package/tools/debt_harvester.py +237 -0
  276. package/tools/distill_log.py +161 -0
  277. package/tools/dspy_qa_signatures.py +356 -0
  278. package/tools/e2e_flow_prober.py +132 -0
  279. package/tools/export_postman_collection.py +945 -0
  280. package/tools/flaky_detector.py +389 -0
  281. package/tools/fsm_enforcer.py +450 -0
  282. package/tools/fsm_middleware.py +401 -0
  283. package/tools/fuzz_payloads.py +197 -0
  284. package/tools/generate_allure_report.py +88 -0
  285. package/tools/generate_api_matrix.py +193 -0
  286. package/tools/generate_jmx_plan.py +1322 -0
  287. package/tools/generate_sbom.py +252 -0
  288. package/tools/generate_tc_from_story.py +203 -0
  289. package/tools/generate_test_reports.py +133 -0
  290. package/tools/generate_tool_catalog.py +482 -0
  291. package/tools/gherkin_suite.py +758 -0
  292. package/tools/git_pre_commit_guard.py +298 -0
  293. package/tools/goldfish_review.py +366 -0
  294. package/tools/heal/__init__.py +28 -0
  295. package/tools/heal_pr_automator.py +220 -0
  296. package/tools/heuristic_locator_matcher.py +351 -0
  297. package/tools/hub_publisher.py +623 -0
  298. package/tools/humanize_linter.py +438 -0
  299. package/tools/infer_linter.py +977 -0
  300. package/tools/init_config.py +306 -0
  301. package/tools/interview_story.py +116 -0
  302. package/tools/jira_sync.py +566 -0
  303. package/tools/jtl_analyzer.py +474 -0
  304. package/tools/lint/__init__.py +30 -0
  305. package/tools/lint_ai_docs.py +374 -0
  306. package/tools/lookup_tc.py +165 -0
  307. package/tools/lookup_xpath.py +167 -0
  308. package/tools/matrix_sharder.py +148 -0
  309. package/tools/mcp/__init__.py +18 -0
  310. package/tools/mcp_docx_server.ps1 +13 -0
  311. package/tools/mcp_docx_server.py +851 -0
  312. package/tools/mcp_excel_server.ps1 +13 -0
  313. package/tools/mcp_excel_server.py +441 -0
  314. package/tools/mcp_server.py +725 -0
  315. package/tools/md_to_xlsx.py +327 -0
  316. package/tools/micro_mutator.py +887 -0
  317. package/tools/mipro_assertion_tuner.py +210 -0
  318. package/tools/network_mock_shield.py +311 -0
  319. package/tools/newman_analyzer.py +384 -0
  320. package/tools/omni_emitter.py +579 -0
  321. package/tools/omni_parser.py +450 -0
  322. package/tools/omni_transpiler.py +168 -0
  323. package/tools/openxml_guard.py +438 -0
  324. package/tools/output_formatter.py +182 -0
  325. package/tools/package_release.py +325 -0
  326. package/tools/perf/__init__.py +24 -0
  327. package/tools/pinpoint_failure.py +190 -0
  328. package/tools/project_state.py +171 -0
  329. package/tools/qa_event_stream.py +358 -0
  330. package/tools/repo_map.py +346 -0
  331. package/tools/report/__init__.py +32 -0
  332. package/tools/reversible_sandbox.py +344 -0
  333. package/tools/safety_firewall.py +437 -0
  334. package/tools/security_coverage_ledger.py +538 -0
  335. package/tools/security_scanner.py +229 -0
  336. package/tools/senior_code_review.py +393 -0
  337. package/tools/setup_project.py +770 -0
  338. package/tools/skill_collision_guard.py +304 -0
  339. package/tools/skill_profiles.py +217 -0
  340. package/tools/skill_vault.py +481 -0
  341. package/tools/skillspector.py +1278 -0
  342. package/tools/smart_visual_masker.py +132 -0
  343. package/tools/spec_drift_sentinel.py +438 -0
  344. package/tools/swe_qa_aci.py +369 -0
  345. package/tools/synapse_observer.py +485 -0
  346. package/tools/synapse_qa_bench.py +190 -0
  347. package/tools/sync_agent_rules.py +274 -0
  348. package/tools/telemetry_correlator.py +397 -0
  349. package/tools/template_excel_exporter.py +514 -0
  350. package/tools/templates/jmeter-distributed/README.md +54 -0
  351. package/tools/templates/jmeter-distributed/docker-compose.yml +83 -0
  352. package/tools/test_impact.py +419 -0
  353. package/tools/test_memory_os.py +462 -0
  354. package/tools/textgrad_mutation_optimizer.py +237 -0
  355. package/tools/tms_sync_bridge.py +834 -0
  356. package/tools/tot_exploratory_tester.py +239 -0
  357. package/tools/trace_data_flow.py +240 -0
  358. package/tools/traffic_session_converter.py +256 -0
  359. package/tools/trend_analytics.py +314 -0
  360. package/tools/ui_server.py +401 -0
  361. package/tools/universal_ir.py +488 -0
  362. package/tools/update_sentinel.py +383 -0
  363. package/tools/validate_groovy_scripts.py +173 -0
  364. package/tools/verify_all.py +1271 -0
  365. package/tools/visual_diff_canvas.py +143 -0
  366. package/tools/visual_som_helper.py +550 -0
  367. package/tools/watch_mode.py +308 -0
  368. package/tools/wcag_audit.py +239 -0
  369. package/tools/welcome_page.py +290 -0
@@ -0,0 +1,725 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Enterprise Model Context Protocol (MCP) Standard Server
4
+ -------------------------------------------------------
5
+ Exposes centralized tools/ capabilities as standardized JSON-RPC 2.0 MCP Tools
6
+ compatible with Google Antigravity, Cursor, Claude Desktop, Windsurf, and any MCP client.
7
+ Communicates via standard JSON-RPC stdio.
8
+ """
9
+
10
+ import os
11
+ import sys
12
+ import json
13
+ import re
14
+ from pathlib import Path
15
+ from typing import Dict, Any, Optional, Set
16
+
17
+ # Enforce UTF-8 stdio encoding
18
+ if hasattr(sys.stdout, 'reconfigure'):
19
+ try:
20
+ sys.stdout.reconfigure(encoding='utf-8')
21
+ sys.stderr.reconfigure(encoding='utf-8')
22
+ sys.stdin.reconfigure(encoding='utf-8')
23
+ except Exception:
24
+ pass
25
+
26
+ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
27
+ HUB_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, ".."))
28
+ sys.path.insert(0, SCRIPT_DIR)
29
+
30
+ import verify_all
31
+ import analyze_project
32
+ import setup_project
33
+ import auto_heal
34
+ import safety_firewall
35
+ import api_drift_sentinel
36
+ import cache_resolver
37
+ import distill_log
38
+ import micro_mutator
39
+ import heal_pr_automator
40
+ import matrix_sharder
41
+ import tms_sync_bridge
42
+ import db_sandbox
43
+ import traffic_session_converter
44
+ import visual_som_helper
45
+ import gherkin_suite
46
+ import api_fuzzer
47
+
48
+ SERVER_NAME = "enterprise-agent-qa"
49
+ SERVER_VERSION = "3.8.3"
50
+
51
+ MCP_TOOLS = [
52
+ {
53
+ "name": "verify_all_gates",
54
+ "description": "Validates the 10 Quality Gates Definition of Done (UTF-8, paths, Clean POM, AI docs, blacklist, security, infer linter, micro-mutator, skill collision, performance SLA) with pre-flight integrity check.",
55
+ "inputSchema": {
56
+ "type": "object",
57
+ "properties": {
58
+ "repo_path": {"type": "string", "description": "Absolute or relative path to the target repository. Defaults to CWD."}
59
+ }
60
+ }
61
+ },
62
+ {
63
+ "name": "analyze_project",
64
+ "description": "Executes 5-in-1 project health and AST intelligence analysis, creating PROJECT_HEALTH_REPORT.md and repo_map.txt.",
65
+ "inputSchema": {
66
+ "type": "object",
67
+ "properties": {
68
+ "repo_path": {"type": "string", "description": "Target project repository directory to audit."}
69
+ }
70
+ }
71
+ },
72
+ {
73
+ "name": "setup_project",
74
+ "description": "Autonomous 1-click bootstrap of any test project: detects stack, generates PROJECT_AI_GUIDE.md, installs Git hook, and maps AST.",
75
+ "inputSchema": {
76
+ "type": "object",
77
+ "properties": {
78
+ "repo_path": {"type": "string", "description": "Path to target project to bootstrap."},
79
+ "dry_run": {"type": "boolean", "description": "Preview setup without modifying filesystem (default: false)."},
80
+ "no_global": {"type": "boolean", "description": "Local-only mode: do not touch ~/.gemini (default: true)."}
81
+ }
82
+ }
83
+ },
84
+ {
85
+ "name": "auto_heal_failure",
86
+ "description": "Diagnoses test failures in 0.1s from JUnit XML and queries semantic memory cache for proven patches.",
87
+ "inputSchema": {
88
+ "type": "object",
89
+ "properties": {
90
+ "target_dir": {"type": "string", "description": "Target project root directory."},
91
+ "junit_xml_path": {"type": "string", "description": "Optional direct path to failing JUnit XML report."}
92
+ }
93
+ }
94
+ },
95
+ {
96
+ "name": "check_action_safety",
97
+ "description": "Action Safety Firewall: verifies whether an intended UI action (click, fill) touches destructive elements (Delete, Pay, Drop).",
98
+ "inputSchema": {
99
+ "type": "object",
100
+ "properties": {
101
+ "action_type": {"type": "string", "description": "Action type (e.g. click, fill, submit)."},
102
+ "element_text": {"type": "string", "description": "Text or label of target DOM element."},
103
+ "selector": {"type": "string", "description": "CSS or XPath selector of element."}
104
+ }
105
+ }
106
+ },
107
+ {
108
+ "name": "check_contract_drift",
109
+ "description": "Compares two OpenAPI / Swagger specifications and detects breaking changes (removed endpoints, changed types, newly required params).",
110
+ "inputSchema": {
111
+ "type": "object",
112
+ "properties": {
113
+ "old_spec_path": {"type": "string", "description": "Path to baseline OpenAPI JSON file."},
114
+ "new_spec_path": {"type": "string", "description": "Path to current OpenAPI JSON file."}
115
+ },
116
+ "required": ["old_spec_path", "new_spec_path"]
117
+ }
118
+ },
119
+ {
120
+ "name": "query_memory_cache",
121
+ "description": "Queries the 0-token SQLite semantic memory cache for known UI exceptions and proven repair patches.",
122
+ "inputSchema": {
123
+ "type": "object",
124
+ "properties": {
125
+ "error_signature": {"type": "string", "description": "Exception trace or error message to lookup."}
126
+ },
127
+ "required": ["error_signature"]
128
+ }
129
+ },
130
+ {
131
+ "name": "distill_log",
132
+ "description": "Filters verbose CLI or Gradle build logs by 95%, retaining only actionable stacktraces and pointers.",
133
+ "inputSchema": {
134
+ "type": "object",
135
+ "properties": {
136
+ "raw_log_text": {"type": "string", "description": "Raw terminal log output to compress."}
137
+ },
138
+ "required": ["raw_log_text"]
139
+ }
140
+ },
141
+ {
142
+ "name": "run_micro_mutation",
143
+ "description": "Injects syntactic micro-mutants (flipping operators, booleans) to verify that AI-generated test assertions are robust.",
144
+ "inputSchema": {
145
+ "type": "object",
146
+ "properties": {
147
+ "target_path": {"type": "string", "description": "Path to test script or directory to mutate."}
148
+ }
149
+ }
150
+ },
151
+ {
152
+ "name": "plan_healing_pr",
153
+ "description": "Calculates composite confidence score for healed locators and formats an automated Pull Request draft.",
154
+ "inputSchema": {
155
+ "type": "object",
156
+ "properties": {
157
+ "page_file": {"type": "string", "description": "Page Class path."},
158
+ "old_locator": {"type": "string", "description": "Original stale selector."},
159
+ "new_locator": {"type": "string", "description": "Healed replacement selector."},
160
+ "aom_score": {"type": "number", "description": "AOM match score 0.0-1.0."},
161
+ "spatial_score": {"type": "number", "description": "Spatial score 0.0-1.0."},
162
+ "visual_score": {"type": "number", "description": "Visual SSIM score 0.0-1.0."}
163
+ },
164
+ "required": ["page_file", "old_locator", "new_locator"]
165
+ }
166
+ },
167
+ {
168
+ "name": "shard_test_matrix",
169
+ "description": "Distributes test cases evenly across N parallel CI/CD runners using Duration-Balanced Bin-Packing.",
170
+ "inputSchema": {
171
+ "type": "object",
172
+ "properties": {
173
+ "target_dir": {"type": "string", "description": "Target project root directory."},
174
+ "num_shards": {"type": "integer", "description": "Number of parallel workers (default 4)."}
175
+ }
176
+ }
177
+ },
178
+ {
179
+ "name": "pull_alm_story",
180
+ "description": "Pulls User Story and Acceptance Criteria (Given-When-Then) from Jira REST API v3 (or mock simulation) for test generation context.",
181
+ "inputSchema": {
182
+ "type": "object",
183
+ "properties": {
184
+ "issue_key": {"type": "string", "description": "ALM Issue Key (e.g. PROJ-1042)."}
185
+ },
186
+ "required": ["issue_key"]
187
+ }
188
+ },
189
+ {
190
+ "name": "report_alm_defect",
191
+ "description": "Creates an automated Bug Ticket in Jira/TMS with full diagnostic reproduction steps, stack trace, and screenshot attachments.",
192
+ "inputSchema": {
193
+ "type": "object",
194
+ "properties": {
195
+ "project_key": {"type": "string", "description": "Target project key (e.g. PROJ)."},
196
+ "test_case_id": {"type": "string", "description": "Failing test case ID."},
197
+ "summary": {"type": "string", "description": "Defect summary."},
198
+ "error_message": {"type": "string", "description": "Exact failure error message."},
199
+ "stack_trace": {"type": "string", "description": "Exception stack trace."},
200
+ "screenshot_path": {"type": "string", "description": "Path to FAILED screenshot image."}
201
+ },
202
+ "required": ["project_key", "test_case_id", "summary", "error_message"]
203
+ }
204
+ },
205
+ {
206
+ "name": "manage_db_sandbox",
207
+ "description": "Zero-pollution ephemeral database manager: creates baseline snapshot, restores pristine DB state, or executes transaction savepoints.",
208
+ "inputSchema": {
209
+ "type": "object",
210
+ "properties": {
211
+ "action": {"type": "string", "enum": ["snapshot", "restore", "audit_and_purge"], "description": "Sandbox operation to execute."},
212
+ "db_path": {"type": "string", "description": "Path to database file (optional for SQLite)."},
213
+ "snapshot_id": {"type": "string", "description": "Snapshot identifier (default: pristine_baseline)."},
214
+ "dry_run": {"type": "boolean", "description": "For audit_and_purge: preview records to purge without deleting."}
215
+ },
216
+ "required": ["action"]
217
+ }
218
+ },
219
+ {
220
+ "name": "convert_traffic_session",
221
+ "description": "Shift-Right Replay: Transforms recorded HTTP Archive (.har) or RUM session into PII-sanitized Playwright test suite.",
222
+ "inputSchema": {
223
+ "type": "object",
224
+ "properties": {
225
+ "input_file": {"type": "string", "description": "Path to .har or JSON network session file."},
226
+ "test_name": {"type": "string", "description": "Generated test suite name."}
227
+ },
228
+ "required": ["input_file"]
229
+ }
230
+ },
231
+ {
232
+ "name": "resolve_visual_som_coordinates",
233
+ "description": "Multimodal Vision Grounding: Resolves click coordinates (x, y) on HTML5 Canvas or Shadow DOM using Set-of-Marks (SoM).",
234
+ "inputSchema": {
235
+ "type": "object",
236
+ "properties": {
237
+ "image_path": {"type": "string", "description": "Path to screenshot image."},
238
+ "target_label": {"type": "string", "description": "Target element label or text."},
239
+ "mark_id": {"type": "integer", "description": "Specific Mark ID to click."}
240
+ }
241
+ }
242
+ },
243
+ {
244
+ "name": "compile_gherkin_suite",
245
+ "description": "Compiles Gherkin .feature files into an expanded test matrix, hub Universal IR and a proven-vs-owed coverage-gap report (0 LLM tokens).",
246
+ "inputSchema": {
247
+ "type": "object",
248
+ "properties": {
249
+ "target": {"type": "string", "description": "A .feature file or directory containing .feature files."}
250
+ },
251
+ "required": ["target"]
252
+ }
253
+ },
254
+ {
255
+ "name": "fuzz_api",
256
+ "description": "Autonomous API fuzzing (active, dry-run by default for safety) or offline passive spec audit with ZAP-style severity taxonomy.",
257
+ "inputSchema": {
258
+ "type": "object",
259
+ "properties": {
260
+ "base_url": {"type": "string", "description": "Base URL of target API (non-production allowlist enforced)."},
261
+ "spec_path": {"type": "string", "description": "Path or URL to OpenAPI/Swagger JSON spec."},
262
+ "mode": {"type": "string", "enum": ["active", "passive"], "description": "active fuzzing or passive offline spec audit."},
263
+ "dry_run": {"type": "boolean", "description": "Deterministic offline mock (default true for safety)."}
264
+ },
265
+ "required": ["base_url"]
266
+ }
267
+ }
268
+ ]
269
+
270
+
271
+ def _validate_safe_path(filepath: str, allowed_root: Optional[str] = None, allowed_exts: Optional[Set[str]] = None) -> str:
272
+ """
273
+ Validates that a path is safe and does not access restricted system paths or traverse outside the project root.
274
+ Resolves symlinks via Path.resolve() and enforces cross-platform boundaries (Windows, macOS, Linux).
275
+ """
276
+ if not filepath or not isinstance(filepath, str):
277
+ raise ValueError("File path must be a non-empty string")
278
+
279
+ # Reject null bytes and Windows UNC network share paths
280
+ if "\0" in filepath or filepath.startswith("\\\\"):
281
+ raise PermissionError(f"Access denied: invalid or UNC path '{filepath}'")
282
+
283
+ from tools.core.cli_runtime import get_repo_root
284
+ effective_root = allowed_root or os.environ.get("SYNAPSE_PROJECT_ROOT") or get_repo_root()
285
+ try:
286
+ root_path = Path(effective_root).resolve()
287
+ target_path = Path(filepath).resolve()
288
+ except Exception as e:
289
+ raise PermissionError(f"Access denied: cannot resolve path '{filepath}': {e}")
290
+
291
+ # Case-insensitive path comparison across OS filesystems
292
+ root_norm = os.path.normcase(str(root_path))
293
+ target_norm = os.path.normcase(str(target_path))
294
+
295
+ # Path must reside within the allowed root
296
+ if target_norm != root_norm and not target_norm.startswith(root_norm + os.sep):
297
+ raise PermissionError(f"Access denied: path '{filepath}' resolves outside allowed project root '{root_path}'")
298
+
299
+ # Reject explicit sensitive configuration / secret files and private keys
300
+ base_name = target_path.name.lower()
301
+ sensitive_exact = {
302
+ ".env", ".env.local", ".env.production", ".env.staging", ".npmrc", ".netrc", ".git-credentials",
303
+ "id_rsa", "id_ecdsa", "id_ed25519", "id_dsa", "credentials.json", "service-account.json"
304
+ }
305
+ sensitive_exts = {".pem", ".key", ".p12", ".pfx", ".pkcs12"}
306
+ if base_name in sensitive_exact or base_name.startswith(".env.") or target_path.suffix.lower() in sensitive_exts:
307
+ raise PermissionError(f"Access denied: path references sensitive credentials or secret file '{target_path.name}'")
308
+
309
+ # Cross-platform sensitive system prefixes
310
+ try:
311
+ user_home = Path.home().resolve()
312
+ except Exception:
313
+ user_home = Path(os.path.expanduser("~")).resolve()
314
+
315
+ sensitive_prefixes = [
316
+ Path("/etc"), Path("/var/run"), Path("/proc"), Path("/sys"), Path("/dev"), Path("/root"), Path("/private/etc"),
317
+ user_home / ".ssh",
318
+ user_home / ".aws",
319
+ user_home / ".gnupg",
320
+ user_home / ".kube",
321
+ user_home / ".docker",
322
+ user_home / ".config" / "gh",
323
+ user_home / "Library" / "Keychains",
324
+ ]
325
+ if sys.platform == "win32":
326
+ for env_win in ("SystemRoot", "WINDIR", "APPDATA", "LOCALAPPDATA", "ProgramFiles", "ProgramFiles(x86)"):
327
+ win_val = os.environ.get(env_win)
328
+ if win_val:
329
+ try:
330
+ sensitive_prefixes.append(Path(win_val).resolve())
331
+ except OSError:
332
+ sensitive_prefixes.append(Path(win_val))
333
+
334
+ for sp in sensitive_prefixes:
335
+ sp_norm = os.path.normcase(str(sp))
336
+ if target_norm == sp_norm or target_norm.startswith(sp_norm + os.sep):
337
+ raise PermissionError(f"Access denied: path references restricted system directory '{sp}'")
338
+
339
+ if allowed_exts:
340
+ ext = target_path.suffix.lower()
341
+ if ext not in allowed_exts and not target_path.is_dir():
342
+ raise PermissionError(f"Access denied: file extension '{ext}' is not permitted")
343
+
344
+ return str(target_path)
345
+
346
+
347
+ def _handle_verify_all_gates(arguments: Dict[str, Any]) -> str:
348
+ repo = _validate_safe_path(arguments.get("repo_path") or os.getcwd())
349
+ mode = verify_all.detect_repo_mode(repo)
350
+ if not verify_all.verify_engine_preflight(repo, mode=mode, silent=True):
351
+ return "[DoD BLOCKED] Pre-flight Engine Integrity Guard failed: Author Attribution / MIT License Violated."
352
+ passed = True
353
+ gates = [
354
+ ("Gate 1: UTF-8 No BOM", verify_all.gate_1_bom_check),
355
+ ("Gate 2: Path Portability", verify_all.gate_2_path_portability),
356
+ ("Gate 3: Clean POM", verify_all.gate_3_clean_pom),
357
+ ("Gate 4: AI Docs Linter", verify_all.gate_4_ai_docs_lint),
358
+ ("Gate 5: Temp Blacklist", verify_all.gate_5_cleanup_blacklist),
359
+ ("Gate 6: Credential Security", verify_all.gate_6_credential_security),
360
+ ("Gate 7: Infer Linter", verify_all.gate_7_infer_linter),
361
+ ("Gate 8: AST Mutation Sentinel", verify_all.gate_8_micro_mutator),
362
+ ("Gate 9: Skill Collision Guard", verify_all.gate_9_skill_collision),
363
+ ("Gate 10: Performance & SLA Sentinel", verify_all.gate_10_performance_sla),
364
+ ]
365
+ results = []
366
+ for g_name, g_fn in gates:
367
+ res = g_fn(repo, mode=mode)
368
+ results.append(f"{g_name}: {'PASS' if res else 'FAIL'}")
369
+ if not res:
370
+ passed = False
371
+ summary = "100% ALL 10 GATES PASSED" if passed else "VERIFICATION FAILED"
372
+ return f"[{summary}]\n" + "\n".join(results)
373
+
374
+
375
+ def _handle_analyze_project(arguments: Dict[str, Any]) -> str:
376
+ repo = _validate_safe_path(arguments.get("repo_path") or os.getcwd())
377
+ code = analyze_project.run_full_analysis(repo)
378
+ return f"Project Analysis finished with exit code {code}. Report saved at {os.path.join(repo, 'PROJECT_HEALTH_REPORT.md')}."
379
+
380
+
381
+ def _handle_setup_project(arguments: Dict[str, Any]) -> str:
382
+ repo = _validate_safe_path(arguments.get("repo_path") or os.getcwd())
383
+ dry_run = bool(arguments.get("dry_run", False))
384
+ no_global = bool(arguments.get("no_global", True))
385
+ code = setup_project.run_setup(
386
+ repo,
387
+ dry_run=dry_run,
388
+ no_global=no_global,
389
+ no_git_hook=True,
390
+ no_browser=True,
391
+ open_browser=False
392
+ )
393
+ mode_label = " (DRY-RUN)" if dry_run else ""
394
+ return f"Project Setup finished with exit code {code}{mode_label}."
395
+
396
+
397
+ def _handle_auto_heal_failure(arguments: Dict[str, Any]) -> str:
398
+ target = _validate_safe_path(arguments.get("target_dir") or os.getcwd())
399
+ xml = _validate_safe_path(arguments["junit_xml_path"]) if arguments.get("junit_xml_path") else None
400
+ plan = auto_heal.diagnose_and_plan_heal(target, xml)
401
+ return json.dumps(plan, indent=2)
402
+
403
+
404
+ def _handle_check_action_safety(arguments: Dict[str, Any]) -> str:
405
+ auth = safety_firewall.inspect_and_authorize(
406
+ action_type=arguments.get("action_type", "click"),
407
+ text=arguments.get("element_text", ""),
408
+ selector=arguments.get("selector", ""),
409
+ force=False
410
+ )
411
+ return json.dumps(auth, indent=2)
412
+
413
+
414
+ def _handle_check_contract_drift(arguments: Dict[str, Any]) -> str:
415
+ old_path = _validate_safe_path(arguments["old_spec_path"])
416
+ new_path = _validate_safe_path(arguments["new_spec_path"])
417
+ old_data = api_drift_sentinel.load_spec(old_path)
418
+ new_data = api_drift_sentinel.load_spec(new_path)
419
+ analysis = api_drift_sentinel.compare_specs(old_data, new_data)
420
+ return api_drift_sentinel.generate_markdown_report(analysis, old_path, new_path)
421
+
422
+
423
+ def _handle_query_memory_cache(arguments: Dict[str, Any]) -> str:
424
+ res = cache_resolver.query_solution(arguments["error_signature"])
425
+ return json.dumps(res, indent=2) if res else "No matching solution found in memory cache."
426
+
427
+
428
+ def _handle_distill_log(arguments: Dict[str, Any]) -> str:
429
+ return distill_log.distill_log_content(arguments["raw_log_text"])
430
+
431
+
432
+ def _handle_run_micro_mutation(arguments: Dict[str, Any]) -> str:
433
+ target = _validate_safe_path(
434
+ arguments.get("target_path") or os.getcwd(),
435
+ allowed_exts={".py", ".ts", ".js", ".groovy", ".java"}
436
+ )
437
+ if os.path.isdir(target):
438
+ mutants = micro_mutator.scan_directory_for_mutants(target)
439
+ else:
440
+ with open(target, "r", encoding="utf-8", errors="ignore") as f:
441
+ content = f.read()
442
+ mutants = micro_mutator.generate_mutants_for_code(content, target)
443
+
444
+ sanitized_samples = []
445
+ for m in mutants[:5]:
446
+ sanitized_samples.append({
447
+ "id": m.get("id"),
448
+ "file": m.get("file"),
449
+ "line": m.get("line"),
450
+ "operator": m.get("description", "mutation"),
451
+ "original_snippet": m.get("original_snippet", ""),
452
+ "mutated_snippet": m.get("mutated_snippet", ""),
453
+ "status": m.get("status", "PENDING")
454
+ })
455
+ return json.dumps({"total_mutants": len(mutants), "sample_mutants": sanitized_samples}, indent=2)
456
+
457
+
458
+ def _handle_plan_healing_pr(arguments: Dict[str, Any]) -> str:
459
+ page_file = _validate_safe_path(arguments["page_file"])
460
+ conf = heal_pr_automator.calculate_healing_confidence(
461
+ arguments.get("aom_score", 0.95),
462
+ arguments.get("spatial_score", 0.90),
463
+ arguments.get("visual_score", 0.92)
464
+ )
465
+ pr = heal_pr_automator.generate_pr_draft(page_file, arguments["old_locator"], arguments["new_locator"], conf)
466
+ return json.dumps({"confidence": conf, "pr": pr}, indent=2)
467
+
468
+
469
+ def _handle_shard_test_matrix(arguments: Dict[str, Any]) -> str:
470
+ target = _validate_safe_path(arguments.get("target_dir") or os.getcwd())
471
+ num_shards = arguments.get("num_shards", 4)
472
+ files = matrix_sharder.find_test_files(target)
473
+ shards = matrix_sharder.shard_tests_lpt(files, target, num_shards)
474
+ return json.dumps({"total_tests": len(files), "shards": shards}, indent=2)
475
+
476
+
477
+ def _handle_pull_alm_story(arguments: Dict[str, Any]) -> str:
478
+ bridge = tms_sync_bridge.TMSBridge()
479
+ story = bridge.pull_story_acceptance_criteria(arguments["issue_key"])
480
+ return json.dumps(story, indent=2)
481
+
482
+
483
+ def _handle_report_alm_defect(arguments: Dict[str, Any]) -> str:
484
+ bridge = tms_sync_bridge.TMSBridge()
485
+ raw_screenshot = arguments.get("screenshot_path", "")
486
+ safe_screenshot = _validate_safe_path(raw_screenshot) if raw_screenshot else ""
487
+ ticket = bridge.report_defect(
488
+ project_key=arguments["project_key"],
489
+ test_case_id=arguments["test_case_id"],
490
+ summary=arguments["summary"],
491
+ error_message=arguments["error_message"],
492
+ stack_trace=arguments.get("stack_trace", ""),
493
+ screenshot_path=safe_screenshot
494
+ )
495
+ return json.dumps(ticket, indent=2)
496
+
497
+
498
+ def _handle_manage_db_sandbox(arguments: Dict[str, Any]) -> str:
499
+ action = arguments["action"]
500
+ raw_db = arguments.get("db_path", "")
501
+ safe_db = _validate_safe_path(raw_db) if raw_db else ""
502
+ raw_id = arguments.get("snapshot_id", "pristine_baseline")
503
+ safe_id = re.sub(r'[^a-zA-Z0-9_\-]', '', raw_id) or "pristine_baseline"
504
+
505
+ sandbox = db_sandbox.DBSandbox(db_path=safe_db)
506
+ if action == "snapshot":
507
+ res = sandbox.create_snapshot(safe_id)
508
+ elif action == "restore":
509
+ res = sandbox.restore_snapshot(safe_id)
510
+ elif action == "audit_and_purge":
511
+ dry_run = bool(arguments.get("dry_run", False))
512
+ res = sandbox.audit_and_purge_pollution(dry_run=dry_run)
513
+ else:
514
+ raise ValueError(f"Unknown sandbox action: {action}")
515
+ return json.dumps(res, indent=2)
516
+
517
+
518
+ def _handle_convert_traffic_session(arguments: Dict[str, Any]) -> str:
519
+ input_file = _validate_safe_path(arguments["input_file"])
520
+ test_name = arguments.get("test_name", "ProductionTrafficReplay")
521
+ with open(input_file, "r", encoding="utf-8", errors="ignore") as f:
522
+ data = json.load(f)
523
+ converter = traffic_session_converter.TrafficConverter(sanitize_pii=True)
524
+ requests = converter.parse_har(data)
525
+ test_code = converter.generate_playwright_test(requests, test_name=test_name)
526
+ return json.dumps({"total_requests": len(requests), "generated_test": test_code}, indent=2)
527
+
528
+
529
+ def _handle_resolve_visual_som_coordinates(arguments: Dict[str, Any]) -> str:
530
+ helper = visual_som_helper.VisualSoMHelper()
531
+ raw_img = arguments.get("image_path", "screenshot.png")
532
+ img = _validate_safe_path(raw_img)
533
+ lbl = arguments.get("target_label")
534
+ mid = arguments.get("mark_id")
535
+ marked_img, marks_map = helper.generate_som_overlay(img, [])
536
+ resolved = helper.resolve_mark_coordinates(marks_map, target_mark_id=mid, target_label=lbl)
537
+ return json.dumps({"marked_image": marked_img, "resolved_target": resolved}, indent=2)
538
+
539
+
540
+ def _handle_compile_gherkin_suite(arguments: Dict[str, Any]) -> str:
541
+ target = _validate_safe_path(arguments["target"])
542
+ res = gherkin_suite.compile_feature(target) if os.path.isfile(target) else gherkin_suite.run(target)
543
+ if isinstance(res, int):
544
+ return json.dumps({"exit_code": res, "detail": "see reports/gherkin_suite_report.json"}, indent=2)
545
+ persist = {k: v for k, v in res.items() if not k.startswith("_")}
546
+ return json.dumps({
547
+ "feature": persist.get("feature"),
548
+ "totals": persist.get("totals"),
549
+ "errors": persist.get("errors"),
550
+ "gaps": persist.get("gaps"),
551
+ "health_score_pct": persist.get("health_score_pct"),
552
+ }, indent=2)
553
+
554
+
555
+ def _handle_fuzz_api(arguments: Dict[str, Any]) -> str:
556
+ mode = arguments.get("mode", "active")
557
+ dry_run = arguments.get("dry_run", True)
558
+ spec_path = arguments.get("spec_path")
559
+ if spec_path and not (spec_path.startswith("http://") or spec_path.startswith("https://")):
560
+ spec_path = _validate_safe_path(spec_path)
561
+ fuzzer = api_fuzzer.ApiFuzzer(
562
+ base_url=arguments["base_url"],
563
+ spec_path_or_url=spec_path,
564
+ )
565
+ if mode == "passive":
566
+ scorecard = fuzzer.run_passive_scan()
567
+ return json.dumps({
568
+ "mode": scorecard["mode"],
569
+ "total_findings": scorecard["total_findings"],
570
+ "severity_summary": scorecard["severity_summary"],
571
+ "findings": scorecard["findings"],
572
+ }, indent=2)
573
+ scorecard = fuzzer.run_fuzz_suite(dry_run=dry_run)
574
+ return json.dumps({
575
+ "mode": scorecard["mode"],
576
+ "total_mutations": scorecard["total_mutations"],
577
+ "passed": scorecard["passed"],
578
+ "failed": scorecard["failed"],
579
+ "severity_summary": scorecard["severity_summary"],
580
+ }, indent=2)
581
+
582
+
583
+ TOOL_DISPATCH_TABLE: Dict[str, Any] = {
584
+ "verify_all_gates": _handle_verify_all_gates,
585
+ "analyze_project": _handle_analyze_project,
586
+ "setup_project": _handle_setup_project,
587
+ "auto_heal_failure": _handle_auto_heal_failure,
588
+ "check_action_safety": _handle_check_action_safety,
589
+ "check_contract_drift": _handle_check_contract_drift,
590
+ "query_memory_cache": _handle_query_memory_cache,
591
+ "distill_log": _handle_distill_log,
592
+ "run_micro_mutation": _handle_run_micro_mutation,
593
+ "plan_healing_pr": _handle_plan_healing_pr,
594
+ "shard_test_matrix": _handle_shard_test_matrix,
595
+ "pull_alm_story": _handle_pull_alm_story,
596
+ "report_alm_defect": _handle_report_alm_defect,
597
+ "manage_db_sandbox": _handle_manage_db_sandbox,
598
+ "convert_traffic_session": _handle_convert_traffic_session,
599
+ "resolve_visual_som_coordinates": _handle_resolve_visual_som_coordinates,
600
+ "compile_gherkin_suite": _handle_compile_gherkin_suite,
601
+ "fuzz_api": _handle_fuzz_api,
602
+ }
603
+
604
+
605
+ def handle_tool_call(name: str, arguments: Dict[str, Any]) -> str:
606
+ """Executes the corresponding internal tool function via dispatch table."""
607
+ handler = TOOL_DISPATCH_TABLE.get(name)
608
+ if not handler:
609
+ raise ValueError(f"Unknown MCP tool: {name}")
610
+ return handler(arguments)
611
+
612
+
613
+ def process_message(msg: Dict[str, Any]) -> Optional[Dict[str, Any]]:
614
+ """Processes an incoming JSON-RPC 2.0 message."""
615
+ method = msg.get("method")
616
+ msg_id = msg.get("id")
617
+
618
+ if method == "initialize":
619
+ return {
620
+ "jsonrpc": "2.0",
621
+ "id": msg_id,
622
+ "result": {
623
+ "protocolVersion": "2024-11-05",
624
+ "capabilities": {
625
+ "tools": {}
626
+ },
627
+ "serverInfo": {
628
+ "name": SERVER_NAME,
629
+ "version": SERVER_VERSION
630
+ }
631
+ }
632
+ }
633
+
634
+ elif method in ("notifications/initialized", "initialized"):
635
+ return None # No response needed for notification
636
+
637
+ elif method == "tools/list":
638
+ return {
639
+ "jsonrpc": "2.0",
640
+ "id": msg_id,
641
+ "result": {
642
+ "tools": MCP_TOOLS
643
+ }
644
+ }
645
+
646
+ elif method == "tools/call":
647
+ params = msg.get("params", {})
648
+ tool_name = params.get("name")
649
+ arguments = params.get("arguments", {})
650
+ try:
651
+ output_text = handle_tool_call(tool_name, arguments)
652
+ return {
653
+ "jsonrpc": "2.0",
654
+ "id": msg_id,
655
+ "result": {
656
+ "content": [
657
+ {
658
+ "type": "text",
659
+ "text": output_text
660
+ }
661
+ ],
662
+ "isError": False
663
+ }
664
+ }
665
+ except Exception as e:
666
+ return {
667
+ "jsonrpc": "2.0",
668
+ "id": msg_id,
669
+ "result": {
670
+ "content": [
671
+ {
672
+ "type": "text",
673
+ "text": f"Error executing {tool_name}: {type(e).__name__}: {str(e)}"
674
+ }
675
+ ],
676
+ "isError": True
677
+ }
678
+ }
679
+
680
+ elif method == "ping":
681
+ return {"jsonrpc": "2.0", "id": msg_id, "result": {}}
682
+
683
+ return {
684
+ "jsonrpc": "2.0",
685
+ "id": msg_id,
686
+ "error": {
687
+ "code": -32601,
688
+ "message": f"Method not found: {method}"
689
+ }
690
+ }
691
+
692
+
693
+ def run_stdio_server():
694
+ """Runs the MCP server over standard input/output."""
695
+ while True:
696
+ try:
697
+ line = sys.stdin.readline()
698
+ if not line:
699
+ break
700
+ line = line.strip()
701
+ if not line:
702
+ continue
703
+
704
+ msg = json.loads(line)
705
+ response = process_message(msg)
706
+ if response is not None:
707
+ sys.stdout.write(json.dumps(response) + "\n")
708
+ sys.stdout.flush()
709
+ except KeyboardInterrupt:
710
+ break
711
+ except Exception as e:
712
+ err_resp = {
713
+ "jsonrpc": "2.0",
714
+ "id": None,
715
+ "error": {
716
+ "code": -32700,
717
+ "message": f"Parse error: {str(e)}"
718
+ }
719
+ }
720
+ sys.stdout.write(json.dumps(err_resp) + "\n")
721
+ sys.stdout.flush()
722
+
723
+
724
+ if __name__ == "__main__":
725
+ run_stdio_server()