synapse-hub 0.0.0-stage → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/.agents/agents/failure-analyst.md +47 -0
  2. package/.agents/agents/live-explorer.md +41 -0
  3. package/.agents/agents/orchestrator.md +43 -0
  4. package/.agents/agents/pom-crafter.md +81 -0
  5. package/.agents/agents/quality-gatekeeper.md +47 -0
  6. package/.agents/agents/test-runner.md +43 -0
  7. package/.agents/rules/context-engineering.md +88 -0
  8. package/.agents/rules/git-push-protocol.md +101 -0
  9. package/.agents/rules/graphify.md +14 -0
  10. package/.agents/rules/lessons-learned.md +23 -0
  11. package/.agents/rules/mandatory-playwright-live.md +29 -0
  12. package/.agents/rules/skill-precedence.md +42 -0
  13. package/.agents/rules/systematic-debugging.md +99 -0
  14. package/.agents/skills/agent-orchestration-multi-agent-optimize/SKILL.md +239 -0
  15. package/.agents/skills/antigravity-test-sentinel/SKILL.md +64 -0
  16. package/.agents/skills/api-network-mocking-interception/SKILL.md +142 -0
  17. package/.agents/skills/api-spec-to-e2e-matrix/SKILL.md +70 -0
  18. package/.agents/skills/architecture-decision-records/SKILL.md +441 -0
  19. package/.agents/skills/auth-session-and-cookie-manager/SKILL.md +72 -0
  20. package/.agents/skills/backend-load-and-stress-patterns/SKILL.md +214 -0
  21. package/.agents/skills/bats-testing-patterns/SKILL.md +100 -0
  22. package/.agents/skills/bats-testing-patterns/resources/implementation-playbook.md +614 -0
  23. package/.agents/skills/clean-pom-crafter/SKILL.md +75 -0
  24. package/.agents/skills/clean-pom-crafter/examples/standard_test_case.groovy +28 -0
  25. package/.agents/skills/clean-pom-crafter/references/pom_patterns.groovy +138 -0
  26. package/.agents/skills/code-refactoring-refactor-clean/SKILL.md +64 -0
  27. package/.agents/skills/code-refactoring-refactor-clean/resources/implementation-playbook.md +879 -0
  28. package/.agents/skills/db-state-verifier-and-seeder/SKILL.md +123 -0
  29. package/.agents/skills/e2e-testing-patterns/SKILL.md +103 -0
  30. package/.agents/skills/e2e-testing-patterns/resources/implementation-playbook.md +522 -0
  31. package/.agents/skills/failure-autopsy-and-healing/SKILL.md +54 -0
  32. package/.agents/skills/failure-autopsy-and-healing/references/healing_matrix.md +64 -0
  33. package/.agents/skills/failure-autopsy-and-healing/references/qa_investigation_protocol.md +56 -0
  34. package/.agents/skills/failure-autopsy-and-healing/scripts/triage_failures.sh +98 -0
  35. package/.agents/skills/file-and-report-validator/SKILL.md +90 -0
  36. package/.agents/skills/flaky-test-sentinel-and-quarantine/SKILL.md +114 -0
  37. package/.agents/skills/github-actions-templates/SKILL.md +334 -0
  38. package/.agents/skills/graphify-impact-analyzer/SKILL.md +78 -0
  39. package/.agents/skills/katalon-cli-runner/SKILL.md +76 -0
  40. package/.agents/skills/katalon-cli-runner/references/groovy-patterns.md +209 -0
  41. package/.agents/skills/katalon-cli-runner/references/katalon-api.md +155 -0
  42. package/.agents/skills/katalon-cli-runner/references/runner_commands.md +67 -0
  43. package/.agents/skills/lam-script-generator/SKILL.md +83 -0
  44. package/.agents/skills/playwright-live-interaction/SKILL.md +86 -0
  45. package/.agents/skills/playwright-live-interaction/references/advanced_superpowers.md +160 -0
  46. package/.agents/skills/playwright-live-interaction/references/compact_accessibility_snapshots.md +75 -0
  47. package/.agents/skills/playwright-live-interaction/references/recipes.md +388 -0
  48. package/.agents/skills/playwright-live-interaction/references/swarm_orchestration.md +134 -0
  49. package/.agents/skills/security-dast-sentinel/SKILL.md +176 -0
  50. package/.agents/skills/self-healing-locator/SKILL.md +73 -0
  51. package/.agents/skills/synthetic-test-data-generator/SKILL.md +135 -0
  52. package/.agents/skills/token-and-context-optimizer/SKILL.md +70 -0
  53. package/.agents/skills/visual-regression-sentinel/SKILL.md +62 -0
  54. package/.agents/skills/wcag-audit-patterns/SKILL.md +77 -0
  55. package/.agents/skills/wcag-audit-patterns/resources/implementation-playbook.md +541 -0
  56. package/.agents/skills/web-vitals-and-performance-profiler/SKILL.md +65 -0
  57. package/.agents/templates/completion_report.md +57 -0
  58. package/.agents/workflows/graphify.md +10 -0
  59. package/.agents/workflows/test-impact.md +15 -0
  60. package/.agents/workflows/verify.md +34 -0
  61. package/AGENTS.md +115 -0
  62. package/README.md +394 -2
  63. package/bin/agent-qa.js +90 -0
  64. package/package.json +59 -4
  65. package/skills_manifest.json +262 -0
  66. package/templates/PROJECT_AI_GUIDE_TEMPLATE.md +97 -0
  67. package/templates/PROJECT_STATE_TEMPLATE.md +20 -0
  68. package/tools/TOOLS_RUNBOOK.md +298 -0
  69. package/tools/agent_canary.py +501 -0
  70. package/tools/analyze_project.py +242 -0
  71. package/tools/api_drift_sentinel.py +208 -0
  72. package/tools/auto_heal.py +189 -0
  73. package/tools/browser_helpers.js +593 -0
  74. package/tools/bug_reporter.py +224 -0
  75. package/tools/cache_resolver.py +846 -0
  76. package/tools/check_env.py +288 -0
  77. package/tools/ci_healing_hook.py +128 -0
  78. package/tools/cli.py +402 -0
  79. package/tools/config_decoupler.py +253 -0
  80. package/tools/db_sandbox.py +341 -0
  81. package/tools/distill_log.py +152 -0
  82. package/tools/e2e_flow_prober.ps1 +65 -0
  83. package/tools/flaky_detector.py +222 -0
  84. package/tools/fuzz_payloads.py +197 -0
  85. package/tools/generate_allure_report.ps1 +30 -0
  86. package/tools/generate_api_matrix.py +193 -0
  87. package/tools/generate_tc_from_story.py +182 -0
  88. package/tools/generate_test_reports.ps1 +135 -0
  89. package/tools/git_pre_commit_guard.py +203 -0
  90. package/tools/heal_pr_automator.py +195 -0
  91. package/tools/heuristic_locator_matcher.py +202 -0
  92. package/tools/infer_linter.py +238 -0
  93. package/tools/lint_ai_docs.py +254 -0
  94. package/tools/lookup_tc.py +165 -0
  95. package/tools/lookup_xpath.py +167 -0
  96. package/tools/matrix_sharder.py +146 -0
  97. package/tools/mcp_excel_server.ps1 +251 -0
  98. package/tools/mcp_server.py +490 -0
  99. package/tools/micro_mutator.py +309 -0
  100. package/tools/network_mock_shield.py +170 -0
  101. package/tools/omni_emitter.py +500 -0
  102. package/tools/omni_parser.py +435 -0
  103. package/tools/omni_transpiler.py +168 -0
  104. package/tools/pinpoint_failure.py +88 -0
  105. package/tools/project_state.py +169 -0
  106. package/tools/repo_map.json +12 -0
  107. package/tools/repo_map.py +277 -0
  108. package/tools/repo_map.txt +7 -0
  109. package/tools/safety_firewall.py +245 -0
  110. package/tools/setup_project.py +265 -0
  111. package/tools/smart_visual_masker.py +134 -0
  112. package/tools/test_impact.py +321 -0
  113. package/tools/tms_sync_bridge.py +342 -0
  114. package/tools/trace_data_flow.py +240 -0
  115. package/tools/traffic_session_converter.py +256 -0
  116. package/tools/universal_ir.py +480 -0
  117. package/tools/validate_groovy_scripts.py +173 -0
  118. package/tools/verify_all.py +496 -0
  119. package/tools/verify_all.sh +4 -0
  120. package/tools/visual_diff_canvas.py +142 -0
  121. package/tools/visual_som_helper.py +418 -0
  122. package/tools/wcag_audit.py +214 -0
@@ -0,0 +1,99 @@
1
+ ---
2
+ trigger: always_on
3
+ description: Enforce rigorous engineering discipline, systematic debugging without guesswork, and verification before completion.
4
+ ---
5
+
6
+ # Systematic Debugging & Verification Discipline (Superpowers Standard)
7
+
8
+ *(Inherited from `obra/superpowers`)*
9
+
10
+ This rule governs all AI Agents operating on the repository. It mandates strict engineering rigor, prohibiting intuitive guesswork and unverified declarations of completion.
11
+
12
+ ---
13
+
14
+ ## 1. Iron Discipline: Zero Guesswork Debugging
15
+
16
+ 1. **Evidence Before Action:**
17
+ - Never modify code based on a hunch or assumption.
18
+ - Every bug fix or locator update must be preceded by concrete ground-truth evidence:
19
+ - Log excerpt showing the exact failing line and exception.
20
+ - Visual inspection of `Screenshots/FAILED_*.png`.
21
+ - Live DOM element state verified via Playwright Live Interaction.
22
+ 2. **Preserve Working Code:**
23
+ - When fixing an issue in a Page Class or script, touch only the minimal lines required. Never rewrite working methods speculatively.
24
+
25
+ ---
26
+
27
+ ## 2. Verification-First & Zero False Completion
28
+
29
+ 1. **Never Declare Complete Without Running Verification:**
30
+ - Any agent claiming a fix or refactoring is finished MUST run:
31
+ ```bash
32
+ python3 tools/verify_all.py
33
+ ```
34
+ - All 8 Gates must return `PASS`. If any gate fails, the task is NOT complete.
35
+ 2. **Targeted Re-Test:**
36
+ - After modifying Page Classes, check impacted Test Cases with:
37
+ ```bash
38
+ python3 tools/test_impact.py --git-diff
39
+ ```
40
+ - Verify the affected test cases pass before handoff.
41
+ 3. **Synchronize Knowledge Graph & Repo Map:**
42
+ - Run `graphify update .` to keep the AST knowledge graph updated.
43
+ - Run `python3 tools/repo_map.py` if any Page Class or Helper was modified.
44
+
45
+ ---
46
+
47
+ ## 3. Situational Tool Dispatch Matrix & Zero-Command Autonomy
48
+
49
+ > 🚀 **Zero-Command Autonomous Invariant (Zero Manual Commands):**
50
+ > The user **NEVER** needs to remember syntax or manually type tool commands (`agent-qa setup`, `agent-qa analyze`, `verify_all.py`...).
51
+ > The AI Agent **MUST AUTONOMOUSLY recognize context and trigger** the corresponding tools below on-demand whenever the situation arises.
52
+ >
53
+ > 🎯 **On-Demand Activation Principle (Situation-Specific — Never Run Blindly):**
54
+ > Tools assigned to AI and Subagents are **situational weapons**, **NEVER executed all at once**. Agents draw the specific tool from the arsenal if and only if a concrete need arises (e.g.: failing test triggers `auto_heal`, new project triggers `setup_project`, API breaking change triggers `api_drift_sentinel`).
55
+
56
+ | Context / Trigger | Mandatory Tool | Specific Objective |
57
+ | :--- | :--- | :--- |
58
+ | **New project / Missing `PROJECT_AI_GUIDE.md` / Fresh clone** | `python3 tools/setup_project.py [target]` | 100% Autonomous: Detects framework (Playwright/Katalon/Pytest), generates `PROJECT_AI_GUIDE.md`, installs `pre-push` hook, extracts `repo_map.txt`, runs initial audit. |
59
+ | **User requests: "analyze project" / "re-analyze" / "project audit"** | `python3 tools/analyze_project.py [target]` | Execute comprehensive 5-in-1 health audit, sync repo_map, infer_linter, data_flow, verify_all & generate PROJECT_HEALTH_REPORT.md.<br/>**Post-Action:** Stage, commit & push updated project files (`PROJECT_HEALTH_REPORT.md`, `repo_map.txt`) to git. |
60
+ | **Starting task / Querying Page Class methods** | `tools/repo_map.txt`<br/>*(run `python3 tools/repo_map.py` if classes changed)* | Read compressed 500-token map for signatures; avoid reading 4,000-line files. |
61
+ | **Dispatching Browser Actions (Live/CDP)** | `python3 tools/safety_firewall.py --dry-run` | Mandatory Pre-execution Hook: Block irreversible/destructive operations before browser dispatch. |
62
+ | **Creating or updating Test Scripts** | `python3 tools/infer_linter.py` | Run AST scan for Fake-Pass (0 asserts) and empty catch blocks. |
63
+ | **New/Modified Test Case Quality** | `python3 tools/micro_mutator.py --min-score 80` | AST Mutation Testing: Reject test suites with mutation score < 80%. |
64
+ | **Before Git Commit or Completing Task** | `python3 tools/verify_all.py` | Validate all 8 Quality Gates DoD. |
65
+ | **After modifying Page Classes** | `python3 tools/test_impact.py --git-diff` | Scope impacted test cases; avoid re-running entire test suites. |
66
+ | **When Test FAILS in CLI/KRE** | `python3 tools/pinpoint_failure.py` | Parse JUnit XML to identify exact failing line and exception in 0.1s. |
67
+ | **When CLI / Gradle logs are verbose** | `python3 tools/distill_log.py <log>` | Filter 95% noise; preserve only actionable stacktraces and pointers. |
68
+ | **Handling UI exceptions (Overlay, Stale)** | `python3 tools/cache_resolver.py query "<error>"` | Lookup 0-token solution from local SQLite memory cache before improvising. |
69
+ | **Pre-Push / Suite Acceptance** | `python3 tools/trace_data_flow.py` | Run Taint Analysis to verify no orphan database junk remains uncleaned. |
70
+ | **Canary Self-Healing Audit** | `python3 tools/agent_canary.py --run` | Inject 8 failure vectors to benchmark MTTR and autonomous recovery rate. |
71
+ | **Testing GIS Canvas / Chart without DOM** | `python3 tools/visual_diff_canvas.py` | Compare pixel / SSIM to detect visual rendering regression. |
72
+ | **Pulling code / New clone** | `python3 tools/cache_resolver.py init` | Automatically sync Central Agent Memory (`~/.agent_memory/global_cache.db`). |
73
+ | **Before authoring test for Page/Flow** | `python3 tools/cache_resolver.py get-lessons --context "<page>"` | Query top 2 episodic lessons learned to avoid repeating past failure patterns. |
74
+ | **After healing a bug / failure** | `python3 tools/cache_resolver.py record-lesson` | Record a concise 2-line lesson into SQLite memory for cross-session reflexion. |
75
+
76
+ ---
77
+
78
+ ## 4. Cognitive Forcing Functions (Structured Reasoning Pipeline)
79
+
80
+ > **Core Principle:** Autocomplete mode generates weak, tautological tests. Before outputting any test script, Universal IR, or Page Class, the agent **MUST** pass through a 4-step System-2 reasoning pipeline:
81
+
82
+ ```markdown
83
+ <reasoning_protocol>
84
+ Step 1 - Boundary & Invariant Extraction: Xác định các bất biến (invariants) của hệ thống. Cái gì bắt buộc không bao giờ được phép xảy ra?
85
+ Step 2 - Falsification Hypotheses (Phản đề Popper): Đưa ra 3 kịch bản lập trình viên có thể làm hàm chạy sai mà test thông thường vẫn pass (False Negatives).
86
+ Step 3 - Self-Debate: Tự giải thích tại sao assertion chuẩn bị viết sẽ bắt chết cả 3 kịch bản phá hoại ở Step 2.
87
+ Step 4 - Emit Code / Universal IR: Chỉ sinh code khi đã hoàn thành 3 bước trên.
88
+ </reasoning_protocol>
89
+ ```
90
+
91
+ ---
92
+
93
+ ## 5. Adversarial Self-Play: Red-Team vs Blue-Team
94
+
95
+ - **Agent Blue (`pom-crafter`):** Synthesizes Clean POM code and defensive assertions.
96
+ - **Agent Red (`failure-analyst`):** Acts as the rogue developer, actively injecting AST mutants via `tools/micro_mutator.py` into source/mocks.
97
+ - **Evaluation Loop:**
98
+ - If Blue's tests let mutants survive (Mutation Score $< 80\%$), Red-Team **REJECTS** the code and commands Blue to strengthen assertions.
99
+ - Test suites are only Approved when Mutation Score reaches $\ge 80\%$.
@@ -0,0 +1,239 @@
1
+ ---
2
+ name: agent-orchestration-multi-agent-optimize
3
+ description: "Optimize multi-agent systems with coordinated profiling, workload distribution, and cost-aware orchestration. Use when improving agent performance, throughput, or reliability."
4
+ ---
5
+
6
+ # Multi-Agent Optimization Toolkit
7
+
8
+ ## Use this skill when
9
+
10
+ - Improving multi-agent coordination, throughput, or latency
11
+ - Profiling agent workflows to identify bottlenecks
12
+ - Designing orchestration strategies for complex workflows
13
+ - Optimizing cost, context usage, or tool efficiency
14
+
15
+ ## Do not use this skill when
16
+
17
+ - You only need to tune a single agent prompt
18
+ - There are no measurable metrics or evaluation data
19
+ - The task is unrelated to multi-agent orchestration
20
+
21
+ ## Instructions
22
+
23
+ 1. Establish baseline metrics and target performance goals.
24
+ 2. Profile agent workloads and identify coordination bottlenecks.
25
+ 3. Apply orchestration changes and cost controls incrementally.
26
+ 4. Validate improvements with repeatable tests and rollbacks.
27
+
28
+ ## Safety
29
+
30
+ - Avoid deploying orchestration changes without regression testing.
31
+ - Roll out changes gradually to prevent system-wide regressions.
32
+
33
+ ## Role: AI-Powered Multi-Agent Performance Engineering Specialist
34
+
35
+ ### Context
36
+
37
+ The Multi-Agent Optimization Tool is an advanced AI-driven framework designed to holistically improve system performance through intelligent, coordinated agent-based optimization. Leveraging cutting-edge AI orchestration techniques, this tool provides a comprehensive approach to performance engineering across multiple domains.
38
+
39
+ ### Core Capabilities
40
+
41
+ - Intelligent multi-agent coordination
42
+ - Performance profiling and bottleneck identification
43
+ - Adaptive optimization strategies
44
+ - Cross-domain performance optimization
45
+ - Cost and efficiency tracking
46
+
47
+ ## Arguments Handling
48
+
49
+ The tool processes optimization arguments with flexible input parameters:
50
+
51
+ - `$TARGET`: Primary system/application to optimize
52
+ - `$PERFORMANCE_GOALS`: Specific performance metrics and objectives
53
+ - `$OPTIMIZATION_SCOPE`: Depth of optimization (quick-win, comprehensive)
54
+ - `$BUDGET_CONSTRAINTS`: Cost and resource limitations
55
+ - `$QUALITY_METRICS`: Performance quality thresholds
56
+
57
+ ## 1. Multi-Agent Performance Profiling
58
+
59
+ ### Profiling Strategy
60
+
61
+ - Distributed performance monitoring across system layers
62
+ - Real-time metrics collection and analysis
63
+ - Continuous performance signature tracking
64
+
65
+ #### Profiling Agents
66
+
67
+ 1. **Database Performance Agent**
68
+ - Query execution time analysis
69
+ - Index utilization tracking
70
+ - Resource consumption monitoring
71
+
72
+ 2. **Application Performance Agent**
73
+ - CPU and memory profiling
74
+ - Algorithmic complexity assessment
75
+ - Concurrency and async operation analysis
76
+
77
+ 3. **Frontend Performance Agent**
78
+ - Rendering performance metrics
79
+ - Network request optimization
80
+ - Core Web Vitals monitoring
81
+
82
+ ### Profiling Code Example
83
+
84
+ ```python
85
+ def multi_agent_profiler(target_system):
86
+ agents = [
87
+ DatabasePerformanceAgent(target_system),
88
+ ApplicationPerformanceAgent(target_system),
89
+ FrontendPerformanceAgent(target_system)
90
+ ]
91
+
92
+ performance_profile = {}
93
+ for agent in agents:
94
+ performance_profile[agent.__class__.__name__] = agent.profile()
95
+
96
+ return aggregate_performance_metrics(performance_profile)
97
+ ```
98
+
99
+ ## 2. Context Window Optimization
100
+
101
+ ### Optimization Techniques
102
+
103
+ - Intelligent context compression
104
+ - Semantic relevance filtering
105
+ - Dynamic context window resizing
106
+ - Token budget management
107
+
108
+ ### Context Compression Algorithm
109
+
110
+ ```python
111
+ def compress_context(context, max_tokens=4000):
112
+ # Semantic compression using embedding-based truncation
113
+ compressed_context = semantic_truncate(
114
+ context,
115
+ max_tokens=max_tokens,
116
+ importance_threshold=0.7
117
+ )
118
+ return compressed_context
119
+ ```
120
+
121
+ ## 3. Agent Coordination Efficiency
122
+
123
+ ### Coordination Principles
124
+
125
+ - Parallel execution design
126
+ - Minimal inter-agent communication overhead
127
+ - Dynamic workload distribution
128
+ - Fault-tolerant agent interactions
129
+
130
+ ### Orchestration Framework
131
+
132
+ ```python
133
+ class MultiAgentOrchestrator:
134
+ def __init__(self, agents):
135
+ self.agents = agents
136
+ self.execution_queue = PriorityQueue()
137
+ self.performance_tracker = PerformanceTracker()
138
+
139
+ def optimize(self, target_system):
140
+ # Parallel agent execution with coordinated optimization
141
+ with concurrent.futures.ThreadPoolExecutor() as executor:
142
+ futures = {
143
+ executor.submit(agent.optimize, target_system): agent
144
+ for agent in self.agents
145
+ }
146
+
147
+ for future in concurrent.futures.as_completed(futures):
148
+ agent = futures[future]
149
+ result = future.result()
150
+ self.performance_tracker.log(agent, result)
151
+ ```
152
+
153
+ ## 4. Parallel Execution Optimization
154
+
155
+ ### Key Strategies
156
+
157
+ - Asynchronous agent processing
158
+ - Workload partitioning
159
+ - Dynamic resource allocation
160
+ - Minimal blocking operations
161
+
162
+ ## 5. Cost Optimization Strategies
163
+
164
+ ### LLM Cost Management
165
+
166
+ - Token usage tracking
167
+ - Adaptive model selection
168
+ - Caching and result reuse
169
+ - Efficient prompt engineering
170
+
171
+ ### Cost Tracking Example
172
+
173
+ ```python
174
+ class CostOptimizer:
175
+ def __init__(self):
176
+ self.token_budget = 100000 # Monthly budget
177
+ self.token_usage = 0
178
+ self.model_costs = { # USD per 1K input tokens
179
+ 'gpt-5': 0.03,
180
+ 'claude-sonnet-4-6': 0.003,
181
+ 'claude-haiku-4-5': 0.001
182
+ }
183
+
184
+ def select_optimal_model(self, complexity):
185
+ # Dynamic model selection based on task complexity and budget
186
+ pass
187
+ ```
188
+
189
+ ## 6. Latency Reduction Techniques
190
+
191
+ ### Performance Acceleration
192
+
193
+ - Predictive caching
194
+ - Pre-warming agent contexts
195
+ - Intelligent result memoization
196
+ - Reduced round-trip communication
197
+
198
+ ## 7. Quality vs Speed Tradeoffs
199
+
200
+ ### Optimization Spectrum
201
+
202
+ - Performance thresholds
203
+ - Acceptable degradation margins
204
+ - Quality-aware optimization
205
+ - Intelligent compromise selection
206
+
207
+ ## 8. Monitoring and Continuous Improvement
208
+
209
+ ### Observability Framework
210
+
211
+ - Real-time performance dashboards
212
+ - Automated optimization feedback loops
213
+ - Machine learning-driven improvement
214
+ - Adaptive optimization strategies
215
+
216
+ ## Reference Workflows
217
+
218
+ ### Workflow 1: E-Commerce Platform Optimization
219
+
220
+ 1. Initial performance profiling
221
+ 2. Agent-based optimization
222
+ 3. Cost and performance tracking
223
+ 4. Continuous improvement cycle
224
+
225
+ ### Workflow 2: Enterprise API Performance Enhancement
226
+
227
+ 1. Comprehensive system analysis
228
+ 2. Multi-layered agent optimization
229
+ 3. Iterative performance refinement
230
+ 4. Cost-efficient scaling strategy
231
+
232
+ ## Key Considerations
233
+
234
+ - Always measure before and after optimization
235
+ - Maintain system stability during optimization
236
+ - Balance performance gains with resource consumption
237
+ - Implement gradual, reversible changes
238
+
239
+ Target Optimization: $ARGUMENTS
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: antigravity-test-sentinel
3
+ description: >-
4
+ Verification-first sentinel for test automation in Antigravity. Strictly locks task completion until test runner commands (verify_all.py, KRE CLI, Playwright) return exit code 0. Forbids declaring completion on unverified code.
5
+ ---
6
+
7
+ # Antigravity Test Sentinel — Verification-First Gatekeeper
8
+
9
+ The **Antigravity Test Sentinel** enforces absolute engineering integrity across test creation, script refactoring, and bug fixes. It acts as an autonomous circuit breaker that physically prohibits the AI Agent from concluding a task without verifiable proof of test execution success.
10
+
11
+ ---
12
+
13
+ ## 1. The Sentinel Axiom (Zero-Hallucination Gate)
14
+
15
+ 1. **The Core Rule:**
16
+ - Writing code is NOT completing the task.
17
+ - Editing a locator is NOT fixing a failure.
18
+ - **A task is ONLY complete when the test execution returns Exit Code 0.**
19
+
20
+ 2. **Prohibited Agent Behaviors:**
21
+ - 🚫 Saying *"I have fixed the issue"* without executing verification.
22
+ - 🚫 Assuming a locator or script will work based on static text analysis.
23
+ - 🚫 Ignoring non-zero exit codes from CLI runners or Gradle builds.
24
+
25
+ ---
26
+
27
+ ## 2. Gate-Lock Protocol
28
+
29
+ Whenever an Agent modifies any test script, Page Class, locator, or helper method:
30
+
31
+ ```mermaid
32
+ flowchart TD
33
+ Edit["1. Code Edit / Bug Fix Applied"] --> Run["2. Execute Test Runner Command"]
34
+ Run --> Check{"3. Check Process Exit Code"}
35
+ Check -- "Exit Code == 0" --> DoD["4. Run verify_all.py (6 Gates)"]
36
+ DoD -- "All Gates PASS" --> Complete["5. Declare Task Complete ✅"]
37
+ Check -- "Exit Code != 0" --> Extract["4a. Extract Stack Trace & Failing Line"]
38
+ Extract --> Heal["4b. In-Place Healing Loop"]
39
+ Heal --> Run
40
+ ```
41
+
42
+ 1. **Step 1: Execute Runner Command:**
43
+ - Run the targeted test case or test suite via headless CLI runner or verification gate:
44
+ ```bash
45
+ python3 tools/verify_all.py
46
+ ```
47
+ 2. **Step 2: Inspect Exit Code:**
48
+ - If the process terminates with exit code != 0, the task is **LOCKED**.
49
+ - The Agent must not ask the user for confirmation or declare success.
50
+ 3. **Step 3: Self-Diagnosis & Auto-Healing:**
51
+ - The Agent must parse the exact error exception and stack trace from the failure output.
52
+ - Apply targeted in-place healing and re-execute.
53
+ 4. **Step 4: Definition of Done Verification:**
54
+ - Run `python3 tools/verify_all.py` to confirm all 6 quality gates pass.
55
+
56
+ ---
57
+
58
+ ## 3. Sentinel Status Header
59
+
60
+ In accordance with Antigravity operating discipline, include the sentinel verification status in the session summary:
61
+
62
+ ```text
63
+ > 🛡️ SENTINEL STATUS: VERIFIED (Exit Code: 0 | 6/6 Gates PASS)
64
+ ```
@@ -0,0 +1,142 @@
1
+ ---
2
+ name: api-network-mocking-interception
3
+ description: Runtime HTTP/GraphQL request interception, route stubbing (page.route), and chaos network resilience testing (latency, 502/503/504 faults, offline, circuit breaker) during UI execution.
4
+ ---
5
+
6
+ # API Network Mocking, Interception & Resilience Skill
7
+
8
+ > **Target:** Eliminate flaky tests caused by backend dependencies, slow microservices, or inconsistent staging data by intercepting browser-level network requests, and verify frontend resilience against network faults and degradations.
9
+
10
+ ---
11
+
12
+ ## 1. Core Principles
13
+
14
+ 1. **Deterministic State over Staging Data:**
15
+ - UI tests should verify front-end state rendering and user interactions, not whether the backend DB is seeded.
16
+ - Use route interception (`page.route()`) to return predictable JSON contracts (success, 400 Bad Request, 500 Server Error).
17
+
18
+ 2. **Zero Network Latency:**
19
+ - Mock external telemetry, 3rd party analytics, fonts, and heavy media assets to speed up execution by 3x-5x.
20
+
21
+ 3. **Fault Injection & Chaos Verification:**
22
+ - Test UI resiliency against network timeouts, dropped connections, upstream gateway outages (502/503/504), and malformed schemas without altering real server code.
23
+ - Guard against White Screen of Death (WSOD) when sudden network loss or circuit-breaking events occur.
24
+
25
+ ---
26
+
27
+ ## 2. Playwright Route Interception Standard Patterns
28
+
29
+ ### Pattern A: Static JSON Response Stubbing
30
+ ```typescript
31
+ // Stub user profile API
32
+ await page.route('**/api/v1/user/profile', async (route) => {
33
+ await route.fulfill({
34
+ status: 200,
35
+ contentType: 'application/json',
36
+ body: JSON.stringify({
37
+ id: 'USR_AUTO_99',
38
+ username: 'qa_sentinel',
39
+ roles: ['ADMIN_OPERATOR'],
40
+ permissions: ['READ', 'WRITE', 'EXECUTE']
41
+ })
42
+ });
43
+ });
44
+ ```
45
+
46
+ ### Pattern B: Modifying Live Responses (HAR / Passthrough Mutation)
47
+ ```typescript
48
+ // Intercept real response and inject edge-case field
49
+ await page.route('**/api/v1/reports', async (route) => {
50
+ const response = await route.fetch();
51
+ const json = await response.json();
52
+ json.totalItems = 999999; // Test UI overflow / pagination edge case
53
+ await route.fulfill({ response, json });
54
+ });
55
+ ```
56
+
57
+ ### Pattern C: Simulating Network Failures & Delays
58
+ ```typescript
59
+ // Simulate 500 Internal Server Error
60
+ await page.route('**/api/v1/checkout', async (route) => {
61
+ await route.fulfill({
62
+ status: 500,
63
+ contentType: 'application/json',
64
+ body: JSON.stringify({ errorCode: 'ERR_PAYMENT_DOWN', message: 'Gateway unreachable' })
65
+ });
66
+ });
67
+
68
+ // Simulate High Latency (Slow 3G)
69
+ await page.route('**/api/v1/heavy-list', async (route) => {
70
+ await new Promise(res => setTimeout(res, 3000));
71
+ await route.continue();
72
+ });
73
+ ```
74
+
75
+ ---
76
+
77
+ ## 3. Chaos & Network Degradation Patterns
78
+
79
+ ### Pattern D: Emulating Extreme Latency & Jitter via CDP
80
+ ```typescript
81
+ const client = await page.context().newCDPSession(page);
82
+ await client.send('Network.emulateNetworkConditions', {
83
+ offline: false,
84
+ latency: 3500, // 3.5s roundtrip latency
85
+ downloadThroughput: ((500 * 1024) / 8), // 500 kbps
86
+ uploadThroughput: ((500 * 1024) / 8),
87
+ connectionType: 'cellular3g',
88
+ });
89
+
90
+ await page.goto('/orders');
91
+ // Verify UI displays loading skeleton/spinner and submit button is disabled in-flight
92
+ const submitBtn = page.locator('button[type="submit"]');
93
+ if (await submitBtn.isVisible()) {
94
+ await expect(submitBtn).toBeDisabled();
95
+ }
96
+ ```
97
+
98
+ ### Pattern E: Simulating Gateway Drops (502/503/504) & Circuit Breaker Recovery
99
+ ```typescript
100
+ let attemptCount = 0;
101
+ await page.route('**/api/v1/orders/submit', async (route) => {
102
+ attemptCount++;
103
+ if (attemptCount <= 2) {
104
+ await route.fulfill({
105
+ status: 503,
106
+ contentType: 'application/json',
107
+ body: JSON.stringify({ message: 'Upstream gateway overloaded' }),
108
+ });
109
+ } else {
110
+ await route.fulfill({
111
+ status: 200,
112
+ contentType: 'application/json',
113
+ body: JSON.stringify({ success: true, orderId: 'ORD_HEALED_99' }),
114
+ });
115
+ }
116
+ });
117
+ ```
118
+
119
+ ### Pattern F: Sudden Offline Disconnection & Reconnection
120
+ ```typescript
121
+ // 1. Cut network abruptly
122
+ await context.setOffline(true);
123
+ await page.click('[data-testid="nav-reports"]').catch(() => {});
124
+
125
+ // 2. Assert Zero White Screen of Death (WSOD) & Offline alert
126
+ const bodyContent = await page.evaluate(() => document.body.innerText.trim());
127
+ expect(bodyContent.length, 'Page must not be blank').toBeGreaterThan(20);
128
+
129
+ // 3. Restore connectivity
130
+ await context.setOffline(false);
131
+ await page.reload();
132
+ await expect(page.locator('h1')).toBeVisible();
133
+ ```
134
+
135
+ ---
136
+
137
+ ## 4. Best Practices Checklist
138
+ - [ ] Always declare routes **before** calling `page.goto()`.
139
+ - [ ] Use regex or glob patterns with caution; avoid intercepting Vite/Webpack bundling scripts.
140
+ - [ ] Critical forms must disable submit buttons during in-flight network transit to prevent duplicate requests.
141
+ - [ ] HTTP 502/503/504 errors must trigger user-friendly notifications, never raw JSON dumps or blank screens.
142
+ - [ ] For teardown, unroute specific patterns or reset context per test.
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: api-spec-to-e2e-matrix
3
+ description: >-
4
+ Transforms OpenAPI/Swagger specifications and JSON schemas into automated E2E positive, boundary value, and negative test matrices.
5
+ ---
6
+
7
+ # API Spec to E2E Matrix — Contract-Based Test Generator
8
+
9
+ This skill converts OpenAPI / Swagger specifications, JSON Schemas, or REST endpoint contracts into a structured, executable End-to-End (E2E) testing matrix covering happy path, boundary values, and negative error scenarios.
10
+
11
+ ---
12
+
13
+ ## 1. Test Generation Matrix Taxonomy
14
+
15
+ ```mermaid
16
+ flowchart TD
17
+ Spec["OpenAPI / Swagger / JSON Schema"] --> Parse["Extract Endpoint Contracts"]
18
+ Parse --> Pos["1. Positive Happy Path<br/>• Valid payload<br/>• HTTP 200/201<br/>• Response schema match"]
19
+ Parse --> Bound["2. Boundary Value Analysis<br/>• Min/Max string length<br/>• Zero, negative numbers<br/>• Unicode & special chars"]
20
+ Parse --> Neg["3. Negative & Fault Scenarios<br/>• Missing required fields (400)<br/>• Invalid auth token (401/403)<br/>• Malformed payload (422)"]
21
+
22
+ Pos & Bound & Neg --> Suite["Executable Test Suite"]
23
+ ```
24
+
25
+ ---
26
+
27
+ ## 2. Boundary Value Generation Rules
28
+
29
+ For every field defined in the endpoint schema, generate targeted edge cases:
30
+
31
+ | Field Data Type | Schema Constraint | Generated Boundary Test Inputs |
32
+ | :--- | :--- | :--- |
33
+ | **String (Code / ID)** | `minLength: 3, maxLength: 20` | Empty string `""`, 2 chars, exactly 3 chars, 20 chars, 21 chars, special chars `<script>`, SQL `' OR 1=1--` |
34
+ | **Number / Integer** | `minimum: 0, maximum: 1000` | `-1`, `0`, `1`, `999`, `1000`, `1001`, floating point `10.5` |
35
+ | **Date / Timestamp** | `format: date-time` | Past date, today, future date, leap year `2024-02-29`, invalid format `31/12/2026` |
36
+ | **Enum** | `["ACTIVE", "INACTIVE"]` | Exactly `"ACTIVE"`, lowercase `"active"`, null, undefined, unknown enum `"DELETED"` |
37
+ | **Required Properties** | `required: ["code", "name"]` | Omit `code`, omit `name`, send `null` values |
38
+
39
+ ---
40
+
41
+ ## 3. Negative Scenario Validation Checklist
42
+
43
+ Every negative test case must assert two distinct layers:
44
+ 1. **API Layer Assertion:**
45
+ - Verify HTTP Status Code is appropriately 400, 401, 403, 404, or 422.
46
+ - Verify error payload contains expected error codes and localization messages.
47
+ 2. **UI / Toast Notification Layer Assertion:**
48
+ - Verify that the web UI displays the appropriate red toast notification (e.g. *"Dữ liệu không hợp lệ"* or *"Mã đã tồn tại"*).
49
+ - Verify that the form remains open and input fields preserve user state without losing entered data.
50
+
51
+ ---
52
+
53
+ ## 4. Automation Output Standards
54
+
55
+ - Generated test cases must adhere to the project's **Clean POM** structure.
56
+ - All requests should utilize dynamic test data with unique timestamp prefixes to ensure idempotency.
57
+
58
+ ---
59
+
60
+ ## 5. Automated Execution via Tooling
61
+
62
+ Agent can automatically invoke ools/generate_api_matrix.py to produce matrices from Swagger files:
63
+
64
+ ``bash
65
+ # Generate Markdown matrix
66
+ python tools/generate_api_matrix.py --spec path/to/openapi.json --format md -o docs/api_matrix.md
67
+
68
+ # Generate JSON matrix for programmatic ingestion
69
+ python tools/generate_api_matrix.py --spec path/to/openapi.json --format json -o tools/api_matrix.json
70
+ ``