@qijenchen/design-system 0.1.0-beta.10 → 0.1.0-beta.13

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 (307) hide show
  1. package/CLAUDE.md +201 -0
  2. package/README.md +7 -15
  3. package/cli-init.mjs +90 -0
  4. package/ds-canonical/commands/README.md +26 -0
  5. package/ds-canonical/commands/gov-status.md +79 -0
  6. package/ds-canonical/hooks/README.md +145 -0
  7. package/ds-canonical/hooks/_log-fire.sh +44 -0
  8. package/ds-canonical/hooks/block_prototype_imports.py +111 -0
  9. package/ds-canonical/hooks/check_app_shell_primary_header_consistency.sh +68 -0
  10. package/ds-canonical/hooks/check_audit_post_report_validator.sh +88 -0
  11. package/ds-canonical/hooks/check_audit_sample_escape.sh +73 -0
  12. package/ds-canonical/hooks/check_benchmark_citation.sh +106 -0
  13. package/ds-canonical/hooks/check_canonical_propagation.sh +189 -0
  14. package/ds-canonical/hooks/check_chrome_header_handcraft.sh +70 -0
  15. package/ds-canonical/hooks/check_codex_brief_invariants.sh +83 -0
  16. package/ds-canonical/hooks/check_codex_collab_5step.sh +108 -0
  17. package/ds-canonical/hooks/check_datatable_invariants.sh +117 -0
  18. package/ds-canonical/hooks/check_dim_count_drift.sh +72 -0
  19. package/ds-canonical/hooks/check_field_controls_contracts.sh +110 -0
  20. package/ds-canonical/hooks/check_field_family_invariants.sh +205 -0
  21. package/ds-canonical/hooks/check_file_size_budget.sh +60 -0
  22. package/ds-canonical/hooks/check_header_with_tabs_border.sh +87 -0
  23. package/ds-canonical/hooks/check_main_branch_workbench.sh +93 -0
  24. package/ds-canonical/hooks/check_naming_and_abstraction.sh +165 -0
  25. package/ds-canonical/hooks/check_opacity_token_usage.sh +149 -0
  26. package/ds-canonical/hooks/check_pattern_invariants.sh +194 -0
  27. package/ds-canonical/hooks/check_peoplepicker_ssot_drift.sh +56 -0
  28. package/ds-canonical/hooks/check_pixel_quantified_audit.sh +53 -0
  29. package/ds-canonical/hooks/check_propose_plain_chinese.sh +74 -0
  30. package/ds-canonical/hooks/check_propose_pre_grep_verify.sh +70 -0
  31. package/ds-canonical/hooks/check_select_all_canonical.sh +58 -0
  32. package/ds-canonical/hooks/check_solo_workflow.sh +258 -0
  33. package/ds-canonical/hooks/check_spec_class_drift.sh +88 -0
  34. package/ds-canonical/hooks/check_story_invariants.sh +612 -0
  35. package/ds-canonical/hooks/check_substantive_edit_approval_preflight.sh +105 -0
  36. package/ds-canonical/hooks/check_tab_lg_chrome_header_equal.sh +66 -0
  37. package/ds-canonical/hooks/check_wrapper_primitive_schema_drift.sh +104 -0
  38. package/ds-canonical/hooks/enforce_home_charter.sh +44 -0
  39. package/ds-canonical/hooks/inject_pending_self_audit.sh +204 -0
  40. package/ds-canonical/hooks/lib/_approval_re.sh +33 -0
  41. package/ds-canonical/hooks/lib/_code_quality.sh +73 -0
  42. package/ds-canonical/hooks/lib/_cva_default_sync.sh +69 -0
  43. package/ds-canonical/hooks/lib/_governance_coverage_check.sh +49 -0
  44. package/ds-canonical/hooks/lib/_hardcoded_strings.sh +163 -0
  45. package/ds-canonical/hooks/lib/_layout_space_canonical.sh +56 -0
  46. package/ds-canonical/hooks/lib/_overlay_handcraft.sh +141 -0
  47. package/ds-canonical/hooks/lib/_person_data_richness.sh +42 -0
  48. package/ds-canonical/hooks/lib/_story_compile_drift.sh +48 -0
  49. package/ds-canonical/hooks/lib/_token_hygiene.sh +95 -0
  50. package/ds-canonical/hooks/log_governance_fires.sh +50 -0
  51. package/ds-canonical/hooks/log_skill_invokes.sh +41 -0
  52. package/ds-canonical/hooks/post_edit_dispatcher.sh +62 -0
  53. package/ds-canonical/hooks/retired/check_anatomy_section_numbering.sh +106 -0
  54. package/ds-canonical/hooks/retired/check_avatar_hovercard.sh +90 -0
  55. package/ds-canonical/hooks/retired/check_button_icon_literal.sh.retired-2026-04-28 +38 -0
  56. package/ds-canonical/hooks/retired/check_container_breathing.sh +142 -0
  57. package/ds-canonical/hooks/retired/check_governance_compliance.sh +61 -0
  58. package/ds-canonical/hooks/retired/check_icon_only_padding_formula.sh +104 -0
  59. package/ds-canonical/hooks/retired/check_item_content_primitive.sh +150 -0
  60. package/ds-canonical/hooks/retired/check_item_list_gap.sh +153 -0
  61. package/ds-canonical/hooks/retired/check_sideoffset_canonical.sh +65 -0
  62. package/ds-canonical/hooks/retired/check_spec_iteration_tag.sh +87 -0
  63. package/ds-canonical/hooks/retired/check_ssot_consultation.sh +88 -0
  64. package/ds-canonical/hooks/retired/check_sync_update.sh +20 -0
  65. package/ds-canonical/hooks/retired/check_third_party_dom_verified.sh +95 -0
  66. package/ds-canonical/hooks/retired/enforce_home_charter.sh +125 -0
  67. package/ds-canonical/hooks/retired/post_edit_canonical_interrogate.sh +109 -0
  68. package/ds-canonical/hooks/retired/pre_edit_spec_check.sh +68 -0
  69. package/ds-canonical/hooks/retired/pre_new_component_spec.sh +39 -0
  70. package/ds-canonical/hooks/retired/pre_write_subsumption_check.sh +112 -0
  71. package/ds-canonical/hooks/retired/stop_meta_self_audit.sh.retired-2026-05-13 +76 -0
  72. package/ds-canonical/hooks/retired/tests/test_check_anatomy_section_numbering.sh +14 -0
  73. package/ds-canonical/hooks/retired/tests/test_check_avatar_hovercard.sh +15 -0
  74. package/ds-canonical/hooks/retired/tests/test_check_container_breathing.sh +15 -0
  75. package/ds-canonical/hooks/retired/tests/test_check_governance_compliance.sh +15 -0
  76. package/ds-canonical/hooks/retired/tests/test_check_icon_only_padding_formula.sh +79 -0
  77. package/ds-canonical/hooks/retired/tests/test_check_item_content_primitive.sh +15 -0
  78. package/ds-canonical/hooks/retired/tests/test_check_item_list_gap.sh +163 -0
  79. package/ds-canonical/hooks/retired/tests/test_check_sideoffset_canonical.sh +15 -0
  80. package/ds-canonical/hooks/retired/tests/test_check_spec_iteration_tag.sh +15 -0
  81. package/ds-canonical/hooks/retired/tests/test_check_ssot_consultation.sh +15 -0
  82. package/ds-canonical/hooks/retired/tests/test_check_sync_update.sh +14 -0
  83. package/ds-canonical/hooks/retired/tests/test_check_third_party_dom_verified.sh +15 -0
  84. package/ds-canonical/hooks/retired/tests/test_enforce_home_charter.sh +15 -0
  85. package/ds-canonical/hooks/retired/tests/test_pre_edit_spec_check.sh +15 -0
  86. package/ds-canonical/hooks/retired/tests/test_pre_new_component_spec.sh +15 -0
  87. package/ds-canonical/hooks/retired/tests/test_pre_write_subsumption_check.sh +63 -0
  88. package/ds-canonical/hooks/session_start_governance_check.sh +263 -0
  89. package/ds-canonical/hooks/stop_passive_logging.sh +322 -0
  90. package/ds-canonical/hooks/stop_self_audit.sh +450 -0
  91. package/ds-canonical/hooks/tests/KNOWN-BROKEN.md +15 -0
  92. package/ds-canonical/hooks/tests/run-all.sh +76 -0
  93. package/ds-canonical/hooks/tests/test_block_prototype_imports.sh +143 -0
  94. package/ds-canonical/hooks/tests/test_check_app_shell_primary_header_consistency.sh +140 -0
  95. package/ds-canonical/hooks/tests/test_check_audit_post_report_validator.sh +115 -0
  96. package/ds-canonical/hooks/tests/test_check_audit_sample_escape.sh +93 -0
  97. package/ds-canonical/hooks/tests/test_check_benchmark_citation.sh +115 -0
  98. package/ds-canonical/hooks/tests/test_check_canonical_propagation.sh +133 -0
  99. package/ds-canonical/hooks/tests/test_check_chrome_header_handcraft.sh +123 -0
  100. package/ds-canonical/hooks/tests/test_check_code_quality.sh +15 -0
  101. package/ds-canonical/hooks/tests/test_check_codex_collab_5step.sh +96 -0
  102. package/ds-canonical/hooks/tests/test_check_cva_default_sync.sh +15 -0
  103. package/ds-canonical/hooks/tests/test_check_datatable_invariants.sh +122 -0
  104. package/ds-canonical/hooks/tests/test_check_dim_count_drift.sh +98 -0
  105. package/ds-canonical/hooks/tests/test_check_field_controls_contracts.sh +126 -0
  106. package/ds-canonical/hooks/tests/test_check_field_family_invariants.sh +194 -0
  107. package/ds-canonical/hooks/tests/test_check_file_size_budget.sh +32 -0
  108. package/ds-canonical/hooks/tests/test_check_hardcoded_strings.sh +14 -0
  109. package/ds-canonical/hooks/tests/test_check_header_with_tabs_border.sh +110 -0
  110. package/ds-canonical/hooks/tests/test_check_layout_space_canonical.sh +73 -0
  111. package/ds-canonical/hooks/tests/test_check_main_branch_workbench.sh +147 -0
  112. package/ds-canonical/hooks/tests/test_check_naming_and_abstraction.sh +136 -0
  113. package/ds-canonical/hooks/tests/test_check_opacity_token_usage.sh +110 -0
  114. package/ds-canonical/hooks/tests/test_check_overlay_handcraft.sh +126 -0
  115. package/ds-canonical/hooks/tests/test_check_pattern_invariants.sh +148 -0
  116. package/ds-canonical/hooks/tests/test_check_peoplepicker_ssot_drift.sh +108 -0
  117. package/ds-canonical/hooks/tests/test_check_person_data_richness.sh +58 -0
  118. package/ds-canonical/hooks/tests/test_check_pixel_quantified_audit.sh +142 -0
  119. package/ds-canonical/hooks/tests/test_check_propose_plain_chinese.sh +126 -0
  120. package/ds-canonical/hooks/tests/test_check_propose_pre_grep_verify.sh +117 -0
  121. package/ds-canonical/hooks/tests/test_check_select_all_canonical.sh +125 -0
  122. package/ds-canonical/hooks/tests/test_check_solo_workflow.sh +201 -0
  123. package/ds-canonical/hooks/tests/test_check_spec_class_drift.sh +135 -0
  124. package/ds-canonical/hooks/tests/test_check_story_anatomy.sh.broken +197 -0
  125. package/ds-canonical/hooks/tests/test_check_story_category.sh.broken +187 -0
  126. package/ds-canonical/hooks/tests/test_check_story_compile_drift.sh +15 -0
  127. package/ds-canonical/hooks/tests/test_check_story_invariants.sh +209 -0
  128. package/ds-canonical/hooks/tests/test_check_story_name_jargon.sh.broken +53 -0
  129. package/ds-canonical/hooks/tests/test_check_story_slot_split.sh +156 -0
  130. package/ds-canonical/hooks/tests/test_check_substantive_edit_approval_preflight.sh +176 -0
  131. package/ds-canonical/hooks/tests/test_check_tab_lg_chrome_header_equal.sh +138 -0
  132. package/ds-canonical/hooks/tests/test_check_token_hygiene.sh +21 -0
  133. package/ds-canonical/hooks/tests/test_check_wrapper_primitive_schema_drift.sh +169 -0
  134. package/ds-canonical/hooks/tests/test_enforce_home_charter.sh +77 -0
  135. package/ds-canonical/hooks/tests/test_inject_pending_self_audit.sh +125 -0
  136. package/ds-canonical/hooks/tests/test_log_governance_fires.sh +10 -0
  137. package/ds-canonical/hooks/tests/test_log_skill_invokes.sh +7 -0
  138. package/ds-canonical/hooks/tests/test_post_edit_dispatcher.sh +108 -0
  139. package/ds-canonical/hooks/tests/test_session_start_governance_check.sh +143 -0
  140. package/ds-canonical/hooks/tests/test_stop_capture_metrics.sh +95 -0
  141. package/ds-canonical/hooks/tests/test_stop_governance_drift_check.sh.broken +125 -0
  142. package/ds-canonical/hooks/tests/test_stop_harvest_corrections.sh +10 -0
  143. package/ds-canonical/hooks/tests/test_stop_passive_logging.sh +100 -0
  144. package/ds-canonical/hooks/tests/test_stop_self_audit.sh +76 -0
  145. package/ds-canonical/hooks/tests/test_stop_tsc_sanity.sh +10 -0
  146. package/ds-canonical/references/README.md +43 -0
  147. package/ds-canonical/references/audit-coverage-vs-24-checklist.md +74 -0
  148. package/ds-canonical/references/build-ui-canonicals.md +69 -0
  149. package/ds-canonical/references/cva-patterns.md +41 -0
  150. package/ds-canonical/references/drag-canonical.md +331 -0
  151. package/ds-canonical/references/item-anatomy-recipe.md +225 -0
  152. package/ds-canonical/references/naming-conventions.md +56 -0
  153. package/ds-canonical/references/principle-dim-map.json +515 -0
  154. package/ds-canonical/references/props-naming.md +45 -0
  155. package/ds-canonical/references/spec-rules.md +58 -0
  156. package/ds-canonical/references/ssot-consultation.md +63 -0
  157. package/ds-canonical/references/ssot-index.md +40 -0
  158. package/ds-canonical/references/story-baseline-registry.json +79 -0
  159. package/ds-canonical/references/structural-token-retention.md +42 -0
  160. package/ds-canonical/references/tailwind-gotchas.md +87 -0
  161. package/ds-canonical/references/ui-dev-rules.md +60 -0
  162. package/ds-canonical/rules/README.md +34 -0
  163. package/ds-canonical/rules/meta-patterns.md +87 -0
  164. package/ds-canonical/rules/self-verify.md +53 -0
  165. package/ds-canonical/rules/spec-rules.md +25 -0
  166. package/ds-canonical/rules/story-rules.md +56 -0
  167. package/ds-canonical/rules/ui-development.md +87 -0
  168. package/ds-canonical/skills/README.md +88 -0
  169. package/ds-canonical/skills/bug-fix-rhythm/SKILL.md +181 -0
  170. package/ds-canonical/skills/code-quality-audit/SKILL.md +63 -0
  171. package/ds-canonical/skills/codex-collab/SKILL.md +249 -0
  172. package/ds-canonical/skills/codex-collab/references/brief-template.md +48 -0
  173. package/ds-canonical/skills/codex-collab/references/transport.md +58 -0
  174. package/ds-canonical/skills/codify-corrections/SKILL.md +184 -0
  175. package/ds-canonical/skills/codify-principle/SKILL.md +151 -0
  176. package/ds-canonical/skills/component-quality-gate/SKILL.md +102 -0
  177. package/ds-canonical/skills/component-quality-gate/references/checklist.md +79 -0
  178. package/ds-canonical/skills/deep-audit-cross-codex/SKILL.md +247 -0
  179. package/ds-canonical/skills/deep-audit-cross-codex/references/phase-a-workflow.md +123 -0
  180. package/ds-canonical/skills/deep-audit-cross-codex/references/phase-b-codex-brief.md +165 -0
  181. package/ds-canonical/skills/deep-audit-cross-codex/references/triage-rubric.md +91 -0
  182. package/ds-canonical/skills/delivery-handoff/SKILL.md +229 -0
  183. package/ds-canonical/skills/delivery-handoff/references/flow-diagram.md +180 -0
  184. package/ds-canonical/skills/delivery-handoff/references/handoff-template.md +177 -0
  185. package/ds-canonical/skills/delivery-handoff/references/inventory-checklist.md +196 -0
  186. package/ds-canonical/skills/design-system-audit/SKILL.md +343 -0
  187. package/ds-canonical/skills/design-system-audit/references/audit-prompts.md +1260 -0
  188. package/ds-canonical/skills/design-system-audit/references/checkpoints.md +240 -0
  189. package/ds-canonical/skills/design-system-audit/references/historical-bugs.md +240 -0
  190. package/ds-canonical/skills/design-system-audit/references/principle-audit-protocol.md +364 -0
  191. package/ds-canonical/skills/design-system-audit/references/rule-placement.md +175 -0
  192. package/ds-canonical/skills/design-system-audit/references/spec-template.md +66 -0
  193. package/ds-canonical/skills/ensure-canonical/SKILL.md +196 -0
  194. package/ds-canonical/skills/governance-health/SKILL.md +146 -0
  195. package/ds-canonical/skills/knowledge-prune/SKILL.md +303 -0
  196. package/ds-canonical/skills/new-component/SKILL.md +170 -0
  197. package/ds-canonical/skills/new-component/references/new-component-checklist.md +85 -0
  198. package/ds-canonical/skills/performance-audit/SKILL.md +107 -0
  199. package/ds-canonical/skills/product-ui-audit/SKILL.md +230 -0
  200. package/ds-canonical/skills/product-ui-audit/references/audit-checks.md +246 -0
  201. package/ds-canonical/skills/product-ui-audit/references/common-misuses.md +329 -0
  202. package/ds-canonical/skills/product-ui-audit/references/report-template.md +159 -0
  203. package/ds-canonical/skills/propose-options/SKILL.md +177 -0
  204. package/ds-canonical/skills/prototype/SKILL.md +244 -0
  205. package/ds-canonical/skills/prototype/references/audit-checks.md +37 -0
  206. package/ds-canonical/skills/prototype/references/benchmark-sources.md +94 -0
  207. package/ds-canonical/skills/prototype/references/checkpoints.md +191 -0
  208. package/ds-canonical/skills/prototype/references/evaluation-matrix.md +141 -0
  209. package/ds-canonical/skills/prototype/references/ooux-template.md +198 -0
  210. package/ds-canonical/skills/prototype/references/proposal-template.md +229 -0
  211. package/ds-canonical/skills/scan-similar-bugs/SKILL.md +198 -0
  212. package/ds-canonical/skills/story-auto-compile-migrate/SKILL.md +159 -0
  213. package/ds-canonical/skills/story-writing/SKILL.md +122 -0
  214. package/ds-canonical/skills/story-writing/references/anatomy-standard.md +217 -0
  215. package/ds-canonical/skills/story-writing/references/category-templates.md +174 -0
  216. package/ds-canonical/skills/story-writing/references/example-selection.md +70 -0
  217. package/ds-canonical/skills/story-writing/references/self-check.md +20 -0
  218. package/ds-canonical/skills/ux-audit/SKILL.md +130 -0
  219. package/ds-canonical/skills/visual-audit/SKILL.md +245 -0
  220. package/ds-canonical/skills/visual-audit/output/.gitkeep +0 -0
  221. package/ds-canonical/skills/visual-audit/references/audit-architecture.md +100 -0
  222. package/ds-canonical/skills/visual-audit/references/visual-checklist.md +297 -0
  223. package/ds-canonical/skills/visual-audit/references/world-class-benchmarks.md +198 -0
  224. package/package.json +9 -5
  225. package/src/components/Accordion/accordion.spec.md +114 -0
  226. package/src/components/Alert/alert.spec.md +197 -0
  227. package/src/components/AppShell/app-shell.spec.md +331 -0
  228. package/src/components/AspectRatio/aspect-ratio.spec.md +134 -0
  229. package/src/components/Avatar/avatar.spec.md +329 -0
  230. package/src/components/Badge/badge.spec.md +380 -0
  231. package/src/components/Breadcrumb/breadcrumb.spec.md +257 -0
  232. package/src/components/BulkActionBar/bulk-action-bar.spec.md +210 -0
  233. package/src/components/Button/button.spec.md +460 -0
  234. package/src/components/Calendar/calendar.spec.md +242 -0
  235. package/src/components/Carousel/carousel.spec.md +253 -0
  236. package/src/components/Chart/chart.spec.md +155 -0
  237. package/src/components/Checkbox/checkbox.spec.md +344 -0
  238. package/src/components/Chip/chip.spec.md +237 -0
  239. package/src/components/CircularProgress/circular-progress.spec.md +268 -0
  240. package/src/components/Coachmark/coachmark.spec.md +230 -0
  241. package/src/components/Combobox/combobox.spec.md +180 -0
  242. package/src/components/Command/command.spec.md +171 -0
  243. package/src/components/DataTable/data-table.spec.md +525 -0
  244. package/src/components/DateGrid/date-grid.spec.md +215 -0
  245. package/src/components/DatePicker/date-picker.spec.md +334 -0
  246. package/src/components/DescriptionList/description-list.spec.md +214 -0
  247. package/src/components/Dialog/dialog.spec.md +202 -0
  248. package/src/components/DropdownMenu/dropdown-menu.spec.md +250 -0
  249. package/src/components/Empty/empty.spec.md +214 -0
  250. package/src/components/Field/field-controls.spec.md +338 -0
  251. package/src/components/Field/field.spec.md +438 -0
  252. package/src/components/Field/form-validation.spec.md +152 -0
  253. package/src/components/FieldControlGroup/field-control-group.spec.md +176 -0
  254. package/src/components/FileItem/file-item.spec.md +467 -0
  255. package/src/components/FileUpload/file-upload.spec.md +123 -0
  256. package/src/components/FileViewer/file-viewer.spec.md +373 -0
  257. package/src/components/HoverCard/hover-card.spec.md +157 -0
  258. package/src/components/Input/input.spec.md +193 -0
  259. package/src/components/LinkInput/link-input.spec.md +130 -0
  260. package/src/components/Menu/menu-item.spec.md +290 -0
  261. package/src/components/NameCard/name-card.spec.md +171 -0
  262. package/src/components/Notice/notice.spec.md +149 -0
  263. package/src/components/NumberInput/number-input.spec.md +126 -0
  264. package/src/components/OverflowIndicator/overflow-indicator.spec.md +120 -0
  265. package/src/components/PeoplePicker/people-picker.spec.md +263 -0
  266. package/src/components/Popover/popover.spec.md +198 -0
  267. package/src/components/ProgressBar/progress-bar.spec.md +232 -0
  268. package/src/components/RadioGroup/radio-group.spec.md +141 -0
  269. package/src/components/Rating/rating.spec.md +208 -0
  270. package/src/components/ScrollArea/scroll-area.spec.md +145 -0
  271. package/src/components/SegmentedControl/segmented-control.spec.md +295 -0
  272. package/src/components/Select/select.spec.md +299 -0
  273. package/src/components/SelectMenu/select-menu.spec.md +220 -0
  274. package/src/components/SelectionControl/selection-item.spec.md +128 -0
  275. package/src/components/Separator/separator.spec.md +109 -0
  276. package/src/components/Sheet/sheet.spec.md +148 -0
  277. package/src/components/Sidebar/sidebar.spec.md +713 -0
  278. package/src/components/Skeleton/skeleton.spec.md +104 -0
  279. package/src/components/Slider/slider.spec.md +353 -0
  280. package/src/components/Steps/steps.spec.md +465 -0
  281. package/src/components/Switch/switch.spec.md +215 -0
  282. package/src/components/Tabs/tabs.spec.md +314 -0
  283. package/src/components/Tag/tag.spec.md +282 -0
  284. package/src/components/Textarea/textarea.spec.md +151 -0
  285. package/src/components/TimePicker/time-picker.spec.md +279 -0
  286. package/src/components/Toast/toast.spec.md +177 -0
  287. package/src/components/Tooltip/tooltip.spec.md +139 -0
  288. package/src/components/TreeView/tree-view.spec.md +374 -0
  289. package/src/patterns/action-bar/action-bar.spec.md +458 -0
  290. package/src/patterns/element-anatomy/element-anatomy.spec.md +215 -0
  291. package/src/patterns/element-anatomy/inline-action.spec.md +315 -0
  292. package/src/patterns/element-anatomy/item-anatomy.spec.md +1042 -0
  293. package/src/patterns/header-canonical/header-canonical.spec.md +285 -0
  294. package/src/patterns/horizontal-overflow/horizontal-overflow.spec.md +191 -0
  295. package/src/patterns/overlay-surface/overlay-surface.spec.md +428 -0
  296. package/src/patterns/resize-handle/resize-handle.spec.md +109 -0
  297. package/src/tokens/color/color.spec.md +804 -0
  298. package/src/tokens/density/density.spec.md +127 -0
  299. package/src/tokens/elevation/elevation.spec.md +81 -0
  300. package/src/tokens/layoutSpace/layoutSpace.spec.md +314 -0
  301. package/src/tokens/motion/motion.spec.md +97 -0
  302. package/src/tokens/opacity/opacity.spec.md +78 -0
  303. package/src/tokens/orphan-tokens.spec.md +117 -0
  304. package/src/tokens/radius/radius.spec.md +123 -0
  305. package/src/tokens/typography/typography.spec.md +202 -0
  306. package/src/tokens/uiSize/uiSize.spec.md +438 -0
  307. package/src/styles/preset.css +0 -31
package/CLAUDE.md ADDED
@@ -0,0 +1,201 @@
1
+ # 每次任務前的 6 條 mindset(世界級設計系統的工作底色)
2
+
3
+ 這 6 條是本專案所有規則背後的**態度**。接到任務先複習一遍,再看具體規則。
4
+
5
+ 1. **對標世界級 + 不取巧省工**——每個設計決策都要能回答「Polaris / Material / Atlassian / Ant / Carbon / Apple HIG 怎麼做?」沒對齊又說不出理由 = 設計 bug。視覺整齊度不輸原版 + 符合 DS 語言**同時成立**。**禁止以「選較簡單」「省 N edits」為由選 shortcut**——一律最世界級做法。說「快速修」「省工程」是 yellow flag,停下重想。
6
+ 2. **不憑直覺發明 / 優先消費既有**——新增任何值 / 名 / pattern / variant / layout primitive 前先 `grep` 既有。**強制 `# SSOT 消費 canonical` 清單**——寫視覺 code 前列消費的 components/patterns/tokens/spec。提建議也算定 pattern,給 option 必對照 DS canonical + ≥3 家世界級。**禁止憑印象列部分家**。
7
+ 3. **改一處必看三處**——code / spec / story 三方聯動。改 cva `defaultVariants` / variant / token 前先 grep 該元件所有檔案,一次改完。
8
+ 4. **範例必真實業務場景**——Jira / Stripe / Notion / Figma 可辨識情境;禁 `Option A/B/C`、「按鈕一」、極端不現實、ASCII art。
9
+ 5. **猶豫就問**——無前例的決策:grep 既有 → 讀近親 spec → 仍不確定停下問。**禁止憑直覺造新 pattern**。
10
+ 6. **大原則吸收瑣碎**——同類 bug 反覆糾正 = meta 層沒抓住。見 `.claude/rules/meta-patterns.md` 31 active M-rules(M1-M32,M27/M33/M34/M35 retired,折入 M20/M7/M23(c)(d))。**AI 不需 user 提醒才找 root invariant**——rule 震盪 → AI 自跑 M12 benchmark + invariant test。User 第 2 次問 → 必截圖 verify(M13)。對話結論 → AUTO 5-layer pipeline(M14)。Visual / behavior decision 前必先 WebFetch ≥ 3 source(M26)。Solo-work git ops 必先 grep canonical(M28)。**視覺/結構 propose 前必 grep DS spec.md 找 owner SSOT(M29)— 出 3-column 表;否則提案不被接受**。使用者 tell me once 不該要 tell me twice。
11
+
12
+ 完整 M-rules 詳 `.claude/rules/meta-patterns.md`(always loads)。
13
+
14
+ # 治理 canonical(Claude Code 配置 home 分層 + anti-bloat)
15
+
16
+ ## 規則放哪 home(8-home 分層)
17
+
18
+ | Level | Home | 收什麼 |
19
+ |-------|------|--------|
20
+ | 1 | `CLAUDE.md`(本檔) | 每 session signal 的 mindset + 6 條 + 任務導航 |
21
+ | 1.5 | `.claude/rules/*.md` | path-scoped rules(只在相關檔案載入,2026 Anthropic 推薦) |
22
+ | 2 | `{name}.spec.md` | 單元件「何時用 / 為什麼」 |
23
+ | 3 | Pattern `spec.md` | runtime 跨元件 primitive |
24
+ | 4 | Code(`.tsx` / `.css`) | cva / 型別等機械強制 |
25
+ | 5 | Skill(`.claude/skills/`) | invoke 情境的多步驟 workflow + checkpoint |
26
+ | 6 | Memory(`~/.claude/.../memory/` SSOT + repo `.claude/memory/` mirror)| 跨 session 狀態。本機編完跑 `npm run sync-memory` 推回 repo(讓 cloud sandbox 看得到) |
27
+ | 7 | Hook(`.claude/hooks/`) | 機械化 pre/post tool 檢查 |
28
+ | 8 | Slash Command(`.claude/commands/`) | 一次性單步 action |
29
+ | 9 | Plan doc(`.claude/planning/`)| 完整 plan / RFC / spec 草稿 SSOT;memory file 是短 index pointer 指向 plan doc(對齊 ds-devmode / story-auto-compile pattern) |
30
+
31
+ **Q1 設計規則 → Level 1-4 / Q2 invoke 情境 → Skill or Command / Q3 隨時間變化 → Memory(short index)+ Plan doc(完整 spec)/ Q4 機械化 → Hook**。完整 flowchart → `.claude/skills/design-system-audit/references/rule-placement.md`。
32
+
33
+ ## 行數預算(Anthropic 對齊)
34
+
35
+ CLAUDE.md target ≤ 200(Anthropic best-practice)/ transition ≤ 400 / hard cap 800。SKILL ≤ 250 / spec ≤ 300(foundational SSOT 例外 ≤ 800-1200)/ memory **per-file ≤ 100 lines** + **MEMORY.md index ≤ 20 entries**(soft 18 / hard 20,session-start hook 攔)。Hooks **26 soft / 40 hard**(SSOT = `session_start_governance_check.sh:173`)。動態值見 `scripts/sync-governance-counters.mjs` 跑出為準(2026-05-23:**31 M-rules / 56 audit dims / 37 hooks** — 不寫死避 drift,per 2026-05-22 prune codify)。
36
+
37
+ ## Anti-bloat L1-L3
38
+
39
+ - **L1 Pre-write**:`check_file_size_budget.sh`(+ governance hooks listed in `.claude/hooks/` — dynamic SSOT,不在 CLAUDE.md hardcode 個別 hook)
40
+ - **L2 Per-commit**:`log_governance_fires.sh` → `.claude/logs/hook-fires.jsonl`
41
+ - **L3 Periodic**(季度 / `--deep`):`/knowledge-prune` skill,retire ≥ 5%
42
+
43
+ ## 加規則前必過 3 題
44
+
45
+ 1. 既有 Meta-Pattern / 近親 spec / canonical chapter 命中 → append pointer 不新寫
46
+ 2. **Rule-of-3**:同概念 ≥ 3 處 → 選 SSOT 其他 pointer
47
+ 3. 7 天後還會 fire 嗎?不確定 → 不寫
48
+
49
+ # 稽核 canonical
50
+
51
+ 3 層級 × 6 維度。**Stakeholder-visible artifact**(prototype / 元件 merge / 產品 demo)**必過 code + visual 雙層 audit**(搭配 M6+M10)。
52
+
53
+ | Tier | 時機 | Scope | Skill |
54
+ |------|------|-------|------|
55
+ | 1 Stakeholder-gate(強制)| 新元件 merge / prototype / demo | artifact-scoped | `/component-quality-gate` / `/prototype` P3.5 / `/product-ui-audit` P5 |
56
+ | 2 Daily dev | bug / refactor / 文字改 | git diff + direct consumer | `visual-audit --scope=changed`(default) |
57
+ | 3 Periodic deep | release / token 大改 / 季度 | full DS | `/design-system-audit --deep` |
58
+
59
+ | 維度 | 對應 skill |
60
+ |------|-----------|
61
+ | D1 設計語言 | `/design-system-audit` |
62
+ | D2 程式語言 | tsc + lint + `/design-system-audit` |
63
+ | D3 元件效能 | `/performance-audit` |
64
+ | D4 UX 行為 | `/ux-audit` |
65
+ | D5 視覺品質 | `/visual-audit`(Layer A mechanical + B AI) |
66
+ | D6 原則自檢 | `design-system-audit/references/principle-audit-protocol.md` |
67
+
68
+ **Consistency 類稽核必 Phase 0 全掃再判**(避免單元件看漏系統 drift)。
69
+
70
+ **Audit-vs-execute 分權**:動 canonical substantive meaning → STOP 提議;對齊 / 表達統一 / 清 duplicate / 補 pointer → AUTO(對齊 knowledge-prune SKILL Phase 2 P0+P1 scope)。
71
+
72
+ **Scope classifier — Surgical visual bug**(2026-05-12 codex 抓 anti-pattern「surgical bug 升 architecture audit」)。user 列 N 個 visual defects + 無新 canonical / 無新 API contract / 無 cross-component semantic 改動 → **Surgical scope**:**no codex collab / no new M-rule / no audit report,batch fix + final pixel-quantified verify only**。對齊 Anthropic Best Practice 小修 skip plan + M32(c) batch fix + 對立面是「unscoped investigation infinite exploration」反 pattern。Substantive 改動(API / SSOT / cross-component)走 audit-vs-execute STOP 提議流程。
73
+
74
+ # SSOT 消費 canonical
75
+
76
+ 寫視覺 code 前必查對照 — 沒列 = 自創。**完整對照表 + 強制 checklist** → `.claude/references/ssot-consultation.md`(SSOT owner;含 9 項決策對應 SSOT + 新元件 tsx 開頭「── 消費的 SSOT ──」段強制要求)。Hook `check_ssot_consultation.sh` 2026-05-XX 已 retired → 改靠 mindset #2 + audit dim 1 + check_canonical_propagation hook 接手檢查。
77
+
78
+ # 任務導航表
79
+
80
+ | 任務 | 必讀 |
81
+ |------|------|
82
+ | **新增元件** | `.claude/rules/ui-development.md` 「建立 UI 前必讀 / shadcn 元件規範」 + `.claude/rules/spec-rules.md` → `/component-quality-gate` |
83
+ | **修 variant / size / state** | 該元件 `spec.md` → `/story-writing` |
84
+ | **新增 token** | `tokens/README.md` → `.claude/rules/ui-development.md`「Token 命名 4 條硬規則」→ `tokens/xxx.spec.md` |
85
+ | **寫 story / 視覺 code** | `/story-writing` + `# SSOT 消費 canonical` |
86
+ | **命名新檔 / 變數 / prop** | `# 命名與語言一致性` + `.claude/rules/ui-development.md`「元件 Props 命名」 |
87
+ | **新元件 layout** | `# 4-Family Layout Model` |
88
+ | **新 skill / hook / command** | `.claude/{home}/README.md` charter |
89
+ | **無前例設計決策** | `# 遇不確定時的協議` |
90
+ | **Tailwind 出怪事** | `.claude/rules/ui-development.md`「Tailwind 5 條核心」+ `# 失敗記憶索引` |
91
+ | **Stakeholder 產出 / 稽核** | `# 稽核 canonical` |
92
+ | **User 糾正後** | `# 治理 canonical`(home 判斷) |
93
+ | **跟 codex 討論 / 多輪震盪 / 任何 codex 輸出** | `.claude/skills/codex-collab/SKILL.md`(M31 5-step canonical SSOT;含 transport / Step 0.05 user-verbatim relay / queue + interval / hook 機械強制)+ M31 anchor in meta-patterns.md |
94
+ | **PR merge 後 / session start branch 健檢** | `# Git solo-work canonical` |
95
+
96
+ **找不到** → 進 `# 遇不確定時的協議`,不自決定。
97
+
98
+ # Git solo-work canonical(SSOT → `.claude/memory/feedback_solo_dev_workflow.md`)
99
+
100
+ **1 chat = 1 working branch**;**Netlify preview 是 user gate**;**「push」/「OK」trigger 才 merge main**。**Session-start 必先 grep canonical + 開 working branch,禁直接在 main 上 edit production code**(M28 sub-rule,hook `check_main_branch_workbench.sh` mechanical 攔截)。
101
+
102
+ | 步驟 | 動作 |
103
+ |------|------|
104
+ | 1 Edit | AI 改 code |
105
+ | 2 Commit + push working branch | 自動觸發 Netlify per-branch preview |
106
+ | 3 告訴 user 主要 change(or preview URL)| 讓 user 知道看什麼 |
107
+ | 4 等 user trigger | **「push / OK / 好 / 合 main」** → step 5;**「改 X / 不對 / 等等」** → 繼續 step 1 |
108
+ | 5 Squash merge to main | 不開 PR(可 GitHub API squash-merge OR fast-forward)|
109
+ | 6 砍 remote branch | `git push origin --delete <branch>` ;sandbox HTTP 403 → 提醒 user GitHub UI 手動 |
110
+ | 7 Local 對齊 | `git checkout main && git fetch && git reset --hard origin/main && git branch -d <branch>` |
111
+
112
+ **禁止**:開 PR / AI 自決 push main / 同 chat 開多 branch / 留 stale 不刪 / 「下個 session 處理」deferred 措辭。完整禁忌 / Trigger phrase / 反 pattern 詳 SSOT memory file。
113
+
114
+ # 命名與語言一致性
115
+
116
+ **3 重 test**(governance):
117
+ 1. **既有 DS 詞彙**:對齊 `compact/rich / sm/md/lg / action/indicator / scanning/reading`?
118
+ 2. **世界級 idiom**:≥ 2 家 world-class DS 用此詞?
119
+ 3. **跨元件認知衝突**:同字串在其他元件已有不同語義?
120
+
121
+ 3 test 全過才採納。歷史:FileItem `text/picture` 撞 Button `variant="text"` → 改 `compact/rich`。
122
+
123
+ 詳細 → `.claude/references/naming-conventions.md`。
124
+
125
+ **語言一致性**:spec.md 繁中(技術術語保留英) / code identifier 英 / 單一檔案不中英夾雜。
126
+
127
+ # 4-Family Layout Model
128
+
129
+ **每元件 spec 第一段必聲明 Layout Family**(1/2/3/4 或「self-contained」)。
130
+
131
+ | Family | 用途 | SSOT |
132
+ |--------|------|------|
133
+ | 1 Menu item / 2 List item | scanning / reading | `patterns/element-anatomy/item-anatomy.spec.md` |
134
+ | 3 Pill | 單行互動 pill | `components/Button/button.spec.md`「Pill Layout」|
135
+ | 4 Field control | 可編輯資料輸入 | `components/Field/field-controls.spec.md` |
136
+
137
+ # 自主執行 canonical(Autonomy Default,2026-05-14 user SSOT directive)
138
+
139
+ **Default = autonomous + complete + verify-to-perfection;省工 = anti-pattern(違 mindset #1)**。
140
+
141
+ | 動作類別 | 預設 |
142
+ |---------|-----|
143
+ | **SSOT-affecting UI/UX**(增刪改 component / token / spec 視覺結構 / 跨元件 design language) | **ASK** — 中文具體人話講選項 + tradeoff,user 拍板才動。**Enforcement scope split**:production code(`src/**/*.{tsx,ts,css}`)由 `check_substantive_edit_approval_preflight.sh` PreToolUse 攔截;`*.spec.md` 視覺結構 / canonical / SSOT 段落 edit 由 `stop_self_audit.sh` 補位 post-action 攔截(避免 spec typo false-positive BLOCKER)|
144
+ | Bug fix / clean / refactor / 命名一致 / test / audit / verify | **AUTO** — 整批做完 + 完整驗證 + 撤回機制(M33 反 defer) |
145
+ | Governance / hook / skill / spec **內部**(typo / pointer / 結構 — 不動 canonical meaning)| **AUTO** — audit-vs-execute 分權 |
146
+ | Perf / a11y / 漸進遷移(不動 SSOT)| **AUTO** — 整批 + verify |
147
+
148
+ **自主執行同時優化 7 軸**:言簡意賅 / 效率 + 效能(M20 ≥ 80)/ SSOT 鐵律(M17/M23/M29/M30)/ 易懂維護擴充(M9/M21/M23(c))/ 世界級 + 一致設計語言(mindset #1 + M8/M22/M26)/ 完整 self-verify(M20/M31/M32)/ 自動 self-improve(M14/M20)。
149
+
150
+ **反 pattern**(禁):「省工」/「下次再做」/「下個 session」(M33)/「OK 嗎?」過度 ASK / shortcut 避 verify / 不對齊 mindset #1。
151
+
152
+ **Trigger phrase auto-pipeline**(M19 升級):「依原則自主」/「不需問」/「馬不停蹄」/「全部做完」/「自動」→ 進 autonomous mode,僅 SSOT-affecting UI/UX 停下 ASK。
153
+
154
+ **2026-05-23 永久 reinforcement(user verbatim,hook 機械強制)**:
155
+ - **Triple-verify before propose**(M18 Q0 universal gate):propose / 列 option / 發現「問題」(含 codex / deep audit findings)前必 inline 跑 (1) grep DS-wide (2) Read spec.md / tsx (3) 對照 canonical exception。三題全過才 propose;任一 NO → 自動撤回不煩 user。Hook `check_propose_pre_grep_verify.sh`。Anchor:2026-05-18 Sheet/inline-action/SurfaceBody false positive、2026-05-23 Badge `text-[10px]` 誤判為 drift(spec L161-167 documented exception)
156
+ - **SSOT auto-sync invariant**:M-rule count / hook count / dim count / npm scope / version / plugin name 等跨 file 數字禁 hardcode 多處;SSOT in `session_start_governance_check.sh:173` / `meta-patterns.md` / `design-system-audit/SKILL.md` / `package.json` / `.claude-plugin/plugin.json`;其他 file reference 或 `scripts/sync-governance-counters.mjs` 機械對齊,drift 偵測 auto fix
157
+
158
+ # 遇不確定時的協議
159
+
160
+ **無前例且影響 SSOT UI/UX 設計判斷**時 3 步,禁跳:**grep 既有**(30 秒)→ **讀近親 spec.md** → **仍不確定停下問** user。
161
+ **非 SSOT-UI/UX**(refactor / test / perf / a11y / hook / skill / typo / 對齊既有 canonical)→ autonomous,無需問。
162
+ 禁:跳 grep 憑記憶 / 隨便挑 / 留 TODO。
163
+ 可跳:bug 修 / 機械勞動 / user 明確指示。
164
+
165
+ # 失敗記憶索引(技術沉默陷阱 only)
166
+
167
+ 設計判斷類已被 M-rules 吸收(見 `.claude/rules/meta-patterns.md`);具體歷史詳 `.claude/skills/design-system-audit/references/historical-bugs.md`。
168
+
169
+ | 技術陷阱 | 一行 anchor |
170
+ |--------|-----------|
171
+ | Tailwind v4 `[--foo]` 必 `var()` | silent 失效 |
172
+ | tailwind-merge 自訂 utility 必註冊 group | 否則 strip |
173
+ | 元件自包 Provider | 劫持全站 |
174
+ | 清 unused imports 後 runtime | tsc 不充分,需 storybook |
175
+ | shadcn compat alias 回流 | dark mode 不聯動 |
176
+ | `asChild ? Slot : Native` 內部 JSX 仍渲染多 children | React.Children.only runtime fail — Slot 規範 children 必為單 element,內部 `{icon}{label}{badge}` 多 expression 變 array → throw。asChild 分支 render 只傳 consumer child;tsc/build 過,story 打開才炸 |
177
+
178
+ 新 bug → 歸 Meta-Pattern OR 本表 1 行;> 10 條 = 漏寫,**評估 meta-merge 既有 M-rule 而非無腦新增**(meta-patterns velocity ≤ 3/quarter,單 M-rule 必吸收 ≥ 3 prior bugs)。
179
+
180
+ # 專案 Stack
181
+
182
+ Vite + React + TypeScript + Tailwind v4 + shadcn/ui + Storybook + 自訂 Design Token。
183
+ 必要檔案:`index.html` / `src/main.tsx` / `src/globals.css` / `vite.config.ts` / `package.json` / `tsconfig.json`。
184
+ 完整路徑 + Token 系統 → `packages/design-system/src/tokens/README.md`(charter)— Phase 1 後 DS 內化在 npm workspace。
185
+
186
+ # Path-scoped rules(2026 Anthropic 推薦)
187
+
188
+ 僅在相關檔案打開時載入,降低本檔 token 成本:
189
+
190
+ - `.claude/rules/meta-patterns.md` — 31 active M-rules(M1-M32,M27/M33/M34/M35 retired,always loads,fundamental)
191
+ - `.claude/rules/spec-rules.md` — paths: `**/*.spec.md` + `src/design-system/**` + `packages/design-system/**`(post Phase 1 migration)
192
+ - `.claude/rules/ui-development.md` — paths: `**/*.tsx` + `**/*.ts`(含 Tailwind / Token / Props 命名 / shadcn)
193
+ - `.claude/rules/story-rules.md` — paths: `**/*.stories.tsx`(三層定位 + Title + 範例最高準則)
194
+
195
+ # 元件完成 checklist
196
+
197
+ merge 前 invoke `/component-quality-gate`(45 項 + visual + clean-code 三層)。
198
+
199
+ # Exploration & Prototype
200
+
201
+ 正式 `packages/design-system/src/`(Phase 1 後 npm workspace 內化)vs 比稿 `src/explorations/`(hook `block_prototype_imports.py` 強制隔離)。比稿 `*.v1.stories.tsx` + `notes.md`,定案升級 patterns/ 或 components/。Skills:`/prototype` / `/component-quality-gate` / `/delivery-handoff`。
package/README.md CHANGED
@@ -12,29 +12,21 @@ Tailwind v4 + React 18+ project required. License: UNLICENSED (internal use).
12
12
 
13
13
  ## Quick start(consumer side)
14
14
 
15
- ### 推薦:1-line preset(beta.9+,零偏移即取即用)
15
+ ### CSS entry — 3 line setup(Tailwind v4 canonical)
16
16
 
17
17
  ```css
18
18
  /* globals.css (or main.css / src/index.css) */
19
- @import '@qijenchen/design-system/styles/preset';
20
- ```
21
-
22
- 這 1 行展開等於:`tailwindcss` + DS tokens + `@source` directive(自動 scan DS source 產出 utility class)。Consumer 0 config,**Button 立即正確 render with 所有設計準則樣式**。
23
-
24
- > 為何要 preset:Tailwind v4 預設只掃 `src/**` 不掃 `node_modules`。沒 preset 的 `@source`,DS 元件內用的 `h-field-md` / `bg-primary-hover` 等 class 不會被產出 → 元件純文字無樣式。preset 把 setup 收成 1 行。
25
-
26
- ### 替代:4 步驟手動 setup(beta.8 或想自己管 Tailwind scan source)
27
-
28
- ```css
29
- /* globals.css */
30
19
  @import 'tailwindcss';
31
20
  @import '@qijenchen/design-system/styles/tokens';
32
-
33
- /* 必要:讓 Tailwind v4 掃 DS 元件原始碼產生 utility class */
34
21
  @source '../node_modules/@qijenchen/design-system/src/**/*.{js,ts,jsx,tsx}';
35
22
  ```
36
23
 
37
- > ⚠️ 漏 `@source` → 元件看起來像沒套樣式。
24
+ 3 行皆必要:
25
+ 1. `@import 'tailwindcss'` — Tailwind v4 entry
26
+ 2. `@import '@qijenchen/design-system/styles/tokens'` — DS token system(`@theme inline` + color / spacing / typography / radius)
27
+ 3. `@source '../node_modules/...'` — **不能省**。Tailwind v4 預設只掃 `src/**` 不掃 `node_modules`,沒這行 DS 元件內用的 `h-field-md` / `bg-primary-hover` 等 class 不會被產出 → 元件純文字無樣式。
28
+
29
+ > 為何不能合 1 行 preset?Tailwind v4 `@source` directive 在從 `node_modules` 來的 imported CSS 內不被正確 resolve(本 DS 試過 preset.css 失敗),consumer 必須 inline 寫 `@source` 在自己的 entry CSS。對齊 Material UI / Polaris / shadcn 慣例(各自 README 都要 consumer 寫 Tailwind config)。
38
30
 
39
31
  ### 2. App-level Provider(必要)
40
32
 
package/cli-init.mjs ADDED
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+ // cli-init.mjs — `npx @qijenchen/design-system-init` consumer-side 1-cmd setup
3
+ //
4
+ // What it does:
5
+ // 1. Symlink consumer-cwd/.claude/design-system → node_modules/@qijenchen/design-system/ds-canonical
6
+ // → Claude Code 自動 load DS skills / hooks / rules / references / commands
7
+ // 2. Symlink consumer-cwd/CLAUDE.design-system.md → node_modules/@qijenchen/design-system/CLAUDE.md
8
+ // → Consumer 自己的 CLAUDE.md import this for inherit DS mindset
9
+ // 3. Print consumer should add to their entry CSS(3-line setup)
10
+ //
11
+ // Why symlink not copy:
12
+ // `npm update @qijenchen/design-system` 自動 sync 全部 SSOT(consumer 不用再跑)
13
+ // per user 2026-05-25「每次手動更新 package 都能獲取最新跟 ds repo 同步的 ssot 等所有檔案」
14
+ //
15
+ // Idempotent: re-run safe(skip if symlink exists pointing same place).
16
+
17
+ import { existsSync, mkdirSync, symlinkSync, readlinkSync, lstatSync, unlinkSync } from 'node:fs'
18
+ import { join, relative, dirname } from 'node:path'
19
+ import { fileURLToPath } from 'node:url'
20
+
21
+ const CWD = process.cwd()
22
+ const __dirname = dirname(fileURLToPath(import.meta.url))
23
+ const PACKAGE_ROOT = join(__dirname, '..') // = node_modules/@qijenchen/design-system/
24
+
25
+ function ensureSymlink(from, to, label) {
26
+ const fromAbs = join(CWD, from)
27
+ const toAbs = join(PACKAGE_ROOT, to)
28
+ if (!existsSync(toAbs)) {
29
+ console.warn(`⚠️ source not found: ${toAbs} — skip ${label}`)
30
+ return
31
+ }
32
+ mkdirSync(dirname(fromAbs), { recursive: true })
33
+ if (existsSync(fromAbs) || lstatSync(fromAbs, { throwIfNoEntry: false })) {
34
+ // Check if it's already the right symlink
35
+ try {
36
+ const current = readlinkSync(fromAbs)
37
+ const expected = relative(dirname(fromAbs), toAbs)
38
+ if (current === expected) {
39
+ console.log(`✓ ${label} already in sync(${from})`)
40
+ return
41
+ }
42
+ // Wrong target — remove + redo
43
+ unlinkSync(fromAbs)
44
+ } catch {
45
+ console.warn(`⚠️ ${from} exists but not a symlink — skip(remove manually if you want to re-link)`)
46
+ return
47
+ }
48
+ }
49
+ const relPath = relative(dirname(fromAbs), toAbs)
50
+ symlinkSync(relPath, fromAbs, 'dir')
51
+ console.log(`✓ linked ${label}: ${from} → ${relPath}`)
52
+ }
53
+
54
+ console.log('═══ @qijenchen/design-system init ═══')
55
+ console.log(`Consumer cwd: ${CWD}`)
56
+ console.log(`Package root: ${PACKAGE_ROOT}`)
57
+ console.log('')
58
+
59
+ // 1. Symlink DS canonical → .claude/design-system/
60
+ ensureSymlink('.claude/design-system', 'ds-canonical', 'DS canonical(skills/hooks/rules/references/commands)')
61
+
62
+ // 2. Symlink DS CLAUDE.md → CLAUDE.design-system.md
63
+ // Consumer's own CLAUDE.md can `@import` or reference this file.
64
+ const dsCLAUDEsrc = join(PACKAGE_ROOT, 'CLAUDE.md')
65
+ if (existsSync(dsCLAUDEsrc)) {
66
+ const dest = join(CWD, 'CLAUDE.design-system.md')
67
+ if (!existsSync(dest)) {
68
+ const rel = relative(dirname(dest), dsCLAUDEsrc)
69
+ symlinkSync(rel, dest)
70
+ console.log(`✓ linked CLAUDE.design-system.md → ${rel}`)
71
+ } else {
72
+ console.log(`✓ CLAUDE.design-system.md already exists(skip)`)
73
+ }
74
+ }
75
+
76
+ console.log('')
77
+ console.log('═══ Next steps ═══')
78
+ console.log('1. Add to your entry CSS(globals.css):')
79
+ console.log(' @import \'tailwindcss\';')
80
+ console.log(' @import \'@qijenchen/design-system/styles/tokens\';')
81
+ console.log(' @source \'../node_modules/@qijenchen/design-system/src/**/*.{js,ts,jsx,tsx}\';')
82
+ console.log('')
83
+ console.log('2. Wrap your app root in <TooltipProvider>:')
84
+ console.log(' import { TooltipProvider } from \'@qijenchen/design-system\'')
85
+ console.log(' <TooltipProvider><App /></TooltipProvider>')
86
+ console.log('')
87
+ console.log('3. Restart your Claude Code session to pick up newly-linked .claude/design-system/.')
88
+ console.log(' Claude 自動 load DS skills / hooks / rules / references / commands。')
89
+ console.log('')
90
+ console.log('All Done. Future `npm update @qijenchen/design-system` 會 auto-sync all SSOT via symlink.')
@@ -0,0 +1,26 @@
1
+ # .claude/commands/ Charter
2
+
3
+ ## 這裡只收:**one-shot slash commands**(無 phase,單次 action)
4
+
5
+ 每個 command 一檔 `.md`,用戶打 `/<name>` 直接觸發。**vs Skill**:skill 是多 phase workflow + user CP;command 是單次動作無 CP。
6
+
7
+ ## 當前居民(1 pilot,2026-04-24)
8
+
9
+ | Command | 觸發 | 用途 |
10
+ |---------|------|------|
11
+ | `/gov-status` | user 輸入 `/gov-status` | 一次印 governance health snapshot(行數/retire rate/logs freshness/drift/pending)—不走 skill workflow,不要 CP,純 dump |
12
+
13
+ ## 這裡**不收**(反例)
14
+
15
+ | 疑似要放這但其實不是 | 正確去處 | 為什麼 |
16
+ |---------------------|---------|--------|
17
+ | 多 phase + user 決策 | `.claude/skills/` | skill 管 phase + CP |
18
+ | 機械 tool-event 檢查 | `.claude/hooks/` | hook 是 pre/post tool 觸發,不是 user 觸發 |
19
+ | 需要 isolated context / scoped tools | `.claude/agents/` | agent 是 AI worker,command 是 quick action |
20
+
21
+ ## 新 command criteria
22
+
23
+ 1. **< 10 秒完成**(不是 workflow)
24
+ 2. **無 user CP**(有決策點 = skill)
25
+ 3. **輸出簡潔**(一段 markdown / 表)
26
+ 4. **可重複 run**(每次同 behaviour)
@@ -0,0 +1,79 @@
1
+ ---
2
+ description: One-shot dump governance health snapshot(無 workflow,< 10s 完成)
3
+ ---
4
+
5
+ # /gov-status — Governance Health Snapshot
6
+
7
+ 快印現在 governance state,不走 `/governance-health` 完整 skill workflow(那有 5 phase + CP),只是 user 想 quick check 時的一眼看。
8
+
9
+ ## 跑法
10
+
11
+ 執行以下 bash 並 format output 成 markdown table:
12
+
13
+ ```bash
14
+ echo "=== File sizes ==="
15
+ echo "CLAUDE.md: $(wc -l < CLAUDE.md | tr -d ' ') / 400 target / 800 transition"
16
+ echo ""
17
+ echo "=== Over-cap specs ==="
18
+ for f in $(find src/design-system -name "*.spec.md"); do
19
+ lines=$(wc -l < "$f" | tr -d ' ')
20
+ case "$f" in
21
+ */item-anatomy.spec.md) cap=1200 ;;
22
+ */color.spec.md|*/sidebar.spec.md|*/tree-view.spec.md) cap=800 ;;
23
+ *) cap=500 ;;
24
+ esac
25
+ if [ "$lines" -gt "$cap" ]; then
26
+ echo " ❌ $f: $lines > $cap"
27
+ fi
28
+ done
29
+ echo ""
30
+ echo "=== Memory ==="
31
+ MEM_DIR=/Users/chenqiren/.claude/projects/-Users-chenqiren-Library-CloudStorage-GoogleDrive-qijenchen-gmail-com--------my-project/memory
32
+ echo "active: $(ls $MEM_DIR/*.md | grep -v retired | wc -l | tr -d ' ') / 20 target"
33
+ echo ""
34
+ echo "=== Hooks / Skills / Agents / Commands ==="
35
+ for d in hooks skills agents commands; do
36
+ c=$(ls .claude/$d/ 2>/dev/null | grep -v README | grep -v gitignore | wc -l | tr -d ' ')
37
+ echo " .claude/$d: $c"
38
+ done
39
+ echo ""
40
+ echo "=== Logs ==="
41
+ for f in hook-fires skill-invokes user-corrections metric-snapshots; do
42
+ fn=".claude/logs/$f.jsonl"
43
+ if [ -f "$fn" ]; then
44
+ echo " $f: $(wc -l < $fn | tr -d ' ') entries"
45
+ else
46
+ echo " $f: (empty)"
47
+ fi
48
+ done
49
+ echo ""
50
+ echo "=== Benchmark freshness ==="
51
+ if [ -f .claude/benchmarks/last-fetch.txt ]; then
52
+ LAST=$(cat .claude/benchmarks/last-fetch.txt)
53
+ echo " last: $LAST"
54
+ else
55
+ echo " never fetched — run bash .claude/benchmarks/fetch.sh"
56
+ fi
57
+ echo ""
58
+ echo "=== Retire rate(latest snapshot)==="
59
+ if [ -f .claude/logs/metric-snapshots.jsonl ]; then
60
+ tail -1 .claude/logs/metric-snapshots.jsonl | head -c 200
61
+ fi
62
+ echo ""
63
+ echo "=== tsc state ==="
64
+ npx tsc -b 2>&1 | grep -c "error TS" || echo "0"
65
+ echo ""
66
+ echo "=== compile-stories drift ==="
67
+ node scripts/compile-stories.mjs --all --check 2>&1 | tail -1
68
+ ```
69
+
70
+ ## 結論分類
71
+
72
+ 根據上述輸出自動判斷:
73
+ - **✅ OK** — 若無 over-cap spec + 無 tsc error + 無 drift + memory ≤ 20
74
+ - **⚠️ Warning** — 有 over-cap / pending corrections > 10 / benchmark stale > 30 days
75
+ - **❌ Fail** — tsc errors / compile drift / CLAUDE.md > 800
76
+
77
+ 最後給 user 一行 summary:「Governance:{✅/⚠️/❌}{one-line rationale}」。
78
+
79
+ 若要深度 audit → suggest `/governance-health` 跑完整 5-phase skill。
@@ -0,0 +1,145 @@
1
+ # .claude/hooks/ Charter
2
+
3
+ ## 這裡只收:pre/post tool event 的機械化自動檢查
4
+
5
+ 每個 hook 是一個 shell / python script,在 Claude Code tool event 上自動觸發:
6
+ - **PreToolUse**:tool 執行前(可 block 或 inject context)
7
+ - **PostToolUse**:tool 執行後(通常 inject 提醒 / warning)
8
+ - **Stop**:turn 結束(sanity / harvest / metric capture)
9
+ - **SessionStart**:session 開始(governance check)
10
+
11
+ **核心特徵**:**不依賴 AI 自律**,tool 層強制執行;規則可用 `grep` / 條件判斷自動驗證。
12
+
13
+ ## 當前居民(2026-04-26 重整,以 `settings.json` 註冊為準)
14
+
15
+ ### PreToolUse(Bash / Edit / Write / MultiEdit / mcp__github__*)
16
+
17
+ | Hook | 做什麼 |
18
+ |------|--------|
19
+ | `check_solo_workflow.sh` | M28 git ops gate(branch sprawl / PR / merge — solo work canonical) |
20
+ | `check_codex_collab_5step.sh` | M31 codex collab 5-step gate(claude+codex dual-track discipline) |
21
+ | `enforce_home_charter.sh` | classification-sensitive dir / 新檔案的 charter gate(Write only) |
22
+ | `check_file_size_budget.sh` | CLAUDE.md / spec / SKILL / memory 行數預算警告 |
23
+ | `check_story_invariants.sh` | stories 合一 invariant 檢查(anatomy / slot-split / category / principles canonical — 2026-05-10 已合併 5 個 sub-hook) |
24
+ | `check_canonical_propagation.sh` | canonical 改動(spec / token / primitive)時 consumer propagation 檢查 |
25
+ | `check_pattern_invariants.sh` | pattern 層 invariant(overlay-surface / item-anatomy / action-bar / 等) |
26
+ | `check_naming_and_abstraction.sh` | M21 prop variant test + M27 prop name conflict + naming 三 test |
27
+ | `check_benchmark_citation.sh` | M22 benchmark claim inline cite verify |
28
+ | `check_wrapper_primitive_schema_drift.sh` | M30 wrapper schema 必 extends primitive |
29
+ | `check_field_family_invariants.sh` | Field family layout / state machine 統一 |
30
+ | `check_datatable_invariants.sh` | DataTable canonical(virtualizer / column-types / autoRow / overflow) |
31
+ | `check_opacity_token_usage.sh` | opacity token 使用紀律 |
32
+ | `check_substantive_edit_approval_preflight.sh` | substantive edit 前 user 拍板 preflight |
33
+
34
+ ### PostToolUse(Edit / Write / MultiEdit)
35
+
36
+ | Hook | 做什麼 |
37
+ |------|--------|
38
+ | `block_prototype_imports.py` | 產品 code 禁止 import `explorations/` |
39
+ | `post_edit_dispatcher.sh` | **Dispatcher**(2026-05-13 prune):一次 orchestrate 8 個 lib helper(token_hygiene / hardcoded_strings / code_quality / layout_space / person_data / overlay_handcraft / cva_default_sync / story_compile_drift)— hook count 32 → 24 |
40
+ | `check_story_invariants.sh` | (同上,PostToolUse 路徑做 disk read drift check) |
41
+ | `check_pixel_quantified_audit.sh` | M32 audit script 必 pixel-quantified verify(scans audit scripts for `getAttribute(` without `getBoundingClientRect(`) |
42
+ | `check_field_controls_contracts.sh` | Field controls contract 強制(c)/(e)/(f) 等 |
43
+ | `log_governance_fires.sh` | 治理檔 fire log 寫入 `.claude/logs/hook-fires.jsonl`(L2 anti-bloat) |
44
+
45
+ ### PostToolUse(Skill)
46
+
47
+ | Hook | 做什麼 |
48
+ |------|--------|
49
+ | `log_skill_invokes.sh` | skill invoke log(本 hook 僅捕 Skill tool 呼叫,slash-command 走 user prompt 不被捕 — known limitation) |
50
+
51
+ ### Stop
52
+
53
+ | Hook | 做什麼 |
54
+ |------|--------|
55
+ | `stop_passive_logging.sh` | **Dispatcher**(2026-05-13 prune):一次跑 5 rule(tsc sanity / harvest corrections / capture metrics / governance drift / infra best-practice score)— stop hook count 3 → 2 |
56
+ | `stop_self_audit.sh` | turn 行為 audit(claim 沒 verify / prune trigger / topic 重複 ≥ 3 次 → BLOCKER inject,M20 100+ failure mode 升級 2026-05-13) |
57
+ | `stop_meta_self_audit.sh` | turn infra-score audit(8 維 score 跌 ≥ 5 / 任何 dim < 80 → silent log,不 inject — 詳 known issue 段) |
58
+ | `stop_harvest_corrections.sh` | 掃 session 的 user 糾正信號寫 `.claude/logs/user-corrections.jsonl` |
59
+ | `stop_capture_metrics.sh` | session 結束 metric snapshot |
60
+
61
+ ### SessionStart
62
+
63
+ | Hook | 做什麼 |
64
+ |------|--------|
65
+ | `session_start_governance_check.sh` | 4 check(行數 / prune / corrections / benchmarks 過期 auto-fetch) |
66
+
67
+ ### UserPromptSubmit
68
+
69
+ | Hook | 做什麼 |
70
+ |------|--------|
71
+ | `inject_pending_self_audit.sh` | 讀 stop_self_audit / stop_meta_self_audit silent log,dedup + 24h filter + 3KB cap,inject 到 next turn additionalContext。修補 Stop hook silent-log 不 inject 的 known issue。 |
72
+
73
+ ### Helper(非註冊 hook)
74
+
75
+ | File | 用途 |
76
+ |------|------|
77
+ | `_log-fire.sh` | 各 hook source 的 fire-logging helper |
78
+
79
+ ## Anti-bloat 落地
80
+
81
+ - **L1 Pre-write**:`check_file_size_budget.sh` + `check_story_invariants.sh`(內含 principles canonical + l3 primitive 等 5 個合一)等(PreToolUse 阻擋 / 警告)
82
+ - **L2 Per-commit**:`log_governance_fires.sh` → `.claude/logs/hook-fires.jsonl`(governance file 編輯軌跡)+ `log_skill_invokes.sh`
83
+ - **L3 Periodic**:`/knowledge-prune` skill 季度跑,retire ≥ 5%
84
+
85
+ ## 這裡**不收**(反例)
86
+
87
+ | 疑似要放這但其實不是 | 實際應去 | 為什麼 |
88
+ |-------------------|---------|--------|
89
+ | 需要 AI 走流程才能判斷的規則 | `.claude/skills/` | hook 只能機械判斷,複雜 workflow 屬 skill |
90
+ | 每 session signal rule | `CLAUDE.md` | hook 是 tool-level,不是 session-level |
91
+ | 單一元件的 lint rule | 該元件 spec + code | hook 是跨元件系統級,單元件屬 spec |
92
+
93
+ ## 新 hook 的 criteria(必須全部通過)
94
+
95
+ 1. **規則可機械判斷**(grep / 條件邏輯,不需人類 judgment)
96
+ 2. **觸發 event 清楚**(PreToolUse / PostToolUse / Stop / SessionStart + matcher)
97
+ 3. **已有明確 tech debt 或 bug class**(不做預防性空守衛)
98
+ 4. **失敗模式安全**(hook 掛掉不會 block 合法操作 / 誤殺)
99
+
100
+ ## 接線到 settings.json
101
+
102
+ 新 hook 必須在 `.claude/settings.json` 的 `hooks.PreToolUse` / `hooks.PostToolUse` / `hooks.Stop` / `hooks.SessionStart` 陣列註冊,並用 `$CLAUDE_PROJECT_DIR` 作為路徑前綴。範例:
103
+
104
+ ```json
105
+ {
106
+ "type": "command",
107
+ "command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/your-hook.sh\""
108
+ }
109
+ ```
110
+
111
+ ## Hook 退出碼約定(Claude Code 協議)
112
+
113
+ - `exit 0` — 正常,不 inject context
114
+ - `exit 2` + stderr — **blocking**,AI 看到 stderr 訊息後必須處理
115
+ - `stdout` with `{"hookSpecificOutput":{"hookEventName":"...","additionalContext":"..."}}` — non-blocking context injection
116
+
117
+ ## 已修(2026-04-28):Stop hook → UserPromptSubmit inject 鏈路
118
+
119
+ **症狀**:Stop hooks(`stop_self_audit` / `stop_meta_self_audit`)silent-log 但不 inject,M14 / M20 的「auto-inject corrective prompt」 不生效 → AI reactive 模式持續。
120
+
121
+ **修法**:加 `inject_pending_self_audit.sh` 註冊在 UserPromptSubmit hook(該 event 確認支援 `hookSpecificOutput.additionalContext`)。鏈路:
122
+
123
+ ```
124
+ turn 結束 Stop event → stop_self_audit / stop_meta_self_audit silent log to .claude/logs/
125
+
126
+ user 下一個 prompt → UserPromptSubmit fires → inject_pending_self_audit.sh
127
+
128
+ 讀 log (since last-inject-ts)
129
+ dedup + 24h filter + 3KB cap
130
+
131
+ inject 給 AI next-turn context
132
+ ```
133
+
134
+ **Self-test**:`bash .claude/hooks/tests/test_inject_pending_self_audit.sh`(5/5 pass)。
135
+
136
+ ## Retired
137
+
138
+ `retired/` 目錄存舊 hook(不再註冊),保留 reference 不刪除。當前已 retire 的 hook 不在本 inventory 列出 — 以 `settings.json` 為 SSOT。
139
+
140
+ 最近 retire(2026-04-28):
141
+ - `check_button_icon_literal.sh` — 違反 Rule-of-3(DS-wide 0 hits,只我 1 次失誤建)
142
+
143
+ ## 建立前必 Read
144
+
145
+ 本 README + 最接近的既有 hook 當範本 + CLAUDE.md `# 治理 canonical` 的 Hook 章節。
@@ -0,0 +1,44 @@
1
+ #!/bin/bash
2
+ # Note: This file is SOURCED by other hooks. Do NOT add `set -u` / `set -e` /
3
+ # `pipefail` here — `source` runs in caller shell and propagates flags,
4
+ # breaking caller code that legitimately reads unset vars (e.g. ${VIOLATIONS}
5
+ # accumulator pattern). Caller hooks set their own flags as standalone scripts.
6
+ #
7
+ # Shared helper: log per-hook fire to .claude/logs/hook-fires-per-hook.jsonl
8
+ #
9
+ # Why: enables /knowledge-prune D2 dead-hook detection(6 月 0 fire → retire 提名)。
10
+ # 各 hook 在 top-of-file source 本檔 + 呼叫 `log_hook_fire`。
11
+ #
12
+ # 與 hook-fires.jsonl 分離:後者記 governance-file edits(tool+path),本 log 記
13
+ # per-hook fire(hook basename+ts)。兩 log 互補不重疊。
14
+ #
15
+ # 規則:silent on failure,不 block hook 執行。
16
+
17
+ log_hook_fire() {
18
+ local hook_name="${1:-$(basename "${BASH_SOURCE[1]:-$0}")}"
19
+ # Resolve project root from this helper's location(stable; cwd may be anywhere
20
+ # depending on how Claude Code invokes the hook)to avoid stray .claude/ trees.
21
+ local _self_dir
22
+ _self_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
23
+ local _resolved_root="${_self_dir%/.claude/hooks}"
24
+ local log_dir="${CLAUDE_PROJECT_DIR:-$_resolved_root}/.claude/logs"
25
+ local log_file="$log_dir/hook-fires-per-hook.jsonl"
26
+
27
+ mkdir -p "$log_dir" 2>/dev/null || return 0
28
+
29
+ # Rotate if > 1 MB
30
+ if [ -f "$log_file" ]; then
31
+ local size
32
+ size=$(wc -c < "$log_file" 2>/dev/null | tr -d ' ')
33
+ if [ -n "$size" ] && [ "$size" -gt 1048576 ]; then
34
+ mv "$log_file" "${log_file}.$(date +%Y%m)" 2>/dev/null || true
35
+ fi
36
+ fi
37
+
38
+ printf '{"ts":"%s","hook":"%s"}\n' \
39
+ "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
40
+ "$hook_name" \
41
+ >> "$log_file" 2>/dev/null || true
42
+ }
43
+
44
+