banhaten 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/CONTRIBUTING.md +44 -0
  3. package/README.md +65 -13
  4. package/SECURITY.md +15 -0
  5. package/banhaten.config.example.json +0 -2
  6. package/docs/design-system/README.md +9 -0
  7. package/docs/design-system/adoption-quality-remediation.md +87 -0
  8. package/docs/design-system/agent-usage.md +13 -0
  9. package/docs/design-system/appearance-presets.md +6 -1
  10. package/docs/design-system/component-docs-pattern.md +81 -0
  11. package/docs/design-system/component-token-consistency-audit.md +13 -3
  12. package/docs/design-system/components/README.md +3 -2
  13. package/docs/design-system/components/accordion.md +16 -0
  14. package/docs/design-system/components/activity-feed.md +15 -1
  15. package/docs/design-system/components/alert-dialog.md +17 -0
  16. package/docs/design-system/components/alert.md +46 -14
  17. package/docs/design-system/components/aspect-ratio.md +15 -0
  18. package/docs/design-system/components/attribute.md +16 -0
  19. package/docs/design-system/components/autocomplete.md +19 -0
  20. package/docs/design-system/components/avatar.md +18 -0
  21. package/docs/design-system/components/badge.md +19 -0
  22. package/docs/design-system/components/banner.md +15 -1
  23. package/docs/design-system/components/breadcrumbs.md +14 -0
  24. package/docs/design-system/components/button-group.md +34 -0
  25. package/docs/design-system/components/button.md +18 -0
  26. package/docs/design-system/components/card.md +18 -1
  27. package/docs/design-system/components/carousel.md +20 -3
  28. package/docs/design-system/components/catalog-components.md +15 -1
  29. package/docs/design-system/components/chart.md +15 -0
  30. package/docs/design-system/components/checkbox.md +16 -0
  31. package/docs/design-system/components/collapsible.md +15 -0
  32. package/docs/design-system/components/command.md +15 -0
  33. package/docs/design-system/components/context-menu.md +15 -0
  34. package/docs/design-system/components/date-picker.md +21 -1
  35. package/docs/design-system/components/divider.md +16 -0
  36. package/docs/design-system/components/empty-state.md +17 -0
  37. package/docs/design-system/components/field.md +17 -0
  38. package/docs/design-system/components/file-upload.md +14 -0
  39. package/docs/design-system/components/hover-card.md +15 -0
  40. package/docs/design-system/components/input-group.md +17 -0
  41. package/docs/design-system/components/input-otp.md +18 -0
  42. package/docs/design-system/components/input.md +43 -7
  43. package/docs/design-system/components/item.md +72 -0
  44. package/docs/design-system/components/kbd.md +18 -0
  45. package/docs/design-system/components/label.md +16 -0
  46. package/docs/design-system/components/menu.md +17 -0
  47. package/docs/design-system/components/menubar.md +15 -0
  48. package/docs/design-system/components/modal.md +25 -4
  49. package/docs/design-system/components/native-select.md +18 -0
  50. package/docs/design-system/components/navigation-menu.md +15 -0
  51. package/docs/design-system/components/onboarding-step-list-item.md +15 -1
  52. package/docs/design-system/components/page-header.md +15 -1
  53. package/docs/design-system/components/pagination.md +30 -8
  54. package/docs/design-system/components/popover.md +19 -0
  55. package/docs/design-system/components/progress-slider.md +18 -0
  56. package/docs/design-system/components/progress.md +17 -0
  57. package/docs/design-system/components/radio-card.md +16 -0
  58. package/docs/design-system/components/radio-group.md +17 -0
  59. package/docs/design-system/components/resizable.md +15 -0
  60. package/docs/design-system/components/scroll-area.md +15 -0
  61. package/docs/design-system/components/segmented-control.md +71 -0
  62. package/docs/design-system/components/select.md +44 -7
  63. package/docs/design-system/components/sheet.md +17 -0
  64. package/docs/design-system/components/sidebar.md +15 -0
  65. package/docs/design-system/components/skeleton.md +18 -0
  66. package/docs/design-system/components/slideout.md +14 -0
  67. package/docs/design-system/components/slider.md +20 -0
  68. package/docs/design-system/components/social-button.md +21 -3
  69. package/docs/design-system/components/spinner.md +16 -0
  70. package/docs/design-system/components/steps.md +14 -0
  71. package/docs/design-system/components/table.md +15 -1
  72. package/docs/design-system/components/tabs.md +17 -0
  73. package/docs/design-system/components/tag.md +17 -0
  74. package/docs/design-system/components/textarea.md +16 -0
  75. package/docs/design-system/components/timeline.md +14 -0
  76. package/docs/design-system/components/toast.md +17 -0
  77. package/docs/design-system/components/toggle.md +17 -0
  78. package/docs/design-system/components/toolbar.md +21 -1
  79. package/docs/design-system/components/tooltip.md +18 -1
  80. package/docs/design-system/density-and-elevation.md +44 -0
  81. package/docs/design-system/direction-and-localization.md +23 -0
  82. package/docs/design-system/form-recipes.md +73 -0
  83. package/docs/design-system/gap-promotion-policy.md +21 -0
  84. package/docs/design-system/gap-promotion-report.md +166 -0
  85. package/docs/design-system/installation.md +68 -0
  86. package/docs/design-system/launch-comparison-shadcn.md +98 -0
  87. package/docs/design-system/registry-and-cli.md +30 -7
  88. package/docs/design-system/release-policy.md +30 -0
  89. package/docs/design-system/roadmap.md +14 -0
  90. package/docs/design-system/support-matrix.md +23 -0
  91. package/docs/design-system/tabs.md +1 -1
  92. package/docs/design-system/token-governance.md +23 -1
  93. package/package.json +29 -15
  94. package/registry/component-contract.json +40 -0
  95. package/registry/components/alert-dialog.tsx +1 -1
  96. package/registry/components/alert.tsx +86 -65
  97. package/registry/components/autocomplete.tsx +23 -9
  98. package/registry/components/avatar.tsx +7 -7
  99. package/registry/components/badge.tsx +1 -1
  100. package/registry/components/button-group.tsx +321 -4
  101. package/registry/components/button.tsx +38 -17
  102. package/registry/components/card.tsx +68 -59
  103. package/registry/components/carousel.tsx +53 -5
  104. package/registry/components/chart.tsx +36 -3
  105. package/registry/components/checkbox.tsx +3 -3
  106. package/registry/components/collapsible.tsx +1 -1
  107. package/registry/components/command.tsx +1 -1
  108. package/registry/components/context-menu.tsx +1 -1
  109. package/registry/components/date-picker.tsx +245 -104
  110. package/registry/components/expanded/ActivityFeed.tsx +6 -15
  111. package/registry/components/expanded/Banner.tsx +3 -3
  112. package/registry/components/expanded/Breadcrumbs.tsx +5 -5
  113. package/registry/components/expanded/CatalogComponentsShowcase.tsx +13 -13
  114. package/registry/components/expanded/CatalogDivider.tsx +1 -1
  115. package/registry/components/expanded/EmptyState.tsx +1 -1
  116. package/registry/components/expanded/FileUpload.tsx +9 -2
  117. package/registry/components/expanded/OnboardingStepListItem.tsx +2 -4
  118. package/registry/components/expanded/PageHeader.tsx +13 -13
  119. package/registry/components/expanded/Slideout.tsx +15 -415
  120. package/registry/components/expanded/Steps.tsx +4 -4
  121. package/registry/components/expanded/Table.tsx +116 -69
  122. package/registry/components/expanded/Timeline.tsx +3 -3
  123. package/registry/components/expanded/activityFeed.css +1 -1
  124. package/registry/components/expanded/breadcrumbs.css +1 -1
  125. package/registry/components/expanded/divider.css +1 -1
  126. package/registry/components/expanded/emptyState.css +1 -1
  127. package/registry/components/expanded/fileUpload.css +6 -6
  128. package/registry/components/expanded/slideout.css +9 -685
  129. package/registry/components/expanded/steps.css +3 -3
  130. package/registry/components/expanded/table.css +2 -2
  131. package/registry/components/expanded/timeline.css +2 -2
  132. package/registry/components/input-content.ts +1 -0
  133. package/registry/components/input-otp.tsx +13 -3
  134. package/registry/components/input.tsx +68 -43
  135. package/registry/components/item.tsx +189 -0
  136. package/registry/components/kbd.tsx +111 -4
  137. package/registry/components/menu.tsx +31 -245
  138. package/registry/components/menubar.tsx +1 -1
  139. package/registry/components/modal.tsx +142 -102
  140. package/registry/components/native-select.tsx +2 -2
  141. package/registry/components/pagination.tsx +80 -58
  142. package/registry/components/popover.tsx +162 -664
  143. package/registry/components/radio-card.tsx +116 -87
  144. package/registry/components/segmented-control.tsx +87 -0
  145. package/registry/components/select-content.tsx +2 -2
  146. package/registry/components/select.tsx +52 -16
  147. package/registry/components/sheet.tsx +1 -1
  148. package/registry/components/sidebar.tsx +1 -1
  149. package/registry/components/skeleton.css +0 -3
  150. package/registry/components/social-button.tsx +47 -25
  151. package/registry/components/spinner.tsx +18 -55
  152. package/registry/components/tabs.css +1 -1
  153. package/registry/components/tabs.tsx +8 -4
  154. package/registry/components/tag.tsx +2 -2
  155. package/registry/components/textarea.tsx +3 -3
  156. package/registry/components/toast.tsx +16 -11
  157. package/registry/components/toggle.tsx +2 -2
  158. package/registry/components/toolbar.tsx +89 -17
  159. package/registry/components/tooltip.tsx +1 -1
  160. package/registry/examples/alert-demo.tsx +25 -5
  161. package/registry/examples/attribute-demo.tsx +1 -1
  162. package/registry/examples/autocomplete-demo.tsx +3 -3
  163. package/registry/examples/avatar-demo.tsx +7 -7
  164. package/registry/examples/badge-demo.tsx +1 -1
  165. package/registry/examples/button-demo.tsx +6 -6
  166. package/registry/examples/button-group-demo.tsx +23 -2
  167. package/registry/examples/card-demo.tsx +46 -8
  168. package/registry/examples/carousel-demo.tsx +20 -2
  169. package/registry/examples/chart-demo.tsx +1 -1
  170. package/registry/examples/checkbox-demo.tsx +5 -5
  171. package/registry/examples/collection-filter-bar-demo.tsx +135 -0
  172. package/registry/examples/command-demo.tsx +3 -3
  173. package/registry/examples/{expanded/command-bar-demo.tsx → command-palette-demo.tsx} +5 -15
  174. package/registry/examples/context-menu-demo.tsx +1 -1
  175. package/registry/examples/control-density-contract-demo.tsx +61 -0
  176. package/registry/examples/date-picker-demo.tsx +12 -12
  177. package/registry/examples/divider-demo.tsx +3 -3
  178. package/registry/examples/expanded/banner-demo.tsx +1 -1
  179. package/registry/examples/expanded/breadcrumbs-demo.tsx +1 -1
  180. package/registry/examples/expanded/empty-state-demo.tsx +1 -1
  181. package/registry/examples/expanded/file-upload-demo.tsx +1 -1
  182. package/registry/examples/expanded/onboarding-step-demo.tsx +1 -1
  183. package/registry/examples/expanded/slideout-demo.tsx +2 -2
  184. package/registry/examples/expanded/steps-demo.tsx +1 -1
  185. package/registry/examples/expanded/tabs-demo.tsx +1 -1
  186. package/registry/examples/expanded/timeline-demo.tsx +1 -1
  187. package/registry/examples/hover-card-demo.tsx +2 -2
  188. package/registry/examples/input-demo.tsx +6 -6
  189. package/registry/examples/input-otp-demo.tsx +4 -4
  190. package/registry/examples/item-demo.tsx +46 -0
  191. package/registry/examples/kbd-demo.tsx +1 -1
  192. package/registry/examples/label-demo.tsx +1 -1
  193. package/registry/examples/menu-demo.tsx +1 -1
  194. package/registry/examples/modal-demo.tsx +67 -9
  195. package/registry/examples/navigation-menu-demo.tsx +1 -1
  196. package/registry/examples/pagination-demo.tsx +6 -3
  197. package/registry/examples/popover-demo.tsx +19 -19
  198. package/registry/examples/progress-demo.tsx +1 -1
  199. package/registry/examples/progress-slider-demo.tsx +1 -1
  200. package/registry/examples/radio-card-demo.tsx +4 -4
  201. package/registry/examples/radio-group-demo.tsx +2 -2
  202. package/registry/examples/resizable-demo.tsx +1 -1
  203. package/registry/examples/results-toolbar-demo.tsx +44 -0
  204. package/registry/examples/scroll-area-demo.tsx +3 -3
  205. package/registry/examples/segmented-control-demo.tsx +39 -0
  206. package/registry/examples/select-demo.tsx +1 -1
  207. package/registry/examples/sidebar-demo.tsx +1 -1
  208. package/registry/examples/slider-demo.tsx +3 -3
  209. package/registry/examples/social-button-demo.tsx +18 -8
  210. package/registry/examples/spinner-demo.tsx +13 -13
  211. package/registry/examples/tabs-demo.tsx +1 -1
  212. package/registry/examples/tag-demo.tsx +1 -1
  213. package/registry/examples/textarea-demo.tsx +4 -4
  214. package/registry/examples/toast-demo.tsx +1 -1
  215. package/registry/examples/toggle-demo.tsx +6 -6
  216. package/registry/examples/tooltip-demo.tsx +4 -4
  217. package/registry/guidance/USAGE.md +27 -0
  218. package/registry/hooks/use-direction.ts +193 -13
  219. package/registry/index.json +5311 -377
  220. package/registry/styles/globals.css +2440 -4061
  221. package/registry.json +119 -149
  222. package/schema/config.schema.json +11 -8
  223. package/schema/registry.schema.json +150 -45
  224. package/schema/tokens.schema.json +134 -34
  225. package/src/cli/command-line.js +194 -0
  226. package/src/cli/config-editors.js +9 -0
  227. package/src/cli/doctor.js +399 -0
  228. package/src/cli/file-transaction.js +295 -0
  229. package/src/cli/global-css.js +153 -0
  230. package/src/cli/index.js +567 -1613
  231. package/src/cli/install-plan.js +592 -0
  232. package/src/cli/install-receipt.js +171 -0
  233. package/src/cli/jsonc.js +203 -0
  234. package/src/cli/package-install-state.js +254 -0
  235. package/src/cli/package-manager.js +238 -0
  236. package/src/cli/package-plan.js +185 -0
  237. package/src/cli/package-version.js +97 -0
  238. package/src/cli/registry-query.js +207 -0
  239. package/src/cli/reporting.js +55 -0
  240. package/src/cli/schema-validation.js +19 -0
  241. package/src/cli/source-scanner.js +686 -0
  242. package/src/cli/vite-config.js +478 -0
  243. package/tokens/banhaten.tokens.json +4312 -309
  244. package/docs/design-system/components/command-bar.md +0 -57
  245. package/registry/components/expanded/BannerBoard.tsx +0 -225
  246. package/registry/components/expanded/CatalogTag.tsx +0 -85
  247. package/registry/components/expanded/CommandBar.tsx +0 -386
  248. package/registry/components/expanded/IconExplorer.tsx +0 -612
  249. package/registry/components/expanded/TimelineShowcase.tsx +0 -158
  250. package/registry/components/expanded/commandBar.css +0 -470
  251. package/registry/components/expanded/iconExplorer.css +0 -764
  252. package/registry/components/expanded/iconPacks.ts +0 -866
  253. package/registry/components/expanded/tag.css +0 -148
  254. package/registry/examples/expanded/icons-demo.tsx +0 -5
  255. package/tokens/Color mode.zip +0 -0
  256. package/tokens/Numbers.zip +0 -0
  257. package/tokens/Radius.zip +0 -0
  258. package/tokens/Theme.zip +0 -0
@@ -6,80 +6,185 @@
6
6
  "required": ["name", "base", "components"],
7
7
  "additionalProperties": false,
8
8
  "properties": {
9
- "$schema": {
10
- "type": "string"
11
- },
12
- "name": {
13
- "type": "string"
14
- },
15
- "base": {
16
- "$ref": "#/$defs/registryEntry"
17
- },
9
+ "$schema": { "type": "string" },
10
+ "name": { "type": "string", "minLength": 1 },
11
+ "base": { "$ref": "#/$defs/baseEntry" },
18
12
  "components": {
19
13
  "type": "object",
20
- "additionalProperties": {
21
- "$ref": "#/$defs/registryEntry"
22
- }
14
+ "minProperties": 1,
15
+ "additionalProperties": { "$ref": "#/$defs/componentEntry" }
23
16
  }
24
17
  },
25
18
  "$defs": {
26
- "registryEntry": {
19
+ "baseEntry": {
27
20
  "type": "object",
28
- "additionalProperties": true,
21
+ "required": ["dependencies", "files"],
22
+ "additionalProperties": false,
29
23
  "properties": {
30
- "description": {
31
- "type": "string"
32
- },
33
- "dependencies": {
34
- "type": "object",
35
- "additionalProperties": {
36
- "type": "string"
37
- }
38
- },
39
- "registryDependencies": {
24
+ "dependencies": { "$ref": "#/$defs/dependencies" },
25
+ "files": {
40
26
  "type": "array",
41
- "items": {
42
- "type": "string"
43
- }
44
- },
27
+ "minItems": 1,
28
+ "items": { "$ref": "#/$defs/registryFile" }
29
+ }
30
+ }
31
+ },
32
+ "componentEntry": {
33
+ "type": "object",
34
+ "required": [
35
+ "description",
36
+ "dependencies",
37
+ "parts",
38
+ "supportedExports",
39
+ "files",
40
+ "examples"
41
+ ],
42
+ "additionalProperties": false,
43
+ "properties": {
44
+ "description": { "type": "string", "minLength": 1 },
45
+ "status": { "enum": ["expanded"] },
46
+ "dependencies": { "$ref": "#/$defs/dependencies" },
47
+ "registryDependencies": { "$ref": "#/$defs/stringArray" },
45
48
  "parts": {
49
+ "description": "Ordered, non-exhaustive component anatomy. The first value is the primary renderable part; every value must also appear in supportedExports.",
46
50
  "type": "array",
47
- "items": {
48
- "type": "string"
49
- }
51
+ "minItems": 1,
52
+ "uniqueItems": true,
53
+ "items": { "$ref": "#/$defs/componentPartName" }
54
+ },
55
+ "supportedExports": {
56
+ "description": "Exhaustive runtime value exports, grouped by the installed source module that owns each import path. Type-only exports are intentionally excluded.",
57
+ "type": "array",
58
+ "minItems": 1,
59
+ "uniqueItems": true,
60
+ "items": { "$ref": "#/$defs/supportedExportModule" }
50
61
  },
51
62
  "files": {
52
63
  "type": "array",
53
- "items": {
54
- "$ref": "#/$defs/registryFile"
55
- }
64
+ "minItems": 1,
65
+ "items": { "$ref": "#/$defs/registryFile" }
56
66
  },
57
67
  "examples": {
58
68
  "type": "array",
59
- "items": {
60
- "type": "string"
61
- }
69
+ "minItems": 1,
70
+ "items": { "type": "string", "minLength": 1 }
62
71
  },
63
- "rtl": {
72
+ "props": {
73
+ "description": "Machine-readable public prop behavior, including rendered defaults for optional visual slots.",
74
+ "type": "object",
75
+ "minProperties": 1,
76
+ "additionalProperties": { "$ref": "#/$defs/componentProp" }
77
+ },
78
+ "defaults": {
79
+ "description": "Explicit defaults for array-valued capabilities. Keys must name a capability on the same component and values must belong to that capability list.",
64
80
  "type": "object",
81
+ "minProperties": 1,
65
82
  "additionalProperties": {
66
- "type": ["string", "boolean"]
83
+ "type": ["string", "number", "boolean", "null"]
67
84
  }
68
- }
85
+ },
86
+ "recommendedFor": { "$ref": "#/$defs/stringArray" },
87
+ "avoidWhen": { "$ref": "#/$defs/stringArray" },
88
+ "recipes": { "$ref": "#/$defs/stringArray" },
89
+ "rtl": {
90
+ "type": "object",
91
+ "minProperties": 1,
92
+ "additionalProperties": { "type": ["string", "boolean"] }
93
+ },
94
+ "actions": { "$ref": "#/$defs/stringArray" },
95
+ "alignments": { "$ref": "#/$defs/stringArray" },
96
+ "breakpoints": { "$ref": "#/$defs/stringArray" },
97
+ "cardPositions": { "$ref": "#/$defs/stringArray" },
98
+ "colors": { "$ref": "#/$defs/stringArray" },
99
+ "controlPositions": { "$ref": "#/$defs/stringArray" },
100
+ "densities": { "$ref": "#/$defs/stringArray" },
101
+ "directions": { "$ref": "#/$defs/stringArray" },
102
+ "features": { "$ref": "#/$defs/stringArray" },
103
+ "forms": { "$ref": "#/$defs/stringArray" },
104
+ "indicators": { "$ref": "#/$defs/stringArray" },
105
+ "intents": { "$ref": "#/$defs/stringArray" },
106
+ "itemKinds": { "$ref": "#/$defs/stringArray" },
107
+ "itemTypes": { "$ref": "#/$defs/stringArray" },
108
+ "kinds": { "$ref": "#/$defs/stringArray" },
109
+ "labelPositions": { "$ref": "#/$defs/stringArray" },
110
+ "layouts": { "$ref": "#/$defs/stringArray" },
111
+ "modes": { "$ref": "#/$defs/stringArray" },
112
+ "offsets": { "$ref": "#/$defs/stringArray" },
113
+ "options": { "$ref": "#/$defs/stringArray" },
114
+ "orientations": { "$ref": "#/$defs/stringArray" },
115
+ "platforms": { "$ref": "#/$defs/stringArray" },
116
+ "pointerPositions": { "$ref": "#/$defs/stringArray" },
117
+ "selectionTypes": { "$ref": "#/$defs/stringArray" },
118
+ "shapes": { "$ref": "#/$defs/stringArray" },
119
+ "sides": { "$ref": "#/$defs/stringArray" },
120
+ "sizes": { "$ref": "#/$defs/stringArray" },
121
+ "states": { "$ref": "#/$defs/stringArray" },
122
+ "statusColors": { "$ref": "#/$defs/stringArray" },
123
+ "styles": { "$ref": "#/$defs/stringArray" },
124
+ "tokens": { "$ref": "#/$defs/stringArray" },
125
+ "tones": { "$ref": "#/$defs/stringArray" },
126
+ "types": { "$ref": "#/$defs/stringArray" },
127
+ "valueModes": { "$ref": "#/$defs/stringArray" },
128
+ "variants": { "$ref": "#/$defs/stringArray" },
129
+ "widths": { "$ref": "#/$defs/stringArray" }
69
130
  }
70
131
  },
71
- "registryFile": {
132
+ "dependencies": {
72
133
  "type": "object",
73
- "required": ["source", "target"],
134
+ "additionalProperties": { "type": "string", "minLength": 1 }
135
+ },
136
+ "stringArray": {
137
+ "type": "array",
138
+ "uniqueItems": true,
139
+ "items": { "type": "string", "minLength": 1 }
140
+ },
141
+ "exportName": {
142
+ "type": "string",
143
+ "pattern": "^[A-Za-z_$][A-Za-z0-9_$]*$"
144
+ },
145
+ "componentPartName": {
146
+ "type": "string",
147
+ "pattern": "^[A-Z][A-Za-z0-9_$]*$"
148
+ },
149
+ "componentProp": {
150
+ "type": "object",
151
+ "required": ["type", "default", "description"],
152
+ "additionalProperties": false,
153
+ "properties": {
154
+ "type": { "type": "string", "minLength": 1 },
155
+ "default": {
156
+ "type": ["string", "number", "boolean", "null"]
157
+ },
158
+ "description": { "type": "string", "minLength": 1 },
159
+ "deprecated": { "type": "boolean" }
160
+ }
161
+ },
162
+ "supportedExportModule": {
163
+ "type": "object",
164
+ "required": ["source", "values"],
74
165
  "additionalProperties": false,
75
166
  "properties": {
76
167
  "source": {
77
- "type": "string"
168
+ "description": "Exact TypeScript source path from this component's files array.",
169
+ "type": "string",
170
+ "pattern": "^(?!.*\\.d\\.[cm]?[jt]sx?$).+\\.[cm]?[jt]sx?$"
78
171
  },
79
- "target": {
80
- "type": "string"
172
+ "values": {
173
+ "type": "array",
174
+ "minItems": 1,
175
+ "uniqueItems": true,
176
+ "items": { "$ref": "#/$defs/exportName" }
81
177
  }
82
178
  }
179
+ },
180
+ "registryFile": {
181
+ "type": "object",
182
+ "required": ["source", "target"],
183
+ "additionalProperties": false,
184
+ "properties": {
185
+ "source": { "type": "string", "minLength": 1 },
186
+ "target": { "type": "string", "minLength": 1 }
187
+ }
83
188
  }
84
189
  }
85
190
  }
@@ -3,61 +3,161 @@
3
3
  "$id": "urn:banhaten:schema:tokens",
4
4
  "title": "Banhaten design tokens",
5
5
  "type": "object",
6
- "required": ["name", "sourceStatus", "sourceFiles", "modes", "cssContract", "tokens"],
6
+ "required": ["name", "sourceStatus", "sourceFiles", "provenance", "modes", "cssContract", "tokens", "cssVariables"],
7
7
  "additionalProperties": false,
8
8
  "properties": {
9
- "$schema": {
10
- "type": "string"
11
- },
12
- "name": {
13
- "type": "string"
14
- },
15
- "sourceStatus": {
16
- "type": "string"
17
- },
9
+ "$schema": { "type": "string" },
10
+ "name": { "type": "string", "minLength": 1 },
11
+ "sourceStatus": { "const": "manually-curated-from-reference-archives" },
18
12
  "sourceFiles": {
19
13
  "type": "array",
20
- "items": {
21
- "type": "string"
14
+ "minItems": 1,
15
+ "uniqueItems": true,
16
+ "items": { "type": "string", "minLength": 1 }
17
+ },
18
+ "provenance": {
19
+ "type": "object",
20
+ "required": ["method", "lastReviewed", "themeSources", "notes"],
21
+ "additionalProperties": false,
22
+ "properties": {
23
+ "method": { "type": "string", "minLength": 1 },
24
+ "lastReviewed": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
25
+ "themeSources": {
26
+ "type": "object",
27
+ "minProperties": 1,
28
+ "additionalProperties": { "type": "string", "minLength": 1 }
29
+ },
30
+ "notes": {
31
+ "type": "array",
32
+ "minItems": 1,
33
+ "items": { "type": "string", "minLength": 1 }
34
+ }
22
35
  }
23
36
  },
24
37
  "modes": {
25
38
  "type": "object",
26
- "additionalProperties": {
27
- "type": "array",
28
- "items": {
29
- "type": "string"
30
- }
39
+ "required": ["color", "theme", "radius", "numbers"],
40
+ "additionalProperties": false,
41
+ "properties": {
42
+ "color": { "$ref": "#/$defs/stringArray" },
43
+ "theme": { "$ref": "#/$defs/stringArray" },
44
+ "radius": { "$ref": "#/$defs/stringArray" },
45
+ "numbers": { "$ref": "#/$defs/stringArray" }
31
46
  }
32
47
  },
33
48
  "cssContract": {
34
49
  "type": "object",
35
- "required": ["semanticPrefix", "fontFamily", "defaultTheme", "defaultRadius"],
36
- "additionalProperties": true,
50
+ "required": ["semanticPrefix", "fontFamily", "fontFamilies", "defaultTheme", "defaultNeutralTheme", "defaultRadius", "shadcnAliases", "shadowTokens"],
51
+ "additionalProperties": false,
37
52
  "properties": {
38
- "semanticPrefix": {
39
- "type": "string"
40
- },
41
- "fontFamily": {
42
- "type": "string"
43
- },
44
- "defaultTheme": {
45
- "type": "string"
46
- },
47
- "defaultRadius": {
48
- "type": "string"
53
+ "semanticPrefix": { "type": "string", "minLength": 1 },
54
+ "fontFamily": { "type": "string", "minLength": 1 },
55
+ "fontFamilies": {
56
+ "type": "object",
57
+ "required": ["english", "arabic", "fallback"],
58
+ "additionalProperties": false,
59
+ "properties": {
60
+ "english": { "type": "string", "minLength": 1 },
61
+ "arabic": { "type": "string", "minLength": 1 },
62
+ "fallback": { "type": "string", "minLength": 1 }
63
+ }
49
64
  },
65
+ "defaultTheme": { "type": "string", "minLength": 1 },
66
+ "defaultNeutralTheme": { "type": "string", "minLength": 1 },
67
+ "defaultRadius": { "type": "string", "minLength": 1 },
68
+ "shadowTokens": { "type": "string" },
50
69
  "shadcnAliases": {
51
70
  "type": "object",
52
- "additionalProperties": {
53
- "type": "string"
54
- }
71
+ "minProperties": 1,
72
+ "additionalProperties": { "type": "string", "pattern": "^--" }
55
73
  }
56
74
  }
57
75
  },
58
76
  "tokens": {
59
77
  "type": "object",
60
- "additionalProperties": true
78
+ "required": ["colorMode", "theme", "numbers", "radius"],
79
+ "additionalProperties": false,
80
+ "properties": {
81
+ "colorMode": { "$ref": "#/$defs/modeTokenMaps" },
82
+ "theme": { "$ref": "#/$defs/modeTokenMaps" },
83
+ "numbers": { "$ref": "#/$defs/tokenMap" },
84
+ "radius": { "$ref": "#/$defs/modeTokenMaps" }
85
+ }
86
+ },
87
+ "cssVariables": {
88
+ "type": "object",
89
+ "required": ["system", "typography", "effects", "components", "darkEffects", "scopedAliases"],
90
+ "additionalProperties": false,
91
+ "properties": {
92
+ "system": { "$ref": "#/$defs/cssVariableMap" },
93
+ "typography": { "$ref": "#/$defs/cssVariableMap" },
94
+ "effects": { "$ref": "#/$defs/cssVariableMap" },
95
+ "components": { "$ref": "#/$defs/cssVariableMap" },
96
+ "darkEffects": { "$ref": "#/$defs/cssVariableMap" },
97
+ "scopedAliases": { "$ref": "#/$defs/cssVariableMap" }
98
+ }
99
+ }
100
+ },
101
+ "$defs": {
102
+ "stringArray": {
103
+ "type": "array",
104
+ "minItems": 1,
105
+ "uniqueItems": true,
106
+ "items": { "type": "string", "minLength": 1 }
107
+ },
108
+ "modeTokenMaps": {
109
+ "type": "object",
110
+ "minProperties": 1,
111
+ "additionalProperties": { "$ref": "#/$defs/tokenMap" }
112
+ },
113
+ "tokenMap": {
114
+ "type": "object",
115
+ "minProperties": 1,
116
+ "additionalProperties": { "$ref": "#/$defs/token" }
117
+ },
118
+ "token": {
119
+ "oneOf": [
120
+ {
121
+ "type": "object",
122
+ "required": ["type", "value"],
123
+ "additionalProperties": false,
124
+ "properties": {
125
+ "type": { "const": "color" },
126
+ "value": {
127
+ "type": "string",
128
+ "pattern": "^(?:#[0-9A-Fa-f]{6,8}|rgb\\([^\\n]+\\))$"
129
+ },
130
+ "alias": { "type": ["string", "null"], "minLength": 1 }
131
+ }
132
+ },
133
+ {
134
+ "type": "object",
135
+ "required": ["type", "value"],
136
+ "additionalProperties": false,
137
+ "properties": {
138
+ "type": { "const": "number" },
139
+ "value": { "type": "number" },
140
+ "alias": { "type": ["string", "null"], "minLength": 1 }
141
+ }
142
+ }
143
+ ]
144
+ },
145
+ "cssVariableMap": {
146
+ "type": "object",
147
+ "minProperties": 1,
148
+ "propertyNames": { "pattern": "^--(?:bh|shadow)-[a-z0-9-]+$" },
149
+ "additionalProperties": { "$ref": "#/$defs/cssVariableToken" }
150
+ },
151
+ "cssVariableToken": {
152
+ "type": "object",
153
+ "required": ["type", "value"],
154
+ "additionalProperties": false,
155
+ "properties": {
156
+ "type": {
157
+ "enum": ["alias", "cubicBezier", "dimension", "duration", "number", "shadow", "string"]
158
+ },
159
+ "value": { "type": "string", "minLength": 1 }
160
+ }
61
161
  }
62
162
  }
63
163
  }
@@ -0,0 +1,194 @@
1
+ import { parseArgs as parseNodeArgs } from "node:util"
2
+
3
+ const OPTION_DEFINITIONS = {
4
+ cwd: { type: "string" },
5
+ file: { type: "string" },
6
+ "dry-run": { type: "boolean" },
7
+ force: { type: "boolean" },
8
+ help: { type: "boolean", short: "h" },
9
+ json: { type: "boolean" },
10
+ silent: { type: "boolean", short: "s" },
11
+ version: { type: "boolean", short: "v" },
12
+ yes: { type: "boolean", short: "y" },
13
+ }
14
+
15
+ const GLOBAL_OPTIONS = ["help", "silent", "version", "yes"]
16
+
17
+ const COMMAND_SCHEMAS = {
18
+ add: commandSchema({
19
+ minPositionals: 1,
20
+ maxPositionals: Number.POSITIVE_INFINITY,
21
+ options: ["cwd", "dry-run", "force", "json"],
22
+ }),
23
+ diff: commandSchema({
24
+ maxPositionals: Number.POSITIVE_INFINITY,
25
+ options: ["cwd", "json"],
26
+ }),
27
+ docs: commandSchema({
28
+ minPositionals: 1,
29
+ maxPositionals: 1,
30
+ options: ["json"],
31
+ }),
32
+ doctor: commandSchema({
33
+ maxPositionals: 0,
34
+ options: ["cwd", "json"],
35
+ }),
36
+ help: commandSchema(),
37
+ init: commandSchema({
38
+ maxPositionals: 0,
39
+ options: ["cwd", "dry-run", "force", "json"],
40
+ }),
41
+ list: commandSchema({ maxPositionals: 0, options: ["json"] }),
42
+ search: commandSchema({
43
+ minPositionals: 1,
44
+ maxPositionals: Number.POSITIVE_INFINITY,
45
+ options: ["json"],
46
+ }),
47
+ update: commandSchema({
48
+ maxPositionals: Number.POSITIVE_INFINITY,
49
+ options: ["cwd", "dry-run", "force", "json"],
50
+ }),
51
+ version: commandSchema({ maxPositionals: 0 }),
52
+ view: commandSchema({
53
+ minPositionals: 1,
54
+ maxPositionals: 1,
55
+ options: ["file", "json"],
56
+ }),
57
+ }
58
+
59
+ export function parseCommandLine(argv) {
60
+ let parsed
61
+
62
+ try {
63
+ parsed = parseNodeArgs({
64
+ allowPositionals: true,
65
+ args: argv,
66
+ options: OPTION_DEFINITIONS,
67
+ strict: true,
68
+ tokens: true,
69
+ })
70
+ } catch (error) {
71
+ throw new Error(normalizeParseError(error))
72
+ }
73
+
74
+ assertNoDuplicateOptions(parsed.tokens)
75
+ assertNonEmptyValueOptions(parsed.values)
76
+
77
+ const [command, ...positionals] = parsed.positionals
78
+ const flags = { ...parsed.values }
79
+
80
+ if (command === undefined) {
81
+ assertRootOptions(flags)
82
+ return { command: undefined, flags, positionals }
83
+ }
84
+
85
+ const schema = COMMAND_SCHEMAS[command]
86
+ if (!schema) {
87
+ throw new Error(`unknown command "${command}"`)
88
+ }
89
+
90
+ assertAllowedOptions(command, flags, schema)
91
+
92
+ if (!flags.help && !flags.version) {
93
+ assertPositionalCount(command, positionals, schema)
94
+ }
95
+
96
+ return { command, flags, positionals }
97
+ }
98
+
99
+ function commandSchema({
100
+ minPositionals = 0,
101
+ maxPositionals = 0,
102
+ options = [],
103
+ } = {}) {
104
+ return {
105
+ minPositionals,
106
+ maxPositionals,
107
+ options: new Set([...GLOBAL_OPTIONS, ...options]),
108
+ }
109
+ }
110
+
111
+ function assertRootOptions(flags) {
112
+ const allowed = new Set(GLOBAL_OPTIONS)
113
+ for (const name of Object.keys(flags)) {
114
+ if (!allowed.has(name)) {
115
+ throw new Error(`option "--${name}" requires a command`)
116
+ }
117
+ }
118
+ }
119
+
120
+ function assertAllowedOptions(command, flags, schema) {
121
+ for (const name of Object.keys(flags)) {
122
+ if (!schema.options.has(name)) {
123
+ throw new Error(`option "--${name}" is not valid for command "${command}"`)
124
+ }
125
+ }
126
+ }
127
+
128
+ function assertPositionalCount(command, positionals, schema) {
129
+ if (positionals.length < schema.minPositionals) {
130
+ if (command === "add") {
131
+ throw new Error("missing component name. Try `banhaten add button`.")
132
+ }
133
+ if (command === "search") {
134
+ throw new Error("missing search query. Try `banhaten search input`.")
135
+ }
136
+ throw new Error(
137
+ `missing argument for command "${command}"`
138
+ )
139
+ }
140
+
141
+ if (positionals.length > schema.maxPositionals) {
142
+ const unexpected = positionals[schema.maxPositionals]
143
+ throw new Error(
144
+ `unexpected argument "${unexpected}" for command "${command}"`
145
+ )
146
+ }
147
+ }
148
+
149
+ function assertNoDuplicateOptions(tokens) {
150
+ const seen = new Set()
151
+
152
+ for (const token of tokens) {
153
+ if (token.kind !== "option") continue
154
+ if (seen.has(token.name)) {
155
+ throw new Error(`option "--${token.name}" was provided more than once`)
156
+ }
157
+ seen.add(token.name)
158
+ }
159
+ }
160
+
161
+ function assertNonEmptyValueOptions(values) {
162
+ for (const name of ["cwd", "file"]) {
163
+ if (name in values && values[name].trim() === "") {
164
+ throw new Error(`option "--${name}" requires a non-empty value`)
165
+ }
166
+ }
167
+ }
168
+
169
+ function normalizeParseError(error) {
170
+ if (error?.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION") {
171
+ const match = error.message.match(/Unknown option '([^']+)'/)
172
+ return match ? `unknown option "${match[1]}"` : error.message
173
+ }
174
+
175
+ if (error?.code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE") {
176
+ const missing = error.message.match(/Option '([^']+)' argument missing/)
177
+ if (missing) {
178
+ const optionName = missing[1]
179
+ .split(", ")
180
+ .at(-1)
181
+ .replace(/\s*<value>\s*$/, "")
182
+ .trim()
183
+ return `option "${optionName}" requires a value`
184
+ }
185
+
186
+ const ambiguous = error.message.match(/Option '([^']+)' argument is ambiguous/)
187
+ if (ambiguous) return `option "${ambiguous[1]}" requires a value`
188
+
189
+ const booleanValue = error.message.match(/Option '([^']+)' does not take an argument/)
190
+ if (booleanValue) return `option "${booleanValue[1]}" does not take a value`
191
+ }
192
+
193
+ return error?.message || String(error)
194
+ }
@@ -0,0 +1,9 @@
1
+ // Facade over the config editors. Kept so callers have one import site while
2
+ // the JSONC, Vite, and scanner concerns stay in separate modules.
3
+
4
+ export { parseJsonc, updateJsoncAliasSource } from "./jsonc.js"
5
+ export {
6
+ readViteAliasKeys,
7
+ readViteAliasSourceRoot,
8
+ updateViteConfigSource,
9
+ } from "./vite-config.js"