@skyroc/scripts 2.5.1 → 2.5.2

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 (265) hide show
  1. package/README.md +6 -3
  2. package/dist/cli.mjs +1 -1
  3. package/dist/{config-BKkdncJS.mjs → config-Cj9IzlRz.mjs} +105 -5
  4. package/dist/index.mjs +1 -1
  5. package/package.json +3 -3
  6. package/templates/admin/package.json +5 -1
  7. package/templates/admin/src/assets/svg-icon/logo.svg +1 -1
  8. package/templates/admin/uno.config.ts +1 -1
  9. package/templates/admin-root/.agents/skills/component-doc/SKILL.md +304 -0
  10. package/templates/admin-root/.agents/skills/component-refactoring/SKILL.md +483 -0
  11. package/templates/admin-root/.agents/skills/component-refactoring/references/complexity-patterns.md +493 -0
  12. package/templates/admin-root/.agents/skills/component-refactoring/references/component-splitting.md +477 -0
  13. package/templates/admin-root/.agents/skills/component-refactoring/references/hook-extraction.md +317 -0
  14. package/templates/admin-root/.agents/skills/doc-coauthoring/SKILL.md +375 -0
  15. package/templates/admin-root/.agents/skills/feature-dev/SKILL.md +78 -0
  16. package/templates/admin-root/.agents/skills/frontend-code-review/SKILL.md +73 -0
  17. package/templates/admin-root/.agents/skills/frontend-code-review/references/business-logic.md +15 -0
  18. package/templates/admin-root/.agents/skills/frontend-code-review/references/code-quality.md +44 -0
  19. package/templates/admin-root/.agents/skills/frontend-code-review/references/performance.md +45 -0
  20. package/templates/admin-root/.agents/skills/frontend-design/LICENSE.txt +177 -0
  21. package/templates/admin-root/.agents/skills/frontend-design/SKILL.md +42 -0
  22. package/templates/admin-root/.agents/skills/frontend-testing/SKILL.md +325 -0
  23. package/templates/admin-root/.agents/skills/frontend-testing/assets/component-test.template.tsx +293 -0
  24. package/templates/admin-root/.agents/skills/frontend-testing/assets/hook-test.template.ts +207 -0
  25. package/templates/admin-root/.agents/skills/frontend-testing/assets/utility-test.template.ts +154 -0
  26. package/templates/admin-root/.agents/skills/frontend-testing/references/async-testing.md +345 -0
  27. package/templates/admin-root/.agents/skills/frontend-testing/references/checklist.md +205 -0
  28. package/templates/admin-root/.agents/skills/frontend-testing/references/common-patterns.md +449 -0
  29. package/templates/admin-root/.agents/skills/frontend-testing/references/domain-components.md +523 -0
  30. package/templates/admin-root/.agents/skills/frontend-testing/references/mocking.md +512 -0
  31. package/templates/admin-root/.agents/skills/frontend-testing/references/workflow.md +269 -0
  32. package/templates/admin-root/.agents/skills/migrate-nativewind-to-uniwind/SKILL.md +734 -0
  33. package/templates/admin-root/.agents/skills/migrate-oxfmt/SKILL.md +202 -0
  34. package/templates/admin-root/.agents/skills/migrate-oxlint/SKILL.md +196 -0
  35. package/templates/admin-root/.agents/skills/native-component-doc/SKILL.md +245 -0
  36. package/templates/admin-root/.agents/skills/senior-frontend/SKILL.md +209 -0
  37. package/templates/admin-root/.agents/skills/senior-frontend/references/frontend_best_practices.md +103 -0
  38. package/templates/admin-root/.agents/skills/senior-frontend/references/nextjs_optimization_guide.md +103 -0
  39. package/templates/admin-root/.agents/skills/senior-frontend/references/react_patterns.md +103 -0
  40. package/templates/admin-root/.agents/skills/senior-frontend/scripts/bundle_analyzer.py +114 -0
  41. package/templates/admin-root/.agents/skills/senior-frontend/scripts/component_generator.py +114 -0
  42. package/templates/admin-root/.agents/skills/senior-frontend/scripts/frontend_scaffolder.py +114 -0
  43. package/templates/admin-root/.agents/skills/skill-creator/SKILL.md +355 -0
  44. package/templates/admin-root/.agents/skills/skill-creator/references/output-patterns.md +86 -0
  45. package/templates/admin-root/.agents/skills/skill-creator/references/workflows.md +28 -0
  46. package/templates/admin-root/.agents/skills/skill-creator/scripts/init_skill.py +300 -0
  47. package/templates/admin-root/.agents/skills/skill-creator/scripts/package_skill.py +110 -0
  48. package/templates/admin-root/.agents/skills/skill-creator/scripts/quick_validate.py +97 -0
  49. package/templates/admin-root/.agents/skills/skyroc-admin-prd-prototype/SKILL.md +163 -0
  50. package/templates/admin-root/.agents/skills/skyroc-admin-prd-prototype/references/acceptance-checklist.md +75 -0
  51. package/templates/admin-root/.agents/skills/skyroc-admin-prd-prototype/references/evidence-order.md +109 -0
  52. package/templates/admin-root/.agents/skills/skyroc-admin-prd-prototype/references/prd-rules.md +103 -0
  53. package/templates/admin-root/.agents/skills/skyroc-admin-prd-prototype/references/prototype-rules.md +85 -0
  54. package/templates/admin-root/.agents/skills/skyroc-admin-prd-prototype/scripts/verify-prototypes.mjs +144 -0
  55. package/templates/admin-root/.agents/skills/skyroc-admin-prd-prototype/templates/admin-page.html +771 -0
  56. package/templates/admin-root/.agents/skills/skyroc-admin-prd-prototype/templates/prd.md +182 -0
  57. package/templates/admin-root/.agents/skills/ui-ux-pro-max/SKILL.md +292 -0
  58. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/charts.csv +26 -0
  59. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/colors.csv +97 -0
  60. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/icons.csv +101 -0
  61. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/landing.csv +31 -0
  62. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/products.csv +97 -0
  63. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  64. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  65. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  66. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  67. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  68. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  69. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  70. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  71. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  72. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  73. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  74. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  75. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  76. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  77. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/styles.csv +68 -0
  78. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/typography.csv +58 -0
  79. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  80. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  81. package/templates/admin-root/.agents/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  82. package/templates/admin-root/.agents/skills/ui-ux-pro-max/scripts/core.py +253 -0
  83. package/templates/admin-root/.agents/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
  84. package/templates/admin-root/.agents/skills/ui-ux-pro-max/scripts/search.py +114 -0
  85. package/templates/admin-root/.agents/skills/uniwind/SKILL.md +64 -0
  86. package/templates/admin-root/.agents/skills/uniwind/references/component-bindings.md +338 -0
  87. package/templates/admin-root/.agents/skills/uniwind/references/css-and-utilities.md +325 -0
  88. package/templates/admin-root/.agents/skills/uniwind/references/integrations.md +75 -0
  89. package/templates/admin-root/.agents/skills/uniwind/references/pro.md +354 -0
  90. package/templates/admin-root/.agents/skills/uniwind/references/setup.md +144 -0
  91. package/templates/admin-root/.agents/skills/uniwind/references/styling-patterns.md +237 -0
  92. package/templates/admin-root/.agents/skills/uniwind/references/theming.md +309 -0
  93. package/templates/admin-root/.agents/skills/uniwind/references/troubleshooting.md +179 -0
  94. package/templates/admin-root/.agents/skills/uniwind/references/variants-and-selectors.md +224 -0
  95. package/templates/admin-root/.agents/skills/vercel-react-best-practices/AGENTS.md +2934 -0
  96. package/templates/admin-root/.agents/skills/vercel-react-best-practices/SKILL.md +136 -0
  97. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  98. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
  99. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
  100. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
  101. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
  102. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
  103. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
  104. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
  105. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
  106. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
  107. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
  108. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  109. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
  110. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
  111. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
  112. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
  113. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
  114. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
  115. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
  116. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
  117. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
  118. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
  119. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
  120. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
  121. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
  122. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
  123. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
  124. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
  125. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
  126. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
  127. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  128. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
  129. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
  130. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  131. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  132. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
  133. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
  134. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
  135. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
  136. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
  137. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
  138. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
  139. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
  140. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  141. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
  142. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
  143. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
  144. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
  145. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
  146. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
  147. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
  148. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
  149. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
  150. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
  151. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
  152. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
  153. package/templates/admin-root/.agents/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
  154. package/templates/admin-root/.claude/settings.json +5 -0
  155. package/templates/admin-root/.claude/skills/component-doc/SKILL.md +304 -0
  156. package/templates/admin-root/.claude/skills/component-refactoring/SKILL.md +483 -0
  157. package/templates/admin-root/.claude/skills/component-refactoring/references/complexity-patterns.md +493 -0
  158. package/templates/admin-root/.claude/skills/component-refactoring/references/component-splitting.md +477 -0
  159. package/templates/admin-root/.claude/skills/component-refactoring/references/hook-extraction.md +317 -0
  160. package/templates/admin-root/.claude/skills/doc-coauthoring/SKILL.md +375 -0
  161. package/templates/admin-root/.claude/skills/feature-dev/SKILL.md +78 -0
  162. package/templates/admin-root/.claude/skills/frontend-code-review/SKILL.md +73 -0
  163. package/templates/admin-root/.claude/skills/frontend-code-review/references/business-logic.md +15 -0
  164. package/templates/admin-root/.claude/skills/frontend-code-review/references/code-quality.md +44 -0
  165. package/templates/admin-root/.claude/skills/frontend-code-review/references/performance.md +45 -0
  166. package/templates/admin-root/.claude/skills/frontend-design/LICENSE.txt +177 -0
  167. package/templates/admin-root/.claude/skills/frontend-design/SKILL.md +42 -0
  168. package/templates/admin-root/.claude/skills/frontend-testing/SKILL.md +325 -0
  169. package/templates/admin-root/.claude/skills/frontend-testing/assets/component-test.template.tsx +293 -0
  170. package/templates/admin-root/.claude/skills/frontend-testing/assets/hook-test.template.ts +207 -0
  171. package/templates/admin-root/.claude/skills/frontend-testing/assets/utility-test.template.ts +154 -0
  172. package/templates/admin-root/.claude/skills/frontend-testing/references/async-testing.md +345 -0
  173. package/templates/admin-root/.claude/skills/frontend-testing/references/checklist.md +205 -0
  174. package/templates/admin-root/.claude/skills/frontend-testing/references/common-patterns.md +449 -0
  175. package/templates/admin-root/.claude/skills/frontend-testing/references/domain-components.md +523 -0
  176. package/templates/admin-root/.claude/skills/frontend-testing/references/mocking.md +512 -0
  177. package/templates/admin-root/.claude/skills/frontend-testing/references/workflow.md +269 -0
  178. package/templates/admin-root/.claude/skills/migrate-nativewind-to-uniwind +1 -0
  179. package/templates/admin-root/.claude/skills/native-component-doc/SKILL.md +245 -0
  180. package/templates/admin-root/.claude/skills/senior-frontend/SKILL.md +209 -0
  181. package/templates/admin-root/.claude/skills/senior-frontend/references/frontend_best_practices.md +103 -0
  182. package/templates/admin-root/.claude/skills/senior-frontend/references/nextjs_optimization_guide.md +103 -0
  183. package/templates/admin-root/.claude/skills/senior-frontend/references/react_patterns.md +103 -0
  184. package/templates/admin-root/.claude/skills/senior-frontend/scripts/bundle_analyzer.py +114 -0
  185. package/templates/admin-root/.claude/skills/senior-frontend/scripts/component_generator.py +114 -0
  186. package/templates/admin-root/.claude/skills/senior-frontend/scripts/frontend_scaffolder.py +114 -0
  187. package/templates/admin-root/.claude/skills/skill-creator/SKILL.md +355 -0
  188. package/templates/admin-root/.claude/skills/skill-creator/references/output-patterns.md +86 -0
  189. package/templates/admin-root/.claude/skills/skill-creator/references/workflows.md +28 -0
  190. package/templates/admin-root/.claude/skills/skill-creator/scripts/init_skill.py +300 -0
  191. package/templates/admin-root/.claude/skills/skill-creator/scripts/package_skill.py +110 -0
  192. package/templates/admin-root/.claude/skills/skill-creator/scripts/quick_validate.py +97 -0
  193. package/templates/admin-root/.claude/skills/ui-ux-pro-max/SKILL.md +386 -0
  194. package/templates/admin-root/.claude/skills/ui-ux-pro-max/data +1 -0
  195. package/templates/admin-root/.claude/skills/ui-ux-pro-max/scripts +1 -0
  196. package/templates/admin-root/.claude/skills/uniwind +1 -0
  197. package/templates/admin-root/.claude/skills/vercel-react-best-practices/AGENTS.md +2934 -0
  198. package/templates/admin-root/.claude/skills/vercel-react-best-practices/SKILL.md +136 -0
  199. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  200. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
  201. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
  202. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
  203. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
  204. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
  205. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
  206. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
  207. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
  208. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
  209. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
  210. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  211. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
  212. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
  213. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
  214. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
  215. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
  216. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
  217. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
  218. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
  219. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
  220. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
  221. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
  222. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
  223. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
  224. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
  225. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
  226. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
  227. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
  228. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
  229. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  230. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
  231. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
  232. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  233. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  234. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
  235. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
  236. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
  237. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
  238. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
  239. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
  240. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
  241. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
  242. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  243. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
  244. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
  245. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
  246. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
  247. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
  248. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
  249. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
  250. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
  251. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
  252. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
  253. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
  254. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
  255. package/templates/admin-root/.claude/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
  256. package/templates/admin-root/.cursor/settings.json +10 -0
  257. package/templates/admin-root/.editorconfig +19 -0
  258. package/templates/admin-root/.gitattributes +16 -0
  259. package/templates/admin-root/.oxfmtrc.json +35 -0
  260. package/templates/admin-root/AGENTS.md +297 -0
  261. package/templates/admin-root/CLAUDE.md +1 -0
  262. package/templates/admin-root/skills-lock.json +27 -0
  263. package/templates/admin-root.manifest.json +1317 -0
  264. package/templates/admin.meta.json +9 -4
  265. package/LICENSE +0 -21
package/README.md CHANGED
@@ -144,10 +144,13 @@ pnpm sa create-admin my-admin --install
144
144
 
145
145
  从 `apps/admin` 生成 `packages/@core/scripts/templates/admin`。`apps/admin` 是唯一源码,模板目录是发布快照,不手工维护。
146
146
 
147
- 同步产出两样东西:
147
+ 同步产出三样东西:
148
148
 
149
- 1. `templates/admin/` —— `apps/admin` 的逐字节镜像。跳过 `node_modules`、`dist`、`.turbo`、`.tanstack`、`coverage`、`.DS_Store`、本地 `.env.*.local` `src/features/router/routeTree.gen.ts`,再根据模板自身的 `src/pages` 重新生成 `routeTree.gen.ts`。
150
- 2. `templates/admin.meta.json` —— 物化元数据。**只有在 monorepo 内才解析得出**,所以必须在同步期算好:解析后的依赖版本、展平后的 tsconfig oxlint 配置、根级 `overrides`、以及未发布的 workspace 包清单。`create-admin` 的 standalone 模式只读这份文件做替换,不需要 monorepo 在场。
149
+ 1. `templates/admin-root/` + `templates/admin-root.manifest.json` —— 仓库根级工程文件快照。包含 Git 已跟踪的根级点文件/点目录,以及 `AGENTS.md`、`CLAUDE.md`、`skills-lock.json`;排除 `.git`、缓存、构建产物、本机文件,以及 admin 模板已经自带的 `.oxlintrc.json`。manifest 用于还原 npm 固定忽略的 `.npmignore`、`.npmrc` 等点文件及符号链接。
150
+ 2. `templates/admin/` —— `apps/admin` 的逐字节镜像。跳过 `node_modules`、`dist`、`.turbo`、`.tanstack`、`coverage`、`.DS_Store`、本地 `.env.*.local` `src/features/router/routeTree.gen.ts`,再根据模板自身的 `src/pages` 重新生成 `routeTree.gen.ts`。
151
+ 3. `templates/admin.meta.json` —— 物化元数据。**只有在 monorepo 内才解析得出**,所以必须在同步期算好:解析后的依赖版本、展平后的 tsconfig 与 oxlint 配置、根级 `overrides`、以及未发布的 workspace 包清单。`create-admin` 的 standalone 模式只读这份文件做替换,不需要 monorepo 在场。
152
+
153
+ `create-admin` 会先复制 `admin-root`,再覆盖 `admin`。因此协作说明、编辑器配置、skills 和格式化配置会进入新项目;`package.json`、`README.md`、`.oxlintrc.json` 等应用已有文件只取 admin 模板版本。
151
154
 
152
155
  元数据放在 `templates/admin/` **外层**,这样快照目录仍是纯镜像,逐字节比对不需要为 sidecar 开特例。
153
156
 
package/dist/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { h as genChangelog, i as release, l as createAdminTemplate, m as cleanup, n as updatePkg, o as gitCommit, r as syncAdminTemplate, s as gitCommitVerify, t as loadCliOptions } from "./config-BKkdncJS.mjs";
1
+ import { h as genChangelog, i as release, l as createAdminTemplate, m as cleanup, n as updatePkg, o as gitCommit, r as syncAdminTemplate, s as gitCommitVerify, t as loadCliOptions } from "./config-Cj9IzlRz.mjs";
2
2
  import process from "node:process";
3
3
  import { blue, lightGreen, red } from "kolorist";
4
4
  import { cac } from "cac";
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
2
2
  import { generateChangelog, generateTotalChangelog } from "@soybeanjs/changelog";
3
3
  import { rimraf } from "rimraf";
4
4
  import { existsSync, readFileSync } from "node:fs";
5
- import { cp, mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
5
+ import { cp, lstat, mkdir, mkdtemp, readFile, readdir, readlink, rm, stat, symlink, writeFile } from "node:fs/promises";
6
6
  import path from "node:path";
7
7
  import process from "node:process";
8
8
  import { bgRed, cyan, green, red, yellow } from "kolorist";
@@ -249,6 +249,12 @@ function toStoragePrefix(name) {
249
249
  function getTemplateDir() {
250
250
  return path.join(getPackageRoot(), "templates", TEMPLATE_NAME$1);
251
251
  }
252
+ function getRootTemplateDir() {
253
+ return path.join(getPackageRoot(), "templates", "admin-root");
254
+ }
255
+ function getRootTemplateManifestPath() {
256
+ return path.join(getPackageRoot(), "templates", "admin-root.manifest.json");
257
+ }
252
258
  function getShellTemplateDir() {
253
259
  return path.join(getPackageRoot(), "templates", "admin-shell");
254
260
  }
@@ -288,6 +294,28 @@ async function installDependencies(cwd) {
288
294
  stdio: "inherit"
289
295
  });
290
296
  }
297
+ async function restoreRootTemplateFiles(targetDir) {
298
+ const manifestPath = getRootTemplateManifestPath();
299
+ if (!existsSync(manifestPath)) throw new Error(`Admin root template manifest is missing: ${manifestPath}`);
300
+ const entries = JSON.parse(await readFile(manifestPath, "utf8"));
301
+ await Promise.all(entries.map(async (entry) => {
302
+ const target = path.resolve(targetDir, entry.path);
303
+ const relativeTarget = path.relative(targetDir, target);
304
+ if (path.isAbsolute(entry.path) || relativeTarget.startsWith("..") || path.isAbsolute(relativeTarget)) throw new Error(`Invalid admin root template path: ${entry.path}`);
305
+ await mkdir(path.dirname(target), { recursive: true });
306
+ if (entry.type === "symlink") {
307
+ if (!entry.target) throw new Error(`Admin root template symlink target is missing: ${entry.path}`);
308
+ await rm(target, {
309
+ force: true,
310
+ recursive: true
311
+ });
312
+ await symlink(entry.target, target);
313
+ return;
314
+ }
315
+ if (entry.content === void 0) throw new Error(`Admin root template content is missing: ${entry.path}`);
316
+ await writeFile(target, Buffer.from(entry.content, "base64"));
317
+ }));
318
+ }
291
319
  /** 独立模式下把 monorepo 协议物化掉,并把物化过程中发现的隐患打印出来。 */
292
320
  async function applyStandaloneMaterialization(targetDir, packageName, description) {
293
321
  const metaPath = getTemplateMetaPath();
@@ -309,7 +337,9 @@ async function createAdminTemplate(name, options = {}) {
309
337
  const directoryName = packageName.replace(/^@[^/]+\//, "");
310
338
  const targetDir = path.resolve(process.cwd(), options.target || path.join("apps", directoryName));
311
339
  const templateDir = getTemplateDir();
340
+ const rootTemplateDir = getRootTemplateDir();
312
341
  if (!existsSync(templateDir)) throw new Error(`Admin template is missing: ${templateDir}`);
342
+ if (!existsSync(rootTemplateDir)) throw new Error(`Admin root template is missing: ${rootTemplateDir}`);
313
343
  if (existsSync(targetDir) && !await isDirectoryEmpty(targetDir)) {
314
344
  if (!options.force) throw new Error(`Target directory is not empty: ${targetDir}. Use --force to overwrite it.`);
315
345
  await rm(targetDir, {
@@ -318,6 +348,11 @@ async function createAdminTemplate(name, options = {}) {
318
348
  });
319
349
  }
320
350
  await mkdir(path.dirname(targetDir), { recursive: true });
351
+ await cp(rootTemplateDir, targetDir, {
352
+ recursive: true,
353
+ verbatimSymlinks: true
354
+ });
355
+ await restoreRootTemplateFiles(targetDir);
321
356
  await cp(templateDir, targetDir, { recursive: true });
322
357
  if (options.workspace) await updatePackageJson(targetDir, packageName, description);
323
358
  else {
@@ -698,9 +733,21 @@ async function resolveTemplateMeta(options) {
698
733
  //#endregion
699
734
  //#region src/commands/sync-admin-template.ts
700
735
  const TEMPLATE_NAME = "admin";
701
- /** shell 源码模板目录名,与 templates/admin 平级,保持 admin/ 仍是 apps/admin 的逐字节镜像。 */
736
+ /** 仓库根级工程文件模板目录;生成项目时先铺这一层,再由 admin 应用文件覆盖同名项。 */
737
+ const ROOT_TEMPLATE_NAME = "admin-root";
738
+ /** Npm 会主动忽略部分点文件,因此另存一份可完整还原根快照的清单。 */
739
+ const ROOT_TEMPLATE_MANIFEST_FILE = "admin-root.manifest.json";
740
+ /** 不以点开头、但应随新项目保留的仓库根级文件。 */
741
+ const ROOT_TEMPLATE_FILES = [
742
+ "AGENTS.md",
743
+ "CLAUDE.md",
744
+ "skills-lock.json"
745
+ ];
746
+ /** Admin 应用模板已有自己的版本,不再从仓库根重复复制。 */
747
+ const ROOT_TEMPLATE_EXCLUDED_FILES = new Set([".oxlintrc.json"]);
748
+ /** Shell 源码模板目录名,与 templates/admin 平级,保持 admin/ 仍是 apps/admin 的逐字节镜像。 */
702
749
  const SHELL_TEMPLATE_NAME = "admin-shell";
703
- /** shell 里会被复制进生成项目 src/framework 的运行时目录;配置、测试与文档不属于产物。 */
750
+ /** Shell 里会被复制进生成项目 src/framework 的运行时目录;配置、测试与文档不属于产物。 */
704
751
  const SHELL_RUNTIME_DIRS = [
705
752
  "i18n",
706
753
  "layouts",
@@ -716,6 +763,7 @@ const MAX_REPORTED_DIFFERENCES = 20;
716
763
  const TECHNICAL_DIRS = new Set([
717
764
  ".tanstack",
718
765
  ".turbo",
766
+ "__pycache__",
719
767
  "coverage",
720
768
  "dist",
721
769
  "node_modules"
@@ -731,7 +779,7 @@ function isTechnicalGeneratedPath(relativePath) {
731
779
  if (!relativePath) return false;
732
780
  const segments = relativePath.split("/");
733
781
  const basename = segments.at(-1);
734
- return basename === ".DS_Store" || basename?.endsWith(".tsbuildinfo") || basename?.endsWith(".log") || isLocalEnvFile(relativePath) || segments.some((segment) => TECHNICAL_DIRS.has(segment));
782
+ return basename === ".DS_Store" || basename?.endsWith(".pyc") || basename?.endsWith(".tsbuildinfo") || basename?.endsWith(".log") || isLocalEnvFile(relativePath) || segments.some((segment) => TECHNICAL_DIRS.has(segment));
735
783
  }
736
784
  function isRouteTreeFile(relativePath) {
737
785
  return relativePath === "src/features/router/routeTree.gen.ts";
@@ -748,6 +796,46 @@ function resolveSourceDir(workspaceRoot, source) {
748
796
  function resolveTargetDir(target) {
749
797
  return path.resolve(process.cwd(), target || path.join(getPackageRoot(), "templates", TEMPLATE_NAME));
750
798
  }
799
+ async function collectTrackedRootTemplateFiles(workspaceRoot) {
800
+ const { execa } = await import("execa");
801
+ const { stdout } = await execa("git", [
802
+ "ls-files",
803
+ "-z",
804
+ "--",
805
+ ".*",
806
+ ...ROOT_TEMPLATE_FILES
807
+ ], { cwd: workspaceRoot });
808
+ return stdout.split("\0").map(normalizeRelativePath).filter(Boolean).filter((relativePath) => !ROOT_TEMPLATE_EXCLUDED_FILES.has(relativePath)).filter((relativePath) => !isTechnicalGeneratedPath(relativePath));
809
+ }
810
+ async function copyRootSource(workspaceRoot, targetDir) {
811
+ await rm(targetDir, {
812
+ force: true,
813
+ recursive: true
814
+ });
815
+ const files = await collectTrackedRootTemplateFiles(workspaceRoot);
816
+ const manifestEntries = [];
817
+ for (const relativePath of files) {
818
+ const source = path.join(workspaceRoot, relativePath);
819
+ const target = path.join(targetDir, relativePath);
820
+ const sourceStat = await lstat(source);
821
+ await mkdir(path.dirname(target), { recursive: true });
822
+ await cp(source, target, {
823
+ recursive: true,
824
+ verbatimSymlinks: true
825
+ });
826
+ if (sourceStat.isSymbolicLink()) manifestEntries.push({
827
+ path: relativePath,
828
+ target: await readlink(source),
829
+ type: "symlink"
830
+ });
831
+ else if (sourceStat.isFile()) manifestEntries.push({
832
+ content: (await readFile(source)).toString("base64"),
833
+ path: relativePath,
834
+ type: "file"
835
+ });
836
+ }
837
+ await writeFile(path.join(path.dirname(targetDir), ROOT_TEMPLATE_MANIFEST_FILE), `${JSON.stringify(manifestEntries, null, 2)}\n`);
838
+ }
751
839
  async function copyAdminSource(sourceDir, targetDir) {
752
840
  await rm(targetDir, {
753
841
  force: true,
@@ -861,6 +949,7 @@ async function generateSnapshot(workspaceRoot, sourceDir, targetDir) {
861
949
  if (!existsSync(sourceDir)) throw new Error(`Admin source is missing: ${sourceDir}`);
862
950
  const shellSourceDir = path.join(workspaceRoot, "packages/web/admin");
863
951
  const shellTargetDir = path.join(path.dirname(targetDir), SHELL_TEMPLATE_NAME);
952
+ await copyRootSource(workspaceRoot, path.join(path.dirname(targetDir), ROOT_TEMPLATE_NAME));
864
953
  await copyAdminSource(sourceDir, targetDir);
865
954
  await copyShellSource(shellSourceDir, shellTargetDir);
866
955
  await generateRouteTree(targetDir);
@@ -891,11 +980,22 @@ async function checkAdminTemplate(workspaceRoot, sourceDir, targetDir) {
891
980
  const { metaContent } = await generateSnapshot(workspaceRoot, sourceDir, generatedDir);
892
981
  const differences = await compareDirectories(targetDir, generatedDir);
893
982
  const shellDifferences = await compareDirectories(path.join(path.dirname(targetDir), SHELL_TEMPLATE_NAME), path.join(tempDir, SHELL_TEMPLATE_NAME));
894
- differences.push(...shellDifferences.map((item) => ({
983
+ const rootDifferences = await compareDirectories(path.join(path.dirname(targetDir), ROOT_TEMPLATE_NAME), path.join(tempDir, ROOT_TEMPLATE_NAME));
984
+ differences.push(...rootDifferences.map((item) => ({
985
+ ...item,
986
+ path: `${ROOT_TEMPLATE_NAME}/${item.path}`
987
+ })), ...shellDifferences.map((item) => ({
895
988
  ...item,
896
989
  path: `${SHELL_TEMPLATE_NAME}/${item.path}`
897
990
  })));
898
991
  const currentMetaContent = await readMetaContent(path.join(path.dirname(targetDir), TEMPLATE_META_FILE));
992
+ const rootManifestPath = path.join(path.dirname(targetDir), ROOT_TEMPLATE_MANIFEST_FILE);
993
+ const generatedRootManifestPath = path.join(tempDir, ROOT_TEMPLATE_MANIFEST_FILE);
994
+ const [currentRootManifest, generatedRootManifest] = await Promise.all([readMetaContent(rootManifestPath), readMetaContent(generatedRootManifestPath)]);
995
+ if (currentRootManifest !== generatedRootManifest) differences.push({
996
+ path: ROOT_TEMPLATE_MANIFEST_FILE,
997
+ type: currentRootManifest ? "changed" : "added"
998
+ });
899
999
  if (currentMetaContent !== metaContent) differences.push({
900
1000
  path: TEMPLATE_META_FILE,
901
1001
  type: currentMetaContent ? "changed" : "added"
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as createCommitMessageRegExp, c as locales, d as replaceEnvValue, f as toStoragePrefix, h as genChangelog, i as release, l as createAdminTemplate, m as cleanup, n as updatePkg, o as gitCommit, p as toTitle, r as syncAdminTemplate, s as gitCommitVerify, t as loadCliOptions, u as normalizePackageName } from "./config-BKkdncJS.mjs";
1
+ import { a as createCommitMessageRegExp, c as locales, d as replaceEnvValue, f as toStoragePrefix, h as genChangelog, i as release, l as createAdminTemplate, m as cleanup, n as updatePkg, o as gitCommit, p as toTitle, r as syncAdminTemplate, s as gitCommitVerify, t as loadCliOptions, u as normalizePackageName } from "./config-Cj9IzlRz.mjs";
2
2
 
3
3
  //#region src/index.ts
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyroc/scripts",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "type": "module",
5
5
  "description": "Skyroc admin CLI - changelog, release, git-commit, cleanup and other project automation scripts",
6
6
  "keywords": [
@@ -67,8 +67,8 @@
67
67
  "tsx": "^4.21.0",
68
68
  "typescript": "^6.0.3",
69
69
  "vitest": "^4.0.18",
70
- "@skyroc/config": "1.0.0",
71
- "@skyroc/tsconfig": "1.0.0"
70
+ "@skyroc/tsconfig": "1.0.0",
71
+ "@skyroc/config": "1.0.0"
72
72
  },
73
73
  "scripts": {
74
74
  "build": "tsdown",
@@ -39,6 +39,10 @@
39
39
  "update-pkg": "sa update-pkg"
40
40
  },
41
41
  "dependencies": {
42
+ "@better-scroll/core": "catalog:web",
43
+ "@dnd-kit/core": "^6.3.1",
44
+ "@dnd-kit/sortable": "^10.0.0",
45
+ "@dnd-kit/utilities": "^3.2.2",
42
46
  "@skyroc/axios": "workspace:*",
43
47
  "@skyroc/color": "workspace:*",
44
48
  "@skyroc/core-state": "workspace:*",
@@ -68,7 +72,7 @@
68
72
  "@iconify/json": "catalog:ui-shared",
69
73
  "@iconify/react": "catalog:ui-shared",
70
74
  "@iconify/types": "catalog:ui-shared",
71
- "@sa/uno-config": "workspace:*",
75
+ "@skyroc/uno-config": "workspace:*",
72
76
  "@skyroc/scripts": "workspace:*",
73
77
  "@skyroc/web-admin-vite": "workspace:*",
74
78
  "@svgr/core": "catalog:web",
@@ -1,3 +1,3 @@
1
1
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 160" role="img" aria-label="Skyroc 天鹏">
2
- <path fill="#6366F1" fill-rule="evenodd" d="M 8.31 49.69 Q 8.00 51.38 8.00 54.15 Q 8.00 56.92 8.46 59.08 Q 8.92 61.23 9.85 63.54 Q 10.77 65.85 12.31 68.15 Q 13.85 70.46 15.77 72.38 Q 17.69 74.31 19.85 75.85 Q 22.00 77.38 24.46 78.62 Q 26.92 79.85 30.85 81.00 Q 34.77 82.15 31.92 82.23 Q 29.08 82.31 27.38 82.00 Q 25.69 81.69 23.85 81.08 Q 22.00 80.46 19.23 78.92 Q 16.46 77.38 16.38 78.08 Q 16.31 78.77 16.77 80.15 Q 17.23 81.54 18.15 83.23 Q 19.08 84.92 22.08 87.92 Q 25.08 90.92 28.15 92.46 Q 31.23 94.00 36.00 94.77 Q 40.77 95.54 44.62 95.23 Q 48.46 94.92 53.85 93.69 Q 59.23 92.46 62.15 92.46 Q 65.08 92.46 67.38 93.38 Q 69.69 94.31 70.85 95.46 Q 72.00 96.62 72.46 97.54 Q 72.92 98.46 72.77 100.77 Q 72.62 103.08 71.54 105.38 Q 70.46 107.69 66.92 113.23 Q 63.38 118.77 62.92 120.31 Q 62.46 121.85 62.46 123.54 Q 62.46 125.23 63.08 126.92 Q 63.69 128.62 64.69 129.62 Q 65.69 130.62 69.00 123.92 Q 72.31 117.23 73.92 111.15 Q 75.54 105.08 75.62 108.38 Q 75.69 111.69 74.31 118.31 Q 72.92 124.92 72.77 126.92 Q 72.62 128.92 72.92 130.62 Q 73.23 132.31 74.15 134.31 Q 75.08 136.31 77.31 139.00 Q 79.54 141.69 80.00 141.69 Q 80.46 141.69 81.31 140.85 Q 82.15 140.00 83.85 137.69 Q 85.54 135.38 86.46 132.46 Q 87.38 129.54 87.23 127.08 Q 87.08 124.62 85.69 117.54 Q 84.31 110.46 84.38 107.62 Q 84.46 104.77 86.23 111.31 Q 88.00 117.85 91.00 124.23 Q 94.00 130.62 95.00 129.77 Q 96.00 128.92 96.77 127.23 Q 97.54 125.54 97.54 123.38 Q 97.54 121.23 97.08 119.85 Q 96.62 118.46 93.38 113.54 Q 90.15 108.62 88.77 105.54 Q 87.38 102.46 87.23 100.77 Q 87.08 99.08 88.00 97.38 Q 88.92 95.69 90.08 94.69 Q 91.23 93.69 93.23 92.92 Q 95.23 92.15 97.54 92.15 Q 99.85 92.15 107.08 93.69 Q 114.31 95.23 118.31 95.23 Q 122.31 95.23 126.31 94.15 Q 130.31 93.08 133.08 91.38 Q 135.85 89.69 138.69 86.54 Q 141.54 83.38 142.69 80.38 Q 143.85 77.38 139.08 79.54 Q 134.31 81.69 132.62 82.00 Q 130.92 82.31 128.23 82.23 Q 125.54 82.15 129.00 81.15 Q 132.46 80.15 135.54 78.62 Q 138.62 77.08 140.31 75.85 Q 142.00 74.62 144.69 71.77 Q 147.38 68.92 148.77 66.46 Q 150.15 64.00 150.92 61.54 Q 151.69 59.08 151.85 55.08 Q 152.00 51.08 151.54 49.08 Q 151.08 47.08 150.77 47.08 Q 150.46 47.08 147.85 51.08 Q 145.23 55.08 140.69 59.15 Q 136.15 63.23 131.08 66.00 Q 126.00 68.77 119.69 70.92 Q 113.38 73.08 109.69 74.77 Q 106.00 76.46 101.85 79.85 Q 97.69 83.23 97.46 83.15 Q 97.23 83.08 98.77 80.92 Q 100.31 78.77 103.62 75.92 Q 106.92 73.08 110.62 71.08 Q 114.31 69.08 119.54 67.08 Q 124.77 65.08 129.54 62.46 Q 134.31 59.85 137.31 57.15 Q 140.31 54.46 141.85 52.31 Q 143.38 50.15 144.77 46.31 Q 146.15 42.46 146.15 38.62 Q 146.15 34.77 145.38 32.00 Q 144.62 29.23 143.54 26.92 Q 142.46 24.62 139.92 21.46 Q 137.38 18.31 136.54 22.69 Q 135.69 27.08 134.62 29.85 Q 133.54 32.62 130.00 38.00 Q 126.46 43.38 121.62 48.08 Q 116.77 52.77 108.15 59.38 Q 99.54 66.00 95.08 70.77 Q 90.62 75.54 89.92 75.00 Q 89.23 74.46 88.46 73.08 Q 87.69 71.69 87.38 68.92 Q 87.08 66.15 88.15 63.69 Q 89.23 61.23 90.54 60.08 Q 91.85 58.92 93.15 58.54 Q 94.46 58.15 93.77 57.15 Q 93.08 56.15 88.92 56.31 Q 84.77 56.46 82.62 57.69 Q 80.46 58.92 78.69 60.85 Q 76.92 62.77 77.85 62.77 Q 78.77 62.77 76.62 66.77 Q 74.46 70.77 72.85 72.38 Q 71.23 74.00 70.15 74.46 Q 69.08 74.92 64.46 70.15 Q 59.85 65.38 51.23 58.77 Q 42.62 52.15 38.08 47.77 Q 33.54 43.38 31.54 40.77 Q 29.54 38.15 27.85 35.08 Q 26.15 32.00 25.08 28.92 Q 24.00 25.85 23.31 22.08 Q 22.62 18.31 20.23 21.31 Q 17.85 24.31 16.77 26.46 Q 15.69 28.62 14.77 31.85 Q 13.85 35.08 13.85 38.77 Q 13.85 42.46 15.23 46.31 Q 16.62 50.15 18.15 52.31 Q 19.69 54.46 23.62 57.77 Q 27.54 61.08 30.77 62.77 Q 34.00 64.46 40.00 66.77 Q 46.00 69.08 50.46 71.54 Q 54.92 74.00 57.77 76.69 Q 60.62 79.38 61.77 81.46 Q 62.92 83.54 60.46 81.23 Q 58.00 78.92 55.23 77.08 Q 52.46 75.23 49.69 74.00 Q 46.92 72.77 39.85 70.46 Q 32.77 68.15 27.69 65.23 Q 22.62 62.31 19.00 59.00 Q 15.38 55.69 12.38 51.31 Q 9.38 46.92 9.00 47.46 Q 8.62 48.00 8.31 49.69 Z"/>
2
+ <path fill="currentColor" fill-rule="evenodd" d="M 8.31 49.69 Q 8.00 51.38 8.00 54.15 Q 8.00 56.92 8.46 59.08 Q 8.92 61.23 9.85 63.54 Q 10.77 65.85 12.31 68.15 Q 13.85 70.46 15.77 72.38 Q 17.69 74.31 19.85 75.85 Q 22.00 77.38 24.46 78.62 Q 26.92 79.85 30.85 81.00 Q 34.77 82.15 31.92 82.23 Q 29.08 82.31 27.38 82.00 Q 25.69 81.69 23.85 81.08 Q 22.00 80.46 19.23 78.92 Q 16.46 77.38 16.38 78.08 Q 16.31 78.77 16.77 80.15 Q 17.23 81.54 18.15 83.23 Q 19.08 84.92 22.08 87.92 Q 25.08 90.92 28.15 92.46 Q 31.23 94.00 36.00 94.77 Q 40.77 95.54 44.62 95.23 Q 48.46 94.92 53.85 93.69 Q 59.23 92.46 62.15 92.46 Q 65.08 92.46 67.38 93.38 Q 69.69 94.31 70.85 95.46 Q 72.00 96.62 72.46 97.54 Q 72.92 98.46 72.77 100.77 Q 72.62 103.08 71.54 105.38 Q 70.46 107.69 66.92 113.23 Q 63.38 118.77 62.92 120.31 Q 62.46 121.85 62.46 123.54 Q 62.46 125.23 63.08 126.92 Q 63.69 128.62 64.69 129.62 Q 65.69 130.62 69.00 123.92 Q 72.31 117.23 73.92 111.15 Q 75.54 105.08 75.62 108.38 Q 75.69 111.69 74.31 118.31 Q 72.92 124.92 72.77 126.92 Q 72.62 128.92 72.92 130.62 Q 73.23 132.31 74.15 134.31 Q 75.08 136.31 77.31 139.00 Q 79.54 141.69 80.00 141.69 Q 80.46 141.69 81.31 140.85 Q 82.15 140.00 83.85 137.69 Q 85.54 135.38 86.46 132.46 Q 87.38 129.54 87.23 127.08 Q 87.08 124.62 85.69 117.54 Q 84.31 110.46 84.38 107.62 Q 84.46 104.77 86.23 111.31 Q 88.00 117.85 91.00 124.23 Q 94.00 130.62 95.00 129.77 Q 96.00 128.92 96.77 127.23 Q 97.54 125.54 97.54 123.38 Q 97.54 121.23 97.08 119.85 Q 96.62 118.46 93.38 113.54 Q 90.15 108.62 88.77 105.54 Q 87.38 102.46 87.23 100.77 Q 87.08 99.08 88.00 97.38 Q 88.92 95.69 90.08 94.69 Q 91.23 93.69 93.23 92.92 Q 95.23 92.15 97.54 92.15 Q 99.85 92.15 107.08 93.69 Q 114.31 95.23 118.31 95.23 Q 122.31 95.23 126.31 94.15 Q 130.31 93.08 133.08 91.38 Q 135.85 89.69 138.69 86.54 Q 141.54 83.38 142.69 80.38 Q 143.85 77.38 139.08 79.54 Q 134.31 81.69 132.62 82.00 Q 130.92 82.31 128.23 82.23 Q 125.54 82.15 129.00 81.15 Q 132.46 80.15 135.54 78.62 Q 138.62 77.08 140.31 75.85 Q 142.00 74.62 144.69 71.77 Q 147.38 68.92 148.77 66.46 Q 150.15 64.00 150.92 61.54 Q 151.69 59.08 151.85 55.08 Q 152.00 51.08 151.54 49.08 Q 151.08 47.08 150.77 47.08 Q 150.46 47.08 147.85 51.08 Q 145.23 55.08 140.69 59.15 Q 136.15 63.23 131.08 66.00 Q 126.00 68.77 119.69 70.92 Q 113.38 73.08 109.69 74.77 Q 106.00 76.46 101.85 79.85 Q 97.69 83.23 97.46 83.15 Q 97.23 83.08 98.77 80.92 Q 100.31 78.77 103.62 75.92 Q 106.92 73.08 110.62 71.08 Q 114.31 69.08 119.54 67.08 Q 124.77 65.08 129.54 62.46 Q 134.31 59.85 137.31 57.15 Q 140.31 54.46 141.85 52.31 Q 143.38 50.15 144.77 46.31 Q 146.15 42.46 146.15 38.62 Q 146.15 34.77 145.38 32.00 Q 144.62 29.23 143.54 26.92 Q 142.46 24.62 139.92 21.46 Q 137.38 18.31 136.54 22.69 Q 135.69 27.08 134.62 29.85 Q 133.54 32.62 130.00 38.00 Q 126.46 43.38 121.62 48.08 Q 116.77 52.77 108.15 59.38 Q 99.54 66.00 95.08 70.77 Q 90.62 75.54 89.92 75.00 Q 89.23 74.46 88.46 73.08 Q 87.69 71.69 87.38 68.92 Q 87.08 66.15 88.15 63.69 Q 89.23 61.23 90.54 60.08 Q 91.85 58.92 93.15 58.54 Q 94.46 58.15 93.77 57.15 Q 93.08 56.15 88.92 56.31 Q 84.77 56.46 82.62 57.69 Q 80.46 58.92 78.69 60.85 Q 76.92 62.77 77.85 62.77 Q 78.77 62.77 76.62 66.77 Q 74.46 70.77 72.85 72.38 Q 71.23 74.00 70.15 74.46 Q 69.08 74.92 64.46 70.15 Q 59.85 65.38 51.23 58.77 Q 42.62 52.15 38.08 47.77 Q 33.54 43.38 31.54 40.77 Q 29.54 38.15 27.85 35.08 Q 26.15 32.00 25.08 28.92 Q 24.00 25.85 23.31 22.08 Q 22.62 18.31 20.23 21.31 Q 17.85 24.31 16.77 26.46 Q 15.69 28.62 14.77 31.85 Q 13.85 35.08 13.85 38.77 Q 13.85 42.46 15.23 46.31 Q 16.62 50.15 18.15 52.31 Q 19.69 54.46 23.62 57.77 Q 27.54 61.08 30.77 62.77 Q 34.00 64.46 40.00 66.77 Q 46.00 69.08 50.46 71.54 Q 54.92 74.00 57.77 76.69 Q 60.62 79.38 61.77 81.46 Q 62.92 83.54 60.46 81.23 Q 58.00 78.92 55.23 77.08 Q 52.46 75.23 49.69 74.00 Q 46.92 72.77 39.85 70.46 Q 32.77 68.15 27.69 65.23 Q 22.62 62.31 19.00 59.00 Q 15.38 55.69 12.38 51.31 Q 9.38 46.92 9.00 47.46 Q 8.62 48.00 8.31 49.69 Z"/>
3
3
  </svg>
@@ -1,4 +1,4 @@
1
- import { presetSoybeanAdmin } from '@sa/uno-config';
1
+ import { presetSoybeanAdmin } from '@skyroc/uno-config';
2
2
  import { defineConfig, presetWind3, transformerDirectives, transformerVariantGroup } from 'unocss';
3
3
 
4
4
  export default defineConfig({
@@ -0,0 +1,304 @@
1
+ ---
2
+ name: component-doc
3
+ description: 为 @skyroc/web-ui 组件编写文档。当用户说出组件名(如 Button、Accordion、AlertDialog)时触发。自动定位组件源码、playground demo、已有文档,按照项目文档规范生成或更新 MDX 文档。
4
+ argument-hint: 组件名,如 Button、Accordion、AlertDialog
5
+ ---
6
+
7
+ # Component Documentation Workflow
8
+
9
+ 为 `@skyroc/web-ui` 组件库编写文档的专用工作流。
10
+
11
+ ## 文件定位规则
12
+
13
+ 给定组件名 `$COMPONENT`(用户输入,如 `Button`),将其转为 kebab-case `$slug`(如 `button`),然后按以下路径查找:
14
+
15
+ | 用途 | 路径 |
16
+ |---|---|
17
+ | 组件源码 | `packages/web/ui/shadcn/src/components/$slug/` |
18
+ | Playground Demo | `apps/web-ui-playground/src/app/[locale]/(demo)/$slug/modules/` |
19
+ | 文档 MDX | `apps/web-ui-docs/content/docs/components/$slug.mdx` |
20
+
21
+ **文档基础设施文件**(不需要每次都读,但需要了解):
22
+
23
+ | 文件 | 作用 |
24
+ |---|---|
25
+ | `apps/web-ui-docs/components/props-table.tsx` | `<PropsTable>` — API 属性表格 |
26
+ | `apps/web-ui-docs/components/type-table.tsx` | `<TypeTable>` + `<UnionType>` — 类型定义区 |
27
+ | `apps/web-ui-docs/components/type-anchor.tsx` | 类型链接解析(PascalCase 自定义类型 → 蓝色可点击锚点) |
28
+ | `apps/web-ui-docs/components/type-registry.ts` | 跨页面类型链接注册表 |
29
+ | `apps/web-ui-docs/components/demo/index.tsx` | `<Demo>` — 从 playground 加载 live demo |
30
+ | `apps/web-ui-docs/components/mdx.tsx` | MDX 组件注册(Demo / PropsTable / TypeTable / UnionType) |
31
+
32
+ ## 执行流程
33
+
34
+ ### Phase 1: 源码阅读与行为校验
35
+
36
+ 1. 读取 `packages/web/ui/shadcn/src/components/$slug/` 下所有文件
37
+ - 重点关注:`index.ts`(导出)、`types.ts`(Props 定义)、`*-variants.ts`(样式变体)、主组件文件
38
+ 2. 读取 `apps/web-ui-playground/src/app/[locale]/(demo)/$slug/modules/` 下所有 demo
39
+ - 如果目录不存在或 demo 数量不足以覆盖文档需要的功能章节,标记为"需创建 demo"
40
+ 3. 如果 preset 包装器存在,读取 `packages/web/ui/shadcn/src/preset/$slug/` 了解预设封装和 `useComponentConfig` 集成
41
+ 4. 如果已有文档 MDX,读取 `apps/web-ui-docs/content/docs/components/$slug.mdx`
42
+ 5. 读取一个已完成的文档作为参考模板(优先 `alert.mdx`,其次 `button.mdx`)
43
+
44
+ #### 实现一致性校验(必须执行)
45
+
46
+ 文档不是 API 想象稿,必须从 **源码、类型、demo、实际行为** 四者交叉验证。
47
+
48
+ 写文档前必须同时检查:
49
+
50
+ - `types.ts` 声明了哪些 public props / types
51
+ - 主组件实际解构了哪些 props
52
+ - props 是否真的传递给对应子组件或底层库
53
+ - 默认值实际在哪里设置
54
+ - `classNames` / slot props / `size` / `variant` / `color` 等样式控制是否真的生效
55
+ - `index.ts` 实际导出了哪些组件和类型
56
+
57
+ 如果发现 **类型/API 承诺** 与 **实现行为** 不一致:
58
+
59
+ 1. 先明确指出这是实现问题或 API 语义不一致
60
+ 2. 如果任务允许修改代码,应优先修实现或类型,而不是在文档里规避
61
+ 3. 如果不能修改实现,必须在最终说明中列为风险/阻塞,并在文档中避免承诺未实现能力
62
+ 4. 不允许只降低文档表述来掩盖实现 bug
63
+
64
+ 典型例子:
65
+
66
+ - `BottomSheetProps.size` 声明为主组件尺寸,但主组件没有传给 `BottomSheetContent`:这是实现 bug,应提出或修复
67
+ - props 被解构但没有使用:不要在文档中承诺该能力已生效
68
+ - 类型继承了底层库 props,但封装组件覆盖或丢弃了其中一部分:以实际封装行为为准
69
+
70
+ ### Phase 2: 文档编写
71
+
72
+ #### MDX 结构(必须遵循)
73
+
74
+ ```mdx
75
+ ---
76
+ title: $COMPONENT
77
+ description: 一句话描述组件用途
78
+ ---
79
+
80
+ 组件概述段落。
81
+
82
+ \`\`\`tsx
83
+ import { ... } from '@skyroc/web-ui';
84
+ \`\`\`
85
+
86
+ ## 何时使用
87
+
88
+ - 使用场景 1
89
+ - 使用场景 2
90
+ - 与相似组件的区分
91
+
92
+ ## 功能章节 1(如"颜色"、"变体"、"尺寸"等)
93
+
94
+ 说明文字 + 表格(可选)
95
+
96
+ <Demo src="@playground/$slug/modules/DemoName" />
97
+
98
+ \`\`\`tsx
99
+ // 内联代码作为 API 快速参考
100
+ <Component prop="value" />
101
+ \`\`\`
102
+
103
+ ## 功能章节 N
104
+
105
+ ...
106
+
107
+ ## API
108
+
109
+ ### $COMPONENT
110
+
111
+ 通用属性参考说明。
112
+
113
+ <PropsTable data={[...]} />
114
+
115
+ ### 子组件(如有)
116
+
117
+ <PropsTable data={[...]} />
118
+
119
+ ## 类型
120
+
121
+ <TypeTable data={[...]} />
122
+ <UnionType name="..." description="..." type="..." />
123
+ ```
124
+
125
+ #### Demo + 内联代码的组合模式(必须遵循)
126
+
127
+ 每个功能章节的示例由两部分组成,缺一不可:
128
+
129
+ 1. **`<Demo>` 标签**(必须):引用 playground 源码,用户可在文档中看到交互式 live demo 和完整源码。
130
+ 2. **内联代码块**(推荐):紧跟在 `<Demo>` 后面,提供简洁的 API 用法速查。
131
+
132
+ 内联代码块的编写原则:
133
+ - 不需要完整组件结构,只展示关键 API 用法(最核心的 props 组合)
134
+ - Hooks 类的章节用 1-3 行代码展示调用签名即可
135
+ - 如果 Demo 本身已经足够简单直观,可以省略内联代码
136
+ - 纯展示类章节(如尺寸枚举、变体枚举)可以用表格代替内联代码
137
+
138
+ 示例:
139
+
140
+ ```mdx
141
+ ## 受控模式
142
+
143
+ 通过 `page` + `onPageChange` 实现受控分页。
144
+
145
+ <Demo src="@playground/pagination/modules/Controlled" />
146
+
147
+ \`\`\`tsx
148
+ const [page, setPage] = useState(1);
149
+
150
+ <Pagination
151
+ total={200}
152
+ itemsPerPage={10}
153
+ page={page}
154
+ onPageChange={setPage}
155
+ />
156
+ \`\`\`
157
+ ```
158
+
159
+ #### PropsTable 书写规则
160
+
161
+ - `type` 字段:短字面量联合类型必须直接内联,不要另起 PascalCase 类型名,也不要在 `## 类型` 区域写 `<UnionType>`。
162
+ - 典型需要内联的类型:
163
+ - 主题色:`"'primary' | 'destructive' | 'success' | 'warning' | 'info' | 'carbon' | 'secondary' | 'accent'"`
164
+ - 尺寸:`"'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'"`
165
+ - 状态 / 方向 / 位置 / 形状等短联合:`"boolean | 'indeterminate'"`、`"'horizontal' | 'vertical'"`、`"'left' | 'right'"`、`"'square' | 'rounded'"`
166
+ - 对象类型、复杂派生类型、外部库大型类型、子组件 Props、classNames/slots 配置,使用 PascalCase 类型名引用。
167
+ - PascalCase 类型名由 `typeToReactNode` 自动渲染为蓝色可点击链接,跳转到当前页类型定义或 `type-registry.ts` 注册的跨页锚点。
168
+ - `default` 用字符串表示,如 `"'md'"`、`'false'`
169
+ - `required: true` 仅在属性必填时添加
170
+
171
+ #### 类型完整性规则(严格遵循)
172
+
173
+ **核心原则:PropsTable / TypeTable 中出现的每一个非内置 PascalCase 类型名,都必须在当前页 `## 类型` 区域有对应定义,或在 `type-registry.ts` 中注册了跨页面链接。不允许出现"引用了但未定义"的类型。**
174
+
175
+ 检查清单(写完文档后逐项核对):
176
+
177
+ 1. 遍历所有 `<PropsTable>` 的 `type` 字段,收集全部 PascalCase 类型名
178
+ 2. 遍历所有 `<TypeTable>` 的 `fields[].type`,收集全部 PascalCase 类型名
179
+ 3. 排除内置类型(`ReactNode`、`HTMLElement`、`Record`、`Partial` 等,见 `type-anchor.tsx` 的 `BUILTIN_TYPE_NAMES`)
180
+ 4. 对剩余的每一个类型名,确认以下之一成立:
181
+ - 在当前页的 `<TypeTable>` 中作为 `name` 定义
182
+ - 在当前页的 `<UnionType>` 中作为 `name` 定义
183
+ - 在 `type-registry.ts` 中注册了跨页面链接
184
+ 5. 如有遗漏,补充定义后再输出
185
+ 6. 如果遗漏类型只是短字面量联合类型(如 ThemeSize、ThemeColor、方向、位置、形状、简单状态),不要补 `<UnionType>`,应改为在 `type` 字段直接内联。
186
+
187
+ 特别注意:
188
+
189
+ - **子组件 Props 类型**:如果组件有 `titleProps: AlertTitleProps`、`descriptionProps: AlertDescriptionProps` 等 props,这些类型也必须在 TypeTable 中定义,包含各自的字段列表
190
+ - **组件本目录导出的 public 类型**:`index.ts` / `types.ts` 导出的 Props、ClassNames/Ui、Slots、ItemData、Option、Variant 等类型,都必须在当前页类型区定义或跨页注册
191
+ - **封装依赖类型**:如果组件类型继承 `StyledComponentProps<T>`、`HTMLComponentProps<T>`、Radix Props、Vaul Props 等,需要在类型区说明这些包装类型和关键字段
192
+ - **不要展开无关大类型**:如果引用外部组件的大型 Props(如 `ButtonProps`、`DropdownMenuProps`),且该类型不属于当前组件,可以只引用并通过 `type-registry.ts` 跨页链接;不要在当前页复制展开全部字段
193
+ - **共享主题类型**:`ThemeColor`、`ThemeSize` 这类短联合直接内联;`ClassValue` 这类复杂类型可以在类型区保留定义。
194
+ - **BUILTIN_TYPE_NAMES 维护**:如果文档中用到了 PascalCase 类型名但它并非当前组件定义的自定义类型(如 `DeepPartial`、`ElementType`、`StandardSchema`、`Values` 等泛型/外部类型),需要确认它已在 `type-anchor.tsx` 的 `BUILTIN_TYPE_NAMES` 中注册。如果没有注册,会生成错误的本地锚点链接。遇到这种情况需要将其添加到 `BUILTIN_TYPE_NAMES` 中。
195
+
196
+ #### 常用内联类型(直接复制使用)
197
+
198
+ 以下类型在多数组件文档中都需要,按需取用:
199
+
200
+ ```mdx
201
+ type: "'primary' | 'destructive' | 'success' | 'warning' | 'info' | 'carbon' | 'secondary' | 'accent'"
202
+
203
+ type: "'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'"
204
+
205
+ <UnionType name="ClassValue" description="CSS 类名类型" type="string | null | undefined | Record<string, boolean> | ClassValue[]" />
206
+ ```
207
+
208
+ #### 类型定义规则
209
+
210
+ - 页面底部 `## 类型` 区域定义本页引用的所有非内置类型
211
+ - `<TypeTable>` — 对象类型(有字段列表的类型,如 ClassNames、子组件 Props)
212
+ - `<UnionType>` — 复杂联合、外部库派生类型、确实需要解释的类型定义;短字面量联合不要使用 `<UnionType>`,直接内联到表格
213
+ - 类型名与 PropsTable 中的 `type` 字段一致,系统自动生成锚点 ID
214
+ - 排列顺序建议:先 `<TypeTable>`(对象类型),再 `<UnionType>`(联合类型)
215
+
216
+ #### 跨页面类型引用
217
+
218
+ 当 PropsTable 中引用了定义在**其他页面**的类型(如 AlertDialog 引用 ButtonProps):
219
+
220
+ 1. 在 `apps/web-ui-docs/components/type-registry.ts` 中注册映射
221
+ 2. 格式:`TypeName: '/docs/components/target-page#anchor'`
222
+ 3. 无需在当前页重复定义该类型
223
+
224
+ #### Demo 引用规则
225
+
226
+ - 格式:`<Demo src="@playground/$slug/modules/DemoModuleName" />`
227
+ - **每个功能章节必须有 Demo**,Demo 是文档的核心展示方式,不可省略
228
+ - 优先复用 playground 中已经存在、能代表功能点的 demo
229
+ - 引用 demo 前检查 demo 文件是否依赖本地 `./shared`、同目录模块、图片、路由组件或其他非 scope 内容
230
+ - 如果 demo 不是自包含的,必须确认当前 Demo transformer / react-live 环境能处理这些 import
231
+ - 如果不能处理,选择以下方式之一:
232
+ - 调整 playground demo 使其可在文档中运行
233
+ - 新增 docs 专用 demo
234
+ - 在最终说明中明确该 demo 存在运行时风险
235
+ - 不允许假设所有 playground demo 都能被 react-live 直接执行
236
+
237
+ #### 创建缺失的 Playground Demo(必须执行)
238
+
239
+ 当 playground `modules/` 目录不存在或缺少所需 demo 时,**必须创建**,不能因为缺 demo 而只写内联代码。
240
+
241
+ **创建 demo 文件的规范:**
242
+
243
+ 1. 文件路径:`apps/web-ui-playground/src/app/[locale]/(demo)/$slug/modules/$DemoName.tsx`
244
+ 2. 文件结构模板:
245
+
246
+ ```tsx
247
+ 'use client';
248
+
249
+ import { ... } from '@skyroc/web-ui';
250
+
251
+ const $DemoName = () => {
252
+ // demo 实现
253
+ return (
254
+ <div className="...">
255
+ ...
256
+ </div>
257
+ );
258
+ };
259
+
260
+ export default $DemoName;
261
+ ```
262
+
263
+ 3. 创建规则:
264
+ - 必须添加 `'use client'` 指令
265
+ - 组件使用箭头函数 + PascalCase 命名
266
+ - 必须使用 `export default` 导出
267
+ - 从 `@skyroc/web-ui` 导入 UI 组件,不要从内部路径导入
268
+ - 图标从 `lucide-react` 导入
269
+ - 避免依赖外部 `shared.tsx`,demo 应自包含(如需共享常量直接内联到各 demo 中)
270
+ - 使用 tailwind 类名进行布局样式
271
+ - 每个 demo 聚焦展示一个功能点,保持简洁
272
+
273
+ 4. 同步 `page.tsx`:如果 `page.tsx` 不存在或未引用新 demo,需要一并创建/更新
274
+
275
+ **判断流程:**
276
+
277
+ ```
278
+ 读取 playground/$slug/modules/ 目录
279
+ ├── 已有 demo 覆盖文档需要的功能点 → 直接引用
280
+ ├── 有 page.tsx 但缺少部分 demo → 补充缺失的 demo 模块
281
+ └── 目录不存在 → 创建全部 demo 模块 + page.tsx
282
+ ```
283
+
284
+ #### react-live scope 注意事项
285
+
286
+ Demo 在 `react-live` 沙箱中执行,scope 定义在 `apps/web-ui-docs/components/demo/scope.ts`。需注意:
287
+
288
+ - scope 中同时导入了 `@skyroc/web-ui` 和 `lucide-react`,后者也导出部分同名组件(如 `Badge`)
289
+ - 当前 scope 的赋值顺序保证 `@skyroc/web-ui` 优先(最后赋值覆盖同名导出)
290
+ - 如果新增的组件名与 `lucide-react` 图标同名,需确认 scope 中不存在冲突,或调整赋值顺序
291
+
292
+ #### 工作区边界
293
+
294
+ - 默认只新增或修改目标文档 `apps/web-ui-docs/content/docs/components/$slug.mdx`
295
+ - 不要回滚、格式化或整理与当前组件文档无关的用户改动
296
+ - 如果组件源码已有未提交改动,必须基于当前工作区实现写文档
297
+ - 只有当实现问题会导致文档无法正确描述组件时,才修改组件源码或类型;修改前先说明发现的问题
298
+ - 最终回复中要明确区分:本次修改的文件、已有但未处理的工作区改动、验证结果或未验证原因
299
+
300
+ ## 参考范例
301
+
302
+ 以 `apps/web-ui-docs/content/docs/components/alert.mdx` 为首选参考,`button.mdx` 为辅助参考。
303
+
304
+ `alert.mdx` 展示了完整的类型引用模式:PropsTable 使用类型名引用 → 类型区包含全部 TypeTable 和 UnionType 定义 → 无遗漏。