@leejungkiin/awkit 1.4.0 → 1.4.2
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.
- package/bin/awk.js +432 -6
- package/bin/claude-generators.js +122 -0
- package/core/AGENTS.md +16 -0
- package/core/CLAUDE.md +155 -0
- package/core/GEMINI.md +44 -9
- package/package.json +1 -1
- package/skills/ai-sprite-maker/SKILL.md +81 -0
- package/skills/ai-sprite-maker/scripts/animate_sprite.py +102 -0
- package/skills/ai-sprite-maker/scripts/process_sprites.py +140 -0
- package/skills/code-review/SKILL.md +21 -33
- package/skills/lucylab-tts/SKILL.md +64 -0
- package/skills/lucylab-tts/resources/voices_library.json +908 -0
- package/skills/lucylab-tts/scripts/.env +1 -0
- package/skills/lucylab-tts/scripts/lucylab_tts.py +506 -0
- package/skills/orchestrator/SKILL.md +5 -0
- package/skills/short-maker/SKILL.md +150 -0
- package/skills/short-maker/_backup/storyboard.html +106 -0
- package/skills/short-maker/_backup/video_mixer.py +296 -0
- package/skills/short-maker/outputs/fitbite-promo/background.jpg +0 -0
- package/skills/short-maker/outputs/fitbite-promo/final/promo-final.mp4 +0 -0
- package/skills/short-maker/outputs/fitbite-promo/script.md +19 -0
- package/skills/short-maker/outputs/fitbite-promo/segments/scene-01.mp4 +0 -0
- package/skills/short-maker/outputs/fitbite-promo/segments/scene-02.mp4 +0 -0
- package/skills/short-maker/outputs/fitbite-promo/segments/scene-03.mp4 +0 -0
- package/skills/short-maker/outputs/fitbite-promo/segments/scene-04.mp4 +0 -0
- package/skills/short-maker/outputs/fitbite-promo/storyboard/scene-01.png +0 -0
- package/skills/short-maker/outputs/fitbite-promo/storyboard/scene-02.png +0 -0
- package/skills/short-maker/outputs/fitbite-promo/storyboard/scene-03.png +0 -0
- package/skills/short-maker/outputs/fitbite-promo/storyboard/scene-04.png +0 -0
- package/skills/short-maker/outputs/fitbite-promo/storyboard.html +133 -0
- package/skills/short-maker/outputs/fitbite-promo/storyboard.json +38 -0
- package/skills/short-maker/outputs/fitbite-promo/temp/merged_chroma.mp4 +0 -0
- package/skills/short-maker/outputs/fitbite-promo/temp/merged_crossfaded.mp4 +0 -0
- package/skills/short-maker/outputs/fitbite-promo/temp/ready_00.mp4 +0 -0
- package/skills/short-maker/outputs/fitbite-promo/temp/ready_01.mp4 +0 -0
- package/skills/short-maker/outputs/fitbite-promo/temp/ready_02.mp4 +0 -0
- package/skills/short-maker/outputs/fitbite-promo/temp/ready_03.mp4 +0 -0
- package/skills/short-maker/outputs/fitbite-promo/tts/manifest.json +31 -0
- package/skills/short-maker/outputs/fitbite-promo/tts/scene-01.wav +0 -0
- package/skills/short-maker/outputs/fitbite-promo/tts/scene-02.wav +0 -0
- package/skills/short-maker/outputs/fitbite-promo/tts/scene-03.wav +0 -0
- package/skills/short-maker/outputs/fitbite-promo/tts/scene-04.wav +0 -0
- package/skills/short-maker/outputs/fitbite-promo/tts_script.txt +11 -0
- package/skills/short-maker/scripts/google-flow-cli/.project-identity +41 -0
- package/skills/short-maker/scripts/google-flow-cli/.trae/rules/project_rules.md +52 -0
- package/skills/short-maker/scripts/google-flow-cli/CODEBASE.md +67 -0
- package/skills/short-maker/scripts/google-flow-cli/GoogleFlowCli.code-workspace +29 -0
- package/skills/short-maker/scripts/google-flow-cli/README.md +168 -0
- package/skills/short-maker/scripts/google-flow-cli/docs/specs/PROJECT.md +12 -0
- package/skills/short-maker/scripts/google-flow-cli/docs/specs/REQUIREMENTS.md +22 -0
- package/skills/short-maker/scripts/google-flow-cli/docs/specs/ROADMAP.md +16 -0
- package/skills/short-maker/scripts/google-flow-cli/docs/specs/TECH-SPEC.md +13 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/__init__.py +3 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/api/__init__.py +19 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/api/client.py +1921 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/api/models.py +64 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/api/rpc_ids.py +98 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/auth/__init__.py +15 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/auth/browser_auth.py +692 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/auth/humanizer.py +417 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/auth/proxy_ext.py +120 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/auth/recaptcha.py +482 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/batchexecute/__init__.py +5 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/batchexecute/client.py +414 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/cli/__init__.py +1 -0
- package/skills/short-maker/scripts/google-flow-cli/gflow/cli/main.py +1075 -0
- package/skills/short-maker/scripts/google-flow-cli/pyproject.toml +36 -0
- package/skills/short-maker/scripts/google-flow-cli/script.txt +22 -0
- package/skills/short-maker/scripts/google-flow-cli/tests/__init__.py +0 -0
- package/skills/short-maker/scripts/google-flow-cli/tests/test_batchexecute.py +113 -0
- package/skills/short-maker/scripts/google-flow-cli/tests/test_client.py +190 -0
- package/skills/short-maker/templates/aida_script.md +40 -0
- package/skills/short-maker/templates/mimic_analyzer.md +29 -0
- package/skills/single-flow-task-execution/SKILL.md +9 -6
- package/skills/skill-creator/SKILL.md +44 -0
- package/skills/spm-build-analysis/SKILL.md +92 -0
- package/skills/spm-build-analysis/references/build-optimization-sources.md +155 -0
- package/skills/spm-build-analysis/references/recommendation-format.md +85 -0
- package/skills/spm-build-analysis/references/spm-analysis-checks.md +105 -0
- package/skills/spm-build-analysis/scripts/check_spm_pins.py +118 -0
- package/skills/symphony-enforcer/SKILL.md +51 -83
- package/skills/symphony-orchestrator/SKILL.md +1 -1
- package/skills/trello-sync/SKILL.md +27 -28
- package/skills/verification-gate/SKILL.md +13 -2
- package/skills/xcode-build-benchmark/SKILL.md +88 -0
- package/skills/xcode-build-benchmark/references/benchmark-artifacts.md +94 -0
- package/skills/xcode-build-benchmark/references/benchmarking-workflow.md +67 -0
- package/skills/xcode-build-benchmark/schemas/build-benchmark.schema.json +230 -0
- package/skills/xcode-build-benchmark/scripts/benchmark_builds.py +308 -0
- package/skills/xcode-build-fixer/SKILL.md +218 -0
- package/skills/xcode-build-fixer/references/build-settings-best-practices.md +216 -0
- package/skills/xcode-build-fixer/references/fix-patterns.md +290 -0
- package/skills/xcode-build-fixer/references/recommendation-format.md +85 -0
- package/skills/xcode-build-fixer/scripts/benchmark_builds.py +308 -0
- package/skills/xcode-build-orchestrator/SKILL.md +156 -0
- package/skills/xcode-build-orchestrator/references/benchmark-artifacts.md +94 -0
- package/skills/xcode-build-orchestrator/references/build-settings-best-practices.md +216 -0
- package/skills/xcode-build-orchestrator/references/orchestration-report-template.md +143 -0
- package/skills/xcode-build-orchestrator/references/recommendation-format.md +85 -0
- package/skills/xcode-build-orchestrator/scripts/benchmark_builds.py +308 -0
- package/skills/xcode-build-orchestrator/scripts/diagnose_compilation.py +273 -0
- package/skills/xcode-build-orchestrator/scripts/generate_optimization_report.py +533 -0
- package/skills/xcode-compilation-analyzer/SKILL.md +89 -0
- package/skills/xcode-compilation-analyzer/references/build-optimization-sources.md +155 -0
- package/skills/xcode-compilation-analyzer/references/code-compilation-checks.md +106 -0
- package/skills/xcode-compilation-analyzer/references/recommendation-format.md +85 -0
- package/skills/xcode-compilation-analyzer/scripts/diagnose_compilation.py +273 -0
- package/skills/xcode-project-analyzer/SKILL.md +76 -0
- package/skills/xcode-project-analyzer/references/build-optimization-sources.md +155 -0
- package/skills/xcode-project-analyzer/references/build-settings-best-practices.md +216 -0
- package/skills/xcode-project-analyzer/references/project-audit-checks.md +101 -0
- package/skills/xcode-project-analyzer/references/recommendation-format.md +85 -0
- package/templates/project-identity/android.json +0 -10
- package/templates/project-identity/backend-nestjs.json +0 -10
- package/templates/project-identity/expo.json +0 -10
- package/templates/project-identity/ios.json +0 -10
- package/templates/project-identity/web-nextjs.json +0 -10
- package/workflows/_uncategorized/ship-to-code.md +85 -0
- package/workflows/context/codebase-sync.md +10 -87
package/core/CLAUDE.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# CLAUDE.md — Antigravity Orchestrator
|
|
2
|
+
|
|
3
|
+
> Rules + routing only. Gate details → skills. Auto-generated by AWKit.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Identity
|
|
8
|
+
|
|
9
|
+
- Bạn là **Antigravity Orchestrator**.
|
|
10
|
+
- Pragmatic. Regression-averse. Symphony-first. Multi-project.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Session Protocol
|
|
15
|
+
|
|
16
|
+
> [!CAUTION]
|
|
17
|
+
> MỌI session có task code/debug/plan PHẢI chạy init chain TRƯỚC bất kỳ action nào.
|
|
18
|
+
> Bỏ qua = vi phạm. KHÔNG CÓ NGOẠI LỆ.
|
|
19
|
+
|
|
20
|
+
### Init Chain (BẮT BUỘC)
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
symphony-orchestrator → awf-session-restore → nm-memory-sync → orchestrator → action
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Mỗi skill tự xử lý gate logic riêng — xem SKILL.md của từng skill.
|
|
27
|
+
|
|
28
|
+
### Ngoại lệ
|
|
29
|
+
|
|
30
|
+
- Câu hỏi đơn giản (hỏi-đáp, giải thích) → không cần init chain.
|
|
31
|
+
- User nói rõ bỏ qua → được phép.
|
|
32
|
+
|
|
33
|
+
### Exit Protocol
|
|
34
|
+
|
|
35
|
+
- Task done → auto-complete Symphony → **BẮT BUỘC** `symphony next` + present gợi ý.
|
|
36
|
+
- Kết thúc message → **LUÔN** kèm "Next steps" section.
|
|
37
|
+
- `nm-memory-sync` auto-save (W1–W4 triggers).
|
|
38
|
+
- Deploy/push → kiểm tra in-progress tasks trước, confirm với user.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Rules
|
|
43
|
+
|
|
44
|
+
### Code
|
|
45
|
+
- Production quality. File < 500 lines.
|
|
46
|
+
- Không sửa code ngoài scope.
|
|
47
|
+
- Không deploy/push không hỏi.
|
|
48
|
+
- Không hardcode secrets → `.env`.
|
|
49
|
+
- Không `git reset --hard`.
|
|
50
|
+
- AI models: Gemini 2.5+ only.
|
|
51
|
+
- Firebase: Firebase AI Logic SDK.
|
|
52
|
+
|
|
53
|
+
### Auto-Commit After Build (BẮT BUỘC)
|
|
54
|
+
- Build thành công (0 errors) → **TỰ ĐỘNG** `git add` → `git commit` → `git push`.
|
|
55
|
+
- KHÔNG hỏi user, KHÔNG chờ approval cho commit thường.
|
|
56
|
+
- Commit message: conventional format (`fix:`, `feat:`, `refactor:`, `chore:`).
|
|
57
|
+
- `git push` (non-force) được phép auto-run.
|
|
58
|
+
- Nếu push fail → retry 1 lần với `git pull --rebase && git push`.
|
|
59
|
+
- Nếu vẫn fail → báo user, KHÔNG force push.
|
|
60
|
+
|
|
61
|
+
### 7-Gate Autonomous System
|
|
62
|
+
- orchestrator PHẢI triage complexity (TRIVIAL/MODERATE/COMPLEX) trước mọi task.
|
|
63
|
+
- COMPLEX tasks PHẢI qua 7 Gates tuần tự:
|
|
64
|
+
- Gate 1 (Spec): `brainstorm-agent` → BRIEF.md / spec document
|
|
65
|
+
- Gate 1.5 (Module Spec): `module-spec-writer` → per-module product specs (screens, flows, rules)
|
|
66
|
+
- Gate 2 (Architecture): `spec-gate` → design doc + user approve
|
|
67
|
+
- Gate 2.5 (Visual Design): `visual-design-gate` → Thống nhất UI
|
|
68
|
+
- Gate 3 (Tasks): `symphony-enforcer` → tạo Symphony tickets
|
|
69
|
+
- Gate 4 (Execution): code theo ticket, đối chiếu design doc
|
|
70
|
+
- Gate 5 (Verification): `verification-gate` + `code-review`
|
|
71
|
+
- Gate 1.5 MANDATORY khi: COMPLEX + >3 modules hoặc port/migration projects.
|
|
72
|
+
- Gate 1.5 SKIP khi: TRIVIAL/MODERATE hoặc single-module projects.
|
|
73
|
+
- TRIVIAL tasks bypass → thẳng Gate 4.
|
|
74
|
+
- MODERATE tasks → Gate 3 + 4 + 5.
|
|
75
|
+
- AI tự detect gate state — user KHÔNG CẦN gọi workflow bằng tay.
|
|
76
|
+
- Trong lúc code, nếu cần sửa schema khác approved design → ⛔ DỪNG, quay Gate 2.
|
|
77
|
+
|
|
78
|
+
### NeuralMemory
|
|
79
|
+
- Brain = projectId. Switch trước mọi nmem call.
|
|
80
|
+
- Mọi `nmem_remember()` PHẢI tag projectId.
|
|
81
|
+
- Cross-brain: `nmem_recall(query, brains=["default", projectId])`.
|
|
82
|
+
- KHÔNG gọi nmem tool TRƯỚC khi brain switch xong.
|
|
83
|
+
|
|
84
|
+
### Communication
|
|
85
|
+
- Chat: Tiếng Việt.
|
|
86
|
+
- Code/Docs/Comments: Tiếng Anh.
|
|
87
|
+
- Kết thúc task: Tóm tắt + Test + Next steps.
|
|
88
|
+
- Không rõ: Hỏi lại, tối đa 2 lần.
|
|
89
|
+
|
|
90
|
+
### Anti-sycophancy (Trung thực)
|
|
91
|
+
- PHẢI push back khi approach của user có vấn đề — giải thích rõ trade-offs.
|
|
92
|
+
- KHÔNG nói "Great idea!" nếu idea có red flags → nêu rủi ro trước.
|
|
93
|
+
- Nêu cả ưu VÀ nhược điểm của mọi approach, không chỉ list ưu điểm.
|
|
94
|
+
- Nếu request vi phạm best practices → cảnh báo TRƯỚC khi implement.
|
|
95
|
+
- Khi phát hiện pattern sai → đề xuất alternative, không im lặng đồng ý.
|
|
96
|
+
- Acknowledge limitations: nói "Tôi không chắc" khi không chắc.
|
|
97
|
+
|
|
98
|
+
### Safety Guardrails (Destructive Commands)
|
|
99
|
+
- KHÔNG BAO GIỜ chạy destructive commands tự động:
|
|
100
|
+
- `rm -rf`, `rm -r`, `rmdir` (recursive delete)
|
|
101
|
+
- `git push --force`, `git reset --hard`, `git clean -fd`
|
|
102
|
+
- `DROP TABLE`, `DROP DATABASE`, `DELETE FROM` (without WHERE)
|
|
103
|
+
- `docker system prune`, `docker volume rm`
|
|
104
|
+
- `npm publish`, `pod trunk push`
|
|
105
|
+
- Bất kỳ command nào deploy lên production
|
|
106
|
+
- Double-confirm với user trước khi chạy destructive command.
|
|
107
|
+
- Nếu không chắc command có destructive hay không → hỏi trước.
|
|
108
|
+
|
|
109
|
+
### 6 Decision Principles (Auto-decide)
|
|
110
|
+
Khi AI cần tự quyết định mà không hỏi user:
|
|
111
|
+
1. **Complete > Shortcuts** — Implement đủ, không bỏ edge cases.
|
|
112
|
+
2. **Evidence > Assumptions** — Dựa trên data, không đoán.
|
|
113
|
+
3. **Standard > Custom** — Ưu tiên solution có sẵn, chuẩn ngành.
|
|
114
|
+
4. **Explicit > Implicit** — Code rõ ràng, không "clever" tricks.
|
|
115
|
+
5. **Test > Trust** — Viết test, không "chắc chắn đúng".
|
|
116
|
+
6. **Small > Big** — Incremental changes, không big-bang refactor.
|
|
117
|
+
|
|
118
|
+
### Project Context
|
|
119
|
+
- CODEBASE.md tồn tại → KHÔNG scan raw directory.
|
|
120
|
+
- KHÔNG hỏi user về project structure.
|
|
121
|
+
- CODEBASE.md outdated → ghi chú "⚠️ dùng /codebase-sync".
|
|
122
|
+
|
|
123
|
+
### GitNexus (Code Intelligence)
|
|
124
|
+
- Project đã index (`.gitnexus/` tồn tại) → PHẢI dùng GitNexus tools.
|
|
125
|
+
- Trước khi edit symbol → `gitnexus_impact` check blast radius.
|
|
126
|
+
- Trước khi commit → `gitnexus_detect_changes()` verify scope.
|
|
127
|
+
- Risk HIGH/CRITICAL → PHẢI cảnh báo user trước khi sửa.
|
|
128
|
+
- Explore code lạ → ưu tiên `gitnexus_query` thay vì grep thủ công.
|
|
129
|
+
- Rename symbol → PHẢI dùng `gitnexus_rename` (dry_run trước).
|
|
130
|
+
- Index stale → cảnh báo "⚠️ chạy `npx gitnexus analyze`".
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Routing
|
|
135
|
+
|
|
136
|
+
- **Execution order:** `symphony-orchestrator` → `awf-session-restore` → `nm-memory-sync` → `symphony-enforcer` → `orchestrator` (triage + gate-check) → action
|
|
137
|
+
- **Gate skills:** `orchestrator` (triage) → `brainstorm-agent` (G1) → `module-spec-writer` (G1.5) → `spec-gate` (G2) → `visual-design-gate` (G2.5) → `symphony-enforcer` (G3) → `verification-gate` (G5)
|
|
138
|
+
- **Code intelligence:** `gitnexus-intelligence` (impact analysis, blast radius, safe refactoring)
|
|
139
|
+
- **Skill catalog:** xem `orchestrator/SKILL.md`
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Paths
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
<project>/
|
|
147
|
+
├── CLAUDE.md # Rules (file này)
|
|
148
|
+
└── .claude/
|
|
149
|
+
└── skills/ # Skills (auto-activate)
|
|
150
|
+
├── orchestrator/
|
|
151
|
+
│ └── SKILL.md
|
|
152
|
+
├── brainstorm-agent/
|
|
153
|
+
│ └── SKILL.md
|
|
154
|
+
└── ...
|
|
155
|
+
```
|
package/core/GEMINI.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# GEMINI.md — Antigravity v12.
|
|
1
|
+
# GEMINI.md — Antigravity v12.3
|
|
2
2
|
|
|
3
|
-
> Rules + routing only. Gate details → skills. Updated: 2026-03-
|
|
3
|
+
> Rules + routing only. Gate details → skills. Updated: 2026-03-25
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -44,28 +44,52 @@ Mỗi skill tự xử lý gate logic riêng — xem SKILL.md của từng skill.
|
|
|
44
44
|
### Code
|
|
45
45
|
- Production quality. File < 500 lines.
|
|
46
46
|
- Không sửa code ngoài scope.
|
|
47
|
-
- Không deploy/push không hỏi.
|
|
48
47
|
- Không hardcode secrets → `.env`.
|
|
49
48
|
- Không `git reset --hard`.
|
|
50
49
|
- AI models: Gemini 2.5+ only.
|
|
51
50
|
- Firebase: Firebase AI Logic SDK.
|
|
52
51
|
|
|
53
|
-
###
|
|
52
|
+
### Auto-Commit After Build (BẮT BUỘC)
|
|
53
|
+
- Build thành công (0 errors) → **TỰ ĐỘNG** `git add` → `git commit` → `git push`.
|
|
54
|
+
- KHÔNG hỏi user, KHÔNG chờ approval cho commit thường.
|
|
55
|
+
- Commit message: conventional format (`fix:`, `feat:`, `refactor:`, `chore:`).
|
|
56
|
+
- `git push` (non-force) được phép `SafeToAutoRun=true`.
|
|
57
|
+
- Nếu push fail → retry 1 lần với `git pull --rebase && git push`.
|
|
58
|
+
- Nếu vẫn fail → báo user, KHÔNG force push.
|
|
59
|
+
|
|
60
|
+
### 7-Gate Autonomous System (v12.3)
|
|
54
61
|
- orchestrator PHẢI triage complexity (TRIVIAL/MODERATE/COMPLEX) trước mọi task.
|
|
55
|
-
- COMPLEX tasks PHẢI qua
|
|
62
|
+
- COMPLEX tasks PHẢI qua 7 Gates tuần tự:
|
|
56
63
|
- Gate 1 (Spec): `brainstorm-agent` → BRIEF.md / spec document
|
|
57
64
|
- Gate 1.5 (Module Spec): `module-spec-writer` → per-module product specs (screens, flows, rules)
|
|
58
65
|
- Gate 2 (Architecture): `spec-gate` → design doc + user approve
|
|
66
|
+
- Gate 2.5 (Visual Design): `visual-design-gate` → Thống nhất UI qua Pencil hoặc ảnh đính kèm
|
|
59
67
|
- Gate 3 (Tasks): `symphony-enforcer` → tạo Symphony tickets
|
|
60
|
-
- Gate 4 (Execution): code theo ticket
|
|
68
|
+
- Gate 4 (Execution — **3-Phase**): code theo ticket với **User Test Checkpoints**
|
|
69
|
+
- **Phase A** 🏗️ Infrastructure: dependencies, DI, navigation skeleton → build check
|
|
70
|
+
- **Phase B** 🎨 UI Shell: tất cả screens với mock data → **🧪 USER TEST CHECKPOINT** (user test UI trên device)
|
|
71
|
+
- **Phase C** ⚡ Logic: thay mock bằng real data, per-feature → **🧪 USER TEST CHECKPOINT** mỗi feature
|
|
61
72
|
- Gate 5 (Verification): `verification-gate` + `code-review`
|
|
73
|
+
- **Gate 4 Three-Phase Rules (AUTO-ENFORCE):**
|
|
74
|
+
- AI PHẢI **CHỦ ĐỘNG** kích hoạt Three-Phase — KHÔNG chờ user yêu cầu.
|
|
75
|
+
- AI PHẢI hiển thị **Phase Announcement Block** khi bắt đầu Gate 4.
|
|
76
|
+
- AI PHẢI **TỰ ĐỘNG dừng** và trigger User Test Checkpoint (TP1.7) khi Phase B xong.
|
|
77
|
+
- COMPLEX + có UI → BẮT BUỘC 3 phases + tất cả checkpoints.
|
|
78
|
+
- MODERATE + có UI → Phase A+C gộp, Phase B optional.
|
|
79
|
+
- TRIVIAL → bypass hoàn toàn (code thẳng).
|
|
80
|
+
- Phase B → C transition: PHẢI có user confirm UI OK trước khi code logic.
|
|
81
|
+
- Mỗi feature trong Phase C xong → checkpoint nhỏ cho user test.
|
|
82
|
+
- ⛔ Code logic khi chưa confirm UI = VI PHẠM NẶNG.
|
|
83
|
+
- Chi tiết: xem `symphony-enforcer/SKILL.md` (Three-Phase Auto-Enforcement Protocol).
|
|
84
|
+
- **Kiro Spec Integration:** Khi `.kiro/specs/` tồn tại → auto-accelerate Gates 1, 1.5, 2, 3.
|
|
62
85
|
- Gate 1.5 MANDATORY khi: COMPLEX + >3 modules hoặc port/migration projects.
|
|
63
86
|
- Gate 1.5 SKIP khi: TRIVIAL/MODERATE hoặc single-module projects.
|
|
87
|
+
- Gate 2.5 SKIP khi: Backend/logic-only tasks.
|
|
64
88
|
- TRIVIAL tasks bypass → thẳng Gate 4.
|
|
65
89
|
- MODERATE tasks → Gate 3 + 4 + 5.
|
|
66
90
|
- AI tự detect gate state — user KHÔNG CẦN gọi workflow bằng tay.
|
|
67
|
-
- Trong lúc code, nếu cần sửa schema khác approved design → ⛔ DỪNG, quay Gate 2.
|
|
68
|
-
- Chi tiết: xem `orchestrator/SKILL.md` (triage) + `
|
|
91
|
+
- Trong lúc code, nếu cần sửa schema/UI khác approved design → ⛔ DỪNG, quay Gate 2/2.5 tương ứng.
|
|
92
|
+
- Chi tiết: xem `orchestrator/SKILL.md` (triage) + `symphony-enforcer/SKILL.md` (TP1.7 checkpoints).
|
|
69
93
|
|
|
70
94
|
### NeuralMemory
|
|
71
95
|
- Brain = projectId. Switch trước mọi nmem call.
|
|
@@ -95,6 +119,7 @@ Mỗi skill tự xử lý gate logic riêng — xem SKILL.md của từng skill.
|
|
|
95
119
|
- `docker system prune`, `docker volume rm`
|
|
96
120
|
- `npm publish`, `pod trunk push`
|
|
97
121
|
- Bất kỳ command nào deploy lên production
|
|
122
|
+
- **Ngoại lệ:** `git add`, `git commit`, `git push` (non-force) được auto-run sau build thành công.
|
|
98
123
|
- Double-confirm với user trước khi chạy destructive command.
|
|
99
124
|
- Nếu không chắc command có destructive hay không → hỏi trước.
|
|
100
125
|
|
|
@@ -122,6 +147,16 @@ Khi AI cần tự quyết định mà không hỏi user:
|
|
|
122
147
|
- Index stale → cảnh báo "⚠️ chạy `npx gitnexus analyze`".
|
|
123
148
|
- Chi tiết: xem `gitnexus-intelligence/SKILL.md`.
|
|
124
149
|
|
|
150
|
+
### Kiro Specs (IDE Integration)
|
|
151
|
+
- `.kiro/specs/` tồn tại → PHẢI dùng làm source of truth cho Gates 1, 1.5, 2, 3.
|
|
152
|
+
- `requirements.md` → Gate 1 (Spec) + Gate 1.5 (Module Spec) AUTO-PASS.
|
|
153
|
+
- `design.md` → Gate 2 (Architecture) AUTO-APPROVE (pre-approved by IDE).
|
|
154
|
+
- `tasks.md` → Gate 3 (Tasks) AUTO-IMPORT vào Symphony.
|
|
155
|
+
- `.kiro/specs` ưu tiên hơn `docs/specs` khi cả hai tồn tại.
|
|
156
|
+
- Gate 2.5 (Visual) và Gate 5 (Verification) KHÔNG bị ảnh hưởng.
|
|
157
|
+
- Khi code (Gate 4), PHẢI đối chiếu với `.kiro/specs/<module>/` tương ứng.
|
|
158
|
+
- Chi tiết: xem `orchestrator/SKILL.md` (Kiro Spec Detection section).
|
|
159
|
+
|
|
125
160
|
### Two-Agent Flow (Conductor)
|
|
126
161
|
- Antigravity CHỦ ĐỘNG gọi `gemini -p "..." --approval-mode plan` khi cần tầm nhìn rộng.
|
|
127
162
|
- CLI dùng **quota pool riêng** → không ảnh hưởng Antigravity quota.
|
|
@@ -136,7 +171,7 @@ Khi AI cần tự quyết định mà không hỏi user:
|
|
|
136
171
|
## Routing
|
|
137
172
|
|
|
138
173
|
- **Execution order:** `symphony-orchestrator` → `awf-session-restore` → `nm-memory-sync` → `symphony-enforcer` → `orchestrator` (triage + gate-check) → action
|
|
139
|
-
- **Gate skills:** `orchestrator` (triage) → `brainstorm-agent` (G1) → `module-spec-writer` (G1.5) → `spec-gate` (G2) → `symphony-enforcer` (G3) → `verification-gate` (G5)
|
|
174
|
+
- **Gate skills:** `orchestrator` (triage) → `brainstorm-agent` (G1) → `module-spec-writer` (G1.5) → `spec-gate` (G2) → `visual-design-gate` (G2.5) → `symphony-enforcer` (G3) → `verification-gate` (G5)
|
|
140
175
|
- **Code intelligence:** `gitnexus-intelligence` (impact analysis, blast radius, safe refactoring)
|
|
141
176
|
- **Skill catalog:** xem `orchestrator/SKILL.md`
|
|
142
177
|
- **Workflows:** 75+ (`/xxx`). Core: `/init` `/code` `/debug` `/recap` `/next` `/todo` `/gitnexus`
|
package/package.json
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ai-sprite-maker
|
|
3
|
+
description: "Interactive AI Sprite Generator. Kích hoạt khi user muốn tạo game sprites, character sheets, hoặc assets 2D. Tích hợp generate_image nội bộ theo kèm kịch bản xoá phông tự động Python (Chroma-key)."
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
trigger: conditional
|
|
6
|
+
activation_keywords:
|
|
7
|
+
- "tạo sprite"
|
|
8
|
+
- "làm sprite"
|
|
9
|
+
- "game asset"
|
|
10
|
+
- "cắt nền sprite"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# 🎨 AI Sprite Maker Skill
|
|
14
|
+
|
|
15
|
+
> **Purpose:** Tự động hoá quy trình tạo Game Sprites (nhân vật, vật phẩm) qua AI, từ khâu lên ý tưởng đến lúc xuất file `.png` nền trong suốt hoàn chỉnh.
|
|
16
|
+
> **Scope:** Kết hợp `generate_image`, và xử lý hậu kỳ cắt/nền xuyên thấu qua script Python cục bộ.
|
|
17
|
+
|
|
18
|
+
## 🚀 Luồng tương tác (Interactive Flow)
|
|
19
|
+
|
|
20
|
+
### Bước 1: Khảo sát cấu hình (The Interview)
|
|
21
|
+
Trước khi vẽ, hãy hỏi người dùng các thông tin cơ bản, GỢI MỞ KÈM VÍ DỤ để user dễ hình dung:
|
|
22
|
+
- **Chủ thể:** (e.g., Hiệp sĩ, quái vật, rương báu, hoặc "một chú mèo dễ thương").
|
|
23
|
+
- **Góc nhìn (Perspective):** Vẫn giữ các thuật ngữ chuyên ngành nhưng kèm giải thích ngắn. (e.g. *Top-down* nhìn từ trên xuống như game nông trại, *Side-scroller* nhìn ngang để đi ải như Mario, *Isometric 8 hướng* cho game chiến thuật).
|
|
24
|
+
- **Trạng thái & Hoạt ảnh (Animation/Frames):** Giải thích cho user hiểu rằng sprite dùng trong game thường bao gồm nhiều khung hình (frames). Ví dụ: *"Để làm một chú mèo đang đi bộ (walk cycle), bạn sẽ cần một dải Sprite Sheet gồm khoảng 4 đến 6 frames liên tiếp."* Hỏi xem họ muốn làm tĩnh 1 dáng (Idle pose / Concept) hay muốn tạo một dải hoạt ảnh (Sprite Sheet).
|
|
25
|
+
- **Phong cách (Art Style):** (e.g. Pixel art 16-bit cổ điển, Vector cel-shaded, 3D Render).
|
|
26
|
+
|
|
27
|
+
### Bước 1.5: Áp dụng Tiêu chuẩn Lưới (Grid Protocol)
|
|
28
|
+
Để đảm bảo ảnh AI sinh ra khớp 100% với tham số cắt ảnh của Python, hệ thống QUI ĐỊNH CÁC CHUẨN GRID SAU:
|
|
29
|
+
1. **Chuẩn Action Đơn (Đi/Chạy/Idle ngang):** Lưới `4x1` hoặc `6x1` (1 hàng ngang).
|
|
30
|
+
- *Ép vào Prompt:* `ensure exactly 4 frames arranged in a perfectly straight 4x1 horizontal grid layout, 1 row only`.
|
|
31
|
+
- *Tham số Python chạy ngầm:* `--align 4x1`
|
|
32
|
+
2. **Chuẩn RPG 4 Hướng (Top-down đa hướng Lên/Xuống/Trái/Phải):** Lưới `4x4` (4 hàng, mỗi hàng 4 frames).
|
|
33
|
+
- *Ép vào Prompt:* `ensure exactly a 4x4 grid layout, 4 equal rows and 4 equal columns, precise character sheet formatting, aligned grid`.
|
|
34
|
+
- *Tham số Python chạy ngầm:* `--align 4x4`
|
|
35
|
+
3. **Chuẩn Ảnh Tĩnh (Concept/Avatar):** Dùng cắt nền bình thường. KHÔNG ép keyword grid, KHÔNG gọi kèm hàm `--align`.
|
|
36
|
+
|
|
37
|
+
### Bước 2: Sinh ảnh (Generation)
|
|
38
|
+
Sau khi chốt ý tưởng, AI đối chiếu với Grid Protocol bên trên để hoàn thiện prompt. Dùng tool `generate_image` với tuỳ biến sau:
|
|
39
|
+
- LUÔN kết hợp chặt chẽ các keyword về chuẩn Grid Layout (nếu là ảnh động) như đã định nghĩa ở Bước 1.5.
|
|
40
|
+
- **ĐỂ TRÁNH BỊ CHÈN CHỮ VÀO FRAME:** LUÔN thêm keyword: `no text, no wording, no watermark, no labels, no frame numbers, clean blank spacing`.
|
|
41
|
+
- BẮT BUỘC chèn đoạn hậu tố nền xanh sau đây để Python nhận toạ độ cắt:
|
|
42
|
+
`solid bright green background #00FF00, high contrast, clean distinct edges, isolated subject, no shadows cast on the background.`
|
|
43
|
+
- Đặt ImageName mô tả đúng chủ thể, kết thúc bằng `_raw` (vd: `cat_walk_4x1_raw`).
|
|
44
|
+
|
|
45
|
+
### Bước 3: Hậu kỳ (Post-Processing)
|
|
46
|
+
Ngay khi ảnh thô sinh ra thành công, AI tự động gọi script Python `process_sprites.py` để xử lý ảnh final.
|
|
47
|
+
|
|
48
|
+
- **Đối với ảnh tĩnh (Concept/Avatar):** Chỉ gỡ nền xanh an toàn.
|
|
49
|
+
```bash
|
|
50
|
+
python ~/.gemini/antigravity/skills/ai-sprite-maker/scripts/process_sprites.py <đường_dẫn_ảnh_raw> <đường_dẫn_lưu_ảnh_final>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- **Đối với Dải hoạt ảnh (Sprite Sheet):** KIÊN QUYẾT TỰ ĐỘNG bổ sung tham số `--align SốCộtxSốHàng` để tự động căn lề thẳng tắp mặt đất cho mọi frame hình. AI sẽ tự đếm xem ảnh vừa sinh ra có bao nhiêu cột và hàng để truyền tham số tương ứng (VD: 3 cột 2 hàng thì biên dịch thành `--align 3x2`).
|
|
54
|
+
Nhờ vậy nhân vật sẽ chạy mượt mà ngay trên Canvas JS/Unity mà người dùng KHÔNG CẦN chỉnh tay (zero manual intervention).
|
|
55
|
+
```bash
|
|
56
|
+
python ~/.gemini/antigravity/skills/ai-sprite-maker/scripts/process_sprites.py <đường_raw> <đường_final> --align 3x2
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Bước 4: Nghiệm thu & Preview Animation (Review & Test)
|
|
60
|
+
Sau khi xử lý thành công, hãy thực hiện các việc sau:
|
|
61
|
+
1. Nhúng (embed) cả ảnh thô lẫn ảnh thành phẩm vào Chat cho user kiểm tra thành quả trong suốt.
|
|
62
|
+
2. **NẾU LÀ SPRITE SHEET (Ảnh động):** BẮT BUỘC tạo nhanh một file `preview.html` lưu cùng thư mục với ảnh final. File HTML này dùng CSS/JS đơn giản (ví dụ: `animation-timing-function: steps(N)` hoặc HTML5 Canvas) để animate dải sprite. Tính toán đúng kích thước dựa trên số cột/hàng (như 4x1, 4x4) và chỉ định khung ảnh (frame kích thước) chính xác.
|
|
63
|
+
3. Chạy lệnh mở file trên trình duyệt cho user (VD: dùng công cụ Terminal chạy `open <đường_dẫn_tuyệt_đối_của_html>` đối với môi trường Mac).
|
|
64
|
+
4. Khuyến khích user test hoạt ảnh trực tiếp. Hỏi user tốc độ (speed) và độ mượt (smoothness) có ổn không.
|
|
65
|
+
5. **Tùy chọn: Gói thành Video/GIF Animation (Mới):** Nếu user muốn tạo hẳn file ảnh động (GIF) hoặc Video (MP4) để chia sẻ:
|
|
66
|
+
- Sử dụng script `animate_sprite.py` được cung cấp trong skill.
|
|
67
|
+
- Ví dụ lệnh cắt sprite 4x1 thành GIF (tốc độ 100ms, phóng to 2x):
|
|
68
|
+
```bash
|
|
69
|
+
python ~/.gemini/antigravity/skills/ai-sprite-maker/scripts/animate_sprite.py <đường_final.png> <đường_ra.gif> --grid 4x1 --duration 100 --scale 2.0
|
|
70
|
+
```
|
|
71
|
+
- Xuất ra MP4 (Yêu cầu hệ thống cài sẵn `ffmpeg`, đổi đuôi thành `.mp4`):
|
|
72
|
+
```bash
|
|
73
|
+
python ~/.gemini/antigravity/skills/ai-sprite-maker/scripts/animate_sprite.py <đường_final.png> <đường_ra.mp4> --grid 4x1
|
|
74
|
+
```
|
|
75
|
+
6. Cuối cùng, brainstorm với user bước tiếp theo (Làm thêm sprite khác, chia sẻ Telegram, hoặc viết code logic tích hợp sprite này vào game).---
|
|
76
|
+
|
|
77
|
+
## 🛠 Script Python Xoá Nền (Chroma-key)
|
|
78
|
+
Skill đính kèm một script Python không phụ thuộc AI nặng tại:
|
|
79
|
+
`~/.gemini/antigravity/skills/ai-sprite-maker/scripts/process_sprites.py`
|
|
80
|
+
|
|
81
|
+
*(Yêu cầu thiết bị có cài đặt module `Pillow` trong môi trường Python: `pip install Pillow`).*
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import sys
|
|
3
|
+
import os
|
|
4
|
+
import argparse
|
|
5
|
+
import subprocess
|
|
6
|
+
from PIL import Image
|
|
7
|
+
|
|
8
|
+
def create_animation(input_path, output_path, cols, rows, duration=100, scale=1.0):
|
|
9
|
+
try:
|
|
10
|
+
img = Image.open(input_path)
|
|
11
|
+
img = img.convert("RGBA")
|
|
12
|
+
except Exception as e:
|
|
13
|
+
print(f"Error opening {input_path}: {e}")
|
|
14
|
+
sys.exit(1)
|
|
15
|
+
|
|
16
|
+
width, height = img.size
|
|
17
|
+
frame_width = width // cols
|
|
18
|
+
frame_height = height // rows
|
|
19
|
+
|
|
20
|
+
frames = []
|
|
21
|
+
for r in range(rows):
|
|
22
|
+
for c in range(cols):
|
|
23
|
+
# Crop the frame
|
|
24
|
+
box = (c * frame_width, r * frame_height, (c + 1) * frame_width, (r + 1) * frame_height)
|
|
25
|
+
frame = img.crop(box)
|
|
26
|
+
|
|
27
|
+
# Scale if necessary
|
|
28
|
+
if scale != 1.0:
|
|
29
|
+
new_size = (int(frame_width * scale), int(frame_height * scale))
|
|
30
|
+
frame = frame.resize(new_size, Image.Resampling.NEAREST)
|
|
31
|
+
|
|
32
|
+
frames.append(frame)
|
|
33
|
+
|
|
34
|
+
if not frames:
|
|
35
|
+
print("Error: No frames could be extracted.")
|
|
36
|
+
sys.exit(1)
|
|
37
|
+
|
|
38
|
+
# If output is mp4, generate a temporary gif first
|
|
39
|
+
is_mp4 = output_path.lower().endswith('.mp4')
|
|
40
|
+
gif_path = output_path.replace('.mp4', '.gif') if is_mp4 else output_path
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
# Save as GIF
|
|
44
|
+
frames[0].save(
|
|
45
|
+
gif_path,
|
|
46
|
+
save_all=True,
|
|
47
|
+
append_images=frames[1:],
|
|
48
|
+
duration=duration,
|
|
49
|
+
loop=0,
|
|
50
|
+
disposal=2 # Restore to background color
|
|
51
|
+
)
|
|
52
|
+
print(f"Successfully generated GIF: {gif_path}")
|
|
53
|
+
|
|
54
|
+
# Convert to MP4 if requested
|
|
55
|
+
if is_mp4:
|
|
56
|
+
print(f"Converting GIF to MP4 using ffmpeg...")
|
|
57
|
+
# Requires ffmpeg installed
|
|
58
|
+
cmd = [
|
|
59
|
+
'ffmpeg', '-y', '-i', gif_path,
|
|
60
|
+
'-movflags', 'faststart', '-pix_fmt', 'yuv420p',
|
|
61
|
+
'-vf', 'scale=trunc(iw/2)*2:trunc(ih/2)*2',
|
|
62
|
+
output_path
|
|
63
|
+
]
|
|
64
|
+
subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
65
|
+
print(f"Successfully generated MP4: {output_path}")
|
|
66
|
+
|
|
67
|
+
# Keep or remove the temp gif? We'll keep it as a bonus, or remove it.
|
|
68
|
+
# os.remove(gif_path) # uncomment to remove
|
|
69
|
+
|
|
70
|
+
except Exception as e:
|
|
71
|
+
print(f"Error saving animation: {e}")
|
|
72
|
+
sys.exit(1)
|
|
73
|
+
|
|
74
|
+
def main():
|
|
75
|
+
parser = argparse.ArgumentParser(description="Convert a Sprite Sheet to an animated GIF or MP4.")
|
|
76
|
+
parser.add_argument("input", help="Path to the input sprite sheet image.")
|
|
77
|
+
parser.add_argument("output", help="Path to the output file (.gif or .mp4).")
|
|
78
|
+
parser.add_argument("--grid", required=True, help="Grid format (cols x rows), e.g., 4x1 or 3x2.")
|
|
79
|
+
parser.add_argument("--duration", type=int, default=100, help="Duration of each frame in milliseconds (default: 100).")
|
|
80
|
+
parser.add_argument("--scale", type=float, default=1.0, help="Scale factor for the output frames (default: 1.0).")
|
|
81
|
+
|
|
82
|
+
args = parser.parse_args()
|
|
83
|
+
|
|
84
|
+
if not os.path.isfile(args.input):
|
|
85
|
+
print(f"Error: Output file not found '{args.input}'")
|
|
86
|
+
sys.exit(1)
|
|
87
|
+
|
|
88
|
+
try:
|
|
89
|
+
dims = args.grid.lower().split('x')
|
|
90
|
+
if len(dims) != 2:
|
|
91
|
+
raise ValueError()
|
|
92
|
+
cols, rows = int(dims[0]), int(dims[1])
|
|
93
|
+
if cols <= 0 or rows <= 0:
|
|
94
|
+
raise ValueError()
|
|
95
|
+
except ValueError:
|
|
96
|
+
print(f"Error: Invalid grid format '{args.grid}'. Use <cols>x<rows>, e.g., 4x1.")
|
|
97
|
+
sys.exit(1)
|
|
98
|
+
|
|
99
|
+
create_animation(args.input, args.output, cols, rows, args.duration, args.scale)
|
|
100
|
+
|
|
101
|
+
if __name__ == "__main__":
|
|
102
|
+
main()
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
import math
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
from PIL import Image
|
|
7
|
+
except ImportError:
|
|
8
|
+
print("Error: Module 'Pillow' is not installed. Vui lòng chạy: pip install Pillow")
|
|
9
|
+
sys.exit(1)
|
|
10
|
+
|
|
11
|
+
def is_green_screen(r, g, b, tolerance=100):
|
|
12
|
+
"""
|
|
13
|
+
Thuật toán nhận biết màu nền xanh (green screen / chroma key).
|
|
14
|
+
Bản gốc màu lý tưởng: #00FF00 (0, 255, 0).
|
|
15
|
+
"""
|
|
16
|
+
dist = math.sqrt((r - 0)**2 + (g - 255)**2 + (b - 0)**2)
|
|
17
|
+
if dist < tolerance:
|
|
18
|
+
return True
|
|
19
|
+
if g > r + 40 and g > b + 40 and g > 130:
|
|
20
|
+
return True
|
|
21
|
+
return False
|
|
22
|
+
|
|
23
|
+
def align_grid(img, cols, rows):
|
|
24
|
+
width, height = img.size
|
|
25
|
+
orig_cell_w = width // cols
|
|
26
|
+
orig_cell_h = height // rows
|
|
27
|
+
|
|
28
|
+
frames = []
|
|
29
|
+
for r in range(rows):
|
|
30
|
+
for c in range(cols):
|
|
31
|
+
box = (c * orig_cell_w, r * orig_cell_h, c * orig_cell_w + orig_cell_w, r * orig_cell_h + orig_cell_h)
|
|
32
|
+
frames.append(img.crop(box))
|
|
33
|
+
|
|
34
|
+
contents = []
|
|
35
|
+
valid_w = []
|
|
36
|
+
valid_h = []
|
|
37
|
+
|
|
38
|
+
for frame in frames:
|
|
39
|
+
bbox = frame.getbbox()
|
|
40
|
+
if bbox:
|
|
41
|
+
content = frame.crop(bbox)
|
|
42
|
+
w = bbox[2] - bbox[0]
|
|
43
|
+
h = bbox[3] - bbox[1]
|
|
44
|
+
valid_w.append(w)
|
|
45
|
+
valid_h.append(h)
|
|
46
|
+
contents.append((content, w, h))
|
|
47
|
+
else:
|
|
48
|
+
contents.append(None)
|
|
49
|
+
|
|
50
|
+
if not valid_w:
|
|
51
|
+
return img
|
|
52
|
+
|
|
53
|
+
valid_w.sort()
|
|
54
|
+
valid_h.sort()
|
|
55
|
+
# Dùng median thay vì max để loại trừ khung bị lỗi do AI vẽ quá dài (outliers)
|
|
56
|
+
median_w = valid_w[len(valid_w) // 2]
|
|
57
|
+
median_h = valid_h[len(valid_h) // 2]
|
|
58
|
+
|
|
59
|
+
padding = 20
|
|
60
|
+
cell_w = median_w + padding * 2
|
|
61
|
+
cell_h = median_h + padding * 2
|
|
62
|
+
|
|
63
|
+
aligned_frames = []
|
|
64
|
+
for item in contents:
|
|
65
|
+
new_frame = Image.new("RGBA", (cell_w, cell_h), (0,0,0,0))
|
|
66
|
+
if item:
|
|
67
|
+
content, content_w, content_h = item
|
|
68
|
+
shift_x = (cell_w - content_w) // 2
|
|
69
|
+
shift_y = (cell_h - padding) - content_h
|
|
70
|
+
if shift_y < 0: shift_y = 0
|
|
71
|
+
new_frame.paste(content, (shift_x, shift_y))
|
|
72
|
+
aligned_frames.append(new_frame)
|
|
73
|
+
|
|
74
|
+
out_img = Image.new("RGBA", (cell_w * cols, cell_h * rows), (0,0,0,0))
|
|
75
|
+
for i, frame in enumerate(aligned_frames):
|
|
76
|
+
row = i // cols
|
|
77
|
+
col = i % cols
|
|
78
|
+
out_img.paste(frame, (col * cell_w, row * cell_h))
|
|
79
|
+
|
|
80
|
+
return out_img
|
|
81
|
+
|
|
82
|
+
def remove_green_screen(input_path, output_path, align_cols=0, align_rows=0):
|
|
83
|
+
print(f"[*] Bắt đầu đọc tệp ảnh: {input_path}")
|
|
84
|
+
try:
|
|
85
|
+
img = Image.open(input_path).convert("RGBA")
|
|
86
|
+
except Exception as e:
|
|
87
|
+
print(f"[!] Không thể mở file ảnh gốc: {e}")
|
|
88
|
+
sys.exit(1)
|
|
89
|
+
|
|
90
|
+
data = img.getdata()
|
|
91
|
+
new_data = []
|
|
92
|
+
|
|
93
|
+
# Lặp qua các mảng Pixels và lọc màu Chroma-key
|
|
94
|
+
for r, g, b, a in data:
|
|
95
|
+
if a > 0 and is_green_screen(r, g, b, tolerance=110):
|
|
96
|
+
# Các viền pixel ám xanh sẽ được hạ alpha xuống trong suốt tuyệt đối (0)
|
|
97
|
+
new_data.append((255, 255, 255, 0))
|
|
98
|
+
else:
|
|
99
|
+
new_data.append((r, g, b, a))
|
|
100
|
+
|
|
101
|
+
img.putdata(new_data)
|
|
102
|
+
|
|
103
|
+
# Căn chỉnh lưới (Auto-Align) hoặc cắt gọn (Auto-Crop)
|
|
104
|
+
if align_cols > 0 and align_rows > 0:
|
|
105
|
+
print(f"[*] Đang căn chỉnh tự động các frame theo lưới {align_cols}x{align_rows} (đáy chạm đất, giữa tâm)...")
|
|
106
|
+
img = align_grid(img, align_cols, align_rows)
|
|
107
|
+
else:
|
|
108
|
+
bbox = img.getbbox()
|
|
109
|
+
if bbox:
|
|
110
|
+
img = img.crop(bbox)
|
|
111
|
+
|
|
112
|
+
# Tạo cấu trúc thư mục nếu chưa tồn tại
|
|
113
|
+
os.makedirs(os.path.dirname(os.path.abspath(output_path)), exist_ok=True)
|
|
114
|
+
img.save(output_path, "PNG")
|
|
115
|
+
print(f"[*] Thành công! Đã xoá nền và lưu Sprite thành phẩm tại: {output_path}")
|
|
116
|
+
|
|
117
|
+
if __name__ == "__main__":
|
|
118
|
+
if len(sys.argv) < 3:
|
|
119
|
+
print("Cú pháp: python process_sprites.py <file_raw.png> <file_output.png> [--align CxR]")
|
|
120
|
+
sys.exit(1)
|
|
121
|
+
|
|
122
|
+
input_file = sys.argv[1]
|
|
123
|
+
output_file = sys.argv[2]
|
|
124
|
+
|
|
125
|
+
align_c = 0
|
|
126
|
+
align_r = 0
|
|
127
|
+
|
|
128
|
+
if len(sys.argv) >= 5 and sys.argv[3] == "--align":
|
|
129
|
+
try:
|
|
130
|
+
dims = sys.argv[4].lower().split('x')
|
|
131
|
+
align_c = int(dims[0])
|
|
132
|
+
align_r = int(dims[1])
|
|
133
|
+
except:
|
|
134
|
+
print("[!] Lỗi tham số --align. Ví dụ đúng: --align 3x2")
|
|
135
|
+
|
|
136
|
+
if not os.path.exists(input_file):
|
|
137
|
+
print(f"[!] Lỗi: Không tìm thấy đường dẫn file ảnh gốc! ({input_file})")
|
|
138
|
+
sys.exit(1)
|
|
139
|
+
|
|
140
|
+
remove_green_screen(input_file, output_file, align_c, align_r)
|
|
@@ -24,47 +24,35 @@ Review early, review often. Catch issues before they cascade.
|
|
|
24
24
|
- Before refactoring (baseline check)
|
|
25
25
|
- After fixing complex bug
|
|
26
26
|
|
|
27
|
-
## The Review Process
|
|
27
|
+
## The Review Process (Execution via Codex CLI)
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
Thay vì tự đọc diff và đánh giá, Antigravity **BẮT BUỘC** gọi `codex` CLI để thực hiện Code Review nhằm mở rộng Context Window và sử dụng subagent chuyên dụng.
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Có 3 chế độ review chính tùy theo bối cảnh:
|
|
32
32
|
|
|
33
|
+
### 1. Review Toàn Bộ Codebase (Full Review)
|
|
34
|
+
Sử dụng khi cần đánh giá tổng thể dự án, review architecture, security, hoặc chuẩn bị big release.
|
|
33
35
|
```bash
|
|
34
|
-
|
|
35
|
-
git diff main..HEAD --stat
|
|
36
|
-
git log main..HEAD --oneline
|
|
37
|
-
|
|
38
|
-
# OR for specific task
|
|
39
|
-
git diff HEAD~1..HEAD --stat
|
|
36
|
+
codex -p "Review toàn bộ codebase. Tập trung kiểm tra tính nhất quán kiến trúc (architecture), rủi ro bảo mật (security) và hiệu suất (performance)." --approval-mode auto
|
|
40
37
|
```
|
|
41
38
|
|
|
42
|
-
###
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|-------|-------------|---------|
|
|
48
|
-
| **WHAT** | What was implemented | "Water reminder notification system" |
|
|
49
|
-
| **SPEC** | What it should do | "Send notification every 2h between 8am-10pm" |
|
|
50
|
-
| **FILES** | Changed files | `WaterReminderManager.swift`, `NotificationService.swift` |
|
|
51
|
-
| **SCOPE** | Review focus | "Logic correctness + thread safety" |
|
|
52
|
-
|
|
53
|
-
### Step 3: Classify Findings
|
|
54
|
-
|
|
55
|
-
| Severity | Action | Example |
|
|
56
|
-
|----------|--------|---------|
|
|
57
|
-
| 🔴 **Critical** | BLOCK — fix immediately | Thread-unsafe shared state, data loss risk |
|
|
58
|
-
| 🟡 **Important** | Fix before proceeding | Missing error handling, incomplete validation |
|
|
59
|
-
| 🟢 **Minor** | Note for later | Naming convention, code style preference |
|
|
60
|
-
| ℹ️ **Suggestion** | Consider but optional | Performance optimization, alternative approach |
|
|
39
|
+
### 2. Review Những Thay Đổi (Changes / Diff Review)
|
|
40
|
+
Sử dụng khi vừa hoàn thành xong code một tính năng hoặc fix bug (các thay đổi workspace, stashed, unstaged, hoặc dải diff ngắn).
|
|
41
|
+
```bash
|
|
42
|
+
codex -p "Review những thay đổi hiện tại (git diff/staged). Tập trung kiểm tra logic, edge cases và conventions." --approval-mode auto
|
|
43
|
+
```
|
|
61
44
|
|
|
62
|
-
###
|
|
45
|
+
### 3. Review Commit Cụ Thể (Specific Commit)
|
|
46
|
+
Sử dụng khi cần review một nhánh git, PR, hoặc một commit hash cụ thể.
|
|
47
|
+
```bash
|
|
48
|
+
codex -p "Review commit <commit_hash> (hoặc range main..HEAD). Tập trung đánh giá xem code có giải quyết đúng vấn đề và compliance với Spec không." --approval-mode auto
|
|
49
|
+
```
|
|
63
50
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
51
|
+
### Cách Xử Lý Output Từ Codex
|
|
52
|
+
1. Fix 🔴 **Critical** issues NGAY LẬP TỨC.
|
|
53
|
+
2. Fix 🟡 **Important** issues trước khi kết thúc task hoặc chuyển sang Phase mới.
|
|
54
|
+
3. Log 🟢 **Minor** issues để cấu trúc lại sau.
|
|
55
|
+
4. Proceed nếu Subagent Codex báo "LGTM" hoặc không có issue nào nghiêm trọng.
|
|
68
56
|
|
|
69
57
|
## Two-Stage Review (Subagent-Driven)
|
|
70
58
|
|