sparkdesign 0.0.1 → 0.2.6

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 (403) hide show
  1. package/README.md +279 -5
  2. package/cli/dist/commands/add.js +84 -0
  3. package/cli/dist/commands/diff.js +54 -0
  4. package/cli/dist/commands/init.js +96 -0
  5. package/cli/dist/commands/list.js +25 -0
  6. package/cli/dist/index.js +37 -0
  7. package/cli/dist/utils/config.js +53 -0
  8. package/cli/dist/utils/registry.js +34 -0
  9. package/cli/dist/utils/tokens.js +90 -0
  10. package/cli/dist/utils/transform.js +19 -0
  11. package/cli/registry/basic/alert-dialog.tsx +180 -0
  12. package/cli/registry/basic/avatar.tsx +120 -0
  13. package/cli/registry/basic/button.tsx +100 -0
  14. package/cli/registry/basic/collapse.tsx +94 -0
  15. package/cli/registry/basic/collapsible-card.tsx +230 -0
  16. package/cli/registry/basic/collapsible.tsx +21 -0
  17. package/cli/registry/basic/dropdown-menu.tsx +254 -0
  18. package/cli/registry/basic/icon-button.tsx +66 -0
  19. package/cli/registry/basic/icons-inline.tsx +206 -0
  20. package/cli/registry/basic/kbd.tsx +50 -0
  21. package/cli/registry/basic/option-list.tsx +125 -0
  22. package/cli/registry/basic/pagination.tsx +132 -0
  23. package/cli/registry/basic/progress.tsx +42 -0
  24. package/cli/registry/basic/radio-group.tsx +69 -0
  25. package/cli/registry/basic/resizable.tsx +67 -0
  26. package/cli/registry/basic/scrollbar.tsx +114 -0
  27. package/cli/registry/basic/select.tsx +177 -0
  28. package/cli/registry/basic/skeleton.tsx +33 -0
  29. package/cli/registry/basic/slider.tsx +55 -0
  30. package/cli/registry/basic/sonner.tsx +104 -0
  31. package/cli/registry/basic/spinner.tsx +17 -0
  32. package/cli/registry/basic/switch.tsx +49 -0
  33. package/cli/registry/basic/table.tsx +117 -0
  34. package/cli/registry/basic/tabs.tsx +85 -0
  35. package/cli/registry/basic/tag.tsx +161 -0
  36. package/cli/registry/basic/theme-from-document.ts +10 -0
  37. package/cli/registry/basic/toggle.tsx +223 -0
  38. package/cli/registry/basic/tooltip.tsx +80 -0
  39. package/cli/registry/basic/typography.tsx +201 -0
  40. package/cli/registry/chat/browser-use-part.tsx +166 -0
  41. package/cli/registry/chat/chat-input/chat-input-folder-selector.tsx +185 -0
  42. package/cli/registry/chat/chat-input/chat-input-model-switcher.tsx +131 -0
  43. package/cli/registry/chat/chat-input/chat-input-textarea.tsx +67 -0
  44. package/cli/registry/chat/chat-input/compound.tsx +334 -0
  45. package/cli/registry/chat/chat-input/context.tsx +189 -0
  46. package/cli/registry/chat/chat-input/folder-permission-dialog.tsx +61 -0
  47. package/cli/registry/chat/chat-input/index.tsx +123 -0
  48. package/cli/registry/chat/chat-input/types.ts +77 -0
  49. package/cli/registry/chat/chat-input/useAutoResizeTextarea.ts +20 -0
  50. package/cli/registry/chat/code-block-part.tsx +151 -0
  51. package/cli/registry/chat/file-attachment.tsx +44 -0
  52. package/cli/registry/chat/file-card.tsx +68 -0
  53. package/cli/registry/chat/file-review-part.tsx +259 -0
  54. package/cli/registry/chat/folder-button.tsx +169 -0
  55. package/cli/registry/chat/generated-images-grid.tsx +56 -0
  56. package/cli/registry/chat/generation-status-bar.tsx +72 -0
  57. package/cli/registry/chat/image-attachment.tsx +166 -0
  58. package/cli/registry/chat/image-generating.tsx +281 -0
  59. package/cli/registry/chat/markdown.tsx +146 -0
  60. package/cli/registry/chat/mermaid-part.tsx +90 -0
  61. package/cli/registry/chat/permission-card.tsx +178 -0
  62. package/cli/registry/chat/plan-part.tsx +168 -0
  63. package/cli/registry/chat/question-part.tsx +70 -0
  64. package/cli/registry/chat/queue-indicator.tsx +234 -0
  65. package/cli/registry/chat/reasoning-step.tsx +358 -0
  66. package/cli/registry/chat/related-prompts.tsx +91 -0
  67. package/cli/registry/chat/request.tsx +38 -0
  68. package/cli/registry/chat/response.tsx +271 -0
  69. package/cli/registry/chat/send-button.tsx +94 -0
  70. package/cli/registry/chat/sidebar-menu.tsx +177 -0
  71. package/cli/registry/chat/streaming-markdown-block.tsx +111 -0
  72. package/cli/registry/chat/suggestion-part.tsx +165 -0
  73. package/cli/registry/chat/task-part.tsx +109 -0
  74. package/cli/registry/chat/terminal-code-block-part.tsx +69 -0
  75. package/cli/registry/chat/thinking-indicator.tsx +91 -0
  76. package/cli/registry/chat/tool-invocation-card.tsx +132 -0
  77. package/cli/registry/chat/user-question/UserQuestionCard.tsx +198 -0
  78. package/cli/registry/chat/user-question/UserQuestionFooter.tsx +66 -0
  79. package/cli/registry/chat/user-question/UserQuestionHeader.tsx +64 -0
  80. package/cli/registry/chat/user-question/index.tsx +340 -0
  81. package/cli/registry/chat/user-question/types.ts +61 -0
  82. package/cli/registry/chat/user-question/useUserQuestionKeyboard.ts +127 -0
  83. package/cli/registry/chat/user-question/useUserQuestionState.ts +165 -0
  84. package/cli/registry/chat/user-question-answer.tsx +62 -0
  85. package/cli/registry/lib/file-icon-maps.ts +150 -0
  86. package/cli/registry/lib/use-mermaid-render.ts +76 -0
  87. package/cli/registry/lib/utils.ts +6 -0
  88. package/cli/registry/meta.json +1 -0
  89. package/cli/registry/tokens/scale.css +299 -0
  90. package/cli/registry/tokens/theme.css +633 -0
  91. package/dist/_basePickBy-DnQN8w3y.js +151 -0
  92. package/dist/_basePickBy-a-kPMlkg.cjs +1 -0
  93. package/dist/_baseUniq-B-N2NQ50.js +614 -0
  94. package/dist/_baseUniq-Cc_zbSif.cjs +1 -0
  95. package/dist/arc-BQBhijZ6.js +83 -0
  96. package/dist/arc-mWQt0Yph.cjs +1 -0
  97. package/dist/architectureDiagram-VXUJARFQ-BMZEucno.cjs +36 -0
  98. package/dist/architectureDiagram-VXUJARFQ-DTdjD3Bp.js +4661 -0
  99. package/dist/blockDiagram-VD42YOAC-CzHn0yob.js +2256 -0
  100. package/dist/blockDiagram-VD42YOAC-DDxdHAlz.cjs +122 -0
  101. package/dist/c4Diagram-YG6GDRKO-4Gz0I4gj.cjs +10 -0
  102. package/dist/c4Diagram-YG6GDRKO-BIy--yVN.js +1580 -0
  103. package/dist/channel-BQn0o8bs.js +5 -0
  104. package/dist/channel-DaN7XniJ.cjs +1 -0
  105. package/dist/chunk-4BX2VUAB-BlQFTQqz.cjs +1 -0
  106. package/dist/chunk-4BX2VUAB-Czitj3Kc.js +8 -0
  107. package/dist/chunk-55IACEB6-DXacNZbO.js +8 -0
  108. package/dist/chunk-55IACEB6-DnDxpye9.cjs +1 -0
  109. package/dist/chunk-B4BG7PRW-CBdN0q_V.js +1375 -0
  110. package/dist/chunk-B4BG7PRW-DbGvUkGO.cjs +165 -0
  111. package/dist/chunk-DI55MBZ5-D1YJMs6x.cjs +220 -0
  112. package/dist/chunk-DI55MBZ5-NCQTvayw.js +1370 -0
  113. package/dist/chunk-FMBD7UC4-CsGMbrtr.js +19 -0
  114. package/dist/chunk-FMBD7UC4-Di7cUUh5.cjs +15 -0
  115. package/dist/chunk-QN33PNHL-0j5LC8Lm.cjs +1 -0
  116. package/dist/chunk-QN33PNHL-3GERZBRm.js +19 -0
  117. package/dist/chunk-QZHKN3VN-AVEY9ImQ.js +15 -0
  118. package/dist/chunk-QZHKN3VN-s8Z0a8mc.cjs +1 -0
  119. package/dist/chunk-TZMSLE5B-CAf87HPt.cjs +1 -0
  120. package/dist/chunk-TZMSLE5B-sbiflal0.js +64 -0
  121. package/dist/classDiagram-2ON5EDUG-Ct9JLIN2.cjs +1 -0
  122. package/dist/classDiagram-2ON5EDUG-Dzfrft3a.js +16 -0
  123. package/dist/classDiagram-v2-WZHVMYZB-Ct9JLIN2.cjs +1 -0
  124. package/dist/classDiagram-v2-WZHVMYZB-Dzfrft3a.js +16 -0
  125. package/dist/clone-Cde_NQ8V.js +8 -0
  126. package/dist/clone-DCNjWuM2.cjs +1 -0
  127. package/dist/cose-bilkent-S5V4N54A-0uLijMro.cjs +1 -0
  128. package/dist/cose-bilkent-S5V4N54A-Bb08N431.js +2608 -0
  129. package/dist/cytoscape.esm-CNUX3VTg.cjs +321 -0
  130. package/dist/cytoscape.esm-Cvf3sx9F.js +18704 -0
  131. package/dist/dagre-6UL2VRFP-CY_Wz5Zd.js +444 -0
  132. package/dist/dagre-6UL2VRFP-Dxe7_qZc.cjs +4 -0
  133. package/dist/defaultLocale-BgPVtth8.js +171 -0
  134. package/dist/defaultLocale-C4wbwF1n.cjs +1 -0
  135. package/dist/diagram-PSM6KHXK-D2bdb7MT.js +531 -0
  136. package/dist/diagram-PSM6KHXK-YF69SUjY.cjs +24 -0
  137. package/dist/diagram-QEK2KX5R-BpUSoh0-.js +217 -0
  138. package/dist/diagram-QEK2KX5R-DZPGteon.cjs +43 -0
  139. package/dist/diagram-S2PKOQOG-ht-zdvFG.cjs +24 -0
  140. package/dist/diagram-S2PKOQOG-zFeLJ50Z.js +142 -0
  141. package/dist/erDiagram-Q2GNP2WA-B38iJ6ts.js +841 -0
  142. package/dist/erDiagram-Q2GNP2WA-RgS80DDU.cjs +60 -0
  143. package/dist/flowDiagram-NV44I4VS-BHilOs2p.cjs +162 -0
  144. package/dist/flowDiagram-NV44I4VS-BrBJcoce.js +1620 -0
  145. package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
  146. package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
  147. package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  148. package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
  149. package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
  150. package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  151. package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
  152. package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
  153. package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  154. package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
  155. package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
  156. package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  157. package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
  158. package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
  159. package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  160. package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
  161. package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
  162. package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
  163. package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
  164. package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
  165. package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  166. package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
  167. package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
  168. package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
  169. package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
  170. package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
  171. package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
  172. package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
  173. package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
  174. package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  175. package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
  176. package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
  177. package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
  178. package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
  179. package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
  180. package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  181. package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
  182. package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
  183. package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  184. package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
  185. package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
  186. package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  187. package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
  188. package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
  189. package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
  190. package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
  191. package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
  192. package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  193. package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
  194. package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
  195. package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  196. package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
  197. package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
  198. package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  199. package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
  200. package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
  201. package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  202. package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
  203. package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
  204. package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  205. package/dist/ganttDiagram-JELNMOA3-pZiJeFio.cjs +267 -0
  206. package/dist/ganttDiagram-JELNMOA3-tw6FhkWJ.js +2670 -0
  207. package/dist/gitGraphDiagram-V2S2FVAM-BWn5uIK5.js +699 -0
  208. package/dist/gitGraphDiagram-V2S2FVAM-DKKeG-9R.cjs +65 -0
  209. package/dist/graph-DIbblrZP.cjs +1 -0
  210. package/dist/graph-DPcK91G3.js +247 -0
  211. package/dist/infoDiagram-HS3SLOUP-B8gwwhct.cjs +2 -0
  212. package/dist/infoDiagram-HS3SLOUP-D47PNcP_.js +24 -0
  213. package/dist/init-CHZsXQcr.cjs +1 -0
  214. package/dist/init-DjUOC4st.js +16 -0
  215. package/dist/journeyDiagram-XKPGCS4Q-BG3cfhyU.js +834 -0
  216. package/dist/journeyDiagram-XKPGCS4Q-D8DVLJof.cjs +139 -0
  217. package/dist/kanban-definition-3W4ZIXB7-4OCnEouP.cjs +89 -0
  218. package/dist/kanban-definition-3W4ZIXB7-CWi_ssF9.js +719 -0
  219. package/dist/katex.css +1 -0
  220. package/dist/layout-Byuh8f-J.cjs +1 -0
  221. package/dist/layout-CdLdvj1j.js +1335 -0
  222. package/dist/linear-C2Q_PI9B.js +259 -0
  223. package/dist/linear-C69aPBW1.cjs +1 -0
  224. package/dist/mermaid.core-DBwAx_jp.cjs +249 -0
  225. package/dist/mermaid.core-gFR0XUlD.js +15300 -0
  226. package/dist/mindmap-definition-VGOIOE7T-8P7obVV4.cjs +68 -0
  227. package/dist/mindmap-definition-VGOIOE7T-DnOa7WJ9.js +784 -0
  228. package/dist/ordinal-B6-f3MAq.js +61 -0
  229. package/dist/ordinal-CagbB1m8.cjs +1 -0
  230. package/dist/pieDiagram-ADFJNKIX-5NAlvhMo.js +161 -0
  231. package/dist/pieDiagram-ADFJNKIX-CQBG4yR9.cjs +30 -0
  232. package/dist/qoder-design.css +2 -0
  233. package/dist/quadrantDiagram-AYHSOK5B-Oe4y7RZ0.cjs +7 -0
  234. package/dist/quadrantDiagram-AYHSOK5B-rh2DPEP1.js +1022 -0
  235. package/dist/registry/basic/alert-dialog.d.ts +40 -0
  236. package/dist/registry/basic/avatar.d.ts +30 -0
  237. package/dist/registry/basic/button.d.ts +16 -0
  238. package/dist/registry/basic/collapse.d.ts +22 -0
  239. package/dist/registry/basic/collapsible-card.d.ts +34 -0
  240. package/dist/registry/basic/collapsible.d.ts +15 -0
  241. package/dist/registry/basic/dropdown-menu.d.ts +52 -0
  242. package/dist/registry/basic/icon-button.d.ts +12 -0
  243. package/dist/registry/basic/icons-inline.d.ts +51 -0
  244. package/dist/registry/basic/kbd.d.ts +23 -0
  245. package/dist/registry/basic/option-list.d.ts +16 -0
  246. package/dist/registry/basic/pagination.d.ts +33 -0
  247. package/dist/registry/basic/progress.d.ts +18 -0
  248. package/dist/registry/basic/radio-group.d.ts +25 -0
  249. package/dist/registry/basic/resizable.d.ts +318 -0
  250. package/dist/registry/basic/scrollbar.d.ts +12 -0
  251. package/dist/registry/basic/select.d.ts +35 -0
  252. package/dist/registry/basic/skeleton.d.ts +10 -0
  253. package/dist/registry/basic/slider.d.ts +16 -0
  254. package/dist/registry/basic/sonner.d.ts +23 -0
  255. package/dist/registry/basic/spinner.d.ts +5 -0
  256. package/dist/registry/basic/switch.d.ts +20 -0
  257. package/dist/registry/basic/table.d.ts +18 -0
  258. package/dist/registry/basic/tabs.d.ts +29 -0
  259. package/dist/registry/basic/tag.d.ts +23 -0
  260. package/dist/registry/basic/theme-from-document.d.ts +10 -0
  261. package/dist/registry/basic/toggle.d.ts +29 -0
  262. package/dist/registry/basic/tooltip.d.ts +34 -0
  263. package/dist/registry/basic/typography.d.ts +76 -0
  264. package/dist/registry/chat/browser-use-part.d.ts +28 -0
  265. package/dist/registry/chat/chat-input/chat-input-folder-selector.d.ts +22 -0
  266. package/dist/registry/chat/chat-input/chat-input-model-switcher.d.ts +12 -0
  267. package/dist/registry/chat/chat-input/chat-input-textarea.d.ts +9 -0
  268. package/dist/registry/chat/chat-input/compound.d.ts +97 -0
  269. package/dist/registry/chat/chat-input/context.d.ts +64 -0
  270. package/dist/registry/chat/chat-input/folder-permission-dialog.d.ts +11 -0
  271. package/dist/registry/chat/chat-input/index.d.ts +34 -0
  272. package/dist/registry/chat/chat-input/types.d.ts +79 -0
  273. package/dist/registry/chat/chat-input/useAutoResizeTextarea.d.ts +7 -0
  274. package/dist/registry/chat/code-block-part.d.ts +23 -0
  275. package/dist/registry/chat/file-attachment.d.ts +19 -0
  276. package/dist/registry/chat/file-card.d.ts +10 -0
  277. package/dist/registry/chat/file-review-part.d.ts +30 -0
  278. package/dist/registry/chat/folder-button.d.ts +20 -0
  279. package/dist/registry/chat/generated-images-grid.d.ts +15 -0
  280. package/dist/registry/chat/generation-status-bar.d.ts +19 -0
  281. package/dist/registry/chat/image-attachment.d.ts +19 -0
  282. package/dist/registry/chat/image-generating.d.ts +15 -0
  283. package/dist/registry/chat/markdown.d.ts +8 -0
  284. package/dist/registry/chat/mermaid-part.d.ts +17 -0
  285. package/dist/registry/chat/permission-card.d.ts +24 -0
  286. package/dist/registry/chat/plan-part.d.ts +30 -0
  287. package/dist/registry/chat/question-part.d.ts +24 -0
  288. package/dist/registry/chat/queue-indicator.d.ts +27 -0
  289. package/dist/registry/chat/reasoning-step.d.ts +35 -0
  290. package/dist/registry/chat/related-prompts.d.ts +23 -0
  291. package/dist/registry/chat/request.d.ts +6 -0
  292. package/dist/registry/chat/response.d.ts +28 -0
  293. package/dist/registry/chat/send-button.d.ts +17 -0
  294. package/dist/registry/chat/sidebar-menu.d.ts +23 -0
  295. package/dist/registry/chat/streaming-markdown-block.d.ts +8 -0
  296. package/dist/registry/chat/suggestion-part.d.ts +28 -0
  297. package/dist/registry/chat/task-part.d.ts +28 -0
  298. package/dist/registry/chat/terminal-code-block-part.d.ts +18 -0
  299. package/dist/registry/chat/thinking-indicator.d.ts +14 -0
  300. package/dist/registry/chat/tool-invocation-card.d.ts +20 -0
  301. package/dist/registry/chat/user-question/UserQuestionCard.d.ts +30 -0
  302. package/dist/registry/chat/user-question/UserQuestionFooter.d.ts +18 -0
  303. package/dist/registry/chat/user-question/UserQuestionHeader.d.ts +20 -0
  304. package/dist/registry/chat/user-question/index.d.ts +7 -0
  305. package/dist/registry/chat/user-question/types.d.ts +52 -0
  306. package/dist/registry/chat/user-question/useUserQuestionKeyboard.d.ts +18 -0
  307. package/dist/registry/chat/user-question/useUserQuestionState.d.ts +26 -0
  308. package/dist/registry/chat/user-question-answer.d.ts +13 -0
  309. package/dist/registry/lib/file-icon-maps.d.ts +20 -0
  310. package/dist/registry/lib/use-mermaid-render.d.ts +5 -0
  311. package/dist/registry/lib/utils.d.ts +11 -0
  312. package/dist/requirementDiagram-UZGBJVZJ-DcWaCuXr.js +850 -0
  313. package/dist/requirementDiagram-UZGBJVZJ-gfdlrFiq.cjs +64 -0
  314. package/dist/sankeyDiagram-TZEHDZUN-CQIKFwD0.js +810 -0
  315. package/dist/sankeyDiagram-TZEHDZUN-DvPtzQvC.cjs +10 -0
  316. package/dist/scale.css +307 -0
  317. package/dist/sequenceDiagram-WL72ISMW-BNrsMagL.cjs +145 -0
  318. package/dist/sequenceDiagram-WL72ISMW-iCX3ckKx.js +2511 -0
  319. package/dist/spark-design.cjs.js +265 -0
  320. package/dist/spark-design.es.js +13207 -0
  321. package/dist/src/components/chat/BrowserUsePart/index.d.ts +7 -0
  322. package/dist/src/components/chat/ChatInput/index.d.ts +29 -0
  323. package/dist/src/components/chat/CodeBlockPart/index.d.ts +7 -0
  324. package/dist/src/components/chat/CollapsibleCard/index.d.ts +7 -0
  325. package/dist/src/components/chat/FileAttachment/index.d.ts +3 -0
  326. package/dist/src/components/chat/FileCard/index.d.ts +3 -0
  327. package/dist/src/components/chat/FileReviewPart/index.d.ts +7 -0
  328. package/dist/src/components/chat/FolderButton/index.d.ts +5 -0
  329. package/dist/src/components/chat/GeneratedImagesGrid/index.d.ts +7 -0
  330. package/dist/src/components/chat/GenerationStatusBar/index.d.ts +7 -0
  331. package/dist/src/components/chat/ImageAttachment/index.d.ts +3 -0
  332. package/dist/src/components/chat/ImageGenerating/index.d.ts +6 -0
  333. package/dist/src/components/chat/Markdown/demo-content.d.ts +1 -0
  334. package/dist/src/components/chat/Markdown/index.d.ts +7 -0
  335. package/dist/src/components/chat/MermaidPart/index.d.ts +6 -0
  336. package/dist/src/components/chat/PermissionCard/index.d.ts +4 -0
  337. package/dist/src/components/chat/PlanPart/index.d.ts +6 -0
  338. package/dist/src/components/chat/QuestionPart/index.d.ts +6 -0
  339. package/dist/src/components/chat/QueueIndicator/index.d.ts +4 -0
  340. package/dist/src/components/chat/ReasoningStep/index.d.ts +7 -0
  341. package/dist/src/components/chat/RelatedPrompts/index.d.ts +6 -0
  342. package/dist/src/components/chat/Request/index.d.ts +7 -0
  343. package/dist/src/components/chat/Response/StreamingMarkdownBlock.d.ts +6 -0
  344. package/dist/src/components/chat/Response/index.d.ts +6 -0
  345. package/dist/src/components/chat/SendButton/index.d.ts +5 -0
  346. package/dist/src/components/chat/SidebarMenu/index.d.ts +4 -0
  347. package/dist/src/components/chat/SuggestionPart/index.d.ts +6 -0
  348. package/dist/src/components/chat/TaskPart/index.d.ts +7 -0
  349. package/dist/src/components/chat/TerminalCodeBlockPart/index.d.ts +6 -0
  350. package/dist/src/components/chat/ThinkingIndicator/index.d.ts +6 -0
  351. package/dist/src/components/chat/ToolInvocationCard/index.d.ts +4 -0
  352. package/dist/src/components/chat/UserQuestion/index.d.ts +5 -0
  353. package/dist/src/components/chat/UserQuestionAnswer/index.d.ts +3 -0
  354. package/dist/src/components/foundation/AlertDialog/index.d.ts +20 -0
  355. package/dist/src/components/foundation/Avatar/index.d.ts +7 -0
  356. package/dist/src/components/foundation/Button/index.d.ts +7 -0
  357. package/dist/src/components/foundation/Collapse/index.d.ts +15 -0
  358. package/dist/src/components/foundation/Collapsible/index.d.ts +7 -0
  359. package/dist/src/components/foundation/CollapsibleSection/index.d.ts +43 -0
  360. package/dist/src/components/foundation/DropdownMenu/index.d.ts +19 -0
  361. package/dist/src/components/foundation/EllipsisText/index.d.ts +53 -0
  362. package/dist/src/components/foundation/IconButton/index.d.ts +7 -0
  363. package/dist/src/components/foundation/Kbd/index.d.ts +7 -0
  364. package/dist/src/components/foundation/OptionList/index.d.ts +7 -0
  365. package/dist/src/components/foundation/Pagination/index.d.ts +7 -0
  366. package/dist/src/components/foundation/Progress/index.d.ts +7 -0
  367. package/dist/src/components/foundation/RadioGroup/index.d.ts +7 -0
  368. package/dist/src/components/foundation/Resizable/index.d.ts +7 -0
  369. package/dist/src/components/foundation/Scrollbar/index.d.ts +7 -0
  370. package/dist/src/components/foundation/Select/index.d.ts +17 -0
  371. package/dist/src/components/foundation/Skeleton/index.d.ts +7 -0
  372. package/dist/src/components/foundation/Slider/index.d.ts +7 -0
  373. package/dist/src/components/foundation/Spinner/index.d.ts +7 -0
  374. package/dist/src/components/foundation/Switch/index.d.ts +38 -0
  375. package/dist/src/components/foundation/Table/index.d.ts +7 -0
  376. package/dist/src/components/foundation/Tabs/index.d.ts +7 -0
  377. package/dist/src/components/foundation/Tag/index.d.ts +10 -0
  378. package/dist/src/components/foundation/Toast/index.d.ts +12 -0
  379. package/dist/src/components/foundation/Toggle/index.d.ts +7 -0
  380. package/dist/src/components/foundation/Tooltip/index.d.ts +21 -0
  381. package/dist/src/components/foundation/Typography/index.d.ts +7 -0
  382. package/dist/src/components/index.d.ts +136 -0
  383. package/dist/src/icons/context.d.ts +26 -0
  384. package/dist/src/icons/types.d.ts +18 -0
  385. package/dist/src/lib/ThemeStyleContext.d.ts +21 -0
  386. package/dist/src/lib/file-icon.d.ts +16 -0
  387. package/dist/src/lib/i18n.d.ts +12 -0
  388. package/dist/src/lib/index.d.ts +10 -0
  389. package/dist/src/lib/motion.d.ts +22 -0
  390. package/dist/src/lib/utils.d.ts +11 -0
  391. package/dist/stateDiagram-FKZM4ZOC-DBvJ_eeL.cjs +1 -0
  392. package/dist/stateDiagram-FKZM4ZOC-ZVsJlaHJ.js +263 -0
  393. package/dist/stateDiagram-v2-4FDKWEC3-CB_nTHcE.js +16 -0
  394. package/dist/stateDiagram-v2-4FDKWEC3-Xkx17v6T.cjs +1 -0
  395. package/dist/theme.css +804 -0
  396. package/dist/timeline-definition-IT6M3QCI-BmGkYQiz.cjs +61 -0
  397. package/dist/timeline-definition-IT6M3QCI-Ck8zTt6w.js +795 -0
  398. package/dist/treemap-GDKQZRPO-B9sfERx8.js +17922 -0
  399. package/dist/treemap-GDKQZRPO-BVfJRs0Z.cjs +160 -0
  400. package/dist/xychartDiagram-PRI3JC2R-By_S8NzN.js +1340 -0
  401. package/dist/xychartDiagram-PRI3JC2R-CNfDrGxM.cjs +7 -0
  402. package/package.json +111 -9
  403. package/index.js +0 -5
package/README.md CHANGED
@@ -1,9 +1,283 @@
1
- # sparkdesign
1
+ # Spark Design
2
2
 
3
- > Package name reserved for future development.
3
+ 现代化 React 设计系统,支持双维度主题(颜色 theme + 布局 scale),5 种内置布局风格,提供 Foundation 基础组件与 Chat 对话流组件,可扩展颜色主题。
4
4
 
5
- This package is currently a placeholder. The actual implementation will be coming soon.
5
+ **当前版本**:`0.2.4`([变更说明](docs/NPM发布指南.md))
6
6
 
7
- ## Author
7
+ > 以下为**安装与使用说明**;仓库结构、开发脚本与贡献方式见文末 [仓库与开发](#仓库与开发)。
8
8
 
9
- cunyu666
9
+ ## 特性
10
+
11
+ - **双维度主题**:`data-theme`(颜色)+ `data-style`(布局),独立切换
12
+ - **5 种布局风格**:neutral / compact / soft / sharp / dense
13
+ - **内置颜色主题**:light / dark
14
+ - **CSS 变量驱动**:组件仅用 token,覆盖变量即可定制
15
+ - **Tailwind 友好**:类名与设计 token 映射,无硬编码色值
16
+ - **组件分层**:Foundation 原子组件 + Chat 对话组件,开箱即用
17
+
18
+ ## 两种使用方式
19
+
20
+ | 方式 | 适用场景 | 命令 |
21
+ |------|----------|------|
22
+ | **npm 安装** | 直接引用、不改源码 | `npm install sparkdesign` |
23
+ | **CLI 按需引入** | 复制源码到项目、可自由修改 | `npx sparkdesign init` → `npx sparkdesign add button` |
24
+
25
+ ---
26
+
27
+ ## 安装(npm 包)
28
+
29
+ ```bash
30
+ npm install sparkdesign
31
+ ```
32
+
33
+ **依赖**:需自行安装 `react`、`react-dom`(>=18)。
34
+
35
+ ### 按需引入(CLI)
36
+
37
+ 若希望**将组件源码复制到项目中**并自由修改,可使用 CLI:
38
+
39
+ ```bash
40
+ npx sparkdesign init # 初始化 components.json、tokens、utils
41
+ npx sparkdesign add button tooltip # 添加组件到 src/components/qoder/
42
+ npx sparkdesign list # 列出可用组件
43
+ npx sparkdesign diff button # 对比本地与注册表差异
44
+ ```
45
+
46
+ 详见 [docs/CLI按需引入方案.md](docs/CLI按需引入方案.md)。
47
+
48
+ ---
49
+
50
+ ## 快速开始
51
+
52
+ 三步即可在项目中使用组件,**无需配置 Tailwind**:
53
+
54
+ ```tsx
55
+ // 1. 引入样式(必做)
56
+ import 'sparkdesign/style'
57
+
58
+ // 2. 按需引入组件与类型
59
+ import { Button } from 'sparkdesign'
60
+ import type { ButtonProps } from 'sparkdesign'
61
+
62
+ // 3. 在根节点设置主题与布局(可选,不设则使用默认 light + neutral)
63
+ function App() {
64
+ return (
65
+ <div data-theme="light" data-style="neutral">
66
+ <Button variant="primary" size="md">点击</Button>
67
+ </div>
68
+ )
69
+ }
70
+ ```
71
+
72
+ **样式引入方式**(三选一,推荐方式 A):
73
+
74
+ | 方式 | 用法 | 说明 |
75
+ |------|------|------|
76
+ | **A** | `import 'sparkdesign/style'` | **推荐**。预编译完整样式(Tailwind 工具类 + 设计 token),无需配置 Tailwind |
77
+ | **B** | `import 'sparkdesign/theme.css'`<br>`import 'sparkdesign/scale.css'` | 仅引入设计 token,适合已有 Tailwind 4 项目自行扫描组件并覆盖变量(需在消费者 CSS 中 `@source` 指向本包) |
78
+ | **C** | 只引入组件、不引入样式 | 需在项目中自行提供与设计 token 同名的 CSS 变量,否则组件无样式 |
79
+
80
+ > **Markdown 数学公式**:若使用 `MarkdownBody` 组件且需要渲染 KaTeX 数学公式,额外引入:
81
+ > `import 'sparkdesign/katex.css'`
82
+
83
+ 自定义主题时,请**先**引入设计系统样式,**再**引入你的覆盖 CSS,变量覆盖才会生效。
84
+
85
+ ---
86
+
87
+ ## 设计系统用法
88
+
89
+ ### 1. 引入样式(必做)
90
+
91
+ 样式引入的三种方式见上方「快速开始」表格。
92
+
93
+ - **方式 A**(推荐):`import 'sparkdesign/style'` 包含预编译的 Tailwind 工具类 + theme/scale 设计 token,消费者项目**不需要安装或配置 Tailwind**。
94
+ - **方式 B**(Tailwind 用户):仅引入 token 文件,消费者需在自己的 CSS 中 `@source` 指向本包以扫描组件中使用的 Tailwind 类名:
95
+
96
+ ```css
97
+ /* 消费者 CSS(已有 Tailwind 4 的项目)*/
98
+ @import "tailwindcss";
99
+ @source "../node_modules/sparkdesign/dist";
100
+ @import "sparkdesign/theme.css";
101
+ @import "sparkdesign/scale.css";
102
+ ```
103
+
104
+ 约定:自定义主题时,**先**引入设计系统样式,**再**引入你的覆盖 CSS。
105
+
106
+ ### 2. 颜色主题(theme)
107
+
108
+ 通过 `data-theme` 切换颜色主题,作用于主色、背景、边框、语义色等。
109
+
110
+ | 主题 | 说明 |
111
+ |--------|----------|
112
+ | `light` | 亮色模式(默认) |
113
+ | `dark` | 暗色模式 |
114
+
115
+ ```tsx
116
+ // 在根节点或任意父节点设置
117
+ <div data-theme="dark">
118
+ <Button variant="primary">按钮</Button>
119
+ </div>
120
+ ```
121
+
122
+ ```html
123
+ <!-- 或直接挂在 body -->
124
+ <body data-theme="dark">
125
+ ```
126
+
127
+ 主题对应的 CSS 变量定义在 **theme.css**(如 `--color-primary`、`--color-bg-container` 等)。自定义主题见下文「自定义 theme / scale」。
128
+
129
+ ### 3. 布局风格(scale)
130
+
131
+ 通过 `data-style` 切换布局尺度,作用于间距、圆角、字号等。
132
+
133
+ | 风格 | 描述 | 特点 |
134
+ |-----------|----------------|----------------|
135
+ | `neutral` | 平衡的标准 | 默认,简洁直观 |
136
+ | `compact` | 优化效率 | 更窄间距,紧凑 |
137
+ | `soft` | 舒适至上 | 大圆角、宽松间距 |
138
+ | `sharp` | 几何精度 | 直角、利落线条 |
139
+ | `dense` | 信息密集 | 最小留白 |
140
+
141
+ ```tsx
142
+ <div data-style="soft">
143
+ <Button>按钮</Button>
144
+ </div>
145
+ ```
146
+
147
+ 布局变量定义在 **scale.css**(如 `--spacing-*`、`--radius-*`、`--font-size-*`)。可组合使用:
148
+
149
+ ```tsx
150
+ <div data-theme="dark" data-style="soft">
151
+ {/* 暗色 + 柔和布局 */}
152
+ </div>
153
+ ```
154
+
155
+ ### 4. 自定义 theme / scale
156
+
157
+ 在**先引入设计系统样式之后**,用你自己的 CSS 覆盖变量即可。
158
+
159
+ **选择器约定**:
160
+
161
+ - `:root` — 覆盖默认
162
+ - `[data-theme="主题名"]` — 颜色主题(自定义名称)
163
+ - `[data-style="风格名"]` — 布局风格(自定义名称)
164
+
165
+ ```css
166
+ /* 自定义颜色主题 */
167
+ [data-theme="my-brand"] {
168
+ --color-primary: #3B82F6;
169
+ --color-primary-hover: #2563EB;
170
+ }
171
+
172
+ /* 自定义布局风格 */
173
+ [data-style="custom"] {
174
+ --spacing-4: 20px;
175
+ --radius-md: 8px;
176
+ }
177
+ ```
178
+
179
+ 完整变量清单见 [NPM 发布指南](https://github.com/nicepkg/spark-design/blob/master/docs/NPM发布指南.md)(颜色 `--color-*`、间距 `--spacing-*`、圆角 `--radius-*`、字号 `--font-size-*` 等)。
180
+
181
+ ### 5. Portal 浮层与主题一致
182
+
183
+ DropdownMenu、Tooltip 等会挂到 `body`,不会继承局部容器的 `data-theme` / `data-style`。两种做法:
184
+
185
+ - **做法 A**:把 `data-theme`、`data-style` 设到 `<html>` 或 `<body>`,全局一致。
186
+ - **做法 B**:用 `ThemeStyleProvider` 包裹应用,浮层会使用同一主题/风格:
187
+
188
+ ```tsx
189
+ import { ThemeStyleProvider, Button, DropdownMenu } from 'sparkdesign'
190
+
191
+ function App() {
192
+ const theme = 'dark'
193
+ const style = 'soft'
194
+ return (
195
+ <ThemeStyleProvider value={{ theme, style }}>
196
+ <div data-theme={theme} data-style={style}>
197
+ <Button>打开</Button>
198
+ <DropdownMenu>...</DropdownMenu>
199
+ </div>
200
+ </ThemeStyleProvider>
201
+ )
202
+ }
203
+ ```
204
+
205
+ ## 组件使用
206
+
207
+ 组件与类型均从主入口按需引入,用法见上方「快速开始」。示例:
208
+
209
+ ```tsx
210
+ import 'sparkdesign/style'
211
+ import { Button } from 'sparkdesign'
212
+ import type { ButtonProps } from 'sparkdesign'
213
+
214
+ function App() {
215
+ return (
216
+ <div data-theme="light" data-style="neutral">
217
+ <Button variant="primary" size="md">Click me</Button>
218
+ </div>
219
+ )
220
+ }
221
+ ```
222
+
223
+ ## 组件概览
224
+
225
+ | 分层 | 说明 | 示例 |
226
+ |------|------|------|
227
+ | **Foundation** | 原子级 UI 组件 | Button, IconButton, Tooltip, Select, DropdownMenu, Tabs, Toast, Tag, Progress, Avatar, Table, Slider, Pagination, Collapse, Resizable, Scrollbar, Skeleton, Spinner, Kbd, EllipsisText, Switch, Toggle, ToggleGroup, RadioGroup, AlertDialog, OptionList … |
228
+ | **Chat** | 对话流相关组件 | ChatInput, SendButton, Request, Response, FileCard, FileAttachment, ImageAttachment, FolderButton, ReasoningStep, ToolInvocationCard, PermissionCard, MarkdownBody, GenerationStatusBar, ThinkingIndicator, ImageGenerating, RelatedPrompts, SuggestionPart, SidebarMenu … |
229
+
230
+ 完整导出见 [src/components/index.ts](src/components/index.ts)。图标通过 `IconsProvider` / `useIcon` 注入,可替换为 Lucide、Remix 等,见 [图标自定义说明](docs/图标自定义说明.md)。
231
+
232
+ ## 文档(仓库内)
233
+
234
+ | 文档 | 说明 |
235
+ |------|------|
236
+ | [NPM 发布指南](docs/NPM发布指南.md) | 变量清单、主题覆盖、发布步骤 |
237
+ | [组件入库文档](docs/组件入库文档.md) | 组件与 Showcase 规范 |
238
+ | [图标自定义说明](docs/图标自定义说明.md) | IconsProvider / 替换为 Lucide 等 |
239
+ | [CLI 按需引入方案](docs/CLI按需引入方案.md) | `npx sparkdesign init / add` 使用说明 |
240
+
241
+ ---
242
+
243
+ ## 仓库与开发
244
+
245
+ 以下内容面向**参与仓库开发**的贡献者;仅使用本包时可忽略。
246
+
247
+ ### 组件展示(Showcase)
248
+
249
+ 本仓库内 **apps/showcase** 提供所有组件的演示与 Props 文档:
250
+
251
+ ```bash
252
+ cd apps/showcase && npm install && npm run dev
253
+ ```
254
+
255
+ ### 项目脚本
256
+
257
+ | 脚本 | 说明 |
258
+ |------|------|
259
+ | `npm run dev` | 设计系统开发服务器 |
260
+ | `npm run build` | 生产构建:Vite 输出 JS → @tailwindcss/cli 预编译 CSS → tsc 类型声明 |
261
+ | `npm run build:css` | 仅重新生成预编译 CSS(`dist/qoder-design.css`) |
262
+ | `npm run preview` | 预览构建产物 |
263
+ | `cd apps/showcase && npm run dev` | 组件展示站点 |
264
+
265
+ ### 目录结构
266
+
267
+ ```
268
+ src/
269
+ ├── index.css # dev 模式 CSS 入口
270
+ ├── lib.css # 库构建 CSS 入口(@tailwindcss/cli)
271
+ ├── tokens/ # theme.css、scale.css
272
+ ├── components/ # foundation/、chat/
273
+ └── lib/ # 工具与 ThemeStyleProvider
274
+ ```
275
+
276
+ ### 技术栈与规范
277
+
278
+ - React 19 + TypeScript + Vite 7;Tailwind CSS 4;Radix UI、Framer Motion
279
+ - 项目哲学与 GEB 协议:[CLAUDE.md](https://github.com/nicepkg/spark-design/blob/master/CLAUDE.md)
280
+
281
+ ---
282
+
283
+ *"Keep the map aligned with the terrain."*
@@ -0,0 +1,84 @@
1
+ /**
2
+ * [INPUT]: components[] from argv, options.overwrite
3
+ * [OUTPUT]: void - 写入组件文件到用户项目
4
+ * [POS]: cli/src/commands/add.ts
5
+ *
6
+ * [PROTOCOL]: 文件逻辑变更时同步更新此 Header
7
+ */
8
+ import path from 'node:path';
9
+ import fs from 'fs-extra';
10
+ import chalk from 'chalk';
11
+ import { readConfig, writeConfig, getComponentsBaseAlias, resolveTargetDir } from '../utils/config.js';
12
+ import { getRegistryRoot, getComponentMeta, getComponentSource } from '../utils/registry.js';
13
+ import { stripL3Header, transformImports } from '../utils/transform.js';
14
+ import { projectHasTokens, writeQoderTokensFile, getQoderTokensImportPath } from '../utils/tokens.js';
15
+ export async function add(components, options = {}) {
16
+ const cwd = process.cwd();
17
+ const registryRoot = getRegistryRoot();
18
+ let config = await readConfig(cwd);
19
+ const hasConfig = await fs.pathExists(path.join(cwd, 'components.json'));
20
+ if (!hasConfig) {
21
+ await writeConfig(config, cwd);
22
+ console.log(chalk.green('✓'), 'Created components.json (default config)');
23
+ }
24
+ const hasTokens = await projectHasTokens(cwd);
25
+ if (!hasTokens) {
26
+ const { path: tokensPath, created } = await writeQoderTokensFile(cwd, registryRoot);
27
+ if (created) {
28
+ console.log(chalk.green('✓'), 'Created', tokensPath);
29
+ }
30
+ console.log(chalk.cyan(' To enable component styles, add to your app entry (e.g. main.tsx or layout.tsx):'));
31
+ console.log(chalk.yellow(' import'), chalk.white(`'${getQoderTokensImportPath()}'`));
32
+ console.log(chalk.gray(' (Paste the line above into your entry file.)'));
33
+ console.log(chalk.gray(' Or run'), chalk.cyan('npx sparkdesign init'), chalk.gray('for full setup with tokens in your CSS entry.'));
34
+ }
35
+ const utilsDest = path.join(cwd, 'src', 'lib', 'utils.ts');
36
+ if (!(await fs.pathExists(utilsDest))) {
37
+ const utilsTemplate = await fs.readFile(path.join(registryRoot, 'lib', 'utils.ts'), 'utf-8');
38
+ await fs.ensureDir(path.dirname(utilsDest));
39
+ await fs.writeFile(utilsDest, utilsTemplate, 'utf-8');
40
+ console.log(chalk.green('✓'), 'Created', utilsDest);
41
+ }
42
+ if (!components || components.length === 0) {
43
+ console.log(chalk.cyan('Usage:'), 'npx sparkdesign add button [tooltip] [dropdown-menu]');
44
+ console.log(chalk.cyan('List:'), 'npx sparkdesign list');
45
+ return;
46
+ }
47
+ const targetDir = resolveTargetDir(getComponentsBaseAlias(config), cwd);
48
+ await fs.ensureDir(targetDir);
49
+ const baseAlias = getComponentsBaseAlias(config);
50
+ console.log(chalk.gray(' 组件安装目录:'), chalk.cyan(baseAlias));
51
+ console.log(chalk.gray(' 目标目录:'), chalk.cyan(path.relative(cwd, targetDir) || targetDir));
52
+ console.log(chalk.gray(' (components.json → aliases.ui)'));
53
+ console.log('');
54
+ const allDeps = new Set();
55
+ for (const name of components) {
56
+ const meta = await getComponentMeta(registryRoot, name);
57
+ if (!meta) {
58
+ console.error(chalk.red('✗'), `Component "${name}" not found. Run npx sparkdesign list`);
59
+ continue;
60
+ }
61
+ for (const file of meta.files) {
62
+ const source = await getComponentSource(registryRoot, name, file);
63
+ const transformed = transformImports(stripL3Header(source), config.aliases);
64
+ // 保留相对路径,便于 chat/xxx 与 basic/xxx 的引用关系(对齐 ElevenLabs npx add message 的按需安装)
65
+ const destPath = path.join(targetDir, file);
66
+ const exists = await fs.pathExists(destPath);
67
+ if (exists && !options.overwrite) {
68
+ console.log(chalk.yellow('○'), name, 'already exists, skipped. Use --overwrite to replace.');
69
+ continue;
70
+ }
71
+ await fs.ensureDir(path.dirname(destPath));
72
+ await fs.writeFile(destPath, transformed, 'utf-8');
73
+ console.log(chalk.green('✓'), 'Added', name, '→', destPath);
74
+ }
75
+ if (meta.dependencies) {
76
+ meta.dependencies.forEach((d) => allDeps.add(d));
77
+ }
78
+ }
79
+ if (allDeps.size > 0) {
80
+ console.log('');
81
+ console.log(chalk.cyan('Dependencies (install if needed):'));
82
+ console.log(' npm install', Array.from(allDeps).join(' '));
83
+ }
84
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * [INPUT]: component name from argv
3
+ * [OUTPUT]: void - 打印本地文件与注册表版本的 diff
4
+ * [POS]: cli/src/commands/diff.ts
5
+ *
6
+ * [PROTOCOL]: 文件逻辑变更时同步更新此 Header
7
+ */
8
+ import path from 'node:path';
9
+ import fs from 'fs-extra';
10
+ import chalk from 'chalk';
11
+ import { diffLines } from 'diff';
12
+ import { readConfig, getComponentsBaseAlias, resolveTargetDir } from '../utils/config.js';
13
+ import { getRegistryRoot, getComponentMeta, getComponentSource } from '../utils/registry.js';
14
+ import { stripL3Header, transformImports } from '../utils/transform.js';
15
+ function printLineDiffs(changes) {
16
+ for (const part of changes) {
17
+ const lines = part.value.split('\n').filter((l, i, arr) => i < arr.length - 1 || l.length > 0);
18
+ const color = part.added ? chalk.green : part.removed ? chalk.red : chalk.gray;
19
+ const prefix = part.added ? '+' : part.removed ? '-' : ' ';
20
+ for (const line of lines) {
21
+ console.log(color(prefix + line));
22
+ }
23
+ }
24
+ }
25
+ export async function diffCmd(componentName) {
26
+ const cwd = process.cwd();
27
+ const config = await readConfig(cwd);
28
+ const registryRoot = getRegistryRoot();
29
+ const meta = await getComponentMeta(registryRoot, componentName);
30
+ if (!meta) {
31
+ console.error(chalk.red('✗'), `Component "${componentName}" not found. Run npx sparkdesign list`);
32
+ process.exit(1);
33
+ }
34
+ const targetDir = resolveTargetDir(getComponentsBaseAlias(config), cwd);
35
+ let hasDiff = false;
36
+ for (const file of meta.files) {
37
+ const localPath = path.join(targetDir, file);
38
+ const localExists = await fs.pathExists(localPath);
39
+ const registrySource = await getComponentSource(registryRoot, componentName, file);
40
+ const registryTransformed = transformImports(stripL3Header(registrySource), config.aliases);
41
+ const localContent = localExists ? await fs.readFile(localPath, 'utf-8') : '';
42
+ const changes = diffLines(localContent, registryTransformed);
43
+ const hasChanges = changes.some((c) => c.added || c.removed);
44
+ if (hasChanges) {
45
+ hasDiff = true;
46
+ console.log(chalk.cyan('---'), file);
47
+ printLineDiffs(changes);
48
+ console.log('');
49
+ }
50
+ }
51
+ if (!hasDiff) {
52
+ console.log(chalk.green('No differences for'), componentName);
53
+ }
54
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * [INPUT]: 无(从 process.cwd() 读取项目)
3
+ * [OUTPUT]: void - 写入 components.json、tokens、utils
4
+ * [POS]: cli/src/commands/init.ts
5
+ *
6
+ * [PROTOCOL]: 文件逻辑变更时同步更新此 Header
7
+ */
8
+ import path from 'node:path';
9
+ import fs from 'fs-extra';
10
+ import prompts from 'prompts';
11
+ import chalk from 'chalk';
12
+ import { execa } from 'execa';
13
+ import { writeConfig } from '../utils/config.js';
14
+ import { getRegistryRoot } from '../utils/registry.js';
15
+ import { ensureDesignTokens, projectHasTokens } from '../utils/tokens.js';
16
+ const STYLES = [
17
+ { title: 'neutral(平衡标准)', value: 'neutral' },
18
+ { title: 'compact(紧凑)', value: 'compact' },
19
+ { title: 'soft(舒适)', value: 'soft' },
20
+ { title: 'sharp(几何)', value: 'sharp' },
21
+ { title: 'dense(密集)', value: 'dense' },
22
+ ];
23
+ function resolveComponentsDir(aliasesComponents) {
24
+ const trimmed = aliasesComponents.replace(/^@\//, '');
25
+ return trimmed ? path.join('src', trimmed) : 'src/components';
26
+ }
27
+ export async function init() {
28
+ const cwd = process.cwd();
29
+ const registryRoot = getRegistryRoot();
30
+ const utilsTemplatePath = path.join(registryRoot, 'lib', 'utils.ts');
31
+ const answers = await prompts([
32
+ {
33
+ type: 'select',
34
+ name: 'style',
35
+ message: '选择布局风格 (data-style)',
36
+ choices: STYLES,
37
+ initial: 0,
38
+ },
39
+ {
40
+ type: 'text',
41
+ name: 'componentsDir',
42
+ message: '组件库放在哪个目录下?(我们会在此下创建 ui 子目录;如填 components 即 src/components/ui)',
43
+ initial: 'components',
44
+ },
45
+ {
46
+ type: 'confirm',
47
+ name: 'installDeps',
48
+ message: '是否安装依赖?(class-variance-authority, clsx, tailwind-merge)',
49
+ initial: true,
50
+ },
51
+ ]);
52
+ if (answers.style == null) {
53
+ process.exit(0);
54
+ }
55
+ const style = answers.style;
56
+ const rawDir = (answers.componentsDir ?? 'components').toString().trim().replace(/^src\/?/, '');
57
+ const componentsPath = rawDir || 'components';
58
+ const config = {
59
+ style,
60
+ aliases: {
61
+ components: `@/${componentsPath}`,
62
+ utils: '@/lib/utils',
63
+ ui: `@/${componentsPath}/ui`,
64
+ },
65
+ };
66
+ await writeConfig(config, cwd);
67
+ console.log(chalk.green('✓'), 'Created components.json');
68
+ const componentsDir = resolveComponentsDir(config.aliases.components);
69
+ const libDir = path.join(cwd, 'src', 'lib');
70
+ const utilsDest = path.join(libDir, 'utils.ts');
71
+ await fs.ensureDir(libDir);
72
+ const utilsTemplate = await fs.readFile(utilsTemplatePath, 'utf-8');
73
+ await fs.writeFile(utilsDest, utilsTemplate, 'utf-8');
74
+ console.log(chalk.green('✓'), 'Created', utilsDest);
75
+ const injected = await ensureDesignTokens(cwd, registryRoot);
76
+ if (injected) {
77
+ console.log(chalk.green('✓'), 'Added design tokens (theme + scale) to', injected);
78
+ }
79
+ else if (await projectHasTokens(cwd)) {
80
+ console.log(chalk.yellow('○'), 'Design tokens already present in project');
81
+ }
82
+ else {
83
+ console.log(chalk.yellow('○'), 'Could not inject tokens (no CSS entry found). Add theme/scale manually.');
84
+ }
85
+ if (answers.installDeps) {
86
+ try {
87
+ await execa('npm', ['install', 'class-variance-authority', 'clsx', 'tailwind-merge'], { cwd, stdio: 'inherit' });
88
+ console.log(chalk.green('✓'), 'Installed dependencies');
89
+ }
90
+ catch {
91
+ console.log(chalk.yellow('○'), 'Run manually: npm install class-variance-authority clsx tailwind-merge');
92
+ }
93
+ }
94
+ await fs.ensureDir(path.join(cwd, componentsDir));
95
+ console.log(chalk.green('✓'), 'Spark Design initialized. Run'), chalk.cyan('npx sparkdesign add button'), chalk.green('to add components.');
96
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * [INPUT]: 无
3
+ * [OUTPUT]: void - 打印注册表内所有组件名
4
+ * [POS]: cli/src/commands/list.ts
5
+ *
6
+ * [PROTOCOL]: 文件逻辑变更时同步更新此 Header
7
+ */
8
+ import chalk from 'chalk';
9
+ import { getRegistryRoot, listComponents } from '../utils/registry.js';
10
+ export async function list() {
11
+ const registryRoot = getRegistryRoot();
12
+ try {
13
+ const names = await listComponents(registryRoot);
14
+ if (names.length === 0) {
15
+ console.log('No components in registry.');
16
+ return;
17
+ }
18
+ console.log(chalk.cyan('Available components:'));
19
+ names.forEach((name) => console.log(' ', name));
20
+ }
21
+ catch (e) {
22
+ console.error(chalk.red('Failed to load registry:'), e.message);
23
+ process.exit(1);
24
+ }
25
+ }
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * [INPUT]: process.argv
4
+ * [OUTPUT]: void - 执行对应子命令并退出
5
+ * [POS]: cli/src/index.ts - Spark Design CLI 入口
6
+ *
7
+ * [PROTOCOL]:
8
+ * 1. 逻辑变更时同步更新此 Header
9
+ * 2. 子命令实现位于 commands/
10
+ */
11
+ import { program } from 'commander';
12
+ import { init } from './commands/init.js';
13
+ import { add } from './commands/add.js';
14
+ import { list } from './commands/list.js';
15
+ import { diffCmd } from './commands/diff.js';
16
+ program
17
+ .name('sparkdesign')
18
+ .description('Spark Design CLI - 按需添加组件(源码复制到当前项目)')
19
+ .version('0.1.0');
20
+ program
21
+ .command('init')
22
+ .description('初始化项目:写入 components.json、tokens、utils')
23
+ .action(init);
24
+ program
25
+ .command('add [components...]')
26
+ .description('添加组件到当前项目')
27
+ .option('-o, --overwrite', '覆盖已存在的组件文件')
28
+ .action(add);
29
+ program
30
+ .command('list')
31
+ .description('列出所有可用组件')
32
+ .action(list);
33
+ program
34
+ .command('diff <component>')
35
+ .description('对比本地组件与注册表最新版本的差异')
36
+ .action(diffCmd);
37
+ program.parse();
@@ -0,0 +1,53 @@
1
+ /**
2
+ * [INPUT]: process.cwd() 下的 components.json
3
+ * [OUTPUT]: Config | 默认配置
4
+ * [POS]: cli/src/utils/config.ts
5
+ *
6
+ * [PROTOCOL]: 文件逻辑变更时同步更新此 Header
7
+ */
8
+ import path from 'node:path';
9
+ import fs from 'fs-extra';
10
+ const defaultConfig = {
11
+ style: 'neutral',
12
+ aliases: {
13
+ components: '@/components',
14
+ utils: '@/lib/utils',
15
+ ui: '@/components/ui',
16
+ },
17
+ };
18
+ /** 优先用 aliases.ui 作为组件安装目录,未设时用 components + '/qoder'(兼容旧配置) */
19
+ export function getComponentsBaseAlias(config) {
20
+ return config.aliases.ui ?? config.aliases.components + '/qoder';
21
+ }
22
+ /** 将 alias 解析为绝对目录(如 @/components/qoder → cwd/src/components/qoder) */
23
+ export function resolveTargetDir(aliasesBase, cwd) {
24
+ const withoutAlias = aliasesBase.replace(/^@\//, '').trim();
25
+ let base = withoutAlias || 'components';
26
+ base = base.replace(/^src\/?/, '') || 'components';
27
+ return path.join(cwd, 'src', base);
28
+ }
29
+ export async function readConfig(cwd = process.cwd()) {
30
+ const configPath = path.join(cwd, 'components.json');
31
+ try {
32
+ const content = await fs.readFile(configPath, 'utf-8');
33
+ const parsed = JSON.parse(content);
34
+ return {
35
+ style: parsed.style ?? defaultConfig.style,
36
+ aliases: {
37
+ components: parsed.aliases?.components ?? defaultConfig.aliases.components,
38
+ utils: parsed.aliases?.utils ?? defaultConfig.aliases.utils,
39
+ ui: parsed.aliases?.ui ?? defaultConfig.aliases.ui,
40
+ },
41
+ };
42
+ }
43
+ catch {
44
+ return defaultConfig;
45
+ }
46
+ }
47
+ export async function writeConfig(config, cwd = process.cwd()) {
48
+ const configPath = path.join(cwd, 'components.json');
49
+ await fs.writeJson(configPath, {
50
+ $schema: 'https://qoder.design/schema.json',
51
+ ...config,
52
+ }, { spaces: 2 });
53
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * [INPUT]: 组件名、registry 根路径
3
+ * [OUTPUT]: meta、模板文件内容
4
+ * [POS]: cli/src/utils/registry.ts
5
+ *
6
+ * [PROTOCOL]: 文件逻辑变更时同步更新此 Header
7
+ */
8
+ import path from 'node:path';
9
+ import fs from 'fs-extra';
10
+ import { fileURLToPath } from 'node:url';
11
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
12
+ /** 开发时 src/utils/registry.ts -> 向上到 cli/ -> registry;构建后 dist/utils/registry.js -> 向上到 cli/ -> registry */
13
+ export function getRegistryRoot() {
14
+ const distDir = path.resolve(__dirname, '..');
15
+ const cliRoot = path.resolve(distDir, '..');
16
+ return path.join(cliRoot, 'registry');
17
+ }
18
+ export async function loadMeta(registryRoot) {
19
+ const metaPath = path.join(registryRoot, 'meta.json');
20
+ const content = await fs.readFile(metaPath, 'utf-8');
21
+ return JSON.parse(content);
22
+ }
23
+ export async function getComponentMeta(registryRoot, componentName) {
24
+ const meta = await loadMeta(registryRoot);
25
+ return meta[componentName] ?? null;
26
+ }
27
+ export async function getComponentSource(registryRoot, componentName, relativePath) {
28
+ const fullPath = path.join(registryRoot, relativePath);
29
+ return fs.readFile(fullPath, 'utf-8');
30
+ }
31
+ export async function listComponents(registryRoot) {
32
+ const meta = await loadMeta(registryRoot);
33
+ return Object.keys(meta);
34
+ }