synapse-hub 2.7.0 → 3.0.1

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 (141) hide show
  1. package/.agents/agents/live-explorer.md +2 -0
  2. package/.agents/agents/pom-crafter.md +2 -0
  3. package/.agents/agents/test-runner.md +3 -0
  4. package/.agents/rules/communication-style.md +4 -0
  5. package/.agents/rules/context-engineering.md +1 -0
  6. package/.agents/rules/git-push-protocol.md +17 -0
  7. package/.agents/skills/agentless-qa-repair/examples/three_phase_repair_workflow.md +40 -0
  8. package/.agents/skills/antigravity-test-sentinel/examples/sprint_dod_enforcement.md +47 -0
  9. package/.agents/skills/auth-session-and-cookie-manager/examples/multi_role_auth_matrix.md +70 -0
  10. package/.agents/skills/code-refactoring-refactor-clean/examples/refactored_playwright_pom.ts +52 -0
  11. package/.agents/skills/failure-autopsy-and-healing/examples/closed_loop_healing_walkthrough.md +48 -0
  12. package/.agents/skills/lean-impact-scoreboard/SKILL.md +1 -1
  13. package/.agents/skills/lean-impact-scoreboard/examples/sample_scoreboard.md +1 -1
  14. package/.agents/skills/mipro-prompt-compiler/examples/dspy_assertion_optimizer_case.md +46 -0
  15. package/.agents/skills/persistent-planning-files/SKILL.md +1 -1
  16. package/.agents/skills/qa-aci-interface/examples/surgical_code_window_walkthrough.md +40 -0
  17. package/.agents/skills/repo-quality-audit/SKILL.md +1 -1
  18. package/.agents/skills/review-spec/SKILL.md +1 -1
  19. package/.agents/skills/review-spec/examples/pocock_grilling_decision_rubric.md +40 -0
  20. package/.agents/skills/senior-code-review/SKILL.md +1 -1
  21. package/.agents/skills/skillspector-security-guard/examples/audit_threat_vectors_report.json +35 -0
  22. package/.agents/skills/surgical-coding-principles/SKILL.md +1 -1
  23. package/.agents/skills/technical-debt-harvester/SKILL.md +1 -1
  24. package/.agents/skills/tot-exploratory-testing/examples/payment_gateway_tot_tree.json +62 -0
  25. package/.agents/skills/verification-before-completion/SKILL.md +2 -2
  26. package/.agents/skills/verification-before-completion/examples/evidence_log_example.md +2 -2
  27. package/.agents/skills/web-agent-gym-benchmarking/examples/enterprise_tasks_suite.json +38 -0
  28. package/.agents/skills/web-vitals-and-performance-profiler/examples/playwright_cwv_profiler_fixture.ts +61 -0
  29. package/AGENTS.md +6 -4
  30. package/CLAUDE.md +2 -1
  31. package/README.en.md +71 -292
  32. package/README.md +69 -304
  33. package/action.yml +1 -1
  34. package/bin/agent-qa.js +2 -2
  35. package/docs/ARCHITECTURE.en.md +192 -0
  36. package/docs/ARCHITECTURE.md +135 -88
  37. package/docs/CI_CD_INTEGRATION.en.md +96 -0
  38. package/docs/CI_CD_INTEGRATION.md +24 -22
  39. package/docs/CLI_REFERENCE.en.md +174 -0
  40. package/docs/CLI_REFERENCE.md +120 -115
  41. package/docs/CONTRIBUTING.en.md +49 -0
  42. package/docs/CONTRIBUTING.md +26 -68
  43. package/docs/QUALITY_GATES.en.md +115 -0
  44. package/docs/QUALITY_GATES.md +115 -0
  45. package/docs/research/agent_skill_training_analysis.md +1 -1
  46. package/package.json +1 -1
  47. package/scripts/package_dist.py +2 -1
  48. package/skills_manifest.json +6 -6
  49. package/synapse.config.json +1 -1
  50. package/templates/ai_bridges/CLAUDE.md +2 -1
  51. package/templates/ai_bridges/copilot-instructions.md +2 -2
  52. package/tools/__init__.py +18 -1
  53. package/tools/_openapi_parser.py +1 -1
  54. package/tools/agent_canary.py +42 -30
  55. package/tools/agentless_patcher.py +2 -2
  56. package/tools/analyze_project.py +3 -5
  57. package/tools/api_drift_sentinel.py +4 -4
  58. package/tools/api_fuzzer.py +8 -8
  59. package/tools/auto_heal.py +4 -5
  60. package/tools/auto_heal_reflexion.py +10 -2
  61. package/tools/autogen_qa_broker.py +2 -2
  62. package/tools/browser_helpers.js +2 -2
  63. package/tools/browsergym_eval.py +2 -3
  64. package/tools/bug_reporter.py +11 -13
  65. package/tools/bump_version.py +90 -19
  66. package/tools/cache_resolver.py +78 -83
  67. package/tools/check_env.py +9 -1
  68. package/tools/check_version_sync.py +58 -4
  69. package/tools/ci_healing_hook.py +4 -6
  70. package/tools/cli.py +5 -7
  71. package/tools/config_decoupler.py +2 -3
  72. package/tools/contract_validator.py +141 -0
  73. package/tools/core/__init__.py +52 -0
  74. package/tools/count_tokens.py +22 -20
  75. package/tools/dashboard_generator.py +629 -1000
  76. package/tools/db_sandbox.py +87 -62
  77. package/tools/debt_harvester.py +3 -3
  78. package/tools/distill_log.py +3 -3
  79. package/tools/dspy_qa_signatures.py +3 -4
  80. package/tools/export_postman_collection.py +8 -8
  81. package/tools/flaky_detector.py +2 -2
  82. package/tools/fuzz_payloads.py +5 -5
  83. package/tools/generate_allure_report.py +1 -1
  84. package/tools/generate_jmx_plan.py +4 -4
  85. package/tools/gherkin_suite.py +1 -1
  86. package/tools/git_pre_commit_guard.py +2 -2
  87. package/tools/goldfish_review.py +2 -2
  88. package/tools/heal/__init__.py +28 -0
  89. package/tools/heal_pr_automator.py +6 -6
  90. package/tools/heuristic_locator_matcher.py +2 -2
  91. package/tools/infer_linter.py +143 -29
  92. package/tools/interview_story.py +0 -1
  93. package/tools/jtl_analyzer.py +11 -11
  94. package/tools/lint/__init__.py +30 -0
  95. package/tools/lint_ai_docs.py +42 -0
  96. package/tools/lookup_tc.py +1 -1
  97. package/tools/matrix_sharder.py +15 -13
  98. package/tools/mcp/__init__.py +16 -0
  99. package/tools/mcp_excel_server.py +2 -2
  100. package/tools/mcp_server.py +9 -7
  101. package/tools/md_to_xlsx.py +26 -26
  102. package/tools/micro_mutator.py +32 -15
  103. package/tools/network_mock_shield.py +27 -27
  104. package/tools/newman_analyzer.py +2 -3
  105. package/tools/omni_emitter.py +5 -8
  106. package/tools/omni_parser.py +5 -5
  107. package/tools/omni_transpiler.py +5 -5
  108. package/tools/output_formatter.py +19 -0
  109. package/tools/perf/__init__.py +24 -0
  110. package/tools/pinpoint_failure.py +1 -1
  111. package/tools/project_state.py +0 -2
  112. package/tools/qa_event_stream.py +1 -1
  113. package/tools/repo_map.py +8 -8
  114. package/tools/report/__init__.py +32 -0
  115. package/tools/reversible_sandbox.py +3 -4
  116. package/tools/safety_firewall.py +2 -2
  117. package/tools/senior_code_review.py +4 -3
  118. package/tools/setup_project.py +10 -12
  119. package/tools/skill_collision_guard.py +3 -3
  120. package/tools/skill_vault.py +94 -6
  121. package/tools/skillspector.py +10 -8
  122. package/tools/smart_visual_masker.py +4 -6
  123. package/tools/spec_drift_sentinel.py +1 -2
  124. package/tools/swe_qa_aci.py +2 -2
  125. package/tools/synapse_qa_bench.py +3 -3
  126. package/tools/sync_agent_rules.py +18 -3
  127. package/tools/telemetry_correlator.py +3 -2
  128. package/tools/test_impact.py +2 -1
  129. package/tools/test_memory_os.py +15 -5
  130. package/tools/textgrad_mutation_optimizer.py +3 -3
  131. package/tools/tms_sync_bridge.py +5 -5
  132. package/tools/tot_exploratory_tester.py +5 -6
  133. package/tools/traffic_session_converter.py +9 -9
  134. package/tools/universal_ir.py +2 -3
  135. package/tools/update_sentinel.py +6 -9
  136. package/tools/verify_all.py +12 -2
  137. package/tools/visual_diff_canvas.py +4 -4
  138. package/tools/visual_som_helper.py +15 -13
  139. package/tools/watch_mode.py +1 -1
  140. package/tools/wcag_audit.py +22 -1
  141. package/tools/welcome_page.py +5 -6
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/env python3
2
+ # SPDX-FileCopyrightText: Copyright (c) 2026 Thế Vị (@TeeVee998). All rights reserved.
3
+ # SPDX-License-Identifier: MIT
4
+ # Project: Synapse-Hub (https://github.com/TeeVee998/Synapse-Hub)
5
+
6
+ """
7
+ Swarm Data Contract Validator (Single Front-Door Integrity Guard)
8
+ -----------------------------------------------------------------
9
+ Validates the JSON Data Contract emitted by `live-explorer` before
10
+ `pom-crafter` consumes it for Clean POM code synthesis.
11
+ Ensures zero locator guessing, validates semantic ARIA roles, and enforces
12
+ latency measurement (< 200ms) for durable selectors.
13
+ """
14
+
15
+ import os
16
+ import sys
17
+ import json
18
+ import argparse
19
+ from typing import Dict, Any, List, Tuple
20
+
21
+ # Enforce UTF-8 stdout encoding for Windows console compatibility
22
+ if hasattr(sys.stdout, 'reconfigure'):
23
+ try:
24
+ sys.stdout.reconfigure(encoding='utf-8')
25
+ sys.stderr.reconfigure(encoding='utf-8')
26
+ except Exception:
27
+ pass
28
+
29
+ CONTRACT_SCHEMA = {
30
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
31
+ "title": "SelectorContract",
32
+ "type": "object",
33
+ "required": ["url", "screen_name", "elements"],
34
+ "properties": {
35
+ "url": {"type": "string"},
36
+ "screen_name": {"type": "string"},
37
+ "viewport": {
38
+ "type": "object",
39
+ "properties": {
40
+ "width": {"type": "integer"},
41
+ "height": {"type": "integer"}
42
+ }
43
+ },
44
+ "elements": {
45
+ "type": "array",
46
+ "minItems": 1,
47
+ "items": {
48
+ "type": "object",
49
+ "required": ["name", "role"],
50
+ "properties": {
51
+ "name": {"type": "string"},
52
+ "role": {"type": "string"},
53
+ "selector": {"type": "string"},
54
+ "target": {"type": "string"},
55
+ "latency_ms": {"type": "number"},
56
+ "action_type": {"type": "string"}
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
62
+
63
+
64
+ def validate_contract_dict(data: Dict[str, Any]) -> Tuple[bool, List[str]]:
65
+ """Validates contract structure without external dependencies."""
66
+ errors = []
67
+ if not isinstance(data, dict):
68
+ return False, ["Root contract must be a JSON object."]
69
+
70
+ # Required top-level fields
71
+ for field in ("url", "screen_name", "elements"):
72
+ if field not in data:
73
+ errors.append(f"Missing required top-level field: '{field}'")
74
+
75
+ if "elements" in data:
76
+ elements = data["elements"]
77
+ if not isinstance(elements, list) or len(elements) == 0:
78
+ errors.append("'elements' must be a non-empty list of interactive components.")
79
+ else:
80
+ for idx, el in enumerate(elements):
81
+ if not isinstance(el, dict):
82
+ errors.append(f"Element at index {idx} must be a dictionary object.")
83
+ continue
84
+ if "name" not in el or not el["name"]:
85
+ errors.append(f"Element at index {idx} missing 'name' identifier.")
86
+ if "role" not in el or not el["role"]:
87
+ errors.append(f"Element at index {idx} missing ARIA 'role' classification.")
88
+ if "selector" not in el and "target" not in el:
89
+ errors.append(f"Element '{el.get('name', f'index_{idx}')}' must provide 'selector' or 'target'.")
90
+
91
+ latency = el.get("latency_ms")
92
+ if latency is not None and isinstance(latency, (int, float)):
93
+ if latency > 200:
94
+ errors.append(
95
+ f"Element '{el.get('name')}' latency ({latency}ms) exceeds the 200ms latency budget."
96
+ )
97
+
98
+ return len(errors) == 0, errors
99
+
100
+
101
+ def validate_contract_file(file_path: str) -> Tuple[bool, List[str]]:
102
+ """Loads and validates a contract file from disk."""
103
+ if not os.path.exists(file_path):
104
+ return False, [f"Contract file does not exist: {file_path}"]
105
+ try:
106
+ with open(file_path, "r", encoding="utf-8") as f:
107
+ data = json.load(f)
108
+ return validate_contract_dict(data)
109
+ except json.JSONDecodeError as err:
110
+ return False, [f"Malformed JSON syntax: {err}"]
111
+ except OSError as err:
112
+ return False, [f"File read error: {err}"]
113
+
114
+
115
+ def main():
116
+ parser = argparse.ArgumentParser(description="Swarm Data Contract Validator")
117
+ parser.add_argument("contract_path", nargs="?", default=None, help="Path to JSON Data Contract file")
118
+ parser.add_argument("--schema", action="store_true", help="Print standard JSON schema and exit")
119
+ args = parser.parse_args()
120
+
121
+ if args.schema:
122
+ print(json.dumps(CONTRACT_SCHEMA, indent=2))
123
+ return 0
124
+
125
+ if not args.contract_path:
126
+ parser.print_help()
127
+ return 1
128
+
129
+ valid, errors = validate_contract_file(args.contract_path)
130
+ if valid:
131
+ print(f"✅ [VALID CONTRACT] '{args.contract_path}' is ready for Clean POM synthesis.")
132
+ return 0
133
+ else:
134
+ print(f"❌ [INVALID CONTRACT] '{args.contract_path}' contains {len(errors)} violation(s):")
135
+ for err in errors:
136
+ print(f" • {err}")
137
+ return 1
138
+
139
+
140
+ if __name__ == "__main__":
141
+ sys.exit(main())
@@ -0,0 +1,52 @@
1
+ """
2
+ Synapse Hub — Core Execution Engines & Verification Sentinels (tools.core)
3
+ --------------------------------------------------------------------------
4
+ Domain package grouping all CLI routers, Definition-of-Done Quality Gate
5
+ orchestrators, AST scanners, and autonomous subagent execution bridges.
6
+ """
7
+
8
+ from tools import (
9
+ analyze_project,
10
+ bump_version,
11
+ check_env,
12
+ cli,
13
+ count_tokens,
14
+ debt_harvester,
15
+ distill_log,
16
+ micro_mutator,
17
+ project_state,
18
+ repo_map,
19
+ safety_firewall,
20
+ senior_code_review,
21
+ setup_project,
22
+ skill_vault,
23
+ sync_agent_rules,
24
+ test_impact,
25
+ test_memory_os,
26
+ universal_ir,
27
+ update_sentinel,
28
+ verify_all,
29
+ )
30
+
31
+ __all__ = [
32
+ "analyze_project",
33
+ "bump_version",
34
+ "check_env",
35
+ "cli",
36
+ "count_tokens",
37
+ "debt_harvester",
38
+ "distill_log",
39
+ "micro_mutator",
40
+ "project_state",
41
+ "repo_map",
42
+ "safety_firewall",
43
+ "senior_code_review",
44
+ "setup_project",
45
+ "skill_vault",
46
+ "sync_agent_rules",
47
+ "test_impact",
48
+ "test_memory_os",
49
+ "universal_ir",
50
+ "update_sentinel",
51
+ "verify_all",
52
+ ]
@@ -39,9 +39,9 @@ import hashlib
39
39
  import sqlite3
40
40
  import argparse
41
41
  from datetime import datetime, timezone, timedelta
42
- from typing import Dict, List, Any, Optional, Tuple
42
+ from typing import Dict, List, Any, Optional
43
43
 
44
- PRICING_TABLE = {
44
+ PRICING_TABLE: Dict[str, Dict[str, Any]] = {
45
45
  "gemini-flash": {
46
46
  "name": "Google Gemini 2.5/3.x Flash",
47
47
  "input_per_m": 0.075,
@@ -140,7 +140,7 @@ def get_budget_config() -> Dict[str, int]:
140
140
  "budget_7d": data.get("budget_7d", DEFAULT_7D_BUDGET),
141
141
  }
142
142
  except (OSError, json.JSONDecodeError):
143
- custom_budgets = None
143
+ _ = False
144
144
  return {
145
145
  "budget_5h": DEFAULT_5H_BUDGET,
146
146
  "budget_7d": DEFAULT_7D_BUDGET,
@@ -198,17 +198,19 @@ class AntigravityAdapter:
198
198
  if db_path:
199
199
  try:
200
200
  conn = sqlite3.connect(db_path)
201
- cursor = conn.cursor()
202
- cursor.execute("SELECT conversation_id, title, step_count, last_modified_time FROM conversation_summaries")
203
- for row in cursor.fetchall():
204
- title_map[row[0]] = {
205
- "title": row[1],
206
- "step_count": row[2],
207
- "last_modified": row[3],
208
- }
209
- conn.close()
201
+ try:
202
+ cursor = conn.cursor()
203
+ cursor.execute("SELECT conversation_id, title, step_count, last_modified_time FROM conversation_summaries")
204
+ for row in cursor.fetchall():
205
+ title_map[row[0]] = {
206
+ "title": row[1],
207
+ "step_count": row[2],
208
+ "last_modified": row[3],
209
+ }
210
+ finally:
211
+ conn.close()
210
212
  except (sqlite3.Error, OSError):
211
- conn_closed = True
213
+ _ = False
212
214
 
213
215
  conversations = []
214
216
  for entry in os.listdir(brain_dir):
@@ -240,7 +242,7 @@ class AntigravityAdapter:
240
242
  return {"error": f"Transcript not found at {transcript_path}"}
241
243
 
242
244
  turns = []
243
- current_turn = None
245
+ current_turn: Optional[Dict[str, Any]] = None
244
246
  total_input = 0
245
247
  total_cache = 0
246
248
  total_output = 0
@@ -388,7 +390,7 @@ class AntigravityAdapter:
388
390
  usage_hours["cache"] += cache_tok
389
391
  usage_hours["output"] += out_tok
390
392
  except (OSError, UnicodeDecodeError):
391
- transcript_read = False
393
+ _ = False
392
394
 
393
395
  budgets = get_budget_config()
394
396
  b_5h = budgets["budget_5h"]
@@ -452,7 +454,7 @@ class CursorAdapter:
452
454
  return []
453
455
 
454
456
  pattern = os.path.join(projects_dir, "*", "agent-transcripts", "*", "*.jsonl")
455
- sessions = []
457
+ sessions: List[Dict[str, Any]] = []
456
458
  for fpath in glob.glob(pattern):
457
459
  try:
458
460
  mtime = os.path.getmtime(fpath)
@@ -493,7 +495,7 @@ class CursorAdapter:
493
495
  return {"error": f"Transcript not found at {transcript_path}"}
494
496
 
495
497
  turns = []
496
- current_turn = None
498
+ current_turn: Optional[Dict[str, Any]] = None
497
499
  total_input = 0
498
500
  total_output = 0
499
501
  total_cache = 0
@@ -608,7 +610,7 @@ class ClaudeCodeAdapter:
608
610
 
609
611
  @classmethod
610
612
  def get_sessions(cls) -> List[Dict[str, Any]]:
611
- sessions = []
613
+ sessions: List[Dict[str, Any]] = []
612
614
  home = os.path.expanduser("~")
613
615
  # Search candidate directories
614
616
  patterns = [
@@ -665,7 +667,7 @@ def detect_platform_from_file(file_path: str) -> str:
665
667
  if "claude" in line.lower():
666
668
  return "claude"
667
669
  except (OSError, UnicodeDecodeError):
668
- model_detected = None
670
+ _ = False
669
671
  return "antigravity"
670
672
 
671
673
 
@@ -997,7 +999,7 @@ def export_opentelemetry_genai_spans(parsed: Dict[str, Any], session_id: str = "
997
999
  }
998
1000
  gen_ai_system = system_map.get(platform, "google")
999
1001
 
1000
- spans = []
1002
+ spans: List[Dict[str, Any]] = []
1001
1003
  turns = parsed.get("turns", [])
1002
1004
  for idx, turn in enumerate(turns, 1):
1003
1005
  turn_span_id = hashlib.md5(f"{session_id}_turn_{idx}".encode('utf-8'), usedforsecurity=False).hexdigest()[:16]