@bovinphang/frontend-craft 2.6.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 (414) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +72 -1
  4. package/CHANGELOG.zh-CN.md +71 -1
  5. package/README.md +10 -6
  6. package/README.openclaw.md +100 -42
  7. package/README.openclaw.zh-CN.md +100 -42
  8. package/README.zh-CN.md +10 -6
  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 +88 -88
  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 +84 -69
  32. package/docs/ja-JP/README.md +56 -52
  33. package/docs/ko-KR/README.md +45 -41
  34. package/docs/project-structure.md +19 -7
  35. package/docs/superpowers/plans/2026-05-29-fec-debug.md +491 -0
  36. package/docs/superpowers/specs/2026-05-29-fec-debug-design.md +340 -0
  37. package/docs/zh-CN/example-prompts.md +84 -69
  38. package/docs/zh-CN/project-structure.md +14 -5
  39. package/docs/zh-TW/README.md +33 -29
  40. package/localized/zh-CN/agents/fec-architect.md +125 -0
  41. package/localized/zh-CN/agents/fec-code-reviewer.md +152 -0
  42. package/localized/zh-CN/agents/fec-debugger.md +44 -0
  43. package/localized/zh-CN/agents/fec-design-token-mapper.md +75 -0
  44. package/localized/zh-CN/agents/fec-doc-updater.md +30 -0
  45. package/localized/zh-CN/agents/fec-e2e-runner.md +107 -0
  46. package/localized/zh-CN/agents/fec-figma-implementer.md +104 -0
  47. package/localized/zh-CN/agents/fec-performance-optimizer.md +293 -0
  48. package/localized/zh-CN/agents/fec-refactor-cleaner.md +32 -0
  49. package/localized/zh-CN/agents/fec-security-reviewer.md +116 -0
  50. package/localized/zh-CN/agents/fec-test-planner.md +50 -0
  51. package/localized/zh-CN/agents/fec-typescript-reviewer.md +142 -0
  52. package/localized/zh-CN/agents/fec-ui-checker.md +120 -0
  53. package/localized/zh-CN/commands/fec-debug.md +30 -0
  54. package/localized/zh-CN/commands/fec-doc-sync.md +19 -0
  55. package/localized/zh-CN/commands/fec-init.md +70 -0
  56. package/localized/zh-CN/commands/fec-plan.md +94 -0
  57. package/localized/zh-CN/commands/fec-refactor-clean.md +19 -0
  58. package/localized/zh-CN/commands/fec-review.md +66 -0
  59. package/localized/zh-CN/commands/fec-scaffold.md +205 -0
  60. package/localized/zh-CN/commands/fec-tdd.md +21 -0
  61. package/localized/zh-CN/skills/TEMPLATE.md +155 -0
  62. package/localized/zh-CN/skills/eval_queries.json +1013 -0
  63. package/localized/zh-CN/skills/fec-accessibility-check/SKILL.md +39 -0
  64. package/localized/zh-CN/skills/fec-accessibility-check/references/report-template.md +23 -0
  65. package/localized/zh-CN/skills/fec-accessibility-check/references/screen-reader-testing.md +33 -0
  66. package/localized/zh-CN/skills/fec-alchemy/SKILL.md +74 -0
  67. package/localized/zh-CN/skills/fec-alchemy/assets/absorption-plan-template.md +47 -0
  68. package/localized/zh-CN/skills/fec-alchemy/assets/intake-template.md +55 -0
  69. package/localized/zh-CN/skills/fec-alchemy/assets/review-checklist.md +31 -0
  70. package/localized/zh-CN/skills/fec-alchemy/references/methodology.md +94 -0
  71. package/localized/zh-CN/skills/fec-alchemy/references/originality-and-licensing.md +57 -0
  72. package/localized/zh-CN/skills/fec-api-integration/SKILL.md +78 -0
  73. package/localized/zh-CN/skills/fec-api-integration/references/integration-patterns.md +80 -0
  74. package/localized/zh-CN/skills/fec-backend-requirements-handoff/SKILL.md +45 -0
  75. package/localized/zh-CN/skills/fec-browser-storage/SKILL.md +34 -0
  76. package/localized/zh-CN/skills/fec-browser-storage/references/storage-patterns.md +65 -0
  77. package/localized/zh-CN/skills/fec-canvas-threejs/SKILL.md +66 -0
  78. package/localized/zh-CN/skills/fec-canvas-threejs/references/rendering-patterns.md +67 -0
  79. package/localized/zh-CN/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +67 -0
  80. package/localized/zh-CN/skills/fec-code-review/SKILL.md +143 -0
  81. package/localized/zh-CN/skills/fec-code-review/references/report-template.md +29 -0
  82. package/localized/zh-CN/skills/fec-component-testing/SKILL.md +119 -0
  83. package/localized/zh-CN/skills/fec-data-fetching/SKILL.md +62 -0
  84. package/localized/zh-CN/skills/fec-data-fetching/references/query-patterns.md +103 -0
  85. package/localized/zh-CN/skills/fec-debug-framework/SKILL.md +157 -0
  86. package/localized/zh-CN/skills/fec-debug-framework/references/report-template.md +58 -0
  87. package/localized/zh-CN/skills/fec-dependency-upgrade/SKILL.md +34 -0
  88. package/localized/zh-CN/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +56 -0
  89. package/localized/zh-CN/skills/fec-doc-sync/SKILL.md +39 -0
  90. package/localized/zh-CN/skills/fec-drawio-studio/SKILL.md +73 -0
  91. package/localized/zh-CN/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
  92. package/localized/zh-CN/skills/fec-drawio-studio/data/brand-icons.json +878 -0
  93. package/localized/zh-CN/skills/fec-drawio-studio/data/shape-index.json +83570 -0
  94. package/localized/zh-CN/skills/fec-drawio-studio/references/data-residency.md +27 -0
  95. package/localized/zh-CN/skills/fec-drawio-studio/references/diagram-patterns.md +60 -0
  96. package/localized/zh-CN/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
  97. package/localized/zh-CN/skills/fec-drawio-studio/references/layout-and-export.md +72 -0
  98. package/localized/zh-CN/skills/fec-drawio-studio/references/troubleshooting.md +29 -0
  99. package/localized/zh-CN/skills/fec-drawio-studio/references/xml-and-mermaid.md +58 -0
  100. package/localized/zh-CN/skills/fec-drawio-studio/scripts/brand-symbols.mjs +99 -0
  101. package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-lint.mjs +205 -0
  102. package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-url.mjs +102 -0
  103. package/localized/zh-CN/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
  104. package/localized/zh-CN/skills/fec-drawio-studio/scripts/layout-graph.mjs +107 -0
  105. package/localized/zh-CN/skills/fec-drawio-studio/scripts/png-embed-fix.mjs +26 -0
  106. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-go-packages.mjs +36 -0
  107. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-js-modules.mjs +52 -0
  108. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-classes.mjs +30 -0
  109. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-modules.mjs +55 -0
  110. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
  111. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
  112. package/localized/zh-CN/skills/fec-drawio-studio/scripts/shape-query.mjs +121 -0
  113. package/localized/zh-CN/skills/fec-drawio-studio/scripts/studio-core.mjs +139 -0
  114. package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/corporate.json +49 -0
  115. package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/default.json +49 -0
  116. package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/handdrawn.json +49 -0
  117. package/localized/zh-CN/skills/fec-drawio-studio/styles/schema.json +112 -0
  118. package/localized/zh-CN/skills/fec-e2e-testing/SKILL.md +42 -0
  119. package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-ci-reporting.md +62 -0
  120. package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-special-scenarios.md +52 -0
  121. package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-visual-regression.md +60 -0
  122. package/localized/zh-CN/skills/fec-e2e-testing/references/playwright-patterns.md +95 -0
  123. package/localized/zh-CN/skills/fec-form-handling/SKILL.md +76 -0
  124. package/localized/zh-CN/skills/fec-form-handling/references/advanced-form-patterns.md +101 -0
  125. package/localized/zh-CN/skills/fec-image-generation/SKILL.md +80 -0
  126. package/localized/zh-CN/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
  127. package/localized/zh-CN/skills/fec-image-generation/references/artifact-routing.md +80 -0
  128. package/localized/zh-CN/skills/fec-image-generation/references/diagram-workflows.md +74 -0
  129. package/localized/zh-CN/skills/fec-image-generation/references/html-technical-diagrams.md +236 -0
  130. package/localized/zh-CN/skills/fec-image-generation/references/png-qa-autofix.md +30 -0
  131. package/localized/zh-CN/skills/fec-image-generation/scripts/export-diagram.mjs +364 -0
  132. package/localized/zh-CN/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
  133. package/localized/zh-CN/skills/fec-image-generation/scripts/png-qa.mjs +431 -0
  134. package/localized/zh-CN/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1397 -0
  135. package/localized/zh-CN/skills/fec-implement-from-design/SKILL.md +129 -0
  136. package/localized/zh-CN/skills/fec-implement-from-design/references/design-plan-template.md +36 -0
  137. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/SKILL.md +46 -0
  138. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +110 -0
  139. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +41 -0
  140. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +48 -0
  141. package/localized/zh-CN/skills/fec-legacy-web-standard/SKILL.md +35 -0
  142. package/localized/zh-CN/skills/fec-legacy-web-standard/references/legacy-patterns.md +85 -0
  143. package/localized/zh-CN/skills/fec-list-virtualization/SKILL.md +34 -0
  144. package/localized/zh-CN/skills/fec-list-virtualization/references/virtualization-patterns.md +80 -0
  145. package/localized/zh-CN/skills/fec-monorepo-project-standard/SKILL.md +142 -0
  146. package/localized/zh-CN/skills/fec-motion-interaction/SKILL.md +73 -0
  147. package/localized/zh-CN/skills/fec-motion-interaction/references/motion-patterns.md +112 -0
  148. package/localized/zh-CN/skills/fec-nextjs-project-standard/SKILL.md +123 -0
  149. package/localized/zh-CN/skills/fec-nuxt-project-standard/SKILL.md +122 -0
  150. package/localized/zh-CN/skills/fec-performance-optimization/SKILL.md +80 -0
  151. package/localized/zh-CN/skills/fec-performance-optimization/references/framework-performance-patterns.md +38 -0
  152. package/localized/zh-CN/skills/fec-performance-optimization/references/report-template.md +59 -0
  153. package/localized/zh-CN/skills/fec-pwa-implementation/SKILL.md +35 -0
  154. package/localized/zh-CN/skills/fec-pwa-implementation/references/manifest-and-icons.md +53 -0
  155. package/localized/zh-CN/skills/fec-pwa-implementation/references/service-worker-workbox.md +68 -0
  156. package/localized/zh-CN/skills/fec-react-project-standard/SKILL.md +91 -0
  157. package/localized/zh-CN/skills/fec-react-project-standard/references/react-performance-patterns.md +35 -0
  158. package/localized/zh-CN/skills/fec-react-project-standard/references/react-project-structure.md +197 -0
  159. package/localized/zh-CN/skills/fec-react-project-standard/references/react-quality-patterns.md +131 -0
  160. package/localized/zh-CN/skills/fec-react-project-standard/references/react-runtime-patterns.md +293 -0
  161. package/localized/zh-CN/skills/fec-refactor-clean/SKILL.md +51 -0
  162. package/localized/zh-CN/skills/fec-refactor-clean/references/report-template.md +42 -0
  163. package/localized/zh-CN/skills/fec-responsive-layout/SKILL.md +34 -0
  164. package/localized/zh-CN/skills/fec-responsive-layout/references/responsive-layout-patterns.md +70 -0
  165. package/localized/zh-CN/skills/fec-route-protection/SKILL.md +135 -0
  166. package/localized/zh-CN/skills/fec-security-review/SKILL.md +38 -0
  167. package/localized/zh-CN/skills/fec-security-review/references/report-template.md +27 -0
  168. package/localized/zh-CN/skills/fec-security-review/references/security-checklist.md +64 -0
  169. package/localized/zh-CN/skills/fec-source-driven-development/SKILL.md +87 -0
  170. package/localized/zh-CN/skills/fec-state-management/SKILL.md +140 -0
  171. package/localized/zh-CN/skills/fec-state-management/references/state-patterns.md +109 -0
  172. package/localized/zh-CN/skills/fec-storybook-component-doc/SKILL.md +37 -0
  173. package/localized/zh-CN/skills/fec-storybook-component-doc/references/story-patterns.md +118 -0
  174. package/localized/zh-CN/skills/fec-svg-animation/SKILL.md +148 -0
  175. package/localized/zh-CN/skills/fec-tailwind-design-system/SKILL.md +34 -0
  176. package/localized/zh-CN/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +59 -0
  177. package/localized/zh-CN/skills/fec-tdd-workflow/SKILL.md +52 -0
  178. package/localized/zh-CN/skills/fec-testing-strategy/SKILL.md +45 -0
  179. package/localized/zh-CN/skills/fec-typescript-project-standard/SKILL.md +54 -0
  180. package/{skills/fec-typescript-type-safety → localized/zh-CN/skills/fec-typescript-project-standard}/references/type-safety-patterns.md +1 -1
  181. package/{skills/fec-typescript-type-safety/SKILL.md → localized/zh-CN/skills/fec-typescript-project-standard/references/type-safety.md} +5 -14
  182. package/localized/zh-CN/skills/fec-ui-design/SKILL.md +108 -0
  183. package/localized/zh-CN/skills/fec-ui-design/data/product-rules.json +231 -0
  184. package/localized/zh-CN/skills/fec-ui-design/data/stack-ui-rules.json +146 -0
  185. package/localized/zh-CN/skills/fec-ui-design/data/style-archetypes.json +373 -0
  186. package/localized/zh-CN/skills/fec-ui-design/data/ux-quality-rules.json +203 -0
  187. package/localized/zh-CN/skills/fec-ui-design/references/design-intelligence.md +97 -0
  188. package/localized/zh-CN/skills/fec-ui-design/references/master-page-overrides.md +30 -0
  189. package/localized/zh-CN/skills/fec-ui-design/references/pre-delivery-checklist.md +39 -0
  190. package/localized/zh-CN/skills/fec-ui-design/scripts/design-system.mjs +648 -0
  191. package/localized/zh-CN/skills/fec-validation-fix/SKILL.md +51 -0
  192. package/localized/zh-CN/skills/fec-validation-fix/references/report-template.md +43 -0
  193. package/localized/zh-CN/skills/fec-vite-project-standard/SKILL.md +83 -0
  194. package/localized/zh-CN/skills/fec-vue3-project-standard/SKILL.md +58 -0
  195. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +162 -0
  196. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +13 -0
  197. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-project-structure.md +176 -0
  198. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +216 -0
  199. package/localized/zh-CN/skills/fec-web-video-presentation/SKILL.md +61 -0
  200. package/localized/zh-CN/skills/fec-web-video-presentation/data/starter-themes.json +59 -0
  201. package/localized/zh-CN/skills/fec-web-video-presentation/references/chapter-craft.md +37 -0
  202. package/localized/zh-CN/skills/fec-web-video-presentation/references/content-plan.md +38 -0
  203. package/localized/zh-CN/skills/fec-web-video-presentation/references/recording-and-audio.md +33 -0
  204. package/localized/zh-CN/skills/fec-web-video-presentation/references/theme-system.md +36 -0
  205. package/localized/zh-CN/skills/fec-web-video-presentation/scripts/create-video-presentation.mjs +430 -0
  206. package/localized/zh-CN/skills/fec-web-workers/SKILL.md +35 -0
  207. package/localized/zh-CN/skills/fec-web-workers/references/advanced-workers.md +54 -0
  208. package/localized/zh-CN/skills/fec-web-workers/references/basic-worker.md +67 -0
  209. package/localized/zh-CN/skills/metadata.json +1646 -0
  210. package/localized/zh-CN/skills/relations.json +755 -0
  211. package/localized/zh-CN/templates/claude/CLAUDE.md +106 -0
  212. package/localized/zh-CN/templates/claude/settings.json +62 -0
  213. package/localized/zh-CN/templates/codex/AGENTS.md +105 -0
  214. package/localized/zh-CN/templates/codex/config.toml +32 -0
  215. package/localized/zh-CN/templates/openclaw/AGENTS.md +101 -0
  216. package/localized/zh-CN/templates/openclaw/OPENCLAW-CONFIG.md +12 -0
  217. package/localized/zh-CN/templates/shared/rules/fec-agent-workflow.md +54 -0
  218. package/localized/zh-CN/templates/shared/rules/fec-api-layer.md +99 -0
  219. package/localized/zh-CN/templates/shared/rules/fec-ci-cd.md +40 -0
  220. package/localized/zh-CN/templates/shared/rules/fec-code-comments.md +33 -0
  221. package/localized/zh-CN/templates/shared/rules/fec-design-system.md +72 -0
  222. package/localized/zh-CN/templates/shared/rules/fec-error-handling.md +56 -0
  223. package/localized/zh-CN/templates/shared/rules/fec-git-conventions.md +73 -0
  224. package/localized/zh-CN/templates/shared/rules/fec-i18n.md +64 -0
  225. package/localized/zh-CN/templates/shared/rules/fec-naming-conventions.md +120 -0
  226. package/localized/zh-CN/templates/shared/rules/fec-performance.md +101 -0
  227. package/localized/zh-CN/templates/shared/rules/fec-react.md +82 -0
  228. package/localized/zh-CN/templates/shared/rules/fec-refactoring.md +47 -0
  229. package/localized/zh-CN/templates/shared/rules/fec-rendering-patterns.md +40 -0
  230. package/localized/zh-CN/templates/shared/rules/fec-responsive-design.md +50 -0
  231. package/localized/zh-CN/templates/shared/rules/fec-source-driven-development.md +31 -0
  232. package/localized/zh-CN/templates/shared/rules/fec-state-management.md +60 -0
  233. package/localized/zh-CN/templates/shared/rules/fec-testing.md +98 -0
  234. package/localized/zh-CN/templates/shared/rules/fec-typescript.md +112 -0
  235. package/localized/zh-CN/templates/shared/rules/fec-vue.md +64 -0
  236. package/localized/zh-CN/templates/shared/rules/fec-working-modes.md +50 -0
  237. package/openclaw.plugin.json +1 -1
  238. package/package.json +4 -3
  239. package/skills/TEMPLATE.md +74 -74
  240. package/skills/eval_queries.json +717 -619
  241. package/skills/fec-accessibility-check/SKILL.md +21 -21
  242. package/skills/fec-accessibility-check/references/report-template.md +12 -12
  243. package/skills/fec-accessibility-check/references/screen-reader-testing.md +24 -24
  244. package/skills/fec-alchemy/SKILL.md +50 -50
  245. package/skills/fec-alchemy/assets/absorption-plan-template.md +32 -32
  246. package/skills/fec-alchemy/assets/intake-template.md +55 -55
  247. package/skills/fec-alchemy/assets/review-checklist.md +23 -23
  248. package/skills/fec-alchemy/references/methodology.md +66 -66
  249. package/skills/fec-alchemy/references/originality-and-licensing.md +42 -42
  250. package/skills/fec-api-integration/SKILL.md +61 -61
  251. package/skills/fec-api-integration/references/integration-patterns.md +30 -30
  252. package/skills/fec-backend-requirements-handoff/SKILL.md +45 -0
  253. package/skills/fec-browser-storage/SKILL.md +16 -16
  254. package/skills/fec-browser-storage/references/storage-patterns.md +16 -16
  255. package/skills/fec-canvas-threejs/SKILL.md +21 -21
  256. package/skills/fec-canvas-threejs/references/rendering-patterns.md +10 -10
  257. package/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +37 -37
  258. package/skills/fec-code-review/SKILL.md +94 -94
  259. package/skills/fec-code-review/references/report-template.md +13 -13
  260. package/skills/fec-component-testing/SKILL.md +39 -39
  261. package/skills/fec-data-fetching/SKILL.md +16 -16
  262. package/skills/fec-data-fetching/references/query-patterns.md +27 -27
  263. package/skills/fec-debug-framework/SKILL.md +95 -95
  264. package/skills/fec-debug-framework/references/report-template.md +34 -34
  265. package/skills/fec-dependency-upgrade/SKILL.md +17 -17
  266. package/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +31 -31
  267. package/skills/fec-doc-sync/SKILL.md +23 -23
  268. package/skills/fec-drawio-studio/SKILL.md +73 -0
  269. package/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
  270. package/skills/fec-drawio-studio/data/brand-icons.json +878 -0
  271. package/skills/fec-drawio-studio/data/shape-index.json +83570 -0
  272. package/skills/fec-drawio-studio/references/data-residency.md +27 -0
  273. package/skills/fec-drawio-studio/references/diagram-patterns.md +60 -0
  274. package/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
  275. package/skills/fec-drawio-studio/references/layout-and-export.md +72 -0
  276. package/skills/fec-drawio-studio/references/troubleshooting.md +29 -0
  277. package/skills/fec-drawio-studio/references/xml-and-mermaid.md +58 -0
  278. package/skills/fec-drawio-studio/scripts/brand-symbols.mjs +99 -0
  279. package/skills/fec-drawio-studio/scripts/diagram-lint.mjs +205 -0
  280. package/skills/fec-drawio-studio/scripts/diagram-url.mjs +102 -0
  281. package/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
  282. package/skills/fec-drawio-studio/scripts/layout-graph.mjs +107 -0
  283. package/skills/fec-drawio-studio/scripts/png-embed-fix.mjs +26 -0
  284. package/skills/fec-drawio-studio/scripts/scan-go-packages.mjs +36 -0
  285. package/skills/fec-drawio-studio/scripts/scan-js-modules.mjs +52 -0
  286. package/skills/fec-drawio-studio/scripts/scan-python-classes.mjs +30 -0
  287. package/skills/fec-drawio-studio/scripts/scan-python-modules.mjs +55 -0
  288. package/skills/fec-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
  289. package/skills/fec-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
  290. package/skills/fec-drawio-studio/scripts/shape-query.mjs +121 -0
  291. package/skills/fec-drawio-studio/scripts/studio-core.mjs +139 -0
  292. package/skills/fec-drawio-studio/styles/built-in/corporate.json +49 -0
  293. package/skills/fec-drawio-studio/styles/built-in/default.json +49 -0
  294. package/skills/fec-drawio-studio/styles/built-in/handdrawn.json +49 -0
  295. package/skills/fec-drawio-studio/styles/schema.json +112 -0
  296. package/skills/fec-e2e-testing/SKILL.md +24 -22
  297. package/skills/fec-e2e-testing/references/e2e-ci-reporting.md +62 -0
  298. package/skills/fec-e2e-testing/references/e2e-special-scenarios.md +52 -0
  299. package/skills/fec-e2e-testing/references/e2e-visual-regression.md +60 -0
  300. package/skills/fec-e2e-testing/references/playwright-patterns.md +6 -6
  301. package/skills/fec-form-handling/SKILL.md +21 -21
  302. package/skills/fec-form-handling/references/advanced-form-patterns.md +41 -41
  303. package/skills/fec-image-generation/SKILL.md +81 -0
  304. package/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
  305. package/skills/fec-image-generation/references/artifact-routing.md +80 -0
  306. package/skills/fec-image-generation/references/diagram-workflows.md +74 -0
  307. package/skills/fec-image-generation/references/html-technical-diagrams.md +236 -0
  308. package/skills/fec-image-generation/references/png-qa-autofix.md +30 -0
  309. package/skills/fec-image-generation/scripts/export-diagram.mjs +364 -0
  310. package/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
  311. package/skills/fec-image-generation/scripts/png-qa.mjs +431 -0
  312. package/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1397 -0
  313. package/skills/fec-implement-from-design/SKILL.md +81 -74
  314. package/skills/fec-implement-from-design/references/design-plan-template.md +16 -16
  315. package/skills/fec-legacy-to-modern-migration/SKILL.md +29 -173
  316. package/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +110 -0
  317. package/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +37 -37
  318. package/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +48 -0
  319. package/skills/fec-legacy-web-standard/SKILL.md +17 -17
  320. package/skills/fec-legacy-web-standard/references/legacy-patterns.md +16 -16
  321. package/skills/fec-list-virtualization/SKILL.md +16 -16
  322. package/skills/fec-list-virtualization/references/virtualization-patterns.md +31 -31
  323. package/skills/fec-monorepo-project-standard/SKILL.md +52 -52
  324. package/skills/fec-motion-interaction/SKILL.md +51 -44
  325. package/skills/fec-motion-interaction/references/motion-patterns.md +11 -11
  326. package/skills/fec-nextjs-project-standard/SKILL.md +64 -58
  327. package/skills/fec-nuxt-project-standard/SKILL.md +57 -57
  328. package/skills/fec-performance-optimization/SKILL.md +54 -50
  329. package/skills/fec-performance-optimization/references/framework-performance-patterns.md +38 -0
  330. package/skills/fec-performance-optimization/references/report-template.md +34 -28
  331. package/skills/fec-pwa-implementation/SKILL.md +17 -17
  332. package/skills/fec-pwa-implementation/references/manifest-and-icons.md +12 -12
  333. package/skills/fec-pwa-implementation/references/service-worker-workbox.md +13 -13
  334. package/skills/fec-react-project-standard/SKILL.md +72 -64
  335. package/skills/fec-react-project-standard/references/react-performance-patterns.md +35 -0
  336. package/skills/fec-react-project-standard/references/react-project-structure.md +197 -0
  337. package/skills/fec-react-project-standard/references/react-quality-patterns.md +131 -0
  338. package/skills/fec-react-project-standard/references/react-runtime-patterns.md +293 -0
  339. package/skills/fec-refactor-clean/SKILL.md +30 -30
  340. package/skills/fec-refactor-clean/references/report-template.md +23 -23
  341. package/skills/fec-responsive-layout/SKILL.md +17 -17
  342. package/skills/fec-responsive-layout/references/responsive-layout-patterns.md +39 -28
  343. package/skills/fec-route-protection/SKILL.md +26 -26
  344. package/skills/fec-security-review/SKILL.md +20 -20
  345. package/skills/fec-security-review/references/report-template.md +12 -12
  346. package/skills/fec-security-review/references/security-checklist.md +27 -27
  347. package/skills/fec-source-driven-development/SKILL.md +66 -40
  348. package/skills/fec-state-management/SKILL.md +34 -34
  349. package/skills/fec-state-management/references/state-patterns.md +19 -19
  350. package/skills/fec-storybook-component-doc/SKILL.md +19 -19
  351. package/skills/fec-storybook-component-doc/references/story-patterns.md +12 -12
  352. package/skills/fec-svg-animation/SKILL.md +32 -32
  353. package/skills/fec-tailwind-design-system/SKILL.md +17 -17
  354. package/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +36 -32
  355. package/skills/fec-tdd-workflow/SKILL.md +28 -28
  356. package/skills/fec-testing-strategy/SKILL.md +29 -29
  357. package/skills/fec-typescript-project-standard/SKILL.md +54 -0
  358. package/skills/fec-typescript-project-standard/references/type-safety-patterns.md +102 -0
  359. package/skills/fec-typescript-project-standard/references/type-safety.md +148 -0
  360. package/skills/fec-ui-design/SKILL.md +90 -72
  361. package/skills/fec-ui-design/data/style-archetypes.json +40 -0
  362. package/skills/fec-ui-design/data/ux-quality-rules.json +35 -0
  363. package/skills/fec-ui-design/references/design-intelligence.md +81 -21
  364. package/skills/fec-ui-design/references/master-page-overrides.md +15 -15
  365. package/skills/fec-ui-design/references/pre-delivery-checklist.md +38 -32
  366. package/skills/fec-ui-design/scripts/design-system.mjs +119 -1
  367. package/skills/fec-validation-fix/SKILL.md +26 -26
  368. package/skills/fec-validation-fix/references/report-template.md +25 -25
  369. package/skills/fec-vite-project-standard/SKILL.md +39 -39
  370. package/skills/fec-vue3-project-standard/SKILL.md +39 -30
  371. package/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +163 -0
  372. package/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +13 -0
  373. package/skills/fec-vue3-project-standard/references/vue3-project-structure.md +177 -0
  374. package/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +216 -0
  375. package/skills/fec-web-video-presentation/SKILL.md +61 -0
  376. package/skills/fec-web-video-presentation/data/starter-themes.json +59 -0
  377. package/skills/fec-web-video-presentation/references/chapter-craft.md +37 -0
  378. package/skills/fec-web-video-presentation/references/content-plan.md +38 -0
  379. package/skills/fec-web-video-presentation/references/recording-and-audio.md +33 -0
  380. package/skills/fec-web-video-presentation/references/theme-system.md +36 -0
  381. package/skills/fec-web-video-presentation/scripts/create-video-presentation.mjs +430 -0
  382. package/skills/fec-web-workers/SKILL.md +16 -16
  383. package/skills/fec-web-workers/references/advanced-workers.md +13 -13
  384. package/skills/fec-web-workers/references/basic-worker.md +8 -8
  385. package/skills/metadata.json +402 -220
  386. package/skills/relations.json +120 -25
  387. package/templates/claude/CLAUDE.md +60 -60
  388. package/templates/codex/AGENTS.md +76 -76
  389. package/templates/codex/config.toml +4 -4
  390. package/templates/openclaw/AGENTS.md +68 -68
  391. package/templates/openclaw/OPENCLAW-CONFIG.md +8 -8
  392. package/templates/shared/rules/fec-agent-workflow.md +40 -40
  393. package/templates/shared/rules/fec-api-layer.md +52 -52
  394. package/templates/shared/rules/fec-ci-cd.md +29 -117
  395. package/templates/shared/rules/fec-code-comments.md +22 -22
  396. package/templates/shared/rules/fec-design-system.md +65 -241
  397. package/templates/shared/rules/fec-error-handling.md +41 -185
  398. package/templates/shared/rules/fec-git-conventions.md +42 -42
  399. package/templates/shared/rules/fec-i18n.md +48 -96
  400. package/templates/shared/rules/fec-naming-conventions.md +91 -91
  401. package/templates/shared/rules/fec-performance.md +78 -78
  402. package/templates/shared/rules/fec-react.md +58 -58
  403. package/templates/shared/rules/fec-refactoring.md +34 -30
  404. package/templates/shared/rules/fec-rendering-patterns.md +40 -183
  405. package/templates/shared/rules/fec-responsive-design.md +37 -214
  406. package/templates/shared/rules/fec-source-driven-development.md +22 -22
  407. package/templates/shared/rules/fec-state-management.md +45 -148
  408. package/templates/shared/rules/fec-testing.md +64 -64
  409. package/templates/shared/rules/fec-typescript.md +98 -341
  410. package/templates/shared/rules/fec-vue.md +42 -42
  411. package/templates/shared/rules/fec-working-modes.md +34 -34
  412. package/skills/fec-e2e-testing/references/e2e-advanced.md +0 -176
  413. package/skills/fec-react-project-standard/references/react-project-details.md +0 -642
  414. package/skills/fec-vue3-project-standard/references/vue3-project-details.md +0 -547
@@ -1,98 +1,98 @@
1
- # 测试与校验规则
1
+ # Testing and verification rules
2
2
 
3
- 凡是新增、修改、重构或评审代码时,都应用本文件。
3
+ This document should be used whenever code is added, modified, refactored, or reviewed.
4
4
 
5
- ## 校验顺序
5
+ ## Verification sequence
6
6
 
7
- 优先按以下顺序执行:
7
+ Prioritize execution in the following order:
8
8
 
9
9
  1. lint
10
10
  2. type check
11
11
  3. unit test
12
12
  4. build
13
13
 
14
- 优先使用仓库已有脚本。
15
- 如果命令不确定,先检查 `package.json`。
14
+ Priority is given to using existing scripts in the warehouse.
15
+ If the command is uncertain, check `package.json` first.
16
16
 
17
- ## 改动校验原则
17
+ ## Change the verification principle
18
18
 
19
- - 先修复范围最小且正确的问题
20
- - 每次关键修复后重新执行受影响的命令
21
- - 不要盲目压掉报错或关闭规则
22
- - 不要为了通过检查而降低类型安全
23
- - 不要因为一个局部测试失败就重写无关模块
19
+ - Fix the smallest and correct issues first
20
+ - Re-execute affected commands after each critical fix
21
+ - Don’t blindly suppress error reporting or closing rules
22
+ - Don't compromise type safety to pass checks
23
+ - Don't rewrite unrelated modules just because a local test fails
24
24
 
25
- ## 测试要求
25
+ ## Testing requirements
26
26
 
27
- 新增或修改行为时,考虑是否需要覆盖以下内容:
27
+ When adding or modifying behaviors, consider whether you need to override the following:
28
28
 
29
- - 组件渲染
30
- - 交互行为
31
- - 状态切换
32
- - 边界场景
33
- - loading / empty / error 状态
34
- - 与可访问性相关的关键交互
29
+ - Component rendering
30
+ - interactive behavior
31
+ - Status switching
32
+ - Border scenes
33
+ - loading / empty / error status
34
+ - Key interactions related to accessibility
35
35
 
36
- 如果没有补测试,需要说明原因。
36
+ If there is no supplementary test, the reason needs to be explained.
37
37
 
38
- ## Fixture 与 Mock
38
+ ## Fixture and Mock
39
39
 
40
- - Fixture 表达业务场景,不使用随机、无语义或只对测试作者有意义的数据
41
- - 复杂对象使用 builder 填充默认值,每个测试只覆盖当前场景相关字段
42
- - 测试间不共享可变全局状态、fake timer、store 或 mock server handler
43
- - 网络 mock 应模拟公开契约和用户可见错误,不复制后端内部实现
40
+ - Fixture expresses business scenarios without using random, meaningless or data that is meaningful only to the test author
41
+ - Complex objects use builder to fill in default values, and each test only covers fields related to the current scenario.
42
+ - No mutable global state, fake timers, stores or mock server handlers are shared between tests
43
+ - Network mocks should simulate public contracts and user-visible errors and not replicate backend internal implementations
44
44
 
45
- ## TDD 与回归测试
45
+ ## TDD and regression testing
46
46
 
47
- 新增行为、修复 Bug 或重构关键逻辑时,优先采用 TDD:
47
+ When adding new behaviors, fixing bugs, or refactoring key logic, TDD is preferred:
48
48
 
49
- 1. 先写能描述期望行为的失败测试。
50
- 2. 运行测试并确认失败原因正确。
51
- 3. 写最小实现让测试通过。
52
- 4. 测试保持通过后再重构。
49
+ 1. Start by writing failing tests that describe the desired behavior.
50
+ 2. Run the test and confirm that the failure reason is correct.
51
+ 3. Write the minimum implementation to make the test pass.
52
+ 4. Refactor after the test remains passed.
53
53
 
54
- Bug 修复应优先保留能复现问题的回归测试。若现有项目缺少测试基础设施,不要盲目引入新框架;先给出最小测试落地建议并说明维护成本。
54
+ Bug fixes should prioritize keeping regression tests that reproduce the problem. If the existing project lacks testing infrastructure, do not blindly introduce a new framework; first provide minimum test implementation suggestions and explain maintenance costs.
55
55
 
56
- ## 代码评审输出风格
56
+ ## Code review output style
57
57
 
58
- 评审代码时,返回:
58
+ When reviewing code, return:
59
59
 
60
- - 总体评估
61
- - 必修问题
62
- - 建议优化
63
- - 可选优化项
64
- - 风险等级
60
+ - Overall assessment
61
+ - Required questions
62
+ - Suggestions for optimization
63
+ - Optional optimization items
64
+ - Risk level
65
65
 
66
- 结论要具体且可执行。
66
+ Conclusions should be specific and actionable.
67
67
 
68
- ## E2E 测试规则
68
+ ## E2E test rules
69
69
 
70
- 使用 Playwright 或 Cypress 时:
70
+ When using Playwright or Cypress:
71
71
 
72
- - 遵循 **Page Object**,spec 内不写裸选择器;优先 **`data-testid`**,其次 **`role` / `label`**
73
- - 用 **`test.describe` + `beforeEach`** 组织场景,单用例可独立运行、不依赖执行顺序
74
- - 禁止用固定 **`sleep`** 当主要同步手段;用 **Locator 自动等待**、`expect`、`waitForResponse` 等
75
- - Playwright:**`playwright.config.ts`** 中配置 `baseURL`、CI 下 `retries`/`workers`、`trace`/`screenshot`/`video`、**`webServer`** 与多 **`projects`(含移动端)**
76
- - 关键流程至少覆盖桌面、平板、移动端视口(或等价 device 项目)
77
- - **不稳定用例**:`test.fixme` / `test.skip` 需写原因与 issue;用 `--repeat-each` 辅助定位 flaky
78
- - 失败时保留 **截图、Trace、视频**,CI 用 **artifact** 上传 HTML 报告与产物
79
- - 高风险/资金类流程:**勿在生产跑真实 E2E**;staging 或 mock,必要时 `test.skip`
80
- - 测试数据可重复:优先 seed、测试账号或 mock 服务;随机值必须带唯一前缀并在 teardown 清理
72
+ - Follow **Page Object**, do not write naked selectors in spec; give priority to **`data-testid`**, followed by **`role` / `label`**
73
+ - Use **`test.describe` + `beforeEach`** to organize scenarios. A single use case can run independently and does not depend on the execution sequence.
74
+ - It is forbidden to use fixed **`sleep`** as the main synchronization method; use **Locator to automatically wait**, `expect`, `waitForResponse`, etc.
75
+ - Playwright: Configure `baseURL` in **`playwright.config.ts`**, `retries`/`workers`, `trace`/`screenshot`/`video`, **`webServer`** and many **`projects` (including mobile)** under CI
76
+ - Key processes cover at least desktop, tablet, and mobile viewports (or equivalent device projects)
77
+ - **Unstable use case**: `test.fixme` / `test.skip` needs to write the reason and issue; use `--repeat-each` to assist in locating flaky
78
+ - Keep **Screenshots, Traces, Videos** in case of failure, CI uses **artifact** to upload HTML reports and products
79
+ - High-risk/funding processes: **Do not run real E2E in production**; staging or mock, if necessary `test.skip`
80
+ - Test data is repeatable: priority is seed, test account or mock service; random values must be uniquely prefixed and cleaned in teardown
81
81
 
82
- 详细模式与示例见插件 **`fec-e2e-testing`** skill。
82
+ For detailed modes and examples, see the plug-in **`fec-e2e-testing`** skill.
83
83
 
84
- ## 重构规则
84
+ ## Refactoring rules
85
85
 
86
- 进行重构时:
86
+ When refactoring:
87
87
 
88
- - 除非任务明确要求改行为,否则保持行为一致
89
- - 说明可能的迁移风险
90
- - 优先做渐进式修改,而不是大范围重写
91
- - 总结改动文件、执行过的命令和剩余风险
88
+ - Maintain consistent behavior unless the task specifically requires a change in behavior
89
+ - Describe possible migration risks
90
+ - Prioritize incremental changes over extensive rewrites
91
+ - Summarize changed files, executed commands and remaining risks
92
92
 
93
- ## 验证失败处理
93
+ ## Verification failure handling
94
94
 
95
- - 按文件和根因分组错误,一次修复一类问题。
96
- - 每次修复后重新运行最近的失败命令。
97
- - 不删除失败测试、不关闭规则、不降低类型安全来换取通过。
98
- - 同一错误多次修复仍失败时,停止扩大改动并报告阻塞。
95
+ - Group errors by file and root cause to fix one type of problems at a time.
96
+ - Rerun the most recent failed command after each fix.
97
+ - Don't remove failing tests, don't close rules, don't reduce type safety in exchange for passing.
98
+ - When the same error is repaired multiple times and still fails, the expansion of changes will be stopped and a blockage will be reported.
@@ -1,355 +1,112 @@
1
- # TypeScript / JavaScript 规则
1
+ # TypeScript / JavaScript rules
2
2
 
3
- 编写、修改或评审 `.ts`、`.tsx`、`.js`、`.jsx` 时应用本文件。注释风格另见 `fec-code-comments.md`;E2E 与校验流程另见 `fec-testing.md`。
3
+ Use this file when writing, modifying or reviewing `.ts`, `.tsx`, `.js`, `.jsx`. This article only retains the permanent hard constraints of the project; complex type modeling, `tsconfig` layering, declared products, DTO / view model boundaries, type testing and release entry design are left to the `fec-typescript-project-standard` skill or special review. See also `fec-code-comments.md` for comment style; see `fec-testing.md` for E2E and verification process.
4
4
 
5
- ## 类型与接口
5
+ ## Types and interfaces
6
6
 
7
- 用类型让对外 API、共享模型与组件 props 显式、可读、可复用。
8
-
9
- ### 对外导出的 API
7
+ Use types to make external APIs, shared models, and component props explicit, readable, and reusable.
10
8
 
11
- - 对**导出**的函数、共享工具函数、公开类方法,写明参数与返回值类型。
12
- - **局部**变量在类型显而易见时交给 TypeScript 推断。
13
- - 重复出现的内联对象形状抽成具名 `interface` 或 `type`。
9
+ ### Externally exported API
14
10
 
15
- ```typescript
16
- // 错误:导出函数缺少显式类型
17
- export function formatUser(user) {
18
- return `${user.firstName} ${user.lastName}`;
19
- }
20
-
21
- // 正确:对外 API 显式标注
22
- interface User {
23
- firstName: string;
24
- lastName: string;
25
- }
11
+ - For **export** functions, shared tool functions, and public class methods, indicate the parameter and return value types.
12
+ - **Local** variables are handed over to TypeScript for inference when the type is obvious, and obvious intermediate variables are not repeatedly annotated.
13
+ - Recurring inline object shapes are extracted into named `interface` or `type` to avoid the same contract being scattered in multiple signatures.
14
+ - The boundaries of external data, API DTOs, routing parameters, form values and component props must be explicitly named; complex modeling is offloaded to `fec-typescript-project-standard`.
26
15
 
27
- export function formatUser(user: User): string {
28
- return `${user.firstName} ${user.lastName}`;
29
- }
30
- ```
16
+ ### `interface` and `type`
31
17
 
32
- ### `interface` 与 `type`
18
+ - Object shapes that may be extended or `implements` take precedence over `interface`.
19
+ - **Union, intersection, tuple, map type, tool type combination** use `type`.
20
+ - Limited business values such as status, type, role, etc. are first combined with string literals; `enum` is only used when interoperability or team unified requirements are met.
33
21
 
34
- - 可能被扩展或 `implements` 的**对象形状**优先用 `interface`。
35
- - **联合、交叉、元组、映射类型、工具类型组合**用 `type`。
36
- - 优先**字符串字面量联合**;仅在互操作或团队统一要求时使用 `enum`。
37
-
38
- ```typescript
39
- interface User {
40
- id: string;
41
- email: string;
42
- }
22
+ ### Function parameters: complex types should be named
43
23
 
44
- type UserRole = "admin" | "member";
45
- type UserWithRole = User & { role: UserRole };
46
- ```
47
-
48
- ### 函数参数:复杂类型宜具名
49
-
50
- - 参数上的**复杂联合**、**内联对象类型**、**较复杂的回调签名**等,应**优先**提取为具名 `type` / `interface`,再在函数签名中引用,便于阅读、复测与重构。
51
- - **仅当**类型**简单**、**短小**、一眼可读,且**明显无复用**价值时,允许在参数位置内联(如单独的 `string`、`number`、`boolean` 等)。
52
-
53
- ```typescript
54
- // 不推荐:联合与可选散落在参数上,语义不突出
55
- function getUserInfo(id: string | number | undefined) {}
56
-
57
- // 推荐:具名类型表达「用户标识」语义,可选更自然
58
- type UserId = string | number;
59
- function getUserInfo(id?: UserId) {}
60
- ```
61
-
62
- ```typescript
63
- // 不推荐:内联联合对象冗长,难复用、难单测描述
64
- function send(data: string | { content: string; type: "text" | "html" }) {}
65
-
66
- // 推荐:消息载荷单一真源
67
- type MessagePayload =
68
- | string
69
- | {
70
- content: string;
71
- type: "text" | "html";
72
- };
73
-
74
- function send(data: MessagePayload) {}
75
- ```
76
-
77
- ### 避免 `any`
78
-
79
- - 业务代码中避免 `any`。
80
- - 外部或不可信数据用 `unknown`,再安全收窄。
81
- - 类型随调用方变化时用泛型。
82
-
83
- ```typescript
84
- // 错误:any 取消类型检查
85
- function getErrorMessage(error: any) {
86
- return error.message;
87
- }
88
-
89
- // 正确:unknown 强制收窄
90
- function getErrorMessage(error: unknown): string {
91
- if (error instanceof Error) {
92
- return error.message;
93
- }
94
- return "Unexpected error";
95
- }
96
- ```
97
-
98
- ### React 组件 Props
99
-
100
- - 用具名 `interface` 或 `type` 定义 props。
101
- - 回调 props 写清参数与返回值。
102
- - 无特殊理由不使用 `React.FC`(避免隐式 `children` 等差异)。
103
-
104
- ```typescript
105
- interface User {
106
- id: string;
107
- email: string;
108
- }
109
-
110
- interface UserCardProps {
111
- user: User;
112
- onSelect: (id: string) => void;
113
- }
114
-
115
- function UserCard({ user, onSelect }: UserCardProps) {
116
- return <button onClick={() => onSelect(user.id)}>{user.email}</button>;
117
- }
118
- ```
119
-
120
- ## 单文件规模与模块拆分
121
-
122
- - `.ts` / `.tsx` / `.js` / `.jsx` 单文件建议控制在 **约 300 行以内**。该阈值是可维护性与评审效率的经验上限,不是机械的硬限制。
123
- - 当文件明显超过该规模且承担多重职责时,应优先按职责拆分:如数据访问、业务规则、视图渲染、适配层、常量与映射。
124
- - 超阈值优先提取:纯函数、子组件、自定义 Hook、`*.types.ts` 类型模块、常量表,不要仅为压行数做无意义切分。
125
- - 可接受例外:生成代码、极薄的 re-export 聚合文件、经团队评审确认的高内聚模块;例外建议在文件头简短注明原因。
126
-
127
- ### 仍为 JavaScript 的文件
128
-
129
- - 在 `.js` / `.jsx` 中,若短期无法迁 TS,可用 **JSDoc** 补类型,并与运行时行为一致。
130
-
131
- ```javascript
132
- /**
133
- * @param {{ firstName: string, lastName: string }} user
134
- * @returns {string}
135
- */
136
- export function formatUser(user) {
137
- return `${user.firstName} ${user.lastName}`;
138
- }
139
- ```
140
-
141
- ## 禁止 Magic Number / Magic String
142
-
143
- - **业务代码中禁止**使用**无语义**的硬编码数字或字符串(如 `1`、`2`、`3`、`"1"`、`"2"`、`"3"`)直接表示**状态、类型、标识或业务含义**(含 `if`/`switch`/赋值与 API 字段映射等)。
144
- - **固定且有限的取值范围**须在单一真源处定义,并在全仓引用名称,避免裸值散落:
145
- - **`enum`**(与后端或协议对齐、或团队明确约定时使用;注意字符串 enum、const enum 与打包/tree-shaking 策略);
146
- - **`as const` 常量对象**(常与 `typeof` / `keyof` 推导联合类型,适合前端主路径);
147
- - **字面量联合类型**(`type Status = "a" | "b"`)并与上面对象或 map 配套,保证调用处可收窄、可重构。
148
- - **不属本条**的典型例外(仍应保持可读):纯算法下标、 obvious 的 `0`/`1` 长度判断、与业务无关的 UI 刻度若已有设计 Token 则改走 `fec-design-system.md`。
149
-
150
- ```typescript
151
- // 不佳:业务语义依赖裸数字 / 裸字符串
152
- function label(status: number) {
153
- if (status === 1) return "待支付";
154
- if (status === 2) return "已支付";
155
- return "未知";
156
- }
157
- if (user.role === "3") {
158
- /* ... */
159
- }
160
-
161
- // 更佳:字面量联合 + as const 常量对象(或团队约定的 enum)
162
- type OrderStatus = "pending" | "paid" | "cancelled";
163
- const ORDER_STATUS = {
164
- Pending: "pending",
165
- Paid: "paid",
166
- Cancelled: "cancelled",
167
- } as const satisfies Record<string, OrderStatus>;
168
-
169
- function label(status: OrderStatus) {
170
- if (status === ORDER_STATUS.Pending) return "待支付";
171
- if (status === ORDER_STATUS.Paid) return "已支付";
172
- return "已取消";
173
- }
174
- ```
175
-
176
- ## 不可变更新
177
-
178
- 优先用展开运算符合并新对象,避免直接改写入参。
179
-
180
- ```typescript
181
- interface User {
182
- id: string;
183
- name: string;
184
- }
185
-
186
- // 错误:修改原对象
187
- function updateUser(user: User, name: string): User {
188
- user.name = name;
189
- return user;
190
- }
191
-
192
- // 正确:返回新对象
193
- function updateUser(user: Readonly<User>, name: string): User {
194
- return { ...user, name };
195
- }
196
- ```
197
-
198
- ## 异步与错误处理
199
-
200
- 使用 `async/await` 与 `try/catch`,在 `catch` 中将错误视为 `unknown` 再收窄。
201
-
202
- ```typescript
203
- interface User {
204
- id: string;
205
- email: string;
206
- }
207
-
208
- declare function riskyOperation(userId: string): Promise<User>;
209
-
210
- function getErrorMessage(error: unknown): string {
211
- if (error instanceof Error) {
212
- return error.message;
213
- }
214
- return "Unexpected error";
215
- }
216
-
217
- const logger = {
218
- error: (message: string, error: unknown) => {
219
- // 替换为项目内的日志实现(如 pino、winston 等)
220
- },
221
- };
222
-
223
- async function loadUser(userId: string): Promise<User> {
224
- try {
225
- return await riskyOperation(userId);
226
- } catch (error: unknown) {
227
- logger.error("Operation failed", error);
228
- throw new Error(getErrorMessage(error));
229
- }
230
- }
231
- ```
232
-
233
- ## 输入校验
234
-
235
- 对外部输入(表单、API、URL 参数等)宜用 **Zod**(或项目选用的同类库)做模式校验,并用 `z.infer` 推导类型。
236
-
237
- ```typescript
238
- import { z } from "zod";
239
-
240
- const userSchema = z.object({
241
- email: z.string().email(),
242
- age: z.number().int().min(0).max(150),
243
- });
244
-
245
- type UserInput = z.infer<typeof userSchema>;
246
-
247
- const validated: UserInput = userSchema.parse(input);
248
- ```
249
-
250
- ## 类型资产分层与命名
251
-
252
- - 模块或特性专属类型使用 `*.types.ts`,并与实现文件同目录或同 feature 目录放置,例如 `user.types.ts`、`billing.types.ts`。
253
- - 全局与环境相关声明放在 `global.d.ts`、`env.d.ts` 或 `types/*.d.ts`,仅用于真全局或 ambient 声明,不将可模块化类型放入全局。
254
- - 仅用于类型的导入导出优先使用 `import type` 与 `export type`,减少值空间歧义并提升编译语义清晰度。
255
- - 与 API DTO 同源的类型,放在对应 feature 或 API 子目录的 `*.types.ts`,避免在页面或组件实现内散落大型匿名类型。
256
-
257
- ```typescript
258
- // user.types.ts
259
- export interface UserProfile {
260
- id: string;
261
- email: string;
262
- status: "active" | "disabled";
263
- }
264
-
265
- // user.service.ts
266
- import type { UserProfile } from "./user.types";
267
- export type { UserProfile };
268
- ```
269
-
270
- ## 工程化与惯用法补充
271
-
272
- - 使用**判别式联合**配合 `never` 穷尽检查,确保分支新增成员时编译期可发现遗漏。
273
- - 需要同时满足「字面量保留」与「结构校验」时优先使用 `satisfies`,再考虑类型断言。
274
- - 优先使用类型收窄(`typeof` / `in` / 自定义 predicate)而非 `as` 强转;`as` 应用于边界互操作而非消错。
275
- - 对不应被修改的数据优先建模为 `readonly` / `Readonly<T>`,与不可变更新规则协同。
276
- - 新业务代码默认采用 ES Module;`namespace` 与三斜线指令仅用于声明合并或遗留互操作场景。
277
- - `index.ts` 聚合导出应保持浅层且按 feature 边界组织,避免深层 barrel 引发循环依赖与不必要的耦合。
278
- - 扩展第三方类型时使用独立声明文件(如 `types/vendor-foo.d.ts`)并通过 `declare module "pkg"` 局部扩展,避免污染全局实现文件。
279
- - `tsconfig` 应保持 `strict` 族能力;若为兼容遗留场景需要放宽严格项,必须在评审中明确说明范围、风险与回收计划。
280
- - 可在消费项目使用 lint(如 `max-lines`)辅助识别超长文件,但规则设计应服务可维护性,而非追求机械达标。
281
-
282
- ## 日志与 `console.log`
283
-
284
- - 生产路径避免遗留 `console.log`;使用项目统一的日志方案。
285
- - 可在保存后格式化、`tsc` 检查或提交前脚本中对 `console.log` 做提示或拦截(按团队工具链配置)。
286
-
287
- ## 常见模式
288
-
289
- ### 统一 API 响应形状(示例)
290
-
291
- ```typescript
292
- interface ApiResponse<T> {
293
- success: boolean;
294
- data?: T;
295
- error?: string;
296
- meta?: {
297
- total: number;
298
- page: number;
299
- limit: number;
300
- };
301
- }
302
- ```
303
-
304
- ### 自定义 Hook(示例)
305
-
306
- ```typescript
307
- export function useDebounce<T>(value: T, delay: number): T {
308
- const [debouncedValue, setDebouncedValue] = useState<T>(value);
309
-
310
- useEffect(() => {
311
- const handler = setTimeout(() => setDebouncedValue(value), delay);
312
- return () => clearTimeout(handler);
313
- }, [value, delay]);
314
-
315
- return debouncedValue;
316
- }
317
- ```
318
-
319
- ### 仓储接口(示例)
320
-
321
- ```typescript
322
- interface Repository<T> {
323
- findAll(filters?: Filters): Promise<T[]>;
324
- findById(id: string): Promise<T | null>;
325
- create(data: CreateDto): Promise<T>;
326
- update(id: string, data: UpdateDto): Promise<T>;
327
- delete(id: string): Promise<void>;
328
- }
329
- ```
24
+ - **Complex unions**, **inline object types**, **more complex callback signatures**, etc. on parameters should be extracted as named `type` / `interface` first, and then referenced in the function signature.
25
+ - Inlining in parameter positions is only allowed if the type is simple, short, readable at a glance, and has obvious no reuse value.
26
+ - Callback parameters and return values must be expressed clearly; do not use `Function`, wide objects or implicit `any` to undertake business contracts.
330
27
 
331
- ## 密钥与敏感配置
28
+ ### Avoid `any`
332
29
 
333
- - **禁止**在源码中硬编码密钥、Token、私钥。
334
- - **必须**通过环境变量或构建期注入(如 `process.env.*`、`import.meta.env.*`,以项目脚手架为准),并在缺失时显式失败或降级策略清晰。
30
+ - Avoid `any` in business code; existing `any` should not be spread casually.
31
+ - Use `unknown` for external or untrusted data, safely narrowed through `typeof`, `in`, `instanceof`, schema parse or custom predicate.
32
+ - Use generics when the type changes from caller to caller, but don’t introduce an incomprehensible layer of generics for simple scenarios.
33
+ - `as` type assertions are only used for explicit boundary interoperation or supplementary expressions after verified narrowing, and are not used to suppress type errors.
335
34
 
336
- ```typescript
337
- // 错误:硬编码密钥
338
- const apiKey = "sk-proj-xxxxx";
35
+ ### React Component Props
339
36
 
340
- // 正确:环境变量(Node 示例;Vite 等请用 import.meta.env 及 VITE_ 前缀约定)
341
- const apiKey = process.env.OPENAI_API_KEY;
342
- if (!apiKey) {
343
- throw new Error("OPENAI_API_KEY not configured");
344
- }
345
- ```
37
+ - Define props with named `interface` or `type`, and offload complex public props to type modules.
38
+ - Write clear parameters and return values in callback props; event payload does not require long-term inlining of bare objects.
39
+ - Don't use `React.FC` without special reason, avoid differences such as implicit `children`.
40
+ - TSX generics, complex component props or external DTO mapping issues are left to React rules and `fec-typescript-project-standard` to converge together.
346
41
 
347
- 涉及认证、支付、上传等场景时,结合项目安全规范做专项评审。
348
-
349
- ## 与测试规则的关系
350
-
351
- 关键用户路径的端到端覆盖方式(Playwright、Cypress、Page Object 等)以 `fec-testing.md` 为准;本文件不重复展开 E2E 细则。
352
-
353
- ## 与 `typescript-reviewer` 子代理
354
-
355
- 对 **`.ts` / `.tsx` / `.js` / `.jsx`** 进行专项评审(先跑 typecheck/eslint、PR 合并就绪检查、分级结论)时,可委托插件内置的 **`typescript-reviewer`** 子代理;其报告默认写入 `reports/typescript-review-YYYY-MM-DD-HHmmss.md`,规则底线仍以本文件与项目 `CLAUDE.md` 为准。
42
+ ## Single file size and module splitting
43
+
44
+ - `.ts` / `.tsx` / `.js` / `.jsx` It is recommended that a single file be controlled within **about 300 lines**. This threshold is an empirical upper limit for maintainability and review efficiency, not a mechanical hard limit.
45
+ - When the file obviously exceeds this size and bears multiple responsibilities, priority should be given to splitting it by responsibility: data access, business rules, view rendering, adaptation layer, constants and mapping, and type definition.
46
+ - Prioritize extraction of pure functions, subcomponents, custom Hooks, `*.types.ts` type modules, and constant tables above the threshold; do not make meaningless segmentation just for the number of pressed lines.
47
+ - Acceptable exceptions: generated code, very thin re-export aggregation files, high cohesion modules confirmed by team review; exceptions are recommended to briefly indicate the reasons in the file header.
48
+
49
+ ### Still a JavaScript file
50
+
51
+ - In `.js` / `.jsx`, if TS cannot be migrated in the short term, JSDoc can be used to complement the type, and the behavior will be consistent with the runtime.
52
+ - Do not introduce new implicit globals, loose objects, or unvalidated external inputs for migration convenience.
53
+
54
+ ## Disable Magic Number / Magic String
55
+
56
+ - **It is prohibited** in business code to use **semantic** hard-coded numbers or strings to directly represent status, type, identity or business meaning, including `if` / `switch` / assignment / API field mapping.
57
+ - The fixed and limited value range must be defined at a single true source, and the name must be referenced in the entire warehouse to avoid the scattering of bare values.
58
+ - The front-end main path preferentially uses `as const` constant objects with literal unions; `enum` can be used when strongly bound to the back-end protocol or team agreement.
59
+ - Typical exceptions that do not fall under this article should still remain readable: pure algorithm subscripts, obvious `0` / `1` length judgments, UI scales that have nothing to do with business; if the visual value already has a design token, it should be changed to `fec-design-system.md`.
60
+
61
+ ## Immutable updates
62
+
63
+ - Prioritize returning new objects or new arrays and avoid directly modifying parameters, props, store snapshots or cache objects.
64
+ - Data that should not be modified is first modeled as `readonly` / `Readonly<T>`.
65
+ - Large nested updates should use the project's existing state scheme or a clear reducer/helper, without stacking temporary mutable logic in components.
66
+
67
+ ## Asynchronous and error handling
68
+
69
+ - Use `async` / `await` with clear error boundaries; don't swallow promise rejections.
70
+ - In `catch`, errors are treated as `unknown` and then narrowed down, and uniformly mapped to user-visible errors, log errors or domain errors that can be handled by the caller.
71
+ - Cross-border errors such as API, authentication, upload, and payment follow `fec-api-layer.md`, `fec-error-handling.md` and security rules, and are not handled nakedly in business components.
72
+
73
+ ## Input verification
74
+
75
+ - External input (forms, APIs, URL parameters, localStorage, postMessage, third-party SDK callbacks, etc.) must be validated or narrowed at boundaries.
76
+ - You can use Zod, Valibot, Yup or similar schema tools selected by the project; do not introduce specific libraries as unconditional new dependencies.
77
+ - Schema derived types serve as a single source of truth for input types; layering of complex DTOs, domain models and UI view models is left to `fec-typescript-project-standard`.
78
+
79
+ ## Type asset layering and naming
80
+
81
+ - Module or feature-specific types use `*.types.ts` and are placed in the same directory as the implementation file or in the same feature directory.
82
+ - Global and environment-related declarations are placed in `global.d.ts`, `env.d.ts` or `types/*.d.ts`, only for true global or ambient declarations, and do not put modular types into globals.
83
+ - For import and export of types only, use `import type` and `export type` first to reduce value space ambiguity and improve compilation semantic clarity.
84
+ - Types that have the same origin as the API DTO are placed in the corresponding feature or API subdirectory to avoid scattering large anonymous types within the page or component implementation.
85
+ - `index.ts` aggregate exports should be kept shallow and organized according to feature boundaries to avoid deep barrels causing circular dependencies and unnecessary coupling.
86
+
87
+ ## Engineering and idiom additions
88
+
89
+ - When both literal preservation and structure verification need to be met, use `satisfies` first, and then consider type assertions.
90
+ - Use discriminant unions to express clear states; use `never` checks when exhaustiveness is required for critical branches.
91
+ - New business code uses ES Module by default; `namespace` and triple slash directives are only used to declare merge or legacy interop scenarios.
92
+ - When extending third-party types, use independent declaration files and extend them through local `declare module` to avoid polluting the global implementation file.
93
+ - `tsconfig`, package exports, declaration files, path aliases and public API types belong to the deep water area of TypeScript project specifications and are not expanded within this rule.
94
+
95
+ ## Logs and `console.log`
96
+
97
+ - Avoid legacy `console.log` in the production path; use the project's unified logging scheme.
98
+ - Debug logs should be deleted before submission, or prompted by the team toolchain via lint/hook/CI.
99
+
100
+ ## Keys and sensitive configurations
101
+
102
+ - **Prohibited** Hardcoding keys, tokens, private keys, or real credential examples in source code.
103
+ - Configuration must be read via environment variables or build-time injection, and fail explicitly if missing or provide a clear downgrade strategy.
104
+ - When authentication, payment, uploading, third-party scripts or sensitive data processing are involved, special reviews will be conducted in conjunction with project security specifications.
105
+
106
+ ## Relationship with test rules
107
+
108
+ When type changes affect public APIs, DTOs, external input narrowing, or business-critical branches, typechecks, type tests, component tests, or consumer fixtures should be supplemented. The end-to-end coverage method of key user paths (Playwright, Cypress, Page Object, etc.) is subject to `fec-testing.md`; this document does not repeat the E2E details.
109
+
110
+ ## With the `typescript-reviewer` subagent
111
+
112
+ When conducting a special review of **`.ts` / `.tsx` / `.js` / `.jsx`** (run typecheck / eslint first, PR merge readiness check, graded conclusion), you can entrust the plug-in's built-in **`typescript-reviewer`** subagent; its report is written by default `reports/typescript-review-YYYY-MM-DD-HHmmss.md`, the bottom line of the rules is still based on this file and the project `CLAUDE.md`.