ai-developer-skill-os 7.5.0 → 7.5.1

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 (204) hide show
  1. package/.agents/CHANGELOG.md +2 -1
  2. package/.agents/README.md +51 -10
  3. package/.agents/docs/CHI_TIET_SKILLS.md +2 -1
  4. package/.agents/skills/qk-orchestrator/SKILL.md +3 -2
  5. package/.agents/skills/qk-orchestrator/references/routing-table.md +3 -2
  6. package/.agents/skills/qk-project-bootstrap/SKILL.md +2 -1
  7. package/.agents/skills/qk-project-memory/SKILL.md +46 -0
  8. package/.agents/skills/qk-ui-audit/SKILL.md +3 -2
  9. package/.agents/skills/qk-ui-builder/SKILL.md +446 -0
  10. package/.agents/skills/qk-ui-builder/references/anti-patterns.md +295 -0
  11. package/.agents/skills/qk-ui-builder/references/color.md +115 -0
  12. package/.agents/skills/qk-ui-builder/references/component-cookbook.md +1194 -0
  13. package/.agents/skills/qk-ui-builder/references/copy.md +250 -0
  14. package/.agents/skills/qk-ui-builder/references/interaction-and-states.md +115 -0
  15. package/.agents/skills/qk-ui-builder/references/layout-and-space.md +111 -0
  16. package/.agents/skills/qk-ui-builder/references/macrostructures/01-bento-grid.md +48 -0
  17. package/.agents/skills/qk-ui-builder/references/macrostructures/02-long-document.md +50 -0
  18. package/.agents/skills/qk-ui-builder/references/macrostructures/03-marquee-hero.md +51 -0
  19. package/.agents/skills/qk-ui-builder/references/macrostructures/04-stat-led.md +49 -0
  20. package/.agents/skills/qk-ui-builder/references/macrostructures/05-workbench.md +44 -0
  21. package/.agents/skills/qk-ui-builder/references/macrostructures/06-conversational-faq.md +50 -0
  22. package/.agents/skills/qk-ui-builder/references/macrostructures/07-manifesto.md +51 -0
  23. package/.agents/skills/qk-ui-builder/references/macrostructures/08-photographic.md +50 -0
  24. package/.agents/skills/qk-ui-builder/references/macrostructures/09-quote-led.md +50 -0
  25. package/.agents/skills/qk-ui-builder/references/macrostructures/11-catalogue.md +49 -0
  26. package/.agents/skills/qk-ui-builder/references/macrostructures/12-letter.md +49 -0
  27. package/.agents/skills/qk-ui-builder/references/macrostructures/13-index-first.md +49 -0
  28. package/.agents/skills/qk-ui-builder/references/macrostructures/14-narrative-workflow.md +48 -0
  29. package/.agents/skills/qk-ui-builder/references/macrostructures/15-split-studio.md +48 -0
  30. package/.agents/skills/qk-ui-builder/references/macrostructures/16-feature-stack.md +51 -0
  31. package/.agents/skills/qk-ui-builder/references/macrostructures/17-type-specimen.md +48 -0
  32. package/.agents/skills/qk-ui-builder/references/macrostructures/18-portfolio-grid.md +48 -0
  33. package/.agents/skills/qk-ui-builder/references/macrostructures/19-map-diagram.md +50 -0
  34. package/.agents/skills/qk-ui-builder/references/macrostructures/20-ecosystem-index.md +48 -0
  35. package/.agents/skills/qk-ui-builder/references/macrostructures/21-component-playground.md +45 -0
  36. package/.agents/skills/qk-ui-builder/references/macrostructures.md +38 -0
  37. package/.agents/skills/qk-ui-builder/references/motion.md +95 -0
  38. package/.agents/skills/qk-ui-builder/references/responsive.md +115 -0
  39. package/.agents/skills/qk-ui-builder/references/slop-test.md +135 -0
  40. package/.agents/skills/qk-ui-builder/references/structure.md +280 -0
  41. package/.agents/skills/qk-ui-builder/references/themes/atmospheric.md +53 -0
  42. package/.agents/skills/qk-ui-builder/references/themes/carnival.md +52 -0
  43. package/.agents/skills/qk-ui-builder/references/themes/cobalt.md +52 -0
  44. package/.agents/skills/qk-ui-builder/references/themes/editorial.md +52 -0
  45. package/.agents/skills/qk-ui-builder/references/themes/garden.md +52 -0
  46. package/.agents/skills/qk-ui-builder/references/themes/hum.md +52 -0
  47. package/.agents/skills/qk-ui-builder/references/themes/lumen.md +52 -0
  48. package/.agents/skills/qk-ui-builder/references/themes/midnight.md +52 -0
  49. package/.agents/skills/qk-ui-builder/references/themes/modern-minimal.md +52 -0
  50. package/.agents/skills/qk-ui-builder/references/themes/playful.md +52 -0
  51. package/.agents/skills/qk-ui-builder/references/themes/specimen.md +52 -0
  52. package/.agents/skills/qk-ui-builder/references/themes/terminal.md +52 -0
  53. package/.agents/skills/qk-ui-builder/references/typography.md +129 -0
  54. package/.agents/skills.json +4 -4
  55. package/CHANGELOG.md +2 -1
  56. package/README.md +36 -16
  57. package/bin/lint.js +3 -2
  58. package/docs/CHI_TIET_SKILLS.md +2 -1
  59. package/framework/decision-primitives.md +2 -1
  60. package/package.json +2 -2
  61. package/skills/_template/SKILL.md +2 -1
  62. package/skills/qk-access-policy/SKILL.md +3 -2
  63. package/skills/qk-ai-builder/SKILL.md +3 -2
  64. package/skills/qk-api-lifecycle/SKILL.md +3 -2
  65. package/skills/qk-bug-resolution/SKILL.md +3 -2
  66. package/skills/qk-context-loader/SKILL.md +13 -12
  67. package/skills/qk-data-lifecycle/SKILL.md +3 -2
  68. package/skills/qk-db-optimizer/SKILL.md +3 -2
  69. package/skills/qk-docs/SKILL.md +3 -2
  70. package/skills/qk-engineering-standard/SKILL.md +19 -18
  71. package/skills/qk-fe-api-integration/SKILL.md +3 -2
  72. package/skills/qk-feature-delivery/SKILL.md +3 -2
  73. package/skills/qk-help/SKILL.md +3 -2
  74. package/skills/qk-orchestrator/SKILL.md +18 -16
  75. package/skills/qk-orchestrator/references/routing-table.md +3 -2
  76. package/skills/qk-production-release/SKILL.md +15 -14
  77. package/skills/qk-project-bootstrap/SKILL.md +5 -3
  78. package/skills/qk-project-health/SKILL.md +3 -2
  79. package/skills/qk-project-memory/SKILL.md +49 -2
  80. package/skills/qk-system-evolution/SKILL.md +16 -15
  81. package/skills/qk-ui-audit/SKILL.md +21 -19
  82. package/skills/qk-ui-builder/SKILL.md +447 -0
  83. package/skills/qk-ui-builder/references/anti-patterns.md +295 -0
  84. package/skills/qk-ui-builder/references/color.md +115 -0
  85. package/skills/qk-ui-builder/references/component-cookbook.md +1194 -0
  86. package/skills/qk-ui-builder/references/copy.md +250 -0
  87. package/skills/qk-ui-builder/references/interaction-and-states.md +115 -0
  88. package/skills/qk-ui-builder/references/layout-and-space.md +111 -0
  89. package/skills/qk-ui-builder/references/macrostructures/01-bento-grid.md +48 -0
  90. package/skills/qk-ui-builder/references/macrostructures/02-long-document.md +50 -0
  91. package/skills/qk-ui-builder/references/macrostructures/03-marquee-hero.md +51 -0
  92. package/skills/qk-ui-builder/references/macrostructures/04-stat-led.md +49 -0
  93. package/skills/qk-ui-builder/references/macrostructures/05-workbench.md +44 -0
  94. package/skills/qk-ui-builder/references/macrostructures/06-conversational-faq.md +50 -0
  95. package/skills/qk-ui-builder/references/macrostructures/07-manifesto.md +51 -0
  96. package/skills/qk-ui-builder/references/macrostructures/08-photographic.md +50 -0
  97. package/skills/qk-ui-builder/references/macrostructures/09-quote-led.md +50 -0
  98. package/skills/qk-ui-builder/references/macrostructures/11-catalogue.md +49 -0
  99. package/skills/qk-ui-builder/references/macrostructures/12-letter.md +49 -0
  100. package/skills/qk-ui-builder/references/macrostructures/13-index-first.md +49 -0
  101. package/skills/qk-ui-builder/references/macrostructures/14-narrative-workflow.md +48 -0
  102. package/skills/qk-ui-builder/references/macrostructures/15-split-studio.md +48 -0
  103. package/skills/qk-ui-builder/references/macrostructures/16-feature-stack.md +51 -0
  104. package/skills/qk-ui-builder/references/macrostructures/17-type-specimen.md +48 -0
  105. package/skills/qk-ui-builder/references/macrostructures/18-portfolio-grid.md +48 -0
  106. package/skills/qk-ui-builder/references/macrostructures/19-map-diagram.md +50 -0
  107. package/skills/qk-ui-builder/references/macrostructures/20-ecosystem-index.md +48 -0
  108. package/skills/qk-ui-builder/references/macrostructures/21-component-playground.md +45 -0
  109. package/skills/qk-ui-builder/references/macrostructures.md +38 -0
  110. package/skills/qk-ui-builder/references/motion.md +95 -0
  111. package/skills/qk-ui-builder/references/responsive.md +115 -0
  112. package/skills/qk-ui-builder/references/slop-test.md +135 -0
  113. package/skills/qk-ui-builder/references/structure.md +280 -0
  114. package/skills/qk-ui-builder/references/themes/atmospheric.md +53 -0
  115. package/skills/qk-ui-builder/references/themes/carnival.md +52 -0
  116. package/skills/qk-ui-builder/references/themes/cobalt.md +52 -0
  117. package/skills/qk-ui-builder/references/themes/editorial.md +52 -0
  118. package/skills/qk-ui-builder/references/themes/garden.md +52 -0
  119. package/skills/qk-ui-builder/references/themes/hum.md +52 -0
  120. package/skills/qk-ui-builder/references/themes/lumen.md +52 -0
  121. package/skills/qk-ui-builder/references/themes/midnight.md +52 -0
  122. package/skills/qk-ui-builder/references/themes/modern-minimal.md +52 -0
  123. package/skills/qk-ui-builder/references/themes/playful.md +52 -0
  124. package/skills/qk-ui-builder/references/themes/specimen.md +52 -0
  125. package/skills/qk-ui-builder/references/themes/terminal.md +52 -0
  126. package/skills/qk-ui-builder/references/typography.md +129 -0
  127. package/skills/qk-ui-system-builder/SKILL.md +3 -2
  128. package/skills/qk-validation-gate/SKILL.md +18 -17
  129. package/skills.json +28 -27
  130. package/.agents/_template/BEHAVIOR_SPEC.md +0 -96
  131. package/.agents/_template/examples/example-en.md +0 -49
  132. package/.agents/_template/examples/example-vi.md +0 -49
  133. package/.agents/skills/qk-design-to-code/SKILL.md +0 -285
  134. package/.qk-ai-skill-os/CHANGELOG.md +0 -69
  135. package/.qk-ai-skill-os/LICENSE +0 -21
  136. package/.qk-ai-skill-os/README.md +0 -59
  137. package/.qk-ai-skill-os/_template/BEHAVIOR_SPEC.md +0 -96
  138. package/.qk-ai-skill-os/_template/examples/example-en.md +0 -49
  139. package/.qk-ai-skill-os/_template/examples/example-vi.md +0 -49
  140. package/.qk-ai-skill-os/docs/CHI_TIET_SKILLS.md +0 -125
  141. package/.qk-ai-skill-os/docs/GOVERNANCE.md +0 -40
  142. package/.qk-ai-skill-os/docs/HUONG_DAN_SU_DUNG.md +0 -120
  143. package/.qk-ai-skill-os/docs/SPEC.md +0 -87
  144. package/.qk-ai-skill-os/docs/adr/0001-intent-based-architecture.md +0 -19
  145. package/.qk-ai-skill-os/docs/adr/0002-kernel-freeze.md +0 -21
  146. package/.qk-ai-skill-os/docs/adr/0003-risk-based-verification.md +0 -20
  147. package/.qk-ai-skill-os/docs/adr/0004-progressive-evidence.md +0 -19
  148. package/.qk-ai-skill-os/docs/skill-classification.md +0 -25
  149. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-accessibility-audit/SKILL.md +0 -121
  150. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-agent-orchestrator/SKILL.md +0 -179
  151. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-api-integration/SKILL.md +0 -389
  152. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-auth-security/SKILL.md +0 -96
  153. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-backend-architecture/SKILL.md +0 -125
  154. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-bug-fix/SKILL.md +0 -213
  155. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-component-generator/SKILL.md +0 -136
  156. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-context-manager/SKILL.md +0 -175
  157. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-database-engineer/SKILL.md +0 -104
  158. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-deployment/SKILL.md +0 -96
  159. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-design-system/SKILL.md +0 -137
  160. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-form-builder/SKILL.md +0 -140
  161. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-frontend-architecture/SKILL.md +0 -155
  162. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-frontend-debug/SKILL.md +0 -133
  163. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-frontend-performance/SKILL.md +0 -129
  164. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-frontend-testing/SKILL.md +0 -146
  165. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-git-engineer/SKILL.md +0 -304
  166. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-help/SKILL.md +0 -68
  167. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-migration/SKILL.md +0 -284
  168. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-project-audit/SKILL.md +0 -280
  169. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-refactor/SKILL.md +0 -222
  170. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-state-management/SKILL.md +0 -140
  171. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-table-crud-generator/SKILL.md +0 -127
  172. package/.qk-ai-skill-os/skills/_archive_old_skills/qk-ui-builder/SKILL.md +0 -152
  173. package/.qk-ai-skill-os/skills/_template/SKILL.md +0 -238
  174. package/.qk-ai-skill-os/skills/qk-access-policy/SKILL.md +0 -179
  175. package/.qk-ai-skill-os/skills/qk-ai-builder/SKILL.md +0 -221
  176. package/.qk-ai-skill-os/skills/qk-api-lifecycle/SKILL.md +0 -176
  177. package/.qk-ai-skill-os/skills/qk-bug-resolution/SKILL.md +0 -307
  178. package/.qk-ai-skill-os/skills/qk-context-loader/SKILL.md +0 -218
  179. package/.qk-ai-skill-os/skills/qk-data-lifecycle/SKILL.md +0 -192
  180. package/.qk-ai-skill-os/skills/qk-db-optimizer/SKILL.md +0 -196
  181. package/.qk-ai-skill-os/skills/qk-design-to-code/SKILL.md +0 -291
  182. package/.qk-ai-skill-os/skills/qk-docs/SKILL.md +0 -198
  183. package/.qk-ai-skill-os/skills/qk-engineering-standard/SKILL.md +0 -351
  184. package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/backend.md +0 -122
  185. package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/database.md +0 -3
  186. package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/frontend.md +0 -152
  187. package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/security.md +0 -3
  188. package/.qk-ai-skill-os/skills/qk-engineering-standard/rules/testing.md +0 -3
  189. package/.qk-ai-skill-os/skills/qk-fe-api-integration/SKILL.md +0 -326
  190. package/.qk-ai-skill-os/skills/qk-feature-delivery/SKILL.md +0 -305
  191. package/.qk-ai-skill-os/skills/qk-help/SKILL.md +0 -193
  192. package/.qk-ai-skill-os/skills/qk-orchestrator/SKILL.md +0 -277
  193. package/.qk-ai-skill-os/skills/qk-orchestrator/references/routing-table.md +0 -77
  194. package/.qk-ai-skill-os/skills/qk-production-release/SKILL.md +0 -290
  195. package/.qk-ai-skill-os/skills/qk-project-bootstrap/SKILL.md +0 -240
  196. package/.qk-ai-skill-os/skills/qk-project-health/SKILL.md +0 -199
  197. package/.qk-ai-skill-os/skills/qk-project-memory/SKILL.md +0 -172
  198. package/.qk-ai-skill-os/skills/qk-system-evolution/SKILL.md +0 -285
  199. package/.qk-ai-skill-os/skills/qk-ui-audit/SKILL.md +0 -314
  200. package/.qk-ai-skill-os/skills/qk-ui-audit/references/anti-slop-checklist.md +0 -136
  201. package/.qk-ai-skill-os/skills/qk-ui-system-builder/SKILL.md +0 -225
  202. package/.qk-ai-skill-os/skills/qk-validation-gate/SKILL.md +0 -361
  203. package/.qk-ai-skill-os/skills.json +0 -819
  204. package/skills/qk-design-to-code/SKILL.md +0 -285
@@ -0,0 +1,446 @@
1
+ ---
2
+ name: qk-ui-builder
3
+ category: frontend
4
+ version: 7.5.0
5
+ description: "Xây dựng, sửa, audit, và học UI — từ Figma/ảnh, map API, fix bug UI, đến redesign cấu trúc."
6
+ platforms: [antigravity, claude-code, cursor, windsurf, kilo-code]
7
+ execution_mode: deterministic
8
+
9
+ cost: high
10
+ latency: slow
11
+ risk: low
12
+ side_effects: edit_files
13
+ produces: [code, report]
14
+ consumes: [design-md, design-asset, source-code, api-schema]
15
+
16
+ token_budget:
17
+ max_files_read: 5
18
+ max_lines_per_read: 150
19
+ max_shell_commands: 0
20
+ stop_early: false
21
+
22
+ exit_codes: [SUCCESS, BLOCKED, FAILED, PARTIAL]
23
+ skill_version: 7.5.0
24
+ runtime_version: 1
25
+ schema_version: 2
26
+ ---
27
+
28
+ # qk-ui-builder — UI Builder & Auditor
29
+
30
+ > **Language rule:** Code, identifiers, file names → English. Explanations, summaries → Vietnamese.
31
+
32
+ ---
33
+
34
+ ## Verbs
35
+
36
+ | Verb | Trigger | Behavior |
37
+ |------|---------|----------|
38
+ | *(default)* | `./qk-ui-builder` | Build or edit UI from design reference |
39
+ | `--audit` | `./qk-ui-builder --audit` | Score UI against anti-slop checklist, no edits |
40
+ | `--redesign` | `./qk-ui-builder --redesign` | Rebuild structure, keep copy/IA/brand |
41
+ | `--study` | `./qk-ui-builder --study <screenshot\|URL>` | Extract design DNA → `design.md` |
42
+
43
+ ---
44
+
45
+ ## Preconditions
46
+ - [ ] `DESIGN.md` exists with color tokens, spacing scale, typography
47
+ - [ ] For default/edit: design reference or target component specified
48
+ - [ ] For `--audit`: target UI file(s) specified
49
+ - [ ] For `--redesign`: target page + brand/copy context provided
50
+ - [ ] For `--study`: screenshot file or public URL provided
51
+
52
+ ```
53
+ On missing precondition:
54
+ EXIT: BLOCKED
55
+ Message: "[Missing item]. See Escalation Rules."
56
+ ```
57
+
58
+ ---
59
+
60
+ ## Scope
61
+
62
+ ### Default verb
63
+ - ✅ Build new UI from Figma/ảnh/design reference
64
+ - ✅ Sửa text, thêm nội dung, map API key vào component
65
+ - ✅ Fix UI bug: padding, màu, hiển thị, responsive
66
+ - ✅ Generate strict UI từ DESIGN.md tokens
67
+
68
+ ### `--audit`
69
+ - ✅ Score UI against anti-slop checklist (58 gates)
70
+ - ✅ Detect generic AI aesthetics, hardcoded values
71
+ - ✅ Verify ARIA, contrast, responsive states
72
+
73
+ ### `--redesign`
74
+ - ✅ Thay đổi cấu trúc page, giữ nội dung/IA/brand
75
+ - ✅ Pick new macrostructure + theme fingerprint
76
+
77
+ ### `--study`
78
+ - ✅ Extract design DNA từ ảnh/Figma/URL
79
+ - ✅ Emit portable `design.md` for handoff
80
+
81
+ ## Non-Goals
82
+ - ❌ Invent design tokens not in DESIGN.md
83
+ - ❌ Use hardcoded hex colors, px sizes not from token system
84
+ - ❌ Copy generic Tailwind/Bootstrap templates
85
+ - ❌ Skip loading/error/empty states
86
+ - ❌ Clone paid templates or violate design copyright
87
+
88
+ ---
89
+
90
+ ## Priority Order
91
+
92
+ | Priority | Task | Skip Threshold |
93
+ |----------|------|----------------|
94
+ | P1 | HTML structure + semantic markup | Never |
95
+ | P2 | DESIGN.md token application (colors, spacing, typography) | Never |
96
+ | P3 | Interactive states (hover, focus, active) | Budget < 30% |
97
+ | P4 | Responsive breakpoints (mobile) | Budget < 50% |
98
+ | P5 | Loading / error / empty states | Budget < 60% |
99
+ | P6 | Animation / micro-interactions | Budget < 70% |
100
+ | P7 | ARIA roles + keyboard navigation | Budget < 80% |
101
+
102
+ ---
103
+
104
+ ## Workflow
105
+
106
+ ### Phase 1 — Route by Verb
107
+
108
+ **Decision:**
109
+ ```
110
+ IF --audit
111
+ → Load slop-test gates → go to Audit phase
112
+
113
+ ELSE IF --redesign
114
+ → Load macrostructure index → pick new fingerprint → go to Build phase
115
+
116
+ ELSE IF --study
117
+ → Load study protocol → extract DNA → emit design.md → EXIT: SUCCESS
118
+
119
+ ELSE (default: build/edit)
120
+ → go to Build phase
121
+ ```
122
+
123
+ ---
124
+
125
+ ### Phase 2 — Load Design Context (default/edit/redesign only)
126
+
127
+ **Load Discipline (MANDATORY):**
128
+
129
+ ```
130
+ EAGER (load every build):
131
+ - typography.md
132
+ - color.md
133
+ - layout-and-space.md
134
+ - copy.md
135
+ - anti-patterns.md
136
+
137
+ INDEX-THEN-PICK (load index, choose ONE):
138
+ - macrostructures.md → pick ONE → load only that file
139
+
140
+ CONDITIONAL (load only if needed):
141
+ - themes/[name].md → only if project has locked theme
142
+ - motion.md → only if animation requested
143
+ - interaction-and-states.md → only if complex interactions
144
+ - responsive.md → only if mobile breakpoints needed
145
+ - component-cookbook.md → only if building known archetype
146
+
147
+ LOAD-AT-END (post-emit only):
148
+ - slop-test.md → run AFTER build completes
149
+ ```
150
+
151
+ **Steps:**
152
+ 1. Read `DESIGN.md` → extract tokens: colors (HSL), spacing, fonts, radius, shadows
153
+ 2. Load eager references (typography, color, layout, copy, anti-patterns)
154
+ 3. Check `.agents/memory/ui-diversification.json` for last theme/macrostructure used
155
+ 4. If redesign: read `references/macrostructures.md` index → pick ONE different from last → load only that file
156
+ 5. If project has locked theme: load `references/themes/[name].md`
157
+
158
+ **Diversification rule:** consecutive builds must use different theme + macrostructure from `ui-diversification.json`.
159
+
160
+ ---
161
+
162
+ ### Phase 3 — Build or Edit
163
+
164
+ **Steps:**
165
+ 1. For new UI: create component from design reference using DESIGN.md tokens
166
+ 2. For edit: modify existing component per user request (text, API mapping, layout)
167
+ 3. Apply theme + macrostructure fingerprint
168
+ 4. Handle all 3 UI states: Loading, Success, Error
169
+
170
+ **API mapping rule:**
171
+ - Bind API response to component props via generated TypeScript interfaces
172
+ - NEVER hardcode API URLs in component
173
+ - Use existing API client pattern from project
174
+
175
+ ---
176
+
177
+ ### Phase 4 — Slop Test (post-emit)
178
+
179
+ Load `references/slop-test.md` and verify all 58 gates pass.
180
+
181
+ ```
182
+ IF all 58 gates pass
183
+ → EXIT: SUCCESS
184
+
185
+ ELSE IF critical gate fails (hardcoded purple gradient, banned font)
186
+ → EXIT: FAILED — rebuild required
187
+ ```
188
+ 1. Read `references/macrostructures.md` (index only)
189
+ 2. Pick ONE macrostructure different from last build
190
+ 3. Load only that macrostructure file from `references/macrostructures/`
191
+
192
+ ---
193
+
194
+ ### Phase 3 — Build or Edit
195
+
196
+ **Steps:**
197
+ 1. For new UI: create component from design reference using DESIGN.md tokens
198
+ 2. For edit: modify existing component per user request (text, API mapping, layout)
199
+ 3. Apply theme + macrostructure fingerprint
200
+ 4. Handle all 3 UI states: Loading, Success, Error
201
+
202
+ **API mapping rule:**
203
+ - Bind API response to component props via generated TypeScript interfaces
204
+ - NEVER hardcode API URLs in component
205
+ - Use existing API client pattern from project
206
+
207
+ ---
208
+
209
+ ### Phase 4 — Self-Audit (Anti-Slop Check)
210
+
211
+ **Checklist (must pass ALL):**
212
+ - [ ] No hardcoded colors — only DESIGN.md tokens
213
+ - [ ] No font-size in px without token — use rem/token
214
+ - [ ] No `margin: auto` soup — use proper grid/flex
215
+ - [ ] All interactive elements have hover + focus state
216
+ - [ ] Mobile viewport works (no horizontal overflow)
217
+ - [ ] No `!important` overrides (except resets)
218
+ - [ ] No inline styles except dynamic values
219
+ - [ ] Loading state implemented (skeleton or spinner)
220
+ - [ ] Error state implemented (clear message)
221
+ - [ ] Empty state implemented (helpful illustration/text)
222
+
223
+ **Decision:**
224
+ ```
225
+ IF all checks pass
226
+ → EXIT: SUCCESS
227
+
228
+ ELSE IF 1–2 minor fails
229
+ → Fix immediately, EXIT: SUCCESS
230
+
231
+ ELSE IF > 2 fails OR hardcoded colors found
232
+ → Fix all, re-audit, EXIT: PARTIAL if still one gap
233
+ ```
234
+
235
+ ---
236
+
237
+ ### Phase 5 — Slop Test (post-emit)
238
+
239
+ Load `references/slop-test.md` and verify all 58 gates pass.
240
+
241
+ ```
242
+ IF all 58 gates pass
243
+ → EXIT: SUCCESS
244
+
245
+ ELSE IF critical gate fails (hardcoded purple gradient, banned font)
246
+ → EXIT: FAILED — rebuild required
247
+ ```
248
+
249
+ ---
250
+
251
+ ## Confidence Model
252
+
253
+ | Level | Condition | Action |
254
+ |-------|-----------|--------|
255
+ | HIGH | DESIGN.md complete, design reference clear, API schema provided | Build directly |
256
+ | MEDIUM | Some tokens missing or design reference ambiguous | Note gaps, proceed |
257
+ | LOW | DESIGN.md missing or design reference too vague | EXIT: BLOCKED |
258
+
259
+ ---
260
+
261
+ ## Severity
262
+
263
+ | Level | Definition | Example |
264
+ |-------|-----------|---------|
265
+ | CRITICAL | Hardcoded API URL in component, banned font used | `axios.get("http://localhost")` in JSX |
266
+ | HIGH | Missing error/loading state, hardcoded color not in DESIGN.md | No 500 handler |
267
+ | MEDIUM | Missing hover state, spacing off by 1 unit | Button without focus ring |
268
+ | LOW | Comment missing, minor naming inconsistency | `temp` variable name |
269
+
270
+ ---
271
+
272
+ ## Evidence Format
273
+
274
+ ```
275
+ [SEVERITY] path/to/Component.tsx:LINE
276
+ Category: [TOKEN|SEMANTIC|INTERACTION|RESPONSIVE|STATE|ARIA|SLOP]
277
+ Reason: [specific violation]
278
+ Confidence: HIGH
279
+ Fix: [one-line actionable suggestion]
280
+ Points: -N pts (for audit mode)
281
+ ```
282
+
283
+ ---
284
+
285
+ ## Retry Policy
286
+
287
+ ```
288
+ Build/Edit fails
289
+ └─ Check failure type
290
+ ├─ Token missing → infer from DESIGN.md, note assumption
291
+ └─ Design reference unclear → EXIT: BLOCKED, ask user
292
+
293
+ Slop test fails
294
+ └─ Critical gate (hardcoded color, banned font)
295
+ └─ EXIT: FAILED — do not ship, rebuild required
296
+ ```
297
+
298
+ ---
299
+
300
+ ## Escalation Rules
301
+
302
+ ```
303
+ BLOCKED: DESIGN.md missing or design reference unclear
304
+ Missing:
305
+ - DESIGN.md with color/spacing/typography tokens
306
+ - Design reference (Figma/ảnh/wireframe)
307
+ - For --study: screenshot or public URL
308
+ Questions:
309
+ 1. Bạn có DESIGN.md chưa? (chạy qk-project-bootstrap nếu chưa)
310
+ 2. Design reference là gì? (Figma link / ảnh / mô tả)
311
+ 3. Cho phép tạo DESIGN.md mới không?
312
+ Recommended Assumptions (if proceeding):
313
+ - Use industry-standard: 8px spacing, Inter font, neutral gray palette
314
+ ```
315
+
316
+ ---
317
+
318
+ ## Handoff Contract
319
+
320
+ ### Consumes
321
+ ```json
322
+ {
323
+ "from": "user or qk-orchestrator",
324
+ "required_fields": ["verb", "design_md_path"],
325
+ "optional_fields": ["design_reference", "target_component", "api_schema", "framework"]
326
+ }
327
+ ```
328
+
329
+ ### Produces
330
+ ```json
331
+ {
332
+ "to": "user or qk-ui-audit (if --audit)",
333
+ "output_fields": ["component_files", "tokens_used", "states_implemented", "slop_test_result", "exit_code"]
334
+ }
335
+ ```
336
+
337
+ ---
338
+
339
+ ## Output Format
340
+
341
+ ### Default (build/edit)
342
+ ```
343
+ 🎨 UI Builder
344
+ ─────────────────────────────────────────────────
345
+ Component: [ComponentName]
346
+ Theme: [theme name from references/themes/]
347
+ Macrostructure: [macrostructure name]
348
+
349
+ States implemented:
350
+ ✅ Loading / ✅ Success / ✅ Error
351
+ ✅ Hover / ✅ Focus / ✅ Active / ✅ Disabled
352
+
353
+ Tokens used:
354
+ - --color-primary-500, --space-4, --font-size-base
355
+
356
+ API Mapping:
357
+ ✅ [endpoint → prop] mapped
358
+
359
+ Exit Code: [SUCCESS | PARTIAL | BLOCKED | FAILED]
360
+ ```
361
+
362
+ ### `--audit`
363
+ ```
364
+ 🎨 UI Audit Report
365
+ ─────────────────────────────────────────────────
366
+ Component: [path/to/component]
367
+ Theme: [N/A — read-only audit]
368
+
369
+ Scores:
370
+ P1 Accessibility: [X/15]
371
+ P2 Layout: [X/15]
372
+ P3 Typography: [X/15]
373
+ P4 Interactions: [X/15]
374
+ P5 Anti-Slop: [X/15]
375
+ P6 Performance: [X/10]
376
+ ─────────────────
377
+ Total: [X/85] → [PASS ≥ 90% | FAIL < 90%]
378
+
379
+ Violations (top priority first):
380
+ [SEVERITY] file:LINE — reason — Fix: suggestion (-Xpts)
381
+
382
+ Verdict: [PASS | FAIL — requires redesign]
383
+ Exit Code: [SUCCESS | PARTIAL | FAILED]
384
+ ```
385
+
386
+ ### `--redesign`
387
+ ```
388
+ 🎨 UI Redesign
389
+ ─────────────────────────────────────────────────
390
+ Component: [ComponentName]
391
+ Old macrostructure: [old name]
392
+ New macrostructure: [new name]
393
+ Old theme: [old theme]
394
+ New theme: [new theme]
395
+
396
+ Kept:
397
+ - Copy/IA structure
398
+ - Brand colors
399
+ - Primary user flow
400
+
401
+ Changed:
402
+ - Layout fingerprint
403
+ - Section ordering
404
+ - Visual hierarchy
405
+
406
+ Exit Code: [SUCCESS | PARTIAL | BLOCKED | FAILED]
407
+ ```
408
+
409
+ ### `--study`
410
+ ```
411
+ 🎨 Design Study
412
+ ─────────────────────────────────────────────────
413
+ Source: [screenshot path | URL]
414
+ DNA extracted:
415
+ - Macrostructure: [name]
416
+ - Theme axes: [paper band / display style / accent hue]
417
+ - Type pairing: [font1 + font2]
418
+ - Color anchor: [primary / secondary / accent]
419
+
420
+ Output: design.md written to [path]
421
+ Next: ./qk-ui-builder --redesign with extracted DNA
422
+
423
+ Exit Code: [SUCCESS | BLOCKED]
424
+ ```
425
+
426
+ ---
427
+
428
+ ## Exit Codes
429
+
430
+ | Code | Meaning | When |
431
+ |------|---------|------|
432
+ | SUCCESS | Build/edit/audit/study completed successfully | All checks passed |
433
+ | PARTIAL | Built with minor gaps or incomplete audit | Budget exhausted or 1-2 fixes pending |
434
+ | BLOCKED | Missing DESIGN.md, design reference, or screenshot | Cannot proceed |
435
+ | FAILED | Slop test critical failure or architectural conflict | Rebuild required |
436
+
437
+ ---
438
+
439
+ ## References
440
+
441
+ - `references/themes/` — Theme catalog (20 themes)
442
+ - `references/macrostructures/` — 21 page shapes
443
+ - `references/slop-test.md` — 58 anti-slop gates
444
+ - `references/anti-patterns.md` — Named tells to avoid
445
+
446
+ ---