@teevee98/synapse-hub 3.10.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/.agents/rules/context-engineering.md +3 -3
  2. package/.agents/rules/mandatory-playwright-live.md +18 -4
  3. package/.agents/rules/security_testing_rules.md +8 -5
  4. package/.agents/rules/stack-auto-router.md +11 -4
  5. package/.agents/skills/{playwright-webapp-testing → 01-web-automation/playwright-webapp-testing}/SKILL.md +18 -1
  6. package/.agents/skills/05-security-and-compliance/wcag-audit-patterns/SKILL.md +116 -0
  7. package/.agents/workflows/generate_manual_testcases_rbt.md +1 -1
  8. package/Dockerfile +14 -6
  9. package/README.en.md +2 -2
  10. package/README.md +2 -2
  11. package/agentskills.json +16 -2
  12. package/docs/ARCHITECTURE.en.md +1 -1
  13. package/docs/ARCHITECTURE.md +1 -1
  14. package/package.json +1 -1
  15. package/plugin.json +1 -1
  16. package/skills_manifest.json +505 -394
  17. package/synapse.config.json +17 -1
  18. package/tools/__init__.py +1 -1
  19. package/tools/ast_cache.py +171 -0
  20. package/tools/author_integrity.py +7 -2
  21. package/tools/benchmark_swarm_context.py +242 -151
  22. package/tools/browser_helpers.js +2 -2
  23. package/tools/build_consolidated_report.py +6 -6
  24. package/tools/cache_resolver.py +11 -6
  25. package/tools/check_version_sync.py +56 -0
  26. package/tools/cli.py +16 -3
  27. package/tools/core/file_lock.py +187 -14
  28. package/tools/core/process_supervisor.py +25 -0
  29. package/tools/core/telemetry.py +139 -1
  30. package/tools/core/token_estimator.py +145 -0
  31. package/tools/count_tokens.py +28 -0
  32. package/tools/dashboard_generator.py +6 -6
  33. package/tools/debt_harvester.py +20 -9
  34. package/tools/diagram_architect.py +0 -1
  35. package/tools/distill_log.py +266 -89
  36. package/tools/git_pre_commit_guard.py +6 -4
  37. package/tools/git_worktree_manager.py +1 -1
  38. package/tools/infer_linter.py +2 -2
  39. package/tools/lint_ai_docs.py +19 -5
  40. package/tools/mcp_docx_server.py +1 -1
  41. package/tools/mcp_excel_server.py +1 -1
  42. package/tools/mcp_server.py +1 -1
  43. package/tools/mechanical_ui_gate.py +1 -1
  44. package/tools/micro_mutator.py +51 -10
  45. package/tools/pairwise_generator.py +0 -1
  46. package/tools/pentest_scope_guard.py +328 -0
  47. package/tools/perf/benchmark_perf_runner.py +226 -0
  48. package/tools/pinpoint_failure.py +14 -2
  49. package/tools/rules_router.py +596 -0
  50. package/tools/token_telemetry.py +224 -0
  51. package/tools/ui_server.py +1 -1
  52. package/tools/update_sentinel.py +3 -3
  53. package/tools/verify_all.py +67 -7
  54. package/tools/wcag_audit.py +1 -1
  55. package/tools/welcome_page.py +1 -1
  56. package/.agents/skills/wcag-audit-patterns/SKILL.md +0 -77
  57. /package/.agents/skills/{auth-session-and-cookie-manager → 01-web-automation/auth-session-and-cookie-manager}/SKILL.md +0 -0
  58. /package/.agents/skills/{auth-session-and-cookie-manager → 01-web-automation/auth-session-and-cookie-manager}/examples/multi_role_auth_matrix.md +0 -0
  59. /package/.agents/skills/{auth-session-and-cookie-manager → 01-web-automation/auth-session-and-cookie-manager}/examples/storage_state_sample.json +0 -0
  60. /package/.agents/skills/{bats-testing-patterns → 01-web-automation/bats-testing-patterns}/SKILL.md +0 -0
  61. /package/.agents/skills/{bats-testing-patterns → 01-web-automation/bats-testing-patterns}/examples/cli_runner_test.bats +0 -0
  62. /package/.agents/skills/{bats-testing-patterns → 01-web-automation/bats-testing-patterns}/resources/implementation-playbook.md +0 -0
  63. /package/.agents/skills/{clean-pom-crafter → 01-web-automation/clean-pom-crafter}/SKILL.md +0 -0
  64. /package/.agents/skills/{clean-pom-crafter → 01-web-automation/clean-pom-crafter}/examples/standard_test_case.groovy +0 -0
  65. /package/.agents/skills/{clean-pom-crafter → 01-web-automation/clean-pom-crafter}/references/pom_patterns.groovy +0 -0
  66. /package/.agents/skills/{e2e-testing-patterns → 01-web-automation/e2e-testing-patterns}/SKILL.md +0 -0
  67. /package/.agents/skills/{e2e-testing-patterns → 01-web-automation/e2e-testing-patterns}/examples/playwright_sharded_config.ts +0 -0
  68. /package/.agents/skills/{e2e-testing-patterns → 01-web-automation/e2e-testing-patterns}/resources/implementation-playbook.md +0 -0
  69. /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/SKILL.md +0 -0
  70. /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/examples/headless_kre_exec.sh +0 -0
  71. /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/references/groovy-patterns.md +0 -0
  72. /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/references/katalon-api.md +0 -0
  73. /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/references/runner_commands.md +0 -0
  74. /package/.agents/skills/{lam-script-generator → 01-web-automation/lam-script-generator}/SKILL.md +0 -0
  75. /package/.agents/skills/{lam-script-generator → 01-web-automation/lam-script-generator}/examples/user_story_sample.md +0 -0
  76. /package/.agents/skills/{mobile-appium-som → 01-web-automation/mobile-appium-som}/SKILL.md +0 -0
  77. /package/.agents/skills/{mobile-appium-som → 01-web-automation/mobile-appium-som}/examples/BaseScreen.java +0 -0
  78. /package/.agents/skills/{mobile-appium-som → 01-web-automation/mobile-appium-som}/examples/LoginScreen.java +0 -0
  79. /package/.agents/skills/{mobile-appium-som → 01-web-automation/mobile-appium-som}/examples/TC_MobileLogin.java +0 -0
  80. /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/SKILL.md +0 -0
  81. /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/examples/live_probe_script.js +0 -0
  82. /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/references/advanced_superpowers.md +0 -0
  83. /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/references/compact_accessibility_snapshots.md +0 -0
  84. /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/references/recipes.md +0 -0
  85. /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/references/swarm_orchestration.md +0 -0
  86. /package/.agents/skills/{playwright-webapp-testing → 01-web-automation/playwright-webapp-testing}/examples/server_lifecycle_playwright.py +0 -0
  87. /package/.agents/skills/{web-agent-gym-benchmarking → 01-web-automation/web-agent-gym-benchmarking}/SKILL.md +0 -0
  88. /package/.agents/skills/{web-agent-gym-benchmarking → 01-web-automation/web-agent-gym-benchmarking}/examples/benchmark_report_sample.json +0 -0
  89. /package/.agents/skills/{web-agent-gym-benchmarking → 01-web-automation/web-agent-gym-benchmarking}/examples/enterprise_tasks_suite.json +0 -0
  90. /package/.agents/skills/{architecture-decision-records → 02-test-design/architecture-decision-records}/SKILL.md +0 -0
  91. /package/.agents/skills/{architecture-decision-records → 02-test-design/architecture-decision-records}/examples/0001-record-architecture-decisions.md +0 -0
  92. /package/.agents/skills/{gherkin-to-suite → 02-test-design/gherkin-to-suite}/SKILL.md +0 -0
  93. /package/.agents/skills/{gherkin-to-suite → 02-test-design/gherkin-to-suite}/examples/checkout.feature +0 -0
  94. /package/.agents/skills/{gherkin-to-suite → 02-test-design/gherkin-to-suite}/examples/suite_report_sample.json +0 -0
  95. /package/.agents/skills/{rbt-manual-testing → 02-test-design/rbt-manual-testing}/SKILL.md +0 -0
  96. /package/.agents/skills/{rbt-manual-testing → 02-test-design/rbt-manual-testing}/examples/checkout_rbt_manual_suite.md +0 -0
  97. /package/.agents/skills/{rbt-manual-testing → 02-test-design/rbt-manual-testing}/references/field_validation_checklist.md +0 -0
  98. /package/.agents/skills/{review-spec → 02-test-design/review-spec}/SKILL.md +0 -0
  99. /package/.agents/skills/{review-spec → 02-test-design/review-spec}/examples/pocock_grilling_decision_rubric.md +0 -0
  100. /package/.agents/skills/{review-spec → 02-test-design/review-spec}/examples/sample_spec_review.md +0 -0
  101. /package/.agents/skills/{tot-exploratory-testing → 02-test-design/tot-exploratory-testing}/SKILL.md +0 -0
  102. /package/.agents/skills/{tot-exploratory-testing → 02-test-design/tot-exploratory-testing}/examples/payment_gateway_tot_tree.json +0 -0
  103. /package/.agents/skills/{tot-exploratory-testing → 02-test-design/tot-exploratory-testing}/examples/tot_graph_sample.json +0 -0
  104. /package/.agents/skills/{api-network-mocking-interception → 03-api-and-contracts/api-network-mocking-interception}/SKILL.md +0 -0
  105. /package/.agents/skills/{api-network-mocking-interception → 03-api-and-contracts/api-network-mocking-interception}/examples/network_route_stub.json +0 -0
  106. /package/.agents/skills/{api-spec-to-e2e-matrix → 03-api-and-contracts/api-spec-to-e2e-matrix}/SKILL.md +0 -0
  107. /package/.agents/skills/{api-spec-to-e2e-matrix → 03-api-and-contracts/api-spec-to-e2e-matrix}/examples/sample_openapi.json +0 -0
  108. /package/.agents/skills/{consumer-driven-contract-testing → 03-api-and-contracts/consumer-driven-contract-testing}/SKILL.md +0 -0
  109. /package/.agents/skills/{consumer-driven-contract-testing → 03-api-and-contracts/consumer-driven-contract-testing}/examples/order_service_pact.json +0 -0
  110. /package/.agents/skills/{backend-load-and-stress-patterns → 04-performance-and-load/backend-load-and-stress-patterns}/SKILL.md +0 -0
  111. /package/.agents/skills/{backend-load-and-stress-patterns → 04-performance-and-load/backend-load-and-stress-patterns}/examples/k6_load_test_sample.js +0 -0
  112. /package/.agents/skills/{backend-load-and-stress-patterns → 04-performance-and-load/backend-load-and-stress-patterns}/references/k6_load_template.js +0 -0
  113. /package/.agents/skills/{lean-impact-scoreboard → 04-performance-and-load/lean-impact-scoreboard}/SKILL.md +0 -0
  114. /package/.agents/skills/{lean-impact-scoreboard → 04-performance-and-load/lean-impact-scoreboard}/examples/sample_benchmark_gain.md +0 -0
  115. /package/.agents/skills/{lean-impact-scoreboard → 04-performance-and-load/lean-impact-scoreboard}/examples/sample_scoreboard.md +0 -0
  116. /package/.agents/skills/{web-vitals-and-performance-profiler → 04-performance-and-load/web-vitals-and-performance-profiler}/SKILL.md +0 -0
  117. /package/.agents/skills/{web-vitals-and-performance-profiler → 04-performance-and-load/web-vitals-and-performance-profiler}/examples/cwv_budget_policy.json +0 -0
  118. /package/.agents/skills/{web-vitals-and-performance-profiler → 04-performance-and-load/web-vitals-and-performance-profiler}/examples/playwright_cwv_profiler_fixture.ts +0 -0
  119. /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/SKILL.md +0 -0
  120. /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/examples/dast_scan_config.json +0 -0
  121. /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/references/AI-AND-LLM.md +0 -0
  122. /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/references/ATTACK-CLASSES.md +0 -0
  123. /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/references/dast_recipes.ts +0 -0
  124. /package/.agents/skills/{skillspector-security-guard → 05-security-and-compliance/skillspector-security-guard}/SKILL.md +0 -0
  125. /package/.agents/skills/{skillspector-security-guard → 05-security-and-compliance/skillspector-security-guard}/examples/audit_threat_vectors_report.json +0 -0
  126. /package/.agents/skills/{skillspector-security-guard → 05-security-and-compliance/skillspector-security-guard}/examples/safe_mcp_config.json +0 -0
  127. /package/.agents/skills/{wcag-audit-patterns → 05-security-and-compliance/wcag-audit-patterns}/examples/wcag_compliance_checklist.json +0 -0
  128. /package/.agents/skills/{wcag-audit-patterns → 05-security-and-compliance/wcag-audit-patterns}/resources/implementation-playbook.md +0 -0
  129. /package/.agents/skills/{agentless-qa-repair → 06-healing-and-resilience/agentless-qa-repair}/SKILL.md +0 -0
  130. /package/.agents/skills/{agentless-qa-repair → 06-healing-and-resilience/agentless-qa-repair}/examples/healing_report_sample.json +0 -0
  131. /package/.agents/skills/{agentless-qa-repair → 06-healing-and-resilience/agentless-qa-repair}/examples/three_phase_repair_workflow.md +0 -0
  132. /package/.agents/skills/{antigravity-test-sentinel → 06-healing-and-resilience/antigravity-test-sentinel}/SKILL.md +0 -0
  133. /package/.agents/skills/{antigravity-test-sentinel → 06-healing-and-resilience/antigravity-test-sentinel}/examples/dod_gate_policy.json +0 -0
  134. /package/.agents/skills/{antigravity-test-sentinel → 06-healing-and-resilience/antigravity-test-sentinel}/examples/sprint_dod_enforcement.md +0 -0
  135. /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/SKILL.md +0 -0
  136. /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/examples/closed_loop_healing_walkthrough.md +0 -0
  137. /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/examples/sample_junit_failure.xml +0 -0
  138. /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/references/healing_matrix.md +0 -0
  139. /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/references/qa_investigation_protocol.md +0 -0
  140. /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/scripts/triage_failures.sh +0 -0
  141. /package/.agents/skills/{flaky-test-sentinel-and-quarantine → 06-healing-and-resilience/flaky-test-sentinel-and-quarantine}/SKILL.md +0 -0
  142. /package/.agents/skills/{flaky-test-sentinel-and-quarantine → 06-healing-and-resilience/flaky-test-sentinel-and-quarantine}/examples/quarantine_registry.json +0 -0
  143. /package/.agents/skills/{self-healing-locator → 06-healing-and-resilience/self-healing-locator}/SKILL.md +0 -0
  144. /package/.agents/skills/{self-healing-locator → 06-healing-and-resilience/self-healing-locator}/examples/aom_diff_sample.json +0 -0
  145. /package/.agents/skills/{systematic-debugging → 06-healing-and-resilience/systematic-debugging}/SKILL.md +0 -0
  146. /package/.agents/skills/{systematic-debugging → 06-healing-and-resilience/systematic-debugging}/examples/four_phase_case.md +0 -0
  147. /package/.agents/skills/{test-driven-development → 06-healing-and-resilience/test-driven-development}/SKILL.md +0 -0
  148. /package/.agents/skills/{test-driven-development → 06-healing-and-resilience/test-driven-development}/examples/red_green_refactor_qa.md +0 -0
  149. /package/.agents/skills/{verification-before-completion → 06-healing-and-resilience/verification-before-completion}/SKILL.md +0 -0
  150. /package/.agents/skills/{verification-before-completion → 06-healing-and-resilience/verification-before-completion}/examples/evidence_log_example.md +0 -0
  151. /package/.agents/skills/{visual-regression-sentinel → 06-healing-and-resilience/visual-regression-sentinel}/SKILL.md +0 -0
  152. /package/.agents/skills/{visual-regression-sentinel → 06-healing-and-resilience/visual-regression-sentinel}/examples/visual_mask_rules.json +0 -0
  153. /package/.agents/skills/{db-state-verifier-and-seeder → 07-data-and-state/db-state-verifier-and-seeder}/SKILL.md +0 -0
  154. /package/.agents/skills/{db-state-verifier-and-seeder → 07-data-and-state/db-state-verifier-and-seeder}/examples/db_fixture_seed.json +0 -0
  155. /package/.agents/skills/{file-and-report-validator → 07-data-and-state/file-and-report-validator}/SKILL.md +0 -0
  156. /package/.agents/skills/{file-and-report-validator → 07-data-and-state/file-and-report-validator}/examples/sample_export_schema.json +0 -0
  157. /package/.agents/skills/{synthetic-test-data-generator → 07-data-and-state/synthetic-test-data-generator}/SKILL.md +0 -0
  158. /package/.agents/skills/{synthetic-test-data-generator → 07-data-and-state/synthetic-test-data-generator}/examples/idempotent_data_recipe.json +0 -0
  159. /package/.agents/skills/{code-refactoring-refactor-clean → 08-code-quality/code-refactoring-refactor-clean}/SKILL.md +0 -0
  160. /package/.agents/skills/{code-refactoring-refactor-clean → 08-code-quality/code-refactoring-refactor-clean}/examples/refactored_page_sample.groovy +0 -0
  161. /package/.agents/skills/{code-refactoring-refactor-clean → 08-code-quality/code-refactoring-refactor-clean}/examples/refactored_playwright_pom.ts +0 -0
  162. /package/.agents/skills/{code-refactoring-refactor-clean → 08-code-quality/code-refactoring-refactor-clean}/resources/implementation-playbook.md +0 -0
  163. /package/.agents/skills/{graphify-impact-analyzer → 08-code-quality/graphify-impact-analyzer}/SKILL.md +0 -0
  164. /package/.agents/skills/{graphify-impact-analyzer → 08-code-quality/graphify-impact-analyzer}/examples/dependency_blast_radius.json +0 -0
  165. /package/.agents/skills/{lean-code-ladder → 08-code-quality/lean-code-ladder}/SKILL.md +0 -0
  166. /package/.agents/skills/{lean-code-ladder → 08-code-quality/lean-code-ladder}/examples/ladder_walkthrough.md +0 -0
  167. /package/.agents/skills/{repo-quality-audit → 08-code-quality/repo-quality-audit}/SKILL.md +0 -0
  168. /package/.agents/skills/{repo-quality-audit → 08-code-quality/repo-quality-audit}/examples/sample_audit_walkthrough.md +0 -0
  169. /package/.agents/skills/{repo-quality-audit → 08-code-quality/repo-quality-audit}/examples/sample_repo_audit.md +0 -0
  170. /package/.agents/skills/{senior-code-review → 08-code-quality/senior-code-review}/SKILL.md +0 -0
  171. /package/.agents/skills/{senior-code-review → 08-code-quality/senior-code-review}/examples/sample_review_walkthrough.md +0 -0
  172. /package/.agents/skills/{surgical-coding-principles → 08-code-quality/surgical-coding-principles}/SKILL.md +0 -0
  173. /package/.agents/skills/{surgical-coding-principles → 08-code-quality/surgical-coding-principles}/examples/surgical_vs_scope_creep.md +0 -0
  174. /package/.agents/skills/{technical-debt-harvester → 08-code-quality/technical-debt-harvester}/SKILL.md +0 -0
  175. /package/.agents/skills/{technical-debt-harvester → 08-code-quality/technical-debt-harvester}/examples/sample_debt_ledger.md +0 -0
  176. /package/.agents/skills/{technical-debt-harvester → 08-code-quality/technical-debt-harvester}/examples/sample_ledger_output.md +0 -0
  177. /package/.agents/skills/{github-actions-templates → 09-ci-and-devops/github-actions-templates}/SKILL.md +0 -0
  178. /package/.agents/skills/{github-actions-templates → 09-ci-and-devops/github-actions-templates}/examples/matrix_test_pipeline.yml +0 -0
  179. /package/.agents/skills/{actor-qa-swarm → 10-agent-orchestration/actor-qa-swarm}/SKILL.md +0 -0
  180. /package/.agents/skills/{actor-qa-swarm → 10-agent-orchestration/actor-qa-swarm}/examples/broker_sharding_sample.json +0 -0
  181. /package/.agents/skills/{agent-orchestration-multi-agent-optimize → 10-agent-orchestration/agent-orchestration-multi-agent-optimize}/SKILL.md +0 -0
  182. /package/.agents/skills/{agent-orchestration-multi-agent-optimize → 10-agent-orchestration/agent-orchestration-multi-agent-optimize}/examples/swarm_workload_config.json +0 -0
  183. /package/.agents/skills/{event-stream-qa-orchestrator → 10-agent-orchestration/event-stream-qa-orchestrator}/SKILL.md +0 -0
  184. /package/.agents/skills/{event-stream-qa-orchestrator → 10-agent-orchestration/event-stream-qa-orchestrator}/examples/timeline_sample.jsonl +0 -0
  185. /package/.agents/skills/{persistent-planning-files → 10-agent-orchestration/persistent-planning-files}/SKILL.md +0 -0
  186. /package/.agents/skills/{persistent-planning-files → 10-agent-orchestration/persistent-planning-files}/examples/task_plan_example.md +0 -0
  187. /package/.agents/skills/{qa-memory-os → 10-agent-orchestration/qa-memory-os}/SKILL.md +0 -0
  188. /package/.agents/skills/{qa-memory-os → 10-agent-orchestration/qa-memory-os}/examples/archival_memory_sample.json +0 -0
  189. /package/.agents/skills/{meta-prompt-crafter → 11-ai-and-prompting/meta-prompt-crafter}/SKILL.md +0 -0
  190. /package/.agents/skills/{meta-prompt-crafter → 11-ai-and-prompting/meta-prompt-crafter}/examples/qa_prompt_template.md +0 -0
  191. /package/.agents/skills/{mipro-prompt-compiler → 11-ai-and-prompting/mipro-prompt-compiler}/SKILL.md +0 -0
  192. /package/.agents/skills/{mipro-prompt-compiler → 11-ai-and-prompting/mipro-prompt-compiler}/examples/compiled_module_sample.json +0 -0
  193. /package/.agents/skills/{mipro-prompt-compiler → 11-ai-and-prompting/mipro-prompt-compiler}/examples/dspy_assertion_optimizer_case.md +0 -0
  194. /package/.agents/skills/{qa-aci-interface → 11-ai-and-prompting/qa-aci-interface}/SKILL.md +0 -0
  195. /package/.agents/skills/{qa-aci-interface → 11-ai-and-prompting/qa-aci-interface}/examples/surgical_code_window_walkthrough.md +0 -0
  196. /package/.agents/skills/{qa-aci-interface → 11-ai-and-prompting/qa-aci-interface}/examples/surgical_edit_sample.json +0 -0
  197. /package/.agents/skills/{token-and-context-optimizer → 11-ai-and-prompting/token-and-context-optimizer}/SKILL.md +0 -0
  198. /package/.agents/skills/{token-and-context-optimizer → 11-ai-and-prompting/token-and-context-optimizer}/examples/distilled_log_sample.txt +0 -0
  199. /package/.agents/skills/{token-and-context-optimizer → 11-ai-and-prompting/token-and-context-optimizer}/references/context_engineering_guide.md +0 -0
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env python3
2
+ # SPDX-FileCopyrightText: Copyright (c) 2026 Thế Vị (@TeeVee98). All rights reserved.
3
+ # SPDX-License-Identifier: MIT
4
+ # Project: Synapse-Hub (https://github.com/TeeVee98/Synapse-Hub)
5
+
6
+ """
7
+ tools/core/token_estimator.py — Unified Polyglot BPE Token Estimator
8
+ -------------------------------------------------------------------
9
+ Provides deterministic, calibrated token counting across codebases, markdown rules,
10
+ and system prompts. Standardizes token estimation across rules_router, distill_log,
11
+ benchmark_swarm_context, and count_tokens.
12
+
13
+ Key Capabilities:
14
+ 1. High-accuracy fallback heuristic:
15
+ - English / ASCII code: ~3.85 characters/token (calibrated against cl100k_base / o200k_base).
16
+ - Non-ASCII / Vietnamese diacritics / Unicode: ~1.8 characters/token.
17
+ 2. Optional native BPE tokenization if tiktoken is available in runtime.
18
+ 3. Structured token breakdown (Rules, Catalog Metadata, Full Skill Bodies, System Prefix).
19
+ """
20
+
21
+ from __future__ import annotations
22
+
23
+ import os
24
+ import re
25
+ import sys
26
+ from typing import Any, Dict, List, Optional
27
+
28
+ # Attempt native BPE import if available
29
+ _TIKTOKEN_ENCODER = None
30
+ try:
31
+ import tiktoken # type: ignore
32
+
33
+ try:
34
+ _TIKTOKEN_ENCODER = tiktoken.get_encoding("cl100k_base")
35
+ except Exception:
36
+ _TIKTOKEN_ENCODER = None
37
+ except ImportError:
38
+ _TIKTOKEN_ENCODER = None
39
+
40
+
41
+ def count_tokens(text: str, model_hint: str = "cl100k") -> int:
42
+ """
43
+ Counts or estimates tokens for arbitrary polyglot text or code.
44
+ If tiktoken is installed, calculates exact cl100k_base tokens.
45
+ Otherwise, applies calibrated polyglot heuristic:
46
+ - ASCII / Latin / Code: ~3.85 chars/token.
47
+ - Non-ASCII / Diacritics: ~1.8 chars/token.
48
+ """
49
+ if not text:
50
+ return 0
51
+
52
+ if _TIKTOKEN_ENCODER is not None:
53
+ try:
54
+ return len(_TIKTOKEN_ENCODER.encode(text, disallowed_special=()))
55
+ except Exception as err:
56
+ _ = err
57
+
58
+ # Heuristic calibrated against standard LLM subword tokenizers
59
+ non_ascii_chars = len([c for c in text if ord(c) > 127])
60
+ ascii_chars = len(text) - non_ascii_chars
61
+
62
+ # Token density weights
63
+ ascii_tokens = ascii_chars / 3.85
64
+ unicode_tokens = non_ascii_chars / 1.80
65
+
66
+ total_est = int(ascii_tokens + unicode_tokens)
67
+ # Lower bound: words + punctuation count to prevent underestimation on short texts
68
+ word_tokens = len(re.findall(r"\w+|[^\w\s]", text, re.UNICODE))
69
+
70
+ return max(1, max(total_est, int(word_tokens * 1.05)))
71
+
72
+
73
+ def count_file_tokens(file_path: str) -> int:
74
+ """Reads a file from disk and returns its exact/estimated token count."""
75
+ if not os.path.isfile(file_path):
76
+ return 0
77
+ try:
78
+ with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
79
+ content = f.read()
80
+ return count_tokens(content)
81
+ except OSError:
82
+ return 0
83
+
84
+
85
+ def calculate_hydration_payload(
86
+ repo_root: str,
87
+ rules: List[str],
88
+ skills: List[str],
89
+ ) -> Dict[str, Any]:
90
+ """
91
+ Computes precise dual-tier token metrics for a set of selected rules and skills:
92
+ 1. summary: Catalog metadata only (name + summary description ~120 tokens/skill).
93
+ 2. full: Complete SKILL.md body hydrated into context.
94
+ """
95
+ rules_dir = os.path.join(repo_root, ".agents", "rules")
96
+ skills_root = os.path.join(repo_root, ".agents", "skills")
97
+
98
+ rule_tokens = 0
99
+ rule_bytes = 0
100
+ for r in rules:
101
+ p = os.path.join(rules_dir, r)
102
+ if os.path.isfile(p):
103
+ rule_tokens += count_file_tokens(p)
104
+ rule_bytes += os.path.getsize(p)
105
+ else:
106
+ rule_tokens += 500 # Default estimate for virtual rule
107
+ rule_bytes += 2000
108
+
109
+ catalog_skill_tokens = len(skills) * 120
110
+ full_skill_tokens = 0
111
+ full_skill_bytes = 0
112
+
113
+ # Locate each skill directory in .agents/skills
114
+ for skill_name in skills:
115
+ skill_file = _find_skill_file(skills_root, skill_name)
116
+ if skill_file and os.path.isfile(skill_file):
117
+ tokens = count_file_tokens(skill_file)
118
+ size = os.path.getsize(skill_file)
119
+ full_skill_tokens += tokens
120
+ full_skill_bytes += size
121
+ else:
122
+ # Fallback average skill size (~1,800 tokens, 7.5 KB)
123
+ full_skill_tokens += 1800
124
+ full_skill_bytes += 7500
125
+
126
+ return {
127
+ "rule_tokens": rule_tokens,
128
+ "rule_bytes": rule_bytes,
129
+ "skill_catalog_tokens": catalog_skill_tokens,
130
+ "skill_full_body_tokens": full_skill_tokens,
131
+ "skill_full_bytes": full_skill_bytes,
132
+ "total_summary_tokens": rule_tokens + catalog_skill_tokens,
133
+ "total_hydrated_tokens": rule_tokens + full_skill_tokens,
134
+ "total_hydrated_bytes": rule_bytes + full_skill_bytes,
135
+ }
136
+
137
+
138
+ def _find_skill_file(skills_root: str, skill_name: str) -> Optional[str]:
139
+ """Finds SKILL.md for a given skill name across tiered category folders."""
140
+ if not os.path.isdir(skills_root):
141
+ return None
142
+ for root, dirs, files in os.walk(skills_root):
143
+ if os.path.basename(root) == skill_name and "SKILL.md" in files:
144
+ return os.path.join(root, "SKILL.md")
145
+ return None
@@ -31,6 +31,10 @@ Usage:
31
31
 
32
32
  import os
33
33
  import sys
34
+
35
+ _REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
36
+ if _REPO_ROOT not in sys.path:
37
+ sys.path.insert(0, _REPO_ROOT)
34
38
  import glob
35
39
  import json
36
40
  import re
@@ -1135,6 +1139,7 @@ def main():
1135
1139
  parser.add_argument("--pricing", choices=list(PRICING_TABLE.keys()), default=None, help="Model pricing basis (default: auto-detected from transcript)")
1136
1140
  parser.add_argument("--json", action="store_true", help="Output machine-readable JSON format")
1137
1141
  parser.add_argument("--otel", "--opentelemetry", action="store_true", dest="otel", help="Export session spans formatted according to OpenTelemetry GenAI Semantic Conventions")
1142
+ parser.add_argument("--telemetry-summary", action="store_true", help="Display closed-loop MTTR and Tokens-per-Bug telemetry summary")
1138
1143
  parser.add_argument("--file", type=str, help="Direct path to any transcript JSONL file")
1139
1144
 
1140
1145
  args = parser.parse_args()
@@ -1146,6 +1151,29 @@ def main():
1146
1151
  save_budget_config(b5, b7)
1147
1152
  print(f"✅ Token budget updated: 5h = {format_token_shorthand(b5 or get_budget_config()['budget_5h'])}, 7d = {format_token_shorthand(b7 or get_budget_config()['budget_7d'])}")
1148
1153
 
1154
+ # Telemetry summary mode (MTTR & Token/Bug closed-loop ledger)
1155
+ if args.telemetry_summary:
1156
+ try:
1157
+ from tools.core.telemetry import get_telemetry_summary
1158
+ except ImportError:
1159
+ from core.telemetry import get_telemetry_summary
1160
+ summary = get_telemetry_summary()
1161
+ if args.json:
1162
+ print(json.dumps(summary, indent=2, ensure_ascii=False))
1163
+ else:
1164
+ print("╔══════════════════════════════════════════════════════════════════╗")
1165
+ print("║ SYNAPSE HUB — SESSION TELEMETRY & MTTR EFFICIENCY LEDGER ║")
1166
+ print("╚══════════════════════════════════════════════════════════════════╝")
1167
+ print(f" Total Tracked Sessions : {summary['sample_size']}")
1168
+ print(f" Successfully Resolved Defects : {summary['resolved_bugs']}")
1169
+ print(f" Median Tokens / Resolved Bug : {summary['median_tokens_per_bug']:,} tokens")
1170
+ print(f" P90 Tokens / Resolved Bug : {summary['p90_tokens_per_bug']:,} tokens")
1171
+ print(f" Mean Time To Resolution (MTTR): {summary['mttr_seconds']}s")
1172
+ print(f" Average Cache Hit Ratio : {summary['avg_cache_hit_ratio'] * 100:.1f}%")
1173
+ print(f" Average Log Distillation Red. : {summary['avg_distillation_reduction_pct']}%")
1174
+ print("════════════════════════════════════════════════════════════════════")
1175
+ return
1176
+
1149
1177
  # Direct file audit mode
1150
1178
  if args.file:
1151
1179
  plat = detect_platform_from_file(args.file)
@@ -1348,7 +1348,7 @@ def _build_target_translations(
1348
1348
  "th_step_status": "Trạng Thái",
1349
1349
  "th_step_details": "Chi Tiết Kỹ Thuật (OTel & AST)",
1350
1350
 
1351
- "footer_text": "Báo cáo được khởi tạo tự động bởi Synapse-Hub v3.10.0 • Bản quyền © Thế Vị (@TeeVee98) • Chuẩn Clean POM & Kiểm Thử Tự Chủ",
1351
+ "footer_text": "Báo cáo được khởi tạo tự động bởi Synapse-Hub v4.1.0 • Bản quyền © Thế Vị (@TeeVee98) • Chuẩn Clean POM & Kiểm Thử Tự Chủ",
1352
1352
  }
1353
1353
 
1354
1354
  translations_en = {
@@ -1426,7 +1426,7 @@ def _build_target_translations(
1426
1426
  "th_step_status": "Status",
1427
1427
  "th_step_details": "Technical Details (OTel & AST)",
1428
1428
 
1429
- "footer_text": "Generated automatically by Synapse-Hub v3.10.0 • Copyright © Thế Vị (@TeeVee98) • Clean POM & Autonomous Testing",
1429
+ "footer_text": "Generated automatically by Synapse-Hub v4.1.0 • Copyright © Thế Vị (@TeeVee98) • Clean POM & Autonomous Testing",
1430
1430
  }
1431
1431
 
1432
1432
  _inject_gate_translations(translations_vi, translations_en, gates)
@@ -1915,7 +1915,7 @@ def _build_hub_translations(
1915
1915
  """Builds bilingual dictionaries for Hub Dashboard."""
1916
1916
  translations_vi = {
1917
1917
  "header_title": "Bảng Điều Hành Chất Lượng Doanh Nghiệp",
1918
- "header_subtitle": "Synapse-Hub v3.10.0 • Hệ Sinh Thái Kiểm Thử AI Agent Tự Chủ",
1918
+ "header_subtitle": "Synapse-Hub v4.1.0 • Hệ Sinh Thái Kiểm Thử AI Agent Tự Chủ",
1919
1919
  "nav_welcome": "Giới Thiệu",
1920
1920
  "meta_mode": "🏷️ Chế độ: <strong>HỆ SINH THÁI QA HUB</strong>",
1921
1921
  "meta_gen": f"🕒 Khởi tạo: <strong>{now_str}</strong>",
@@ -1985,12 +1985,12 @@ def _build_hub_translations(
1985
1985
  "th_sk_ver": "Phiên Bản",
1986
1986
  "th_sk_cap": "Khả Năng Nghiệp Vụ Cốt Lõi",
1987
1987
 
1988
- "footer_text": "Bảng Điều Hành Chất Lượng Doanh Nghiệp &bull; Synapse-Hub v3.10.0 &bull; Bản quyền &copy; Thế Vị (@TeeVee98) &bull; Hệ Thống Kiểm Thử AI Agent Tự Chủ",
1988
+ "footer_text": "Bảng Điều Hành Chất Lượng Doanh Nghiệp &bull; Synapse-Hub v4.1.0 &bull; Bản quyền &copy; Thế Vị (@TeeVee98) &bull; Hệ Thống Kiểm Thử AI Agent Tự Chủ",
1989
1989
  }
1990
1990
 
1991
1991
  translations_en = {
1992
1992
  "header_title": "Enterprise QA Executive Dashboard",
1993
- "header_subtitle": "Synapse-Hub v3.10.0 &bull; Autonomous AI Agent Testing Ecosystem",
1993
+ "header_subtitle": "Synapse-Hub v4.1.0 &bull; Autonomous AI Agent Testing Ecosystem",
1994
1994
  "nav_welcome": "Welcome",
1995
1995
  "meta_mode": "🏷️ Mode: <strong>QA HUB ECOSYSTEM</strong>",
1996
1996
  "meta_gen": f"🕒 Generated: <strong>{now_str}</strong>",
@@ -2060,7 +2060,7 @@ def _build_hub_translations(
2060
2060
  "th_sk_ver": "Version",
2061
2061
  "th_sk_cap": "Core Capabilities",
2062
2062
 
2063
- "footer_text": "Enterprise QA Executive Dashboard &bull; Synapse-Hub v3.10.0 &bull; Copyright &copy; Thế Vị (@TeeVee98) &bull; Autonomous AI Agent Testing Ecosystem",
2063
+ "footer_text": "Enterprise QA Executive Dashboard &bull; Synapse-Hub v4.1.0 &bull; Copyright &copy; Thế Vị (@TeeVee98) &bull; Autonomous AI Agent Testing Ecosystem",
2064
2064
  }
2065
2065
 
2066
2066
  _inject_gate_translations(translations_vi, translations_en, gates)
@@ -29,8 +29,8 @@ if hasattr(sys.stdout, 'reconfigure'):
29
29
  try:
30
30
  sys.stdout.reconfigure(encoding='utf-8')
31
31
  sys.stderr.reconfigure(encoding='utf-8')
32
- except Exception:
33
- pass
32
+ except Exception as exc:
33
+ _ = exc
34
34
 
35
35
  # Default directories to ignore during scan
36
36
  IGNORED_DIRS = {
@@ -38,7 +38,7 @@ IGNORED_DIRS = {
38
38
  "venv", ".venv", "env", ".env", "__pycache__", ".idea",
39
39
  ".vscode", "coverage", ".mypy_cache", ".ruff_cache",
40
40
  ".pytest_cache", ".sandbox_snapshots", "graphify-out",
41
- "claude-ecosystem-repos", "Reports", "TestReports",
41
+ "claude-ecosystem-repos", "Reports", "reports", "TestReports",
42
42
  "allure-results", "results", "execution_results", "bin", "Libs", "Drivers"
43
43
  }
44
44
 
@@ -59,13 +59,15 @@ class ShortcutEntry:
59
59
  self.description = ""
60
60
  self.ceiling = ""
61
61
  self.upgrade_trigger = ""
62
+ self.owner = "@TeeVee98 (Core Hub)"
63
+ self.sla = "v4.1.0-Sprint"
62
64
  self.has_trigger = False
63
65
  self._parse()
64
66
 
65
67
  def _parse(self):
66
68
  text = self.raw_comment
67
69
  # Format patterns:
68
- # 1. shortcut: <desc>, ceiling: <limit>, upgrade: <trigger>
70
+ # 1. shortcut: <desc>, ceiling: <limit>, upgrade: <trigger>, owner: <owner>, sla: <date>
69
71
  # 2. shortcut: <desc>, <limit>, <trigger>
70
72
  # 3. shortcut: <limit>, <when to upgrade>
71
73
 
@@ -74,12 +76,19 @@ class ShortcutEntry:
74
76
  # Check explicit labels
75
77
  ceiling_match = re.search(r'(?:ceiling|limit):\s*([^,]+)', text, re.IGNORECASE)
76
78
  upgrade_match = re.search(r'(?:upgrade|when|trigger):\s*([^,]+)', text, re.IGNORECASE)
79
+ owner_match = re.search(r'owner:\s*([^,]+)', text, re.IGNORECASE)
80
+ sla_match = re.search(r'(?:sla|due):\s*([^,]+)', text, re.IGNORECASE)
81
+
82
+ if owner_match:
83
+ self.owner = owner_match.group(1).strip()
84
+ if sla_match:
85
+ self.sla = sla_match.group(1).strip()
77
86
 
78
87
  if ceiling_match or upgrade_match:
79
88
  self.ceiling = ceiling_match.group(1).strip() if ceiling_match else ""
80
89
  self.upgrade_trigger = upgrade_match.group(1).strip() if upgrade_match else ""
81
- # Description is what's left before ceiling/upgrade
82
- desc_part = re.split(r'(?:ceiling|limit|upgrade|when|trigger):', text, flags=re.IGNORECASE)[0]
90
+ # Description is what's left before ceiling/upgrade/owner/sla
91
+ desc_part = re.split(r'(?:ceiling|limit|upgrade|when|trigger|owner|sla|due):', text, flags=re.IGNORECASE)[0]
83
92
  self.description = desc_part.strip().rstrip(',')
84
93
  elif len(parts) >= 2:
85
94
  self.description = parts[0]
@@ -103,6 +112,8 @@ class ShortcutEntry:
103
112
  "description": self.description or self.raw_comment,
104
113
  "ceiling": self.ceiling or "Not specified",
105
114
  "upgrade_trigger": self.upgrade_trigger or "No trigger specified",
115
+ "owner": self.owner,
116
+ "sla": self.sla,
106
117
  "has_trigger": self.has_trigger,
107
118
  "raw": self.raw_comment
108
119
  }
@@ -172,13 +183,13 @@ def format_markdown(entries: List[ShortcutEntry], target_dir: str) -> str:
172
183
  lines.append("🎉 **No shortcut debt found. Clean ledger.**")
173
184
  return "\n".join(lines)
174
185
 
175
- lines.append("| Location | Description | Ceiling (Limit) | Upgrade Trigger | Status |")
176
- lines.append("| :--- | :--- | :--- | :--- | :--- |")
186
+ lines.append("| Location | Description | Ceiling (Limit) | Upgrade Trigger | Owner | SLA | Status |")
187
+ lines.append("| :--- | :--- | :--- | :--- | :--- | :--- | :--- |")
177
188
 
178
189
  for e in entries:
179
190
  status = "✅ Tracked" if e.has_trigger else "⚠️ `no-trigger`"
180
191
  loc = f"`{e.file_path}:{e.line_no}`"
181
- lines.append(f"| {loc} | {e.description} | {e.ceiling} | {e.upgrade_trigger or 'None'} | {status} |")
192
+ lines.append(f"| {loc} | {e.description} | {e.ceiling} | {e.upgrade_trigger or 'None'} | {e.owner} | {e.sla} | {status} |")
182
193
 
183
194
  lines.append("")
184
195
  lines.append("### Recommended Action")
@@ -11,7 +11,6 @@ with zero Mermaid dependencies, guaranteed text contrast, and mathematical conta
11
11
  import sys
12
12
  import os
13
13
  import argparse
14
- from typing import Dict, Any
15
14
 
16
15
  # Enforce UTF-8 stdout encoding
17
16
  if hasattr(sys.stdout, "reconfigure"):