@bovinphang/frontend-craft 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (380) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +34 -0
  4. package/CHANGELOG.zh-CN.md +34 -0
  5. package/README.md +1 -1
  6. package/README.openclaw.md +99 -43
  7. package/README.openclaw.zh-CN.md +99 -43
  8. package/README.zh-CN.md +1 -1
  9. package/agents/fec-architect.md +70 -70
  10. package/agents/fec-code-reviewer.md +82 -82
  11. package/agents/fec-debugger.md +20 -20
  12. package/agents/fec-design-token-mapper.md +36 -36
  13. package/agents/fec-doc-updater.md +13 -13
  14. package/agents/fec-e2e-runner.md +45 -45
  15. package/agents/fec-figma-implementer.md +59 -59
  16. package/agents/fec-performance-optimizer.md +128 -128
  17. package/agents/fec-refactor-cleaner.md +14 -14
  18. package/agents/fec-security-reviewer.md +66 -67
  19. package/agents/fec-test-planner.md +27 -27
  20. package/agents/fec-typescript-reviewer.md +87 -87
  21. package/agents/fec-ui-checker.md +74 -74
  22. package/commands/fec-debug.md +19 -19
  23. package/commands/fec-doc-sync.md +11 -11
  24. package/commands/fec-init.md +37 -38
  25. package/commands/fec-plan.md +58 -58
  26. package/commands/fec-refactor-clean.md +11 -11
  27. package/commands/fec-review.md +41 -41
  28. package/commands/fec-scaffold.md +41 -41
  29. package/commands/fec-tdd.md +13 -13
  30. package/dist/bin/frontend-craft.js +29 -27
  31. package/docs/example-prompts.md +3 -0
  32. package/docs/ja-JP/README.md +1 -1
  33. package/docs/ko-KR/README.md +1 -1
  34. package/docs/project-structure.md +13 -5
  35. package/docs/zh-CN/example-prompts.md +3 -0
  36. package/docs/zh-CN/project-structure.md +6 -1
  37. package/docs/zh-TW/README.md +1 -1
  38. package/localized/zh-CN/agents/fec-architect.md +125 -0
  39. package/localized/zh-CN/agents/fec-code-reviewer.md +152 -0
  40. package/localized/zh-CN/agents/fec-debugger.md +44 -0
  41. package/localized/zh-CN/agents/fec-design-token-mapper.md +75 -0
  42. package/localized/zh-CN/agents/fec-doc-updater.md +30 -0
  43. package/localized/zh-CN/agents/fec-e2e-runner.md +107 -0
  44. package/localized/zh-CN/agents/fec-figma-implementer.md +104 -0
  45. package/localized/zh-CN/agents/fec-performance-optimizer.md +293 -0
  46. package/localized/zh-CN/agents/fec-refactor-cleaner.md +32 -0
  47. package/localized/zh-CN/agents/fec-security-reviewer.md +116 -0
  48. package/localized/zh-CN/agents/fec-test-planner.md +50 -0
  49. package/localized/zh-CN/agents/fec-typescript-reviewer.md +142 -0
  50. package/localized/zh-CN/agents/fec-ui-checker.md +120 -0
  51. package/localized/zh-CN/commands/fec-debug.md +30 -0
  52. package/localized/zh-CN/commands/fec-doc-sync.md +19 -0
  53. package/localized/zh-CN/commands/fec-init.md +70 -0
  54. package/localized/zh-CN/commands/fec-plan.md +94 -0
  55. package/localized/zh-CN/commands/fec-refactor-clean.md +19 -0
  56. package/localized/zh-CN/commands/fec-review.md +66 -0
  57. package/localized/zh-CN/commands/fec-scaffold.md +205 -0
  58. package/localized/zh-CN/commands/fec-tdd.md +21 -0
  59. package/localized/zh-CN/skills/TEMPLATE.md +155 -0
  60. package/localized/zh-CN/skills/eval_queries.json +1013 -0
  61. package/localized/zh-CN/skills/fec-accessibility-check/SKILL.md +39 -0
  62. package/localized/zh-CN/skills/fec-accessibility-check/references/report-template.md +23 -0
  63. package/localized/zh-CN/skills/fec-accessibility-check/references/screen-reader-testing.md +33 -0
  64. package/localized/zh-CN/skills/fec-alchemy/SKILL.md +74 -0
  65. package/localized/zh-CN/skills/fec-alchemy/assets/absorption-plan-template.md +47 -0
  66. package/localized/zh-CN/skills/fec-alchemy/assets/intake-template.md +55 -0
  67. package/localized/zh-CN/skills/fec-alchemy/assets/review-checklist.md +31 -0
  68. package/localized/zh-CN/skills/fec-alchemy/references/methodology.md +94 -0
  69. package/localized/zh-CN/skills/fec-alchemy/references/originality-and-licensing.md +57 -0
  70. package/localized/zh-CN/skills/fec-api-integration/SKILL.md +78 -0
  71. package/localized/zh-CN/skills/fec-api-integration/references/integration-patterns.md +80 -0
  72. package/localized/zh-CN/skills/fec-backend-requirements-handoff/SKILL.md +45 -0
  73. package/localized/zh-CN/skills/fec-browser-storage/SKILL.md +34 -0
  74. package/localized/zh-CN/skills/fec-browser-storage/references/storage-patterns.md +65 -0
  75. package/localized/zh-CN/skills/fec-canvas-threejs/SKILL.md +66 -0
  76. package/localized/zh-CN/skills/fec-canvas-threejs/references/rendering-patterns.md +67 -0
  77. package/localized/zh-CN/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +67 -0
  78. package/localized/zh-CN/skills/fec-code-review/SKILL.md +143 -0
  79. package/localized/zh-CN/skills/fec-code-review/references/report-template.md +29 -0
  80. package/localized/zh-CN/skills/fec-component-testing/SKILL.md +119 -0
  81. package/localized/zh-CN/skills/fec-data-fetching/SKILL.md +62 -0
  82. package/localized/zh-CN/skills/fec-data-fetching/references/query-patterns.md +103 -0
  83. package/localized/zh-CN/skills/fec-debug-framework/SKILL.md +157 -0
  84. package/localized/zh-CN/skills/fec-debug-framework/references/report-template.md +58 -0
  85. package/localized/zh-CN/skills/fec-dependency-upgrade/SKILL.md +34 -0
  86. package/localized/zh-CN/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +56 -0
  87. package/localized/zh-CN/skills/fec-doc-sync/SKILL.md +39 -0
  88. package/localized/zh-CN/skills/fec-drawio-studio/SKILL.md +73 -0
  89. package/localized/zh-CN/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
  90. package/localized/zh-CN/skills/fec-drawio-studio/data/brand-icons.json +878 -0
  91. package/localized/zh-CN/skills/fec-drawio-studio/data/shape-index.json +83570 -0
  92. package/localized/zh-CN/skills/fec-drawio-studio/references/data-residency.md +27 -0
  93. package/localized/zh-CN/skills/fec-drawio-studio/references/diagram-patterns.md +60 -0
  94. package/localized/zh-CN/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
  95. package/localized/zh-CN/skills/fec-drawio-studio/references/layout-and-export.md +72 -0
  96. package/localized/zh-CN/skills/fec-drawio-studio/references/troubleshooting.md +29 -0
  97. package/localized/zh-CN/skills/fec-drawio-studio/references/xml-and-mermaid.md +58 -0
  98. package/localized/zh-CN/skills/fec-drawio-studio/scripts/brand-symbols.mjs +99 -0
  99. package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-lint.mjs +205 -0
  100. package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-url.mjs +102 -0
  101. package/localized/zh-CN/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
  102. package/localized/zh-CN/skills/fec-drawio-studio/scripts/layout-graph.mjs +107 -0
  103. package/localized/zh-CN/skills/fec-drawio-studio/scripts/png-embed-fix.mjs +26 -0
  104. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-go-packages.mjs +36 -0
  105. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-js-modules.mjs +52 -0
  106. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-classes.mjs +30 -0
  107. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-modules.mjs +55 -0
  108. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
  109. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
  110. package/localized/zh-CN/skills/fec-drawio-studio/scripts/shape-query.mjs +121 -0
  111. package/localized/zh-CN/skills/fec-drawio-studio/scripts/studio-core.mjs +139 -0
  112. package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/corporate.json +49 -0
  113. package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/default.json +49 -0
  114. package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/handdrawn.json +49 -0
  115. package/localized/zh-CN/skills/fec-drawio-studio/styles/schema.json +112 -0
  116. package/localized/zh-CN/skills/fec-e2e-testing/SKILL.md +42 -0
  117. package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-ci-reporting.md +62 -0
  118. package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-special-scenarios.md +52 -0
  119. package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-visual-regression.md +60 -0
  120. package/localized/zh-CN/skills/fec-e2e-testing/references/playwright-patterns.md +95 -0
  121. package/localized/zh-CN/skills/fec-form-handling/SKILL.md +76 -0
  122. package/localized/zh-CN/skills/fec-form-handling/references/advanced-form-patterns.md +101 -0
  123. package/localized/zh-CN/skills/fec-image-generation/SKILL.md +80 -0
  124. package/localized/zh-CN/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
  125. package/localized/zh-CN/skills/fec-image-generation/references/artifact-routing.md +80 -0
  126. package/localized/zh-CN/skills/fec-image-generation/references/diagram-workflows.md +74 -0
  127. package/localized/zh-CN/skills/fec-image-generation/references/html-technical-diagrams.md +236 -0
  128. package/localized/zh-CN/skills/fec-image-generation/references/png-qa-autofix.md +30 -0
  129. package/localized/zh-CN/skills/fec-image-generation/scripts/export-diagram.mjs +364 -0
  130. package/localized/zh-CN/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
  131. package/localized/zh-CN/skills/fec-image-generation/scripts/png-qa.mjs +431 -0
  132. package/localized/zh-CN/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1397 -0
  133. package/localized/zh-CN/skills/fec-implement-from-design/SKILL.md +129 -0
  134. package/localized/zh-CN/skills/fec-implement-from-design/references/design-plan-template.md +36 -0
  135. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/SKILL.md +46 -0
  136. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +110 -0
  137. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +41 -0
  138. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +48 -0
  139. package/localized/zh-CN/skills/fec-legacy-web-standard/SKILL.md +35 -0
  140. package/localized/zh-CN/skills/fec-legacy-web-standard/references/legacy-patterns.md +85 -0
  141. package/localized/zh-CN/skills/fec-list-virtualization/SKILL.md +34 -0
  142. package/localized/zh-CN/skills/fec-list-virtualization/references/virtualization-patterns.md +80 -0
  143. package/localized/zh-CN/skills/fec-monorepo-project-standard/SKILL.md +142 -0
  144. package/localized/zh-CN/skills/fec-motion-interaction/SKILL.md +73 -0
  145. package/localized/zh-CN/skills/fec-motion-interaction/references/motion-patterns.md +112 -0
  146. package/localized/zh-CN/skills/fec-nextjs-project-standard/SKILL.md +123 -0
  147. package/localized/zh-CN/skills/fec-nuxt-project-standard/SKILL.md +122 -0
  148. package/localized/zh-CN/skills/fec-performance-optimization/SKILL.md +80 -0
  149. package/localized/zh-CN/skills/fec-performance-optimization/references/framework-performance-patterns.md +38 -0
  150. package/localized/zh-CN/skills/fec-performance-optimization/references/report-template.md +59 -0
  151. package/localized/zh-CN/skills/fec-pwa-implementation/SKILL.md +35 -0
  152. package/localized/zh-CN/skills/fec-pwa-implementation/references/manifest-and-icons.md +53 -0
  153. package/localized/zh-CN/skills/fec-pwa-implementation/references/service-worker-workbox.md +68 -0
  154. package/localized/zh-CN/skills/fec-react-project-standard/SKILL.md +91 -0
  155. package/localized/zh-CN/skills/fec-react-project-standard/references/react-performance-patterns.md +35 -0
  156. package/localized/zh-CN/skills/fec-react-project-standard/references/react-project-structure.md +197 -0
  157. package/localized/zh-CN/skills/fec-react-project-standard/references/react-quality-patterns.md +131 -0
  158. package/localized/zh-CN/skills/fec-react-project-standard/references/react-runtime-patterns.md +293 -0
  159. package/localized/zh-CN/skills/fec-refactor-clean/SKILL.md +51 -0
  160. package/localized/zh-CN/skills/fec-refactor-clean/references/report-template.md +42 -0
  161. package/localized/zh-CN/skills/fec-responsive-layout/SKILL.md +34 -0
  162. package/localized/zh-CN/skills/fec-responsive-layout/references/responsive-layout-patterns.md +70 -0
  163. package/localized/zh-CN/skills/fec-route-protection/SKILL.md +135 -0
  164. package/localized/zh-CN/skills/fec-security-review/SKILL.md +38 -0
  165. package/localized/zh-CN/skills/fec-security-review/references/report-template.md +27 -0
  166. package/localized/zh-CN/skills/fec-security-review/references/security-checklist.md +64 -0
  167. package/localized/zh-CN/skills/fec-source-driven-development/SKILL.md +87 -0
  168. package/localized/zh-CN/skills/fec-state-management/SKILL.md +140 -0
  169. package/localized/zh-CN/skills/fec-state-management/references/state-patterns.md +109 -0
  170. package/localized/zh-CN/skills/fec-storybook-component-doc/SKILL.md +37 -0
  171. package/localized/zh-CN/skills/fec-storybook-component-doc/references/story-patterns.md +118 -0
  172. package/localized/zh-CN/skills/fec-svg-animation/SKILL.md +148 -0
  173. package/localized/zh-CN/skills/fec-tailwind-design-system/SKILL.md +34 -0
  174. package/localized/zh-CN/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +59 -0
  175. package/localized/zh-CN/skills/fec-tdd-workflow/SKILL.md +52 -0
  176. package/localized/zh-CN/skills/fec-testing-strategy/SKILL.md +45 -0
  177. package/localized/zh-CN/skills/fec-typescript-project-standard/SKILL.md +54 -0
  178. package/localized/zh-CN/skills/fec-typescript-project-standard/references/type-safety-patterns.md +102 -0
  179. package/localized/zh-CN/skills/fec-typescript-project-standard/references/type-safety.md +148 -0
  180. package/localized/zh-CN/skills/fec-ui-design/SKILL.md +108 -0
  181. package/localized/zh-CN/skills/fec-ui-design/data/product-rules.json +231 -0
  182. package/localized/zh-CN/skills/fec-ui-design/data/stack-ui-rules.json +146 -0
  183. package/localized/zh-CN/skills/fec-ui-design/data/style-archetypes.json +373 -0
  184. package/localized/zh-CN/skills/fec-ui-design/data/ux-quality-rules.json +203 -0
  185. package/localized/zh-CN/skills/fec-ui-design/references/design-intelligence.md +97 -0
  186. package/localized/zh-CN/skills/fec-ui-design/references/master-page-overrides.md +30 -0
  187. package/localized/zh-CN/skills/fec-ui-design/references/pre-delivery-checklist.md +39 -0
  188. package/localized/zh-CN/skills/fec-ui-design/scripts/design-system.mjs +648 -0
  189. package/localized/zh-CN/skills/fec-validation-fix/SKILL.md +51 -0
  190. package/localized/zh-CN/skills/fec-validation-fix/references/report-template.md +43 -0
  191. package/localized/zh-CN/skills/fec-vite-project-standard/SKILL.md +83 -0
  192. package/localized/zh-CN/skills/fec-vue3-project-standard/SKILL.md +58 -0
  193. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +162 -0
  194. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +13 -0
  195. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-project-structure.md +176 -0
  196. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +216 -0
  197. package/localized/zh-CN/skills/fec-web-video-presentation/SKILL.md +61 -0
  198. package/localized/zh-CN/skills/fec-web-video-presentation/data/starter-themes.json +59 -0
  199. package/localized/zh-CN/skills/fec-web-video-presentation/references/chapter-craft.md +37 -0
  200. package/localized/zh-CN/skills/fec-web-video-presentation/references/content-plan.md +38 -0
  201. package/localized/zh-CN/skills/fec-web-video-presentation/references/recording-and-audio.md +33 -0
  202. package/localized/zh-CN/skills/fec-web-video-presentation/references/theme-system.md +36 -0
  203. package/localized/zh-CN/skills/fec-web-video-presentation/scripts/create-video-presentation.mjs +430 -0
  204. package/localized/zh-CN/skills/fec-web-workers/SKILL.md +35 -0
  205. package/localized/zh-CN/skills/fec-web-workers/references/advanced-workers.md +54 -0
  206. package/localized/zh-CN/skills/fec-web-workers/references/basic-worker.md +67 -0
  207. package/localized/zh-CN/skills/metadata.json +1646 -0
  208. package/localized/zh-CN/skills/relations.json +755 -0
  209. package/localized/zh-CN/templates/claude/CLAUDE.md +106 -0
  210. package/localized/zh-CN/templates/claude/settings.json +62 -0
  211. package/localized/zh-CN/templates/codex/AGENTS.md +105 -0
  212. package/localized/zh-CN/templates/codex/config.toml +32 -0
  213. package/localized/zh-CN/templates/openclaw/AGENTS.md +101 -0
  214. package/localized/zh-CN/templates/openclaw/OPENCLAW-CONFIG.md +12 -0
  215. package/localized/zh-CN/templates/shared/rules/fec-agent-workflow.md +54 -0
  216. package/localized/zh-CN/templates/shared/rules/fec-api-layer.md +99 -0
  217. package/localized/zh-CN/templates/shared/rules/fec-ci-cd.md +40 -0
  218. package/localized/zh-CN/templates/shared/rules/fec-code-comments.md +33 -0
  219. package/localized/zh-CN/templates/shared/rules/fec-design-system.md +72 -0
  220. package/localized/zh-CN/templates/shared/rules/fec-error-handling.md +56 -0
  221. package/localized/zh-CN/templates/shared/rules/fec-git-conventions.md +73 -0
  222. package/localized/zh-CN/templates/shared/rules/fec-i18n.md +64 -0
  223. package/localized/zh-CN/templates/shared/rules/fec-naming-conventions.md +120 -0
  224. package/localized/zh-CN/templates/shared/rules/fec-performance.md +101 -0
  225. package/localized/zh-CN/templates/shared/rules/fec-react.md +82 -0
  226. package/localized/zh-CN/templates/shared/rules/fec-refactoring.md +47 -0
  227. package/localized/zh-CN/templates/shared/rules/fec-rendering-patterns.md +40 -0
  228. package/localized/zh-CN/templates/shared/rules/fec-responsive-design.md +50 -0
  229. package/localized/zh-CN/templates/shared/rules/fec-source-driven-development.md +31 -0
  230. package/localized/zh-CN/templates/shared/rules/fec-state-management.md +60 -0
  231. package/localized/zh-CN/templates/shared/rules/fec-testing.md +98 -0
  232. package/localized/zh-CN/templates/shared/rules/fec-typescript.md +112 -0
  233. package/localized/zh-CN/templates/shared/rules/fec-vue.md +64 -0
  234. package/localized/zh-CN/templates/shared/rules/fec-working-modes.md +50 -0
  235. package/openclaw.plugin.json +1 -1
  236. package/package.json +3 -2
  237. package/skills/TEMPLATE.md +74 -74
  238. package/skills/eval_queries.json +678 -678
  239. package/skills/fec-accessibility-check/SKILL.md +21 -21
  240. package/skills/fec-accessibility-check/references/report-template.md +12 -12
  241. package/skills/fec-accessibility-check/references/screen-reader-testing.md +24 -24
  242. package/skills/fec-alchemy/SKILL.md +50 -50
  243. package/skills/fec-alchemy/assets/absorption-plan-template.md +32 -32
  244. package/skills/fec-alchemy/assets/intake-template.md +55 -55
  245. package/skills/fec-alchemy/assets/review-checklist.md +23 -23
  246. package/skills/fec-alchemy/references/methodology.md +66 -66
  247. package/skills/fec-alchemy/references/originality-and-licensing.md +42 -42
  248. package/skills/fec-api-integration/SKILL.md +61 -61
  249. package/skills/fec-api-integration/references/integration-patterns.md +30 -30
  250. package/skills/fec-backend-requirements-handoff/SKILL.md +25 -25
  251. package/skills/fec-browser-storage/SKILL.md +16 -16
  252. package/skills/fec-browser-storage/references/storage-patterns.md +16 -16
  253. package/skills/fec-canvas-threejs/SKILL.md +21 -21
  254. package/skills/fec-canvas-threejs/references/rendering-patterns.md +10 -10
  255. package/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +37 -37
  256. package/skills/fec-code-review/SKILL.md +94 -94
  257. package/skills/fec-code-review/references/report-template.md +13 -13
  258. package/skills/fec-component-testing/SKILL.md +39 -39
  259. package/skills/fec-data-fetching/SKILL.md +16 -16
  260. package/skills/fec-data-fetching/references/query-patterns.md +27 -27
  261. package/skills/fec-debug-framework/SKILL.md +95 -95
  262. package/skills/fec-debug-framework/references/report-template.md +34 -34
  263. package/skills/fec-dependency-upgrade/SKILL.md +17 -17
  264. package/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +31 -31
  265. package/skills/fec-doc-sync/SKILL.md +23 -23
  266. package/skills/fec-drawio-studio/SKILL.md +42 -38
  267. package/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +1 -1
  268. package/skills/fec-drawio-studio/data/shape-index.json +83570 -0
  269. package/skills/fec-drawio-studio/references/diagram-patterns.md +19 -0
  270. package/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
  271. package/skills/fec-drawio-studio/references/layout-and-export.md +18 -3
  272. package/skills/fec-drawio-studio/references/xml-and-mermaid.md +5 -1
  273. package/skills/fec-drawio-studio/scripts/diagram-lint.mjs +62 -0
  274. package/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
  275. package/skills/fec-drawio-studio/scripts/shape-query.mjs +55 -15
  276. package/skills/fec-e2e-testing/SKILL.md +24 -24
  277. package/skills/fec-e2e-testing/references/e2e-ci-reporting.md +20 -20
  278. package/skills/fec-e2e-testing/references/e2e-special-scenarios.md +10 -10
  279. package/skills/fec-e2e-testing/references/e2e-visual-regression.md +17 -17
  280. package/skills/fec-e2e-testing/references/playwright-patterns.md +6 -6
  281. package/skills/fec-form-handling/SKILL.md +21 -21
  282. package/skills/fec-form-handling/references/advanced-form-patterns.md +41 -41
  283. package/skills/fec-image-generation/SKILL.md +54 -29
  284. package/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
  285. package/skills/fec-image-generation/references/diagram-workflows.md +33 -2
  286. package/skills/fec-image-generation/references/html-technical-diagrams.md +236 -0
  287. package/skills/fec-image-generation/scripts/export-diagram.mjs +364 -0
  288. package/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
  289. package/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1397 -0
  290. package/skills/fec-implement-from-design/SKILL.md +81 -81
  291. package/skills/fec-implement-from-design/references/design-plan-template.md +16 -16
  292. package/skills/fec-legacy-to-modern-migration/SKILL.md +29 -29
  293. package/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +81 -81
  294. package/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +37 -37
  295. package/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +31 -31
  296. package/skills/fec-legacy-web-standard/SKILL.md +17 -17
  297. package/skills/fec-legacy-web-standard/references/legacy-patterns.md +16 -16
  298. package/skills/fec-list-virtualization/SKILL.md +16 -16
  299. package/skills/fec-list-virtualization/references/virtualization-patterns.md +31 -31
  300. package/skills/fec-monorepo-project-standard/SKILL.md +52 -52
  301. package/skills/fec-motion-interaction/SKILL.md +51 -51
  302. package/skills/fec-motion-interaction/references/motion-patterns.md +11 -11
  303. package/skills/fec-nextjs-project-standard/SKILL.md +64 -64
  304. package/skills/fec-nuxt-project-standard/SKILL.md +57 -57
  305. package/skills/fec-performance-optimization/SKILL.md +54 -54
  306. package/skills/fec-performance-optimization/references/framework-performance-patterns.md +23 -23
  307. package/skills/fec-performance-optimization/references/report-template.md +31 -31
  308. package/skills/fec-pwa-implementation/SKILL.md +17 -17
  309. package/skills/fec-pwa-implementation/references/manifest-and-icons.md +12 -12
  310. package/skills/fec-pwa-implementation/references/service-worker-workbox.md +13 -13
  311. package/skills/fec-react-project-standard/SKILL.md +72 -72
  312. package/skills/fec-react-project-standard/references/react-performance-patterns.md +28 -28
  313. package/skills/fec-react-project-standard/references/react-project-structure.md +112 -112
  314. package/skills/fec-react-project-standard/references/react-quality-patterns.md +72 -72
  315. package/skills/fec-react-project-standard/references/react-runtime-patterns.md +94 -94
  316. package/skills/fec-refactor-clean/SKILL.md +30 -30
  317. package/skills/fec-refactor-clean/references/report-template.md +23 -23
  318. package/skills/fec-responsive-layout/SKILL.md +17 -17
  319. package/skills/fec-responsive-layout/references/responsive-layout-patterns.md +37 -37
  320. package/skills/fec-route-protection/SKILL.md +26 -26
  321. package/skills/fec-security-review/SKILL.md +20 -20
  322. package/skills/fec-security-review/references/report-template.md +12 -12
  323. package/skills/fec-security-review/references/security-checklist.md +27 -27
  324. package/skills/fec-source-driven-development/SKILL.md +59 -59
  325. package/skills/fec-state-management/SKILL.md +34 -34
  326. package/skills/fec-state-management/references/state-patterns.md +19 -19
  327. package/skills/fec-storybook-component-doc/SKILL.md +19 -19
  328. package/skills/fec-storybook-component-doc/references/story-patterns.md +12 -12
  329. package/skills/fec-svg-animation/SKILL.md +32 -32
  330. package/skills/fec-tailwind-design-system/SKILL.md +17 -17
  331. package/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +36 -36
  332. package/skills/fec-tdd-workflow/SKILL.md +28 -28
  333. package/skills/fec-testing-strategy/SKILL.md +29 -29
  334. package/skills/fec-typescript-project-standard/SKILL.md +38 -38
  335. package/skills/fec-typescript-project-standard/references/type-safety-patterns.md +20 -20
  336. package/skills/fec-typescript-project-standard/references/type-safety.md +18 -18
  337. package/skills/fec-ui-design/SKILL.md +90 -90
  338. package/skills/fec-ui-design/references/design-intelligence.md +61 -61
  339. package/skills/fec-ui-design/references/master-page-overrides.md +15 -15
  340. package/skills/fec-ui-design/references/pre-delivery-checklist.md +38 -38
  341. package/skills/fec-validation-fix/SKILL.md +26 -26
  342. package/skills/fec-validation-fix/references/report-template.md +25 -25
  343. package/skills/fec-vite-project-standard/SKILL.md +39 -39
  344. package/skills/fec-vue3-project-standard/SKILL.md +38 -38
  345. package/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +36 -36
  346. package/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +8 -8
  347. package/skills/fec-vue3-project-standard/references/vue3-project-structure.md +112 -112
  348. package/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +74 -74
  349. package/skills/fec-web-video-presentation/SKILL.md +33 -33
  350. package/skills/fec-web-workers/SKILL.md +16 -16
  351. package/skills/fec-web-workers/references/advanced-workers.md +13 -13
  352. package/skills/fec-web-workers/references/basic-worker.md +8 -8
  353. package/skills/metadata.json +121 -115
  354. package/skills/relations.json +4 -0
  355. package/templates/claude/CLAUDE.md +60 -60
  356. package/templates/codex/AGENTS.md +76 -76
  357. package/templates/codex/config.toml +4 -4
  358. package/templates/openclaw/AGENTS.md +68 -68
  359. package/templates/openclaw/OPENCLAW-CONFIG.md +8 -8
  360. package/templates/shared/rules/fec-agent-workflow.md +40 -40
  361. package/templates/shared/rules/fec-api-layer.md +52 -52
  362. package/templates/shared/rules/fec-ci-cd.md +29 -29
  363. package/templates/shared/rules/fec-code-comments.md +22 -22
  364. package/templates/shared/rules/fec-design-system.md +53 -53
  365. package/templates/shared/rules/fec-error-handling.md +40 -40
  366. package/templates/shared/rules/fec-git-conventions.md +42 -42
  367. package/templates/shared/rules/fec-i18n.md +48 -48
  368. package/templates/shared/rules/fec-naming-conventions.md +91 -91
  369. package/templates/shared/rules/fec-performance.md +78 -78
  370. package/templates/shared/rules/fec-react.md +58 -58
  371. package/templates/shared/rules/fec-refactoring.md +34 -34
  372. package/templates/shared/rules/fec-rendering-patterns.md +36 -36
  373. package/templates/shared/rules/fec-responsive-design.md +37 -37
  374. package/templates/shared/rules/fec-source-driven-development.md +22 -22
  375. package/templates/shared/rules/fec-state-management.md +56 -56
  376. package/templates/shared/rules/fec-testing.md +64 -64
  377. package/templates/shared/rules/fec-typescript.md +75 -75
  378. package/templates/shared/rules/fec-vue.md +42 -42
  379. package/templates/shared/rules/fec-working-modes.md +34 -34
  380. package/skills/fec-drawio-studio/data/shape-index.json.gz +0 -0
@@ -0,0 +1,135 @@
1
+ ---
2
+ name: fec-route-protection
3
+ description: 用于实现或审查前端路由保护、auth guard、RBAC、权限路由、登录态处理、重定向、middleware、React Router、Next.js、Vue Router 或 Nuxt route middleware;中文触发词包括 路由保护、权限路由、登录态。
4
+ ---
5
+
6
+ # 路由保护
7
+
8
+ ## 用途
9
+
10
+ 为前端应用建立清晰的认证、授权和重定向边界,避免越权访问与闪烁渲染。
11
+
12
+ ## 适用场景
13
+
14
+ - 页面需要登录后访问,或不同角色看到不同路由。
15
+ - 需要实现 React Router、Next.js、Nuxt 或 Vue Router 的路由守卫。
16
+ - 登录过期、权限不足、组织/租户切换需要统一处理。
17
+ - 不用于替代服务端授权;前端路由保护只能改善体验,不能作为唯一安全边界。
18
+
19
+ ## 流程
20
+
21
+ ### 1. 定义认证与授权状态
22
+
23
+ ```ts
24
+ export type AuthStatus = "loading" | "anonymous" | "authenticated";
25
+
26
+ export interface CurrentUser {
27
+ id: string;
28
+ roles: string[];
29
+ permissions: string[];
30
+ }
31
+
32
+ export function canAccess(user: CurrentUser, required: string[]) {
33
+ return required.every((permission) => user.permissions.includes(permission));
34
+ }
35
+ ```
36
+
37
+ ### 2. React Router 使用布局守卫
38
+
39
+ ```tsx
40
+ import { Navigate, Outlet, useLocation } from "react-router-dom";
41
+
42
+ interface ProtectedRouteProps {
43
+ requiredPermissions?: string[];
44
+ }
45
+
46
+ export function ProtectedRoute({ requiredPermissions = [] }: ProtectedRouteProps) {
47
+ const location = useLocation();
48
+ const { status, user } = useAuth();
49
+
50
+ if (status === "loading") return <RouteLoading />;
51
+ if (status === "anonymous") {
52
+ return <Navigate to="/login" replace state={{ from: location }} />;
53
+ }
54
+ if (requiredPermissions.length > 0 && !canAccess(user, requiredPermissions)) {
55
+ return <Navigate to="/403" replace />;
56
+ }
57
+
58
+ return <Outlet />;
59
+ }
60
+ ```
61
+
62
+ ```tsx
63
+ const router = createBrowserRouter([
64
+ {
65
+ element: <ProtectedRoute requiredPermissions={["orders:read"]} />,
66
+ children: [{ path: "/orders", element: <OrdersPage /> }],
67
+ },
68
+ ]);
69
+ ```
70
+
71
+ ### 3. Next.js 优先在服务端边界处理
72
+
73
+ ```ts
74
+ // middleware.ts
75
+ import { NextResponse, type NextRequest } from "next/server";
76
+
77
+ export function middleware(request: NextRequest) {
78
+ const token = request.cookies.get("session")?.value;
79
+ const isPrivateRoute = request.nextUrl.pathname.startsWith("/dashboard");
80
+
81
+ if (isPrivateRoute && !token) {
82
+ const loginUrl = new URL("/login", request.url);
83
+ loginUrl.searchParams.set("redirect", request.nextUrl.pathname);
84
+ return NextResponse.redirect(loginUrl);
85
+ }
86
+
87
+ return NextResponse.next();
88
+ }
89
+
90
+ export const config = {
91
+ matcher: ["/dashboard/:path*"],
92
+ };
93
+ ```
94
+
95
+ 对需要精细权限的 App Router 页面,在 server component 或 server action 中重新校验权限,不依赖客户端状态。
96
+
97
+ ### 4. Vue Router / Nuxt 使用导航守卫
98
+
99
+ ```ts
100
+ router.beforeEach(async (to) => {
101
+ const auth = useAuthStore();
102
+ if (auth.status === "unknown") await auth.fetchCurrentUser();
103
+
104
+ if (to.meta.requiresAuth && !auth.user) {
105
+ return { path: "/login", query: { redirect: to.fullPath } };
106
+ }
107
+
108
+ const required = to.meta.permissions as string[] | undefined;
109
+ if (required?.length && !auth.canAccess(required)) {
110
+ return { path: "/403" };
111
+ }
112
+ });
113
+ ```
114
+
115
+ ### 5. 统一失败与跳转体验
116
+
117
+ - `401`:清理过期会话,跳转登录页并保留 `redirect`。
118
+ - `403`:进入无权限页,不反复重试。
119
+ - `loading`:渲染稳定骨架屏,避免先显示私有内容再跳转。
120
+ - 登录成功:只跳转到同源且允许的路径,防止 open redirect。
121
+ - RBAC:权限矩阵来自可信会话或后端返回;前端只用于路由体验和 UI 裁剪,不能替代接口授权。
122
+ - 会话刷新:401 刷新失败后统一清理状态;避免多个并发请求各自触发跳转或刷新风暴。
123
+
124
+ ## 约束
125
+
126
+ - 前端路由保护不是安全边界;API、SSR loader、server action 必须重复做授权校验。
127
+ - 不要在组件渲染后用 `useEffect` 才跳转私有页面,否则会出现敏感内容闪烁。
128
+ - redirect 参数必须限制为站内路径,不能直接信任 URL 输入。
129
+ - 权限信息应来自可信会话或后端响应,不要只依赖 localStorage 中的角色字段。
130
+ - 多租户应用必须把 tenant/org 上下文纳入权限判断。
131
+ - 不把菜单隐藏视为授权完成;用户直接访问 URL、刷新页面、篡改 localStorage 和替换 tenant 都必须验证。
132
+
133
+ ## 预期输出
134
+
135
+ 产出一套路由守卫实现,覆盖 loading、未登录、权限不足、登录后回跳和会话过期。验证时直接访问私有 URL、刷新页面、切换角色、篡改 redirect 参数,确认行为稳定且 API 仍有服务端授权。
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: fec-security-review
3
+ description: 用于审查前端安全风险,如 XSS、CSRF、敏感数据暴露、不安全 DOM API、不可信用户输入、认证/token 处理、支付流程、文件上传、CSP、依赖风险或第三方脚本;中文触发词包括 安全审查、安全检查。
4
+ ---
5
+
6
+ # 前端安全审查
7
+
8
+ ## 用途
9
+
10
+ 识别前端代码中的客户端安全风险,并给出可执行修复建议。
11
+
12
+ ## 流程
13
+
14
+ 1. 先确认审查面:用户输入、动态 HTML、URL 跳转、认证态、RBAC、文件上传、支付/删除等敏感操作、第三方脚本和依赖。
15
+ 2. 搜索高危模式:`dangerouslySetInnerHTML`、`v-html`、`innerHTML`、`document.write`、动态 script、未校验 redirect、明文 token。
16
+ 3. 按风险类型审查:XSS、CSP、敏感数据、CSRF、依赖、输入校验、文件上传、开放重定向、认证授权和第三方脚本。
17
+ 4. 用边界模型判断责任:客户端只能改善体验和减少误用,鉴权、授权、上传信任和敏感操作必须由服务端最终裁决。
18
+ 5. 高危问题标记为阻塞合并;前端校验只能改善体验,不能作为唯一安全边界。
19
+ 6. 输出分级安全报告;报告格式见 [references/report-template.md](references/report-template.md)。
20
+
21
+ ## 详细参考
22
+
23
+ - 需要 XSS、CSP、敏感数据、CSRF、依赖和输入校验细节时,加载 [references/security-checklist.md](references/security-checklist.md)。
24
+ - 撰写安全审查报告时,加载 [references/report-template.md](references/report-template.md)。
25
+
26
+ ## 约束
27
+
28
+ - 不要为了方便开发而绕过安全机制。
29
+ - 不要依赖前端校验作为唯一安全防线。
30
+ - 不要信任任何来自客户端的数据。
31
+ - 发现高危问题时必须标记为阻塞合并。
32
+ - 与通用代码质量 review 分工:本 skill 关注威胁、攻击面和数据泄露。
33
+ - 不把依赖审计结果机械等同为可利用漏洞;需要结合运行路径、暴露面和修复成本判断。
34
+ - 不把隐藏按钮、前端路由守卫或本地角色字段当作授权边界;API、SSR loader、server action 和敏感操作必须有服务端裁决。
35
+
36
+ ## 预期输出
37
+
38
+ 输出 CRITICAL/HIGH/MEDIUM/LOW 分级安全审查报告,每个问题关联具体文件和行号,给出修复建议;报告保存为 `reports/security-review-YYYY-MM-DD-HHmmss.md`。
@@ -0,0 +1,27 @@
1
+ # 安全审查报告模板
2
+
3
+ ```markdown
4
+ # 安全审查报告
5
+
6
+ > 生成时间: YYYY-MM-DD HH:mm
7
+ > 评审工具: frontend-craft
8
+
9
+ ## CRITICAL / 高危 (N项)
10
+ - **[文件:行号]** 风险描述 -> 修复建议
11
+
12
+ ## HIGH / 中高危 (N项)
13
+ - ...
14
+
15
+ ## MEDIUM / 中危 (N项)
16
+ - ...
17
+
18
+ ## LOW / 低危或建议 (N项)
19
+ - ...
20
+
21
+ ## 已通过的安全检查
22
+ - ...
23
+
24
+ **整体安全等级**: 安全 / 存在风险 / 高危需修复
25
+ ```
26
+
27
+ 审查完成后,将报告保存到 `reports/security-review-YYYY-MM-DD-HHmmss.md`,并告知用户报告路径。
@@ -0,0 +1,64 @@
1
+ # 前端安全审查清单
2
+
3
+ ## XSS
4
+
5
+ - `dangerouslySetInnerHTML` 和 `v-html` 必须有明确理由和输入净化。
6
+ - 用户输入不得直接插入 DOM、`innerHTML`、`document.write`。
7
+ - URL 参数不得直接用于页面渲染。
8
+ - 动态生成的 `<script>` 标签必须审查来源。
9
+ - 富文本使用 DOMPurify 等库,并配置标签、属性、协议白名单。
10
+
11
+ ```ts
12
+ import DOMPurify from "dompurify";
13
+
14
+ const clean = DOMPurify.sanitize(dirtyHtml, {
15
+ ALLOWED_TAGS: ["b", "i", "em", "strong", "a", "ul", "ol", "li", "p", "br"],
16
+ ALLOWED_ATTR: ["href", "title"],
17
+ ALLOWED_URI_REGEXP: /^(https?|mailto):/i,
18
+ });
19
+ ```
20
+
21
+ ## 安全重定向
22
+
23
+ ```ts
24
+ function safeRedirect(url: string): string {
25
+ if (url.startsWith("/") && !url.startsWith("//")) return url;
26
+ return "/dashboard";
27
+ }
28
+ ```
29
+
30
+ ## CSP
31
+
32
+ - 推荐先用 `Content-Security-Policy-Report-Only` 验证。
33
+ - `default-src 'self'`、`object-src 'none'`、`frame-ancestors 'none'`、`base-uri 'self'` 是常见底线。
34
+ - 避免 `'unsafe-eval'`;内联脚本优先 nonce。
35
+
36
+ ```http
37
+ Content-Security-Policy: default-src 'self'; script-src 'self'; object-src 'none'; frame-ancestors 'none'; base-uri 'self'; form-action 'self';
38
+ ```
39
+
40
+ ## 敏感数据
41
+
42
+ - 禁止前端硬编码 API Key、Secret、密码。
43
+ - 禁止 localStorage/sessionStorage/IndexedDB 存明文 token、密码、信用卡信息。
44
+ - 禁止 URL query 参数传 token 或密码。
45
+ - 禁止 console.log 或错误上报携带隐私数据。
46
+ - Token 优先 httpOnly + Secure + SameSite cookie。
47
+
48
+ ## CSRF
49
+
50
+ - 变更操作必须携带 CSRF token 或使用同等后端防护。
51
+ - 关键操作不要使用 GET。
52
+ - 检查后端是否校验 `Origin` / `Referer`。
53
+
54
+ ## 依赖与第三方脚本
55
+
56
+ - 定期审查依赖安全公告。
57
+ - 禁止从非官方 CDN 加载脚本,除非有 SRI 和来源审查。
58
+ - 动态加载第三方脚本必须有业务必要性和降级策略。
59
+
60
+ ## 输入校验与文件上传
61
+
62
+ - 前端校验不是安全边界,后端必须二次校验。
63
+ - 文件上传校验 MIME、大小、扩展名和内容;不能只看扩展名。
64
+ - 正则校验注意 ReDoS 风险。
@@ -0,0 +1,87 @@
1
+ ---
2
+ name: fec-source-driven-development
3
+ description: 用于前端决策依赖可能变化的框架、库、浏览器、运行时、包、API 或平台行为时,包括官方文档核验、版本敏感模式、迁移选择或公共接口假设;中文触发词包括 查官方文档、以源码为准、source-driven、版本差异。
4
+ ---
5
+
6
+ # 来源驱动开发
7
+
8
+ ## 用途
9
+
10
+ 在前端实现、评审和架构决策中优先依据项目内事实、官方文档和当前版本行为,避免沿用过时经验或未经验证的假设。
11
+
12
+ ## 流程
13
+
14
+ 1. 判断是否需要查源
15
+ - 涉及框架新版本、路由、渲染模式、缓存、构建工具、浏览器 API、包发布格式、鉴权协议或公共接口时必须查源。
16
+ - 涉及项目约定时先读本仓库 README、配置、模板、已有实现、测试和迁移记录。
17
+ - 只是稳定语言语法或明显局部重构时,可使用项目现有模式作为事实来源。
18
+
19
+ 2. 收集权威材料
20
+ - 首选官方文档、规范、源码、release notes、migration guide、类型定义和项目内测试。
21
+ - 第三方文章只能作为线索,不能作为最终依据。
22
+ - 对快速变化的库记录包名、版本、文档日期或页面标题。
23
+ - 当用户要求从本地知识库、项目资料库或 `knowledge/` 目录回答问题时,先走本地知识检索,不使用网络搜索补事实。
24
+
25
+ 3. 提炼决策
26
+ - 写清当前版本推荐做法、弃用做法、限制条件和迁移注意事项。
27
+ - 对多个可行方案说明选择理由、兼容性、维护成本和回退方式。
28
+ - 若文档和项目现状冲突,优先解释冲突并给出渐进调整,不直接推翻已运行系统。
29
+ - 对依赖升级、框架迁移和公共 API 变化,记录 release notes、migration guide、版本范围、破坏性变更和回滚方案。
30
+
31
+ 4. 落到实现
32
+ - 将外部行为隔离在适配层、配置层或小型工具函数中,避免在组件里散落版本假设。
33
+ - 公共接口变化要保持命名、错误形状、默认值和兼容策略清晰。
34
+ - 代码注释只记录非显而易见的来源约束,不粘贴大段文档。
35
+
36
+ 5. 验证假设
37
+ - 用类型检查、最小复现、单元测试、组件测试、E2E、构建或浏览器验证证明关键假设。
38
+ - 如果无法验证,报告不确定性、风险范围和需要用户或团队确认的信息。
39
+ 6. 留下轻量决策记录
40
+ - 当结论会影响公共接口、依赖版本、目录规范或团队工作流时,补充 ADR/变更记录或交给文档同步流程。
41
+
42
+ ## 本地知识检索
43
+
44
+ 当用户指定本地知识库路径,或默认 `knowledge/` 目录存在时,可用本流程回答资料库问题、抽取证据或辅助决策。
45
+
46
+ 1. 定位根目录
47
+ - 用户明确指定路径时使用该路径。
48
+ - 否则检查当前项目下 `knowledge/` 是否存在;不存在时说明未找到默认知识库并请求路径。
49
+ - 不用文件 glob 判断目录是否存在。
50
+
51
+ 2. 分层导航
52
+ - 优先读取根目录和子目录中的 `data_structure.md`。
53
+ - 根据目录说明选择最相关的少量分支,不一次性遍历整个知识库。
54
+ - 记录候选文件、主题、时间/版本范围和为什么相关。
55
+
56
+ 3. 渐进检索
57
+ - Markdown、文本、日志:先用关键词搜索,再局部读取命中上下文。
58
+ - PDF:处理前先确认可用工具和提取路线,优先提取到临时文本后再检索,避免把整份 PDF 打进上下文。
59
+ - Excel:处理前先确认读取/分析路线,先看工作表、列名和少量样例,再按字段过滤或聚合。
60
+ - 默认最多 5 轮关键词迭代;每轮根据已找到证据调整同义词、缩写和范围。
61
+
62
+ 4. 回答与溯源
63
+ - 先给结论,再列文件路径、章节、页码、工作表或行号附近作为依据。
64
+ - 证据不足时说明查过哪些路径、缺什么信息,以及用户如何缩小范围。
65
+ - 不把知识库外的网络信息混入答案,除非用户另行要求查外部来源。
66
+
67
+ ## 事实源优先级
68
+
69
+ | 优先级 | 来源 | 用途 |
70
+ | ------ | ---- | ---- |
71
+ | 1 | 项目内配置、测试、已有实现 | 判断本仓库真实约定 |
72
+ | 2 | 官方文档、源码、类型定义 | 判断当前推荐行为 |
73
+ | 3 | 标准规范、浏览器兼容数据 | 判断平台能力和兼容边界 |
74
+ | 4 | Issue、讨论、第三方文章 | 辅助排查,不能单独定案 |
75
+
76
+ ## 约束
77
+
78
+ - 不凭记忆给版本敏感结论。
79
+ - 不把过时教程当作当前最佳实践。
80
+ - 不引用无法复核的来源作为关键依据。
81
+ - 不为追新而改动稳定项目约定;必须说明收益和迁移成本。
82
+ - 不在交付中复制长篇外部文档;只保留必要结论和链接或文件路径。
83
+ - 不把“查过文档”停留在口头;版本敏感决策需要能追溯到具体版本、路径或官方页面。
84
+
85
+ ## 预期输出
86
+
87
+ 输出来源清单、版本或项目事实、决策结论、实现影响、验证命令和未决风险。若修改代码,关键行为应有测试或构建验证支撑。
@@ -0,0 +1,140 @@
1
+ ---
2
+ name: fec-state-management
3
+ description: 用于选择、实现、审查或重构 React、Vue、Next.js、Nuxt、URL 状态、服务端状态、表单状态、浏览器持久化或全局 store 的前端状态归属。TanStack Query 缓存细节、浏览器存储持久化或表单校验内部问题优先使用更窄的 skill;中文触发词包括 状态管理、状态归属、store 选型。
4
+ ---
5
+
6
+ # 前端状态管理
7
+
8
+ ## 用途
9
+
10
+ 为前端状态确定清晰归属,避免全局 store 膨胀、重复缓存和派生状态同步错误。
11
+
12
+ ## 流程
13
+
14
+ ### 1. 先分类状态来源
15
+
16
+ 不要先选 Redux、Zustand、Pinia 或 Context。先把每个状态标到唯一归属,再决定工具。
17
+
18
+ | 状态类型 | 典型例子 | 默认归属 |
19
+ | ---------------- | ------------------------------------ | ------------------------ |
20
+ | 本地 UI 状态 | 弹窗开关、tab、展开行、hover 编辑态 | 组件内 state / ref |
21
+ | 表单状态 | 输入值、脏字段、校验错误、提交中 | 表单库或表单组件 |
22
+ | 服务端状态 | 列表、详情、分页结果、远程错误 | 请求缓存库 |
23
+ | URL 状态 | 搜索词、筛选、排序、页码、选中 tab | 路由参数 / search params |
24
+ | 全局客户端状态 | 登录用户、主题、权限快照、购物车草稿 | 全局 store |
25
+ | 浏览器持久化状态 | 跨刷新保留的草稿、偏好、离线队列 | 存储层 + 状态适配器 |
26
+
27
+ ```tsx
28
+ type ReportsStateMap = {
29
+ search: "url";
30
+ selectedReportId: "url";
31
+ reports: "server-state-cache";
32
+ isFilterPanelOpen: "local-ui";
33
+ draftColumns: "browser-persistence";
34
+ };
35
+ ```
36
+
37
+ ### 2. 保持最小状态
38
+
39
+ 可从 props、server state、URL 或已有 state 推导出来的值,不要另存一份。
40
+
41
+ ```tsx
42
+ interface Invoice {
43
+ id: string;
44
+ status: "draft" | "sent" | "paid";
45
+ }
46
+
47
+ function InvoiceList({ invoices }: { invoices: Invoice[] }) {
48
+ const paidInvoices = invoices.filter((invoice) => invoice.status === "paid");
49
+
50
+ return <span>{paidInvoices.length}</span>;
51
+ }
52
+ ```
53
+
54
+ ### 3. 选择 React 全局状态方案
55
+
56
+ React 中优先本地化和组合;只有跨页面、跨 feature 或需要统一动作时才引入全局 store。
57
+
58
+ ```tsx
59
+ import { create } from "zustand";
60
+
61
+ interface WorkspaceState {
62
+ activeWorkspaceId: string | null;
63
+ setActiveWorkspaceId: (workspaceId: string) => void;
64
+ }
65
+
66
+ export const useWorkspaceStore = create<WorkspaceState>((set) => ({
67
+ activeWorkspaceId: null,
68
+ setActiveWorkspaceId: (activeWorkspaceId) => set({ activeWorkspaceId }),
69
+ }));
70
+ ```
71
+
72
+ 决策顺序:
73
+
74
+ 1. 只在一个组件或一个小子树使用:`useState` / `useReducer`。
75
+ 2. 低频全局配置或依赖注入:Context。
76
+ 3. 中等复杂业务状态:Zustand 或 Jotai,按仓库现有选型优先。
77
+ 4. 大型应用、严格动作流、审计或时间旅行调试:Redux Toolkit。
78
+ 5. 远程数据:使用数据获取 skill 管理 query key、缓存和失效策略。
79
+
80
+ ### 4. 选择 Vue 全局状态方案
81
+
82
+ Vue 3 中,局部跨层级传递使用 `provide/inject`;全局业务状态使用 Pinia 或项目既有 store。
83
+
84
+ ```ts
85
+ import { computed, readonly, ref } from "vue";
86
+ import { defineStore } from "pinia";
87
+
88
+ export const useSessionStore = defineStore("session", () => {
89
+ const userId = ref<string | null>(null);
90
+ const isSignedIn = computed(() => userId.value !== null);
91
+
92
+ function signIn(nextUserId: string) {
93
+ userId.value = nextUserId;
94
+ }
95
+
96
+ return {
97
+ userId: readonly(userId),
98
+ isSignedIn,
99
+ signIn,
100
+ };
101
+ });
102
+ ```
103
+
104
+ ### 5. 明确状态边界和迁移步骤
105
+
106
+ 重构状态时先做状态清单,再逐步移动读写入口。每一步都应保持行为可验证。
107
+
108
+ ```ts
109
+ interface StateMigrationItem {
110
+ name: string;
111
+ currentOwner: "component" | "context" | "store" | "query-cache" | "url";
112
+ targetOwner: "component" | "context" | "store" | "query-cache" | "url";
113
+ verification: string;
114
+ }
115
+
116
+ const migrationPlan: StateMigrationItem[] = [
117
+ {
118
+ name: "dashboard filters",
119
+ currentOwner: "store",
120
+ targetOwner: "url",
121
+ verification: "refreshing the page preserves filters through search params",
122
+ },
123
+ ];
124
+ ```
125
+
126
+ ## 详细参考
127
+
128
+ 需要 Store 形状示例、选择器模式、URL 状态同步、持久化适配器、SSR 边界或审查清单时,加载 [references/state-patterns.md](references/state-patterns.md)。
129
+
130
+ ## 约束
131
+
132
+ - 不把服务端响应复制到全局 store;缓存、失效和重试归数据获取层。
133
+ - 不把表单每个字段提升到全局 store;跨步骤共享也优先由表单上下文或提交草稿适配器处理。
134
+ - 不用 Context 承载高频变化的大对象;会扩大重渲染范围。
135
+ - 持久化状态必须明确字段白名单、版本号、过期策略和敏感数据排除。
136
+ - SSR 场景不要在模块顶层创建带用户数据的单例 store。
137
+
138
+ ## 预期输出
139
+
140
+ 产出状态归属清单、选型理由、store/API 边界和验证步骤。实现时应保留 loading/error/empty、刷新、回退、跨路由和权限变化等关键行为。
@@ -0,0 +1,109 @@
1
+ # 状态管理模式
2
+
3
+ ## 所有权审查清单
4
+
5
+ - 每个状态字段有唯一归属:本地状态、表单状态、服务端缓存、URL 状态、全局 Store 或浏览器持久化。
6
+ - 派生值由源状态计算得出,而不是通过 effect 或 watcher 手动同步。
7
+ - URL 状态用于可分享、刷新后需保留的视图状态,如筛选、搜索、排序和分页。
8
+ - 服务端数据保留在请求缓存中;全局 Store 仅存放选中的 ID、本地偏好或乐观更新提示。
9
+ - 持久化的客户端状态需有白名单、schema 版本号、迁移路径和敏感字段排除规则。
10
+ - Store 的 action 以领域事件命名,而非组件处理器命名。
11
+
12
+ ## React Store 形状示例
13
+
14
+ ```tsx
15
+ import { create } from "zustand";
16
+ import { subscribeWithSelector } from "zustand/middleware";
17
+
18
+ interface CartLine {
19
+ sku: string;
20
+ quantity: number;
21
+ }
22
+
23
+ interface CartState {
24
+ lines: CartLine[];
25
+ addLine: (line: CartLine) => void;
26
+ removeLine: (sku: string) => void;
27
+ }
28
+
29
+ export const useCartStore = create<CartState>()(
30
+ subscribeWithSelector((set) => ({
31
+ lines: [],
32
+ addLine: (line) =>
33
+ set((state) => ({
34
+ lines: [...state.lines.filter((item) => item.sku !== line.sku), line],
35
+ })),
36
+ removeLine: (sku) =>
37
+ set((state) => ({
38
+ lines: state.lines.filter((line) => line.sku !== sku),
39
+ })),
40
+ })),
41
+ );
42
+ ```
43
+
44
+ 选择器应尽可能返回稳定的原始值或经过 memo 的切片:
45
+
46
+ ```tsx
47
+ const itemCount = useCartStore((state) =>
48
+ state.lines.reduce((total, line) => total + line.quantity, 0),
49
+ );
50
+ ```
51
+
52
+ ## URL 状态边界
53
+
54
+ 当另一个用户应能打开相同视图,或刷新后需要保留视图时,使用 URL 状态。
55
+
56
+ ```tsx
57
+ import { useSearchParams } from "react-router-dom";
58
+
59
+ export function useReportFilters() {
60
+ const [params, setParams] = useSearchParams();
61
+ const status = params.get("status") ?? "open";
62
+
63
+ function setStatus(nextStatus: string) {
64
+ setParams((next) => {
65
+ next.set("status", nextStatus);
66
+ next.set("page", "1");
67
+ return next;
68
+ });
69
+ }
70
+
71
+ return { status, setStatus };
72
+ }
73
+ ```
74
+
75
+ ## 持久化适配器边界
76
+
77
+ 仅持久化稳定的客户端偏好设置或非敏感草稿。序列化逻辑放在组件外部。
78
+
79
+ ```ts
80
+ interface PersistedGridState {
81
+ version: 1;
82
+ visibleColumns: string[];
83
+ }
84
+
85
+ const storageKey = "reports:grid";
86
+
87
+ export function readGridState(): PersistedGridState | null {
88
+ const raw = window.localStorage.getItem(storageKey);
89
+ if (!raw) return null;
90
+
91
+ try {
92
+ const parsed = JSON.parse(raw) as PersistedGridState;
93
+ return parsed.version === 1 ? parsed : null;
94
+ } catch {
95
+ return null;
96
+ }
97
+ }
98
+
99
+ export function writeGridState(state: PersistedGridState): void {
100
+ window.localStorage.setItem(storageKey, JSON.stringify(state));
101
+ }
102
+ ```
103
+
104
+ ## SSR 与请求隔离
105
+
106
+ - 当状态可能包含用户数据时,每次请求需创建独立的 Store。
107
+ - 服务端渲染期间不要读取 `window`、`localStorage` 或 `document`。
108
+ - 水合后再加载持久化偏好,并在水合前提供确定性默认值。
109
+ - 服务端缓存脱水与纯客户端全局 Store 分开处理。
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: fec-storybook-component-doc
3
+ description: 用于设置或审查 Storybook 组件文档、设计系统展示、隔离组件状态预览、stories、addons、decorators、MDX 文档、组件状态交互检查、视觉基线或 Chromatic。真实浏览器跨页面旅程或更广覆盖规划优先选择对应测试工作流;中文触发词包括 Storybook、组件文档、Design System、视觉回归。
4
+ ---
5
+
6
+ # Storybook 组件文档化
7
+
8
+ ## 用途
9
+
10
+ 为 UI 组件建立文档化、设计系统展示和隔离状态预览环境;交互与视觉测试只覆盖 Storybook 场景内的组件状态。
11
+
12
+ ## 流程
13
+
14
+ 1. 初始化或识别现有 Storybook 配置,沿用项目框架适配器、stories glob、主题和构建命令。
15
+ 2. 每个组件的 Story 覆盖默认态、主要变体、尺寸、语义 tone、disabled、loading、error、empty、selected、invalid 和关键边缘状态。
16
+ 3. 依赖 Router、Store、i18n、ThemeProvider 的组件用 decorators 包裹,不在 Story 中复制应用入口。
17
+ 4. 复杂组件用 MDX 补充使用说明、Props、slots/children、variant 矩阵、状态示例、可访问性要求和源码展示。
18
+ 5. 需要自动化时接入 interaction tests、addon-a11y、Chromatic 或 Storybook Test Runner;这些能力服务于组件文档和设计系统展示,不承接跨页业务旅程。
19
+ 6. 设计系统组件应记录 token 来源、Tailwind/class 变体、暗色模式、响应式尺寸和不支持的组合,避免消费者靠猜测拼装。
20
+
21
+ ## 详细参考
22
+
23
+ - 需要 `main.ts`、`preview.ts`、stories、decorators、MDX、交互测试和视觉回归示例时,加载 [references/story-patterns.md](references/story-patterns.md)。
24
+
25
+ ## 约束
26
+
27
+ - Story 需随组件 prop 变更同步更新。
28
+ - Provider 依赖必须通过 decorator 补齐。
29
+ - Storybook 构建产物 `storybook-static/` 不应提交到 Git。
30
+ - Storybook 用于开发和组件文档,不替代生产页面 SEO。
31
+ - Storybook 视觉基线用于组件状态;跨页面截图和真实路由流程分流到 E2E workflow。
32
+ - 大型组件库需控制 stories glob 和 addon 开销。
33
+ - 不用 Storybook 隐藏组件 API 问题;若变体组合爆炸,应先收敛组件职责或拆分组件。
34
+
35
+ ## 预期输出
36
+
37
+ 可交互的组件文档和设计系统展示站点,每个组件状态都有隔离预览,Props 表格可生成,关键 Storybook 场景有可选 play 测试或视觉回归基线。