@uocnv1998/agent-kit 1.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 (77) hide show
  1. package/README.md +56 -0
  2. package/bin/index.js +161 -0
  3. package/package.json +14 -0
  4. package/templates/.agent/ARCHITECTURE.md +37 -0
  5. package/templates/.agent/common/workflows/brainstorm.md +113 -0
  6. package/templates/.agent/designer/ARCHITECTURE.md +24 -0
  7. package/templates/.agent/designer/rules/GEMINI.md +110 -0
  8. package/templates/.agent/designer/skills/SKILL.md +46 -0
  9. package/templates/.agent/designer/workflows/designer-workflow.md +29 -0
  10. package/templates/.agent/dev/backend/ARCHITECTURE.md +49 -0
  11. package/templates/.agent/dev/backend/agents/backend-specialist.md +116 -0
  12. package/templates/.agent/dev/backend/rules/GEMINI.md +114 -0
  13. package/templates/.agent/dev/backend/skills/clichouse-expert/SKILL.md +144 -0
  14. package/templates/.agent/dev/backend/skills/docker/SKILL.md +409 -0
  15. package/templates/.agent/dev/backend/skills/laravel/SKILL.md +63 -0
  16. package/templates/.agent/dev/backend/skills/laravel-tdd/SKILL.md +146 -0
  17. package/templates/.agent/dev/backend/skills/mysql/SKILL.md +83 -0
  18. package/templates/.agent/dev/backend/skills/mysql/references/character-sets.md +66 -0
  19. package/templates/.agent/dev/backend/skills/mysql/references/composite-indexes.md +59 -0
  20. package/templates/.agent/dev/backend/skills/mysql/references/connection-management.md +70 -0
  21. package/templates/.agent/dev/backend/skills/mysql/references/covering-indexes.md +47 -0
  22. package/templates/.agent/dev/backend/skills/mysql/references/data-types.md +69 -0
  23. package/templates/.agent/dev/backend/skills/mysql/references/deadlocks.md +72 -0
  24. package/templates/.agent/dev/backend/skills/mysql/references/explain-analysis.md +66 -0
  25. package/templates/.agent/dev/backend/skills/mysql/references/fulltext-indexes.md +28 -0
  26. package/templates/.agent/dev/backend/skills/mysql/references/index-maintenance.md +110 -0
  27. package/templates/.agent/dev/backend/skills/mysql/references/isolation-levels.md +49 -0
  28. package/templates/.agent/dev/backend/skills/mysql/references/json-column-patterns.md +77 -0
  29. package/templates/.agent/dev/backend/skills/mysql/references/n-plus-one.md +77 -0
  30. package/templates/.agent/dev/backend/skills/mysql/references/online-ddl.md +53 -0
  31. package/templates/.agent/dev/backend/skills/mysql/references/partitioning.md +92 -0
  32. package/templates/.agent/dev/backend/skills/mysql/references/primary-keys.md +70 -0
  33. package/templates/.agent/dev/backend/skills/mysql/references/query-optimization-pitfalls.md +117 -0
  34. package/templates/.agent/dev/backend/skills/mysql/references/replication-lag.md +46 -0
  35. package/templates/.agent/dev/backend/skills/mysql/references/row-locking-gotchas.md +63 -0
  36. package/templates/.agent/dev/common/rules/GIT_COMMIT.md +9 -0
  37. package/templates/.agent/dev/common/skills/tdd-workflow/SKILL.md +149 -0
  38. package/templates/.agent/dev/common/workflows/dev-workflow.md +46 -0
  39. package/templates/.agent/dev/frontend/ARCHITECTURE.md +47 -0
  40. package/templates/.agent/dev/frontend/agents/frontend-specialist.md +593 -0
  41. package/templates/.agent/dev/frontend/rules/GEMINI.md +117 -0
  42. package/templates/.agent/dev/frontend/skills/frontend-design/SKILL.md +418 -0
  43. package/templates/.agent/dev/frontend/skills/frontend-design/animation-guide.md +331 -0
  44. package/templates/.agent/dev/frontend/skills/frontend-design/color-system.md +311 -0
  45. package/templates/.agent/dev/frontend/skills/frontend-design/decision-trees.md +418 -0
  46. package/templates/.agent/dev/frontend/skills/frontend-design/motion-graphics.md +306 -0
  47. package/templates/.agent/dev/frontend/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  48. package/templates/.agent/dev/frontend/skills/frontend-design/scripts/ux_audit.py +722 -0
  49. package/templates/.agent/dev/frontend/skills/frontend-design/typography-system.md +345 -0
  50. package/templates/.agent/dev/frontend/skills/frontend-design/ux-psychology.md +1116 -0
  51. package/templates/.agent/dev/frontend/skills/frontend-design/visual-effects.md +383 -0
  52. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +312 -0
  53. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
  54. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
  55. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
  56. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
  57. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
  58. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
  59. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
  60. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/SKILL.md +286 -0
  61. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
  62. package/templates/.agent/dev/frontend/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
  63. package/templates/.agent/dev/frontend/skills/tailwind-patterns/SKILL.md +269 -0
  64. package/templates/.agent/dev/frontend/skills/web-design-guidelines/SKILL.md +57 -0
  65. package/templates/.agent/po_ba/ARCHITECTURE.md +28 -0
  66. package/templates/.agent/po_ba/agents/documentation-writer.md +104 -0
  67. package/templates/.agent/po_ba/agents/product-manager.md +112 -0
  68. package/templates/.agent/po_ba/agents/product-owner.md +95 -0
  69. package/templates/.agent/po_ba/rules/GEMINI.md +142 -0
  70. package/templates/.agent/po_ba/skills/SKILL.md +42 -0
  71. package/templates/.agent/po_ba/workflows/po_ba-workflow.md +21 -0
  72. package/templates/.agent/tester/ARCHITECTURE.md +27 -0
  73. package/templates/.agent/tester/agents/qa-automation-engineer.md +103 -0
  74. package/templates/.agent/tester/agents/test-engineer.md +158 -0
  75. package/templates/.agent/tester/rules/GEMINI.md +147 -0
  76. package/templates/.agent/tester/skills/SKILL.md +57 -0
  77. package/templates/.agent/tester/workflows/tester-workflow.md +32 -0
@@ -0,0 +1,46 @@
1
+ ---
2
+ title: Replication Lag Awareness
3
+ description: Read-replica consistency pitfalls and mitigations
4
+ tags: mysql, replication, lag, read-replicas, consistency, gtid
5
+ ---
6
+
7
+ # Replication Lag
8
+
9
+ MySQL replication is asynchronous by default. Reads from a replica may return stale data.
10
+
11
+ ## The Core Problem
12
+ 1. App writes to primary: `INSERT INTO orders ...`
13
+ 2. App immediately reads from replica: `SELECT * FROM orders WHERE id = ?`
14
+ 3. Replica hasn't applied the write yet — returns empty or stale data.
15
+
16
+ ## Detecting Lag
17
+ ```sql
18
+ -- On the replica
19
+ SHOW REPLICA STATUS\G
20
+ -- Key field: Seconds_Behind_Source (0 = caught up, NULL = not replicating)
21
+ ```
22
+ **Warning**: `Seconds_Behind_Source` measures relay-log lag, not true wall-clock staleness. It can underreport during long-running transactions because it only updates when transactions commit.
23
+
24
+ **GTID-based lag**: for more accurate tracking, compare `@@global.gtid_executed` (replica) to primary GTID position, or use `WAIT_FOR_EXECUTED_GTID_SET()` to wait for a specific transaction.
25
+
26
+ **Note**: parallel replication with `replica_parallel_type=LOGICAL_CLOCK` requires `binlog_format=ROW`. Statement-based replication (`binlog_format=STATEMENT`) is more limited for parallel apply.
27
+
28
+ ## Mitigation Strategies
29
+
30
+ | Strategy | How | Trade-off |
31
+ |---|---|---|
32
+ | **Read from primary** | Route critical reads to primary after writes | Increases primary load |
33
+ | **Sticky sessions** | Pin user to primary for N seconds after a write | Adds session affinity complexity |
34
+ | **GTID wait** | `SELECT WAIT_FOR_EXECUTED_GTID_SET('gtid', timeout)` on replica | Adds latency equal to lag |
35
+ | **Semi-sync replication** | Primary waits for >=1 replica ACK before committing | Higher write latency |
36
+
37
+ ## Common Pitfalls
38
+ - **Large transactions cause lag spikes**: A single `INSERT ... SELECT` of 1M rows replays as one big transaction on the replica. Break into batches.
39
+ - **DDL blocks replication**: `ALTER TABLE` with `ALGORITHM=COPY` on primary replays on replica, blocking other relay-log events during execution. `INSTANT` and `INPLACE` DDL are less blocking but still require brief metadata locks.
40
+ - **Long queries on replica**: A slow `SELECT` on the replica can block relay-log application. Use `replica_parallel_workers` (8.0+) with `replica_parallel_type=LOGICAL_CLOCK` for parallel apply. Note: LOGICAL_CLOCK requires `binlog_format=ROW` and `slave_preserve_commit_order=ON` (or `replica_preserve_commit_order=ON`) to preserve commit order.
41
+ - **IO thread bottlenecks**: Network latency, disk I/O, or `relay_log_space_limit` exhaustion can cause lag even when the SQL apply thread isn't saturated. Monitor `Relay_Log_Space` and connectivity.
42
+
43
+ ## Guidelines
44
+ - Assume replicas are always slightly behind. Design reads accordingly.
45
+ - Use GTID-based replication for reliable failover and lag tracking.
46
+ - Monitor `Seconds_Behind_Source` with alerting (>5s warrants investigation).
@@ -0,0 +1,63 @@
1
+ ---
2
+ title: InnoDB Row Locking Gotchas
3
+ description: Gap locks, next-key locks, and surprise escalation
4
+ tags: mysql, innodb, locking, gap-locks, next-key-locks, concurrency
5
+ ---
6
+
7
+ # Row Locking Gotchas
8
+
9
+ InnoDB uses row-level locking, but the actual locked range is often wider than expected.
10
+
11
+ ## Next-Key Locks (REPEATABLE READ)
12
+ InnoDB's default isolation level uses next-key locks for **locking reads** (`SELECT ... FOR UPDATE`, `SELECT ... FOR SHARE`, `UPDATE`, `DELETE`) to prevent phantom reads. A range scan locks every gap in that range. Plain `SELECT` statements use consistent reads (MVCC) and don't acquire locks.
13
+
14
+ **Exception**: a unique index search with a unique search condition (e.g., `WHERE id = 5` on a unique `id`) locks only the index record, not the gap. Gap/next-key locks still apply for range scans and non-unique searches.
15
+
16
+ ```sql
17
+ -- Locks rows with id 5..10 AND the gaps between them and after the range
18
+ SELECT * FROM orders WHERE id BETWEEN 5 AND 10 FOR UPDATE;
19
+ -- Another session inserting id=7 blocks until the lock is released.
20
+ ```
21
+
22
+ ## Gap Locks on Non-Existent Rows
23
+ `SELECT ... FOR UPDATE` on a row that doesn't exist still places a gap lock:
24
+ ```sql
25
+ -- No row with id=999 exists, but this locks the gap around where 999 would be
26
+ SELECT * FROM orders WHERE id = 999 FOR UPDATE;
27
+ -- Concurrent INSERTs into that gap are blocked.
28
+ ```
29
+
30
+ ## Index-Less UPDATE/DELETE = Full Scan and Broad Locking
31
+ If the WHERE column has no index, InnoDB must scan all rows and locks every row examined (often effectively all rows in the table). This is not table-level locking—InnoDB doesn't escalate locks—but rather row-level locks on all rows:
32
+ ```sql
33
+ -- No index on status → locks all rows (not a table lock, but all row locks)
34
+ UPDATE orders SET processed = 1 WHERE status = 'pending';
35
+ -- Fix: CREATE INDEX idx_status ON orders (status);
36
+ ```
37
+
38
+ ## SELECT ... FOR SHARE (Shared Locks)
39
+ `SELECT ... FOR SHARE` acquires shared (S) locks instead of exclusive (X) locks. Multiple sessions can hold shared locks simultaneously, but exclusive locks are blocked:
40
+
41
+ ```sql
42
+ -- Session 1: shared lock
43
+ SELECT * FROM orders WHERE id = 5 FOR SHARE;
44
+
45
+ -- Session 2: also allowed (shared lock)
46
+ SELECT * FROM orders WHERE id = 5 FOR SHARE;
47
+
48
+ -- Session 3: blocked until shared locks are released
49
+ UPDATE orders SET status = 'processed' WHERE id = 5;
50
+ ```
51
+
52
+ Gap/next-key locks can still apply in REPEATABLE READ, so inserts into locked gaps may be blocked even with shared locks.
53
+
54
+ ## INSERT ... ON DUPLICATE KEY UPDATE
55
+ Takes an exclusive next-key lock on the index entry. If multiple sessions do this concurrently on nearby key values, gap-lock deadlocks are common.
56
+
57
+ ## Lock Escalation Misconception
58
+ InnoDB does **not** automatically escalate row locks to table locks. When a missing index causes "table-wide" locking, it's because InnoDB scans and locks all rows individually—not because locks were escalated.
59
+
60
+ ## Mitigation Strategies
61
+ - **Use READ COMMITTED** when gap locks cause excessive blocking (gap locks disabled in RC except for FK/duplicate-key checks).
62
+ - **Keep transactions short** — hold locks for milliseconds, not seconds.
63
+ - **Ensure WHERE columns are indexed** to avoid full-table lock scans.
@@ -0,0 +1,9 @@
1
+ ---
2
+ trigger: model_decision
3
+ description: Apply this rule hen you generate a commit message
4
+ ---
5
+
6
+ - Always generate commit messages in English.
7
+ - Use the Conventional Commits format: <type>(<scope>): <description>
8
+ - Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert.
9
+ - Keep the subject line under 50 characters.
@@ -0,0 +1,149 @@
1
+ ---
2
+ name: tdd-workflow
3
+ description: Test-Driven Development workflow principles. RED-GREEN-REFACTOR cycle.
4
+ allowed-tools: Read, Write, Edit, Glob, Grep, Bash
5
+ ---
6
+
7
+ # TDD Workflow
8
+
9
+ > Write tests first, code second.
10
+
11
+ ---
12
+
13
+ ## 1. The TDD Cycle
14
+
15
+ ```
16
+ 🔴 RED → Write failing test
17
+
18
+ 🟢 GREEN → Write minimal code to pass
19
+
20
+ 🔵 REFACTOR → Improve code quality
21
+
22
+ Repeat...
23
+ ```
24
+
25
+ ---
26
+
27
+ ## 2. The Three Laws of TDD
28
+
29
+ 1. Write production code only to make a failing test pass
30
+ 2. Write only enough test to demonstrate failure
31
+ 3. Write only enough code to make the test pass
32
+
33
+ ---
34
+
35
+ ## 3. RED Phase Principles
36
+
37
+ ### What to Write
38
+
39
+ | Focus | Example |
40
+ |-------|---------|
41
+ | Behavior | "should add two numbers" |
42
+ | Edge cases | "should handle empty input" |
43
+ | Error states | "should throw for invalid data" |
44
+
45
+ ### RED Phase Rules
46
+
47
+ - Test must fail first
48
+ - Test name describes expected behavior
49
+ - One assertion per test (ideally)
50
+
51
+ ---
52
+
53
+ ## 4. GREEN Phase Principles
54
+
55
+ ### Minimum Code
56
+
57
+ | Principle | Meaning |
58
+ |-----------|---------|
59
+ | **YAGNI** | You Aren't Gonna Need It |
60
+ | **Simplest thing** | Write the minimum to pass |
61
+ | **No optimization** | Just make it work |
62
+
63
+ ### GREEN Phase Rules
64
+
65
+ - Don't write unneeded code
66
+ - Don't optimize yet
67
+ - Pass the test, nothing more
68
+
69
+ ---
70
+
71
+ ## 5. REFACTOR Phase Principles
72
+
73
+ ### What to Improve
74
+
75
+ | Area | Action |
76
+ |------|--------|
77
+ | Duplication | Extract common code |
78
+ | Naming | Make intent clear |
79
+ | Structure | Improve organization |
80
+ | Complexity | Simplify logic |
81
+
82
+ ### REFACTOR Rules
83
+
84
+ - All tests must stay green
85
+ - Small incremental changes
86
+ - Commit after each refactor
87
+
88
+ ---
89
+
90
+ ## 6. AAA Pattern
91
+
92
+ Every test follows:
93
+
94
+ | Step | Purpose |
95
+ |------|---------|
96
+ | **Arrange** | Set up test data |
97
+ | **Act** | Execute code under test |
98
+ | **Assert** | Verify expected outcome |
99
+
100
+ ---
101
+
102
+ ## 7. When to Use TDD
103
+
104
+ | Scenario | TDD Value |
105
+ |----------|-----------|
106
+ | New feature | High |
107
+ | Bug fix | High (write test first) |
108
+ | Complex logic | High |
109
+ | Exploratory | Low (spike, then TDD) |
110
+ | UI layout | Low |
111
+
112
+ ---
113
+
114
+ ## 8. Test Prioritization
115
+
116
+ | Priority | Test Type |
117
+ |----------|-----------|
118
+ | 1 | Happy path |
119
+ | 2 | Error cases |
120
+ | 3 | Edge cases |
121
+ | 4 | Performance |
122
+
123
+ ---
124
+
125
+ ## 9. Anti-Patterns
126
+
127
+ | ❌ Don't | ✅ Do |
128
+ |----------|-------|
129
+ | Skip the RED phase | Watch test fail first |
130
+ | Write tests after | Write tests before |
131
+ | Over-engineer initial | Keep it simple |
132
+ | Multiple asserts | One behavior per test |
133
+ | Test implementation | Test behavior |
134
+
135
+ ---
136
+
137
+ ## 10. AI-Augmented TDD
138
+
139
+ ### Multi-Agent Pattern
140
+
141
+ | Agent | Role |
142
+ |-------|------|
143
+ | Agent A | Write failing tests (RED) |
144
+ | Agent B | Implement to pass (GREEN) |
145
+ | Agent C | Optimize (REFACTOR) |
146
+
147
+ ---
148
+
149
+ > **Remember:** The test is the specification. If you can't write a test, you don't understand the requirement.
@@ -0,0 +1,46 @@
1
+ ---
2
+ description: Spec-Driven Development (SDD) using the official OpenSpec tool.
3
+ ---
4
+
5
+ # Developer Execution Workflow (OpenSpec Official Workflow)
6
+
7
+ This project strictly utilizes the **Official OpenSpec framework** (`@fission-ai/openspec`) to manage the AI Spec-Driven Development (SDD) process.
8
+
9
+ **CRITICAL RULE FOR AI:**
10
+ Even if the user simply says "Thực hiện task TAP-1" or "Code chức năng Đăng nhập" without mentioning `/opsx`, **YOU MUST AUTOMATICALLY TRIGGER THE OPENSPEC WORKFLOW**. You are FORBIDDEN from writing source code immediately.
11
+
12
+ ## Workflow Phases
13
+
14
+ ### Phase 1: Establish the Spec (Thuyết minh & Thiết kế kỹ thuật)
15
+ When receiving a task (via Jira Ticket or direct prompt), you must act as if the user typed `/opsx:propose [Task-Key]`.
16
+
17
+ - You will automatically generate or update a folder at `openspec/changes/[Task-Key]/`.
18
+ - You must draft the 4 required artifacts within that folder:
19
+ 1. `proposal.md` - Why we're doing this, what's changing.
20
+ 2. `specs/` - Requirements and scenarios.
21
+ 3. `design.md` - Technical approach.
22
+ 4. `tasks.md` - Implementation checklist.
23
+ - After generating these files, STOP and ask the user to review them via `/opsx:apply`.
24
+
25
+ ### Phase 2: Implementation (Tiến hành Code)
26
+ - **Command**: `/opsx:apply`
27
+ - When you receive this command, you will start implementing the code strictly following the checklist in `tasks.md`.
28
+ - As you complete portions of the work, mark off items in the `tasks.md` internal memory.
29
+ - **MANDATORY**: Upon completing the backend implementation, you MUST document the new or updated APIs:
30
+ 1. Create or update an API Specification page on **Confluence** (using `atlassian-mcp-server_createConfluencePage` or `updateConfluencePage`).
31
+ 2. Add a comment to the corresponding **Jira ticket** (using `atlassian-mcp-server_addCommentToJiraIssue`) containing the direct link to the Confluence API Documentation page so the frontend team can implement their side.
32
+
33
+ ### Phase 3: Archive & Continuous Updates
34
+ - **Command**: `/opsx:archive`
35
+ - Move the feature to `openspec/changes/archive/[date]-[feature-name]/`.
36
+ - Specs must be updated to ensure the AI's prompt rules (e.g., inside `.cursorrules` or `.clinerules` that OpenSpec generates) remain accurate. This ensures the Agent avoids hallucinations in future tasks.
37
+
38
+ ---
39
+
40
+ ## 🛠️ Setup Instructions (For User/Dev)
41
+ If OpenSpec is not yet initialized in this project, run the following commands in the terminal:
42
+ ```bash
43
+ npx @fission-ai/openspec@latest init
44
+ openspec update
45
+ ```
46
+ This forces the AI coding assistants (Cursor, Copilot, Cline, etc.) to load the OpenSpec workflow rules.
@@ -0,0 +1,47 @@
1
+ # Antigravity Kit Architecture
2
+
3
+ > System overview for the current single-agent development setup.
4
+
5
+ ---
6
+
7
+ ## 🏗️ Directory Structure
8
+
9
+ ```plaintext
10
+ .agent/
11
+ ├── ARCHITECTURE.md # This file (System Overview)
12
+ ├── agents/ # Specialist AI Persona (1 active)
13
+ ├── rules/ # Global Rules (GEMINI.md)
14
+ ├── skills/ # Domain-specific knowledge modules
15
+ └── workflows/ # Slash Command Procedures
16
+ ```
17
+
18
+ ---
19
+
20
+ ## 🤖 Active Agent
21
+
22
+ | Agent | Focus | Location |
23
+ | --------------------- | -------------------------------------- | --------------------------------------- |
24
+ | `frontend-specialist` | Web UI/UX, Performance, React, Next.js | `.agent/agents/frontend-specialist.md` |
25
+
26
+ ---
27
+
28
+ ## 🧩 Active Skills (4)
29
+
30
+ Modular knowledge domains loaded by the `frontend-specialist`.
31
+
32
+ | Skill | Description |
33
+ | ------------------------ | -------------------------------------------- |
34
+ | `frontend-design` | Design systems and UX patterns |
35
+ | `nextjs-react-expert` | Next.js performance and patterns |
36
+ | `tailwind-patterns` | Utility-first styling with Tailwind CSS |
37
+ | `web-design-guidelines` | Accessibility and design audit principles |
38
+
39
+ ---
40
+
41
+ ## 🔄 Workflows (1)
42
+
43
+ Slash command procedures. Invoke with `/command`.
44
+
45
+ | Command | Description | Location |
46
+ | ------------- | --------------------------- | ----------------------------------- |
47
+ | `/brainstorm` | Socratic discovery & design | `.agent/workflows/brainstorm.md` |