@leejungkiin/awkit 1.1.9 → 1.3.4

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.
@@ -0,0 +1,459 @@
1
+ ---
2
+ name: module-spec-writer
3
+ description: >-
4
+ Gate 1.5 — Module Specification Writer. Tạo tài liệu mô tả chi tiết từng module
5
+ của ứng dụng: screens, user flows, business rules, validation, data contracts,
6
+ edge cases. Chạy sau brainstorm (Gate 1) và trước architecture design (Gate 2).
7
+ Đặc biệt critical cho port/migration projects.
8
+ Hỗ trợ auto-detect .kiro/specs modules để bypass khi IDE đã tạo specs.
9
+ metadata:
10
+ stage: core
11
+ version: "1.1"
12
+ tags: [gate, spec, module, product-spec, documentation, core, kiro]
13
+ requires: orchestrator
14
+ agent: Spec Writer
15
+ trigger: conditional
16
+ invocation-type: auto
17
+ priority: 1
18
+ activation_keywords:
19
+ - "module spec"
20
+ - "mô tả module"
21
+ - "screen inventory"
22
+ - "feature spec"
23
+ - "product spec"
24
+ - "mô tả app"
25
+ - "document modules"
26
+ ---
27
+
28
+ # Module Spec Writer v1.0 — Gate 1.5: Product Specification
29
+
30
+ > **Purpose:** Tạo tài liệu mô tả chi tiết từng module/feature của ứng dụng
31
+ > ở cấp độ **Product** (screens, flows, rules) — TRƯỚC KHI đi vào thiết kế
32
+ > kỹ thuật (DB/API). Đảm bảo AI và user có shared understanding về "app làm gì"
33
+ > trước khi bàn "app xây thế nào".
34
+ >
35
+ > **Problem it solves:**
36
+ > - "Nhảy thẳng vào code mà chưa ai mô tả rõ app có bao nhiêu màn hình"
37
+ > - "Port app từ iOS sang Android mà không ai document chi tiết app gốc"
38
+
39
+ ---
40
+
41
+ ## ⚠️ SCOPE CLARITY
42
+
43
+ | Skill này LÀM | Skill này KHÔNG làm |
44
+ |---------------|---------------------|
45
+ | Mô tả screens, user flows, business rules per module | Thiết kế DB/API (việc của spec-gate) |
46
+ | Tạo screen inventory cho toàn app | Viết code |
47
+ | Document validation rules & edge cases | Track tasks (việc của symphony-enforcer) |
48
+ | Scan existing codebase để auto-generate spec (port projects) | Brainstorm ý tưởng (việc của brainstorm-agent) |
49
+ | Yêu cầu user approve module spec | Deploy |
50
+
51
+ ---
52
+
53
+ ## 🚀 ACTIVATION
54
+
55
+ Skill này được kích hoạt bởi:
56
+ 1. **Orchestrator auto-trigger:** Khi Gate 1.5 check FAIL (không tìm thấy module specs)
57
+ 2. **Explicit command:** `/module-spec` hoặc `/product-spec`
58
+ 3. **Keyword trigger:** "module spec", "mô tả module", "screen inventory"
59
+
60
+ ### Khi nào Gate 1.5 MANDATORY:
61
+
62
+ ```yaml
63
+ mandatory_when:
64
+ - complexity: COMPLEX (score ≥6)
65
+ - project_type: port/migration (iOS→Android, Android→iOS)
66
+ - module_count: >3 modules in BRIEF.md
67
+ - explicit_request: user asks for module documentation
68
+
69
+ skip_when:
70
+ - complexity: TRIVIAL or MODERATE
71
+ - module_count: ≤3 AND not port/migration
72
+ - user_override: "skip spec" or "bỏ qua spec"
73
+ - kiro_specs: .kiro/specs/ chứa ≥2 module folders với requirements.md
74
+ → AUTO-SKIP: "Kiro module specs detected. Gate 1.5 AUTO-PASS."
75
+ → Load .kiro/specs/<module>/requirements.md làm module specs
76
+ → Chuyển thẳng Gate 2
77
+ ```
78
+
79
+ ---
80
+
81
+ ## 📋 INPUT REQUIREMENTS
82
+
83
+ ```
84
+ REQUIRED:
85
+ → BRIEF.md hoặc docs/specs/<feature>.md (output từ Gate 1)
86
+ HOẶC existing codebase (cho port/migration projects)
87
+ → .project-identity (projectId, techStack)
88
+
89
+ OPTIONAL:
90
+ → CODEBASE.md (project structure overview)
91
+ → KnowledgeItems (existing module documentation)
92
+ → NeuralMemory context (previous decisions)
93
+ → Source codebase (for port/migration — iOS/Android source files)
94
+ ```
95
+
96
+ ---
97
+
98
+ ## 🔄 PROCESS
99
+
100
+ ### Phase 1: Module Discovery
101
+
102
+ ```
103
+ INPUT SOURCE DETECTION (theo thứ tự ưu tiên):
104
+
105
+ 🔍 KIRO CHECK (HIGHEST PRIORITY):
106
+ A0) Scan .kiro/specs/ folder:
107
+ - Nếu tồn tại ≥2 module folders (mỗi folder có requirements.md):
108
+ → AUTO-PASS Gate 1.5
109
+ → Load từng .kiro/specs/<module>/requirements.md làm module spec
110
+ → Thông báo:
111
+ "🔍 Phát hiện .kiro/specs/ với [N] module specs từ IDE Kiro.
112
+ Modules: [list module names]
113
+ Gate 1.5 AUTO-PASS. Chuyển thẳng Gate 2 (Architecture)."
114
+ → SKIP Phase 2-6, không cần user approve (Kiro đã chốt)
115
+ → Lưu vào NeuralMemory: "Kiro module specs loaded: <list>"
116
+ - Nếu không có → tiếp tục các check bình thường bên dưới
117
+
118
+ FALLBACK SOURCES:
119
+ A) Có BRIEF.md → Extract module list từ "TÍNH NĂNG" section
120
+ B) Có existing codebase (port project) → Scan source code structure:
121
+ - iOS: Xcode project groups, Views/, Features/ folders
122
+ - Android: feature/ packages, activities, fragments
123
+ - Đọc CODEBASE.md nếu có
124
+ C) Cả hai → Cross-reference BRIEF với source code
125
+
126
+ OUTPUT: Danh sách modules cần spec:
127
+ Module 1: [name] — [1-line description]
128
+ Module 2: [name] — [1-line description]
129
+ ...
130
+
131
+ PRESENT cho user:
132
+ "📋 Em tìm thấy [N] modules cần document:
133
+ 1. [Module A] — [description]
134
+ 2. [Module B] — [description]
135
+ ...
136
+ Anh xem có đúng/đủ không? Bổ sung/bỏ bớt cứ nói nhé."
137
+ ```
138
+
139
+ ### Phase 2: Per-Module Spec Generation
140
+
141
+ Cho MỖI module, tạo spec theo template chuẩn:
142
+
143
+ ```
144
+ Quy trình:
145
+ 1. Gather context:
146
+ - BRIEF.md → extract relevant features
147
+ - Source code (nếu port) → scan screens, ViewModels, models
148
+ - KnowledgeItems → extract existing documentation
149
+ - NeuralMemory → previous decisions
150
+
151
+ 2. Generate spec draft using template (see TEMPLATE section)
152
+
153
+ 3. Self-review checklist (per module):
154
+ - [ ] Tất cả screens đã liệt kê?
155
+ - [ ] Happy path flow rõ ràng?
156
+ - [ ] Error/edge cases đã cover?
157
+ - [ ] Business rules explicit (không implicit)?
158
+ - [ ] Data contracts rõ input/output?
159
+ - [ ] Acceptance criteria testable?
160
+ ```
161
+
162
+ ### Phase 3: Cross-Module Consistency Check
163
+
164
+ ```
165
+ Sau khi TẤT CẢ module specs xong:
166
+
167
+ 1. Dependency graph:
168
+ - Module A depends on Module B? Đã ghi trong cả 2 specs?
169
+ - Circular dependency? → Cảnh báo
170
+
171
+ 2. Shared concepts:
172
+ - User model xuất hiện ở nhiều modules? → Consistent fields?
173
+ - Navigation flow giữa modules logic?
174
+
175
+ 3. Coverage check:
176
+ - Mọi feature trong BRIEF.md đã có module spec?
177
+ - Mọi screen trong source code (port) đã có trong inventory?
178
+ ```
179
+
180
+ ### Phase 4: Multi-Role Review (AI Simulated)
181
+
182
+ ```
183
+ Trước khi gửi bản thảo cho user, AI BẮT BUỘC đóng vai 6 vai trò sau để review chéo:
184
+ 1. Tech Lead: Tính khả thi kỹ thuật? Có edge cases nào chưa cover?
185
+ 2. PM: Có phục vụ đúng mục tiêu kinh doanh? Scope creep?
186
+ 3. UX Designer: Flow có mượt không? Quá nhiều bước? Có nghĩ đến empty states/error states?
187
+ 4. QA Engineer: Acceptance Criteria đã test được chưa (SMART)? Có đủ rõ ràng?
188
+ 5. Security/Privacy: Có rò rỉ PII? Có checklist GDPR chưa (riêng đối với data y tế)?
189
+ 6. DevOps: Có cản trở CI/CD hoặc scaling không?
190
+ ```
191
+
192
+ ### Phase 5: Present & Approval
193
+
194
+ ```
195
+ Present cho user với format:
196
+
197
+ ────────────────────────────────────
198
+ 📋 MODULE SPECIFICATIONS: <Project Name>
199
+ ────────────────────────────────────
200
+
201
+ Đã tạo [N] module specs:
202
+
203
+ | # | Module | Screens | Flows | Status |
204
+ |---|--------|---------|-------|--------|
205
+ | 1 | [name] | [count] | [count] | Draft |
206
+ | 2 | [name] | [count] | [count] | Draft |
207
+
208
+ ## Cross-Module Notes
209
+ - [Note 1: shared concern]
210
+ - [Note 2: dependency]
211
+
212
+ ────────────────────────────────────
213
+ ⏳ Anh review từng file spec nhé. Sửa gì cứ nói.
214
+ Chốt hết thì mình chuyển sang thiết kế kỹ thuật (Gate 2).
215
+ ────────────────────────────────────
216
+ ```
217
+
218
+ ### Phase 6: Write & Store
219
+
220
+ Sau khi user approve:
221
+
222
+ ```
223
+ 1. Tạo folder: docs/specs/modules/ (nếu chưa có)
224
+
225
+ 2. Write files:
226
+ docs/specs/modules/<module-name>_spec.md (cho mỗi module)
227
+ docs/specs/modules/MODULE_INDEX.md (index file)
228
+
229
+ 3. Thêm approval marker cho mỗi file:
230
+ ## Status: Approved
231
+ **Approved by:** User
232
+ **Approved at:** <ISO date>
233
+
234
+ 4. Lưu vào NeuralMemory:
235
+ nmem_remember(
236
+ content="Module specs approved for <project>. Modules: <list>. Total screens: <N>",
237
+ type="decision",
238
+ tags=["module-spec", "<projectId>"]
239
+ )
240
+
241
+ 5. Proceed → orchestrator re-checks Gate 1.5 → PASS → Gate 2
242
+ ```
243
+
244
+ ---
245
+
246
+ ## 📝 MODULE SPEC TEMPLATE
247
+
248
+ ```markdown
249
+ # 📋 Module Spec: [Module Name]
250
+
251
+ **Project:** [project-name]
252
+ **Version:** 1.0
253
+ **Created:** [date]
254
+ **Status:** Draft | Approved
255
+
256
+ ---
257
+
258
+ ## Overview
259
+ [1-2 câu mô tả mục đích module này trong app]
260
+
261
+ ## Dependencies
262
+ - **Depends on:** [list modules this depends on]
263
+ - **Used by:** [list modules that depend on this]
264
+ - **Shared services:** [auth, analytics, etc.]
265
+
266
+ ---
267
+
268
+ ## Screen Inventory
269
+
270
+ | # | Screen Name | Type | Key Elements | Notes |
271
+ |---|------------|------|--------------|-------|
272
+ | 1 | [name] | [full/modal/sheet/overlay/tab] | [main UI components] | [optional] |
273
+
274
+ ---
275
+
276
+ ## User Flows
277
+
278
+ ### Flow 1: [Happy Path Name]
279
+ **Entry:** [how user gets here]
280
+ **Steps:**
281
+ 1. User [action] → Screen [A]
282
+ 2. User [action] → System [response]
283
+ 3. System [shows/navigates] → Screen [B]
284
+ 4. **End state:** [what user sees/has achieved]
285
+
286
+ ### Flow 2: [Alternative Path / Error Path]
287
+ **Trigger:** [what causes this path]
288
+ **Steps:**
289
+ 1. ...
290
+
291
+ ---
292
+
293
+ ## Business Rules
294
+
295
+ | ID | Rule | Details |
296
+ |----|------|---------|
297
+ | BR-01 | [rule name] | [full description] |
298
+ | BR-02 | [rule name] | [full description] |
299
+
300
+ ---
301
+
302
+ ## Validation Rules
303
+
304
+ | Field | Condition | Error Message | Screen |
305
+ |-------|-----------|---------------|--------|
306
+ | [field] | [rule] | [message] | [where] |
307
+
308
+ ---
309
+
310
+ ## Data Contracts
311
+
312
+ ### Input (consumed by this module)
313
+ | Data | Type | Source | Required |
314
+ |------|------|--------|----------|
315
+ | [name] | [type] | [module/API/local] | [yes/no] |
316
+
317
+ ### Output (produced by this module)
318
+ | Data | Type | Destination | Trigger |
319
+ |------|------|-------------|---------|
320
+ | [name] | [type] | [module/API/local] | [when] |
321
+
322
+ ---
323
+
324
+ ## Edge Cases & Error States
325
+
326
+ | ID | Scenario | Expected Behavior |
327
+ |----|----------|-------------------|
328
+ | EC-01 | [scenario] | [what should happen] |
329
+ | EC-02 | [scenario] | [what should happen] |
330
+
331
+ ---
332
+
333
+ ## Acceptance Criteria
334
+ - [ ] [measurable criterion 1]
335
+ - [ ] [measurable criterion 2]
336
+ - [ ] [measurable criterion 3]
337
+ ```
338
+
339
+ ---
340
+
341
+ ## 📄 MODULE INDEX TEMPLATE
342
+
343
+ ```markdown
344
+ # 📚 Module Index: [Project Name]
345
+
346
+ **Total modules:** [N]
347
+ **Created:** [date]
348
+ **Status:** [All Approved / Some Draft]
349
+
350
+ | # | Module | Spec File | Screens | Status |
351
+ |---|--------|-----------|---------|--------|
352
+ | 1 | [name] | [link to spec file] | [count] | Approved |
353
+ | 2 | [name] | [link to spec file] | [count] | Draft |
354
+
355
+ ## Dependency Graph
356
+ [Module A] → [Module B] → [Module C]
357
+ [Module D] → [Module B]
358
+
359
+ ## Shared Services
360
+ - **Auth:** Used by [modules]
361
+ - **Analytics:** Used by [modules]
362
+ - **AI/ML:** Used by [modules]
363
+ ```
364
+
365
+ ---
366
+
367
+ ## 🔄 PORT/MIGRATION MODE
368
+
369
+ Khi project là port/migration (iOS→Android, Android→iOS):
370
+
371
+ ```
372
+ SPECIAL BEHAVIOR:
373
+
374
+ 🔍 KIRO-FIRST CHECK (luôn chạy trước):
375
+ 0. Scan .kiro/specs/ → nếu có module folders với requirements.md:
376
+ → Dùng Kiro specs làm source of truth
377
+ → SKIP source code scanning (Kiro đã tổng hợp)
378
+ → Cross-reference với source code CHỈ để verify completeness
379
+
380
+ FALLBACK (khi không có .kiro/specs):
381
+ 1. Scan source codebase TRƯỚC → auto-detect modules
382
+ 2. Đọc existing KnowledgeItems cho source project
383
+ 3. Cross-reference với BRIEF.md để catch missing modules
384
+ 4. Generate specs từ source code structure + knowledge
385
+
386
+ AUTO-DETECTION SOURCES:
387
+ iOS:
388
+ → Xcode project navigator groups
389
+ → Features/ or Presentation/Views/ folders
390
+ → NavigationStack/TabView structure
391
+ → Existing CODEBASE.md
392
+
393
+ Android:
394
+ → feature/ packages
395
+ → Navigation graph (nav_graph.xml)
396
+ → Activity/Fragment inventory
397
+ → Existing CODEBASE.md
398
+
399
+ Kiro:
400
+ → .kiro/specs/<module>/requirements.md (pre-generated)
401
+ → .kiro/specs/<module>/design.md (pre-generated)
402
+ → .kiro/specs/<module>/tasks.md (pre-generated)
403
+
404
+ OUTPUT: Pre-filled module specs with data from source code OR Kiro specs
405
+ → User chỉ cần review + approve, không cần viết từ đầu
406
+ ```
407
+
408
+ ---
409
+
410
+ ## 🗣️ Communication Style
411
+
412
+ ```
413
+ ❌ "Module specification documents are required before proceeding."
414
+ ✅ "Trước khi bắt tay vào thiết kế kỹ thuật, để em mô tả chi tiết
415
+ từng module — screens nào, flow ra sao — để anh em hiểu rõ cùng nhau."
416
+
417
+ ❌ "Please review 8 specification documents."
418
+ ✅ "Em đã viết xong spec cho 8 modules. Anh xem từng cái nhé,
419
+ sửa gì cứ nói, chốt hết rồi mình chuyển sang thiết kế DB/API."
420
+ ```
421
+
422
+ ---
423
+
424
+ ## 🚫 Anti-Patterns
425
+
426
+ ```yaml
427
+ never_do:
428
+ - Tự approve module specs (user PHẢI approve)
429
+ - Viết spec quá vắn tắt (< 5 screens → cảnh báo "có thiếu screen không?")
430
+ - Skip cross-module consistency check
431
+ - Trộn lẫn product spec với technical spec (DB/API)
432
+ - Bắt đầu Gate 2 khi còn module spec ở status "Draft"
433
+ - Force Gate 1.5 cho TRIVIAL tasks
434
+
435
+ always_do:
436
+ - Show module list cho user confirm TRƯỚC khi viết spec
437
+ - Chạy cross-module consistency check SAU khi viết hết
438
+ - Ghi acceptance criteria testable (SMART)
439
+ - Scan source code khi port/migration project
440
+ - Tag specs vào NeuralMemory
441
+ ```
442
+
443
+ ---
444
+
445
+ ## 🧩 Skill Relationships
446
+
447
+ ```
448
+ TRIGGERED BY: orchestrator (Gate 1.5 check fail)
449
+ DEPENDS ON: brainstorm-agent output (Gate 1 must pass first)
450
+ FEEDS INTO: spec-gate (Gate 2 reads module specs to design DB/API)
451
+ WORKS WITH:
452
+ - nm-memory-sync (store module decisions)
453
+ - gitnexus-intelligence (scan source codebase structure)
454
+ - KnowledgeItems (read existing project documentation)
455
+ ```
456
+
457
+ ---
458
+
459
+ *module-spec-writer v1.1 — Product Specification Gate for AWKit (Kiro Spec Integration)*