@bovinphang/frontend-craft 2.5.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 (180) hide show
  1. package/.claude-plugin/marketplace.json +61 -0
  2. package/.claude-plugin/plugin.json +32 -0
  3. package/.mcp.json +44 -0
  4. package/CHANGELOG.md +229 -0
  5. package/CHANGELOG.zh-CN.md +228 -0
  6. package/CODE_OF_CONDUCT.md +34 -0
  7. package/CODE_OF_CONDUCT.zh-CN.md +34 -0
  8. package/CONTRIBUTING.md +356 -0
  9. package/CONTRIBUTING.zh-CN.md +356 -0
  10. package/LICENSE +21 -0
  11. package/README.md +467 -0
  12. package/README.openclaw.md +262 -0
  13. package/README.openclaw.zh-CN.md +262 -0
  14. package/README.zh-CN.md +467 -0
  15. package/SECURITY.md +44 -0
  16. package/SECURITY.zh-CN.md +44 -0
  17. package/agents/fec-architect.md +125 -0
  18. package/agents/fec-code-reviewer.md +152 -0
  19. package/agents/fec-debugger.md +44 -0
  20. package/agents/fec-design-token-mapper.md +75 -0
  21. package/agents/fec-doc-updater.md +30 -0
  22. package/agents/fec-e2e-runner.md +107 -0
  23. package/agents/fec-figma-implementer.md +104 -0
  24. package/agents/fec-performance-optimizer.md +293 -0
  25. package/agents/fec-refactor-cleaner.md +32 -0
  26. package/agents/fec-security-reviewer.md +116 -0
  27. package/agents/fec-test-planner.md +50 -0
  28. package/agents/fec-typescript-reviewer.md +142 -0
  29. package/agents/fec-ui-checker.md +120 -0
  30. package/commands/fec-debug.md +30 -0
  31. package/commands/fec-doc-sync.md +18 -0
  32. package/commands/fec-init.md +70 -0
  33. package/commands/fec-plan.md +94 -0
  34. package/commands/fec-refactor-clean.md +19 -0
  35. package/commands/fec-review.md +66 -0
  36. package/commands/fec-scaffold.md +205 -0
  37. package/commands/fec-tdd.md +21 -0
  38. package/dist/bin/frontend-craft.js +82 -0
  39. package/dist/hooks/fec-cleanup-claude-cache.js +4 -0
  40. package/dist/hooks/fec-format-changed-file.js +1 -0
  41. package/dist/hooks/fec-notify.js +1 -0
  42. package/dist/hooks/fec-run-tests.js +1 -0
  43. package/dist/hooks/fec-security-check.js +2 -0
  44. package/dist/hooks/fec-session-start.js +1 -0
  45. package/docs/example-prompts.md +124 -0
  46. package/docs/ja-JP/README.md +467 -0
  47. package/docs/ko-KR/README.md +467 -0
  48. package/docs/project-structure.md +119 -0
  49. package/docs/runtimes/antigravity.md +10 -0
  50. package/docs/runtimes/augment.md +10 -0
  51. package/docs/runtimes/claude.md +171 -0
  52. package/docs/runtimes/claude.zh-CN.md +169 -0
  53. package/docs/runtimes/cline.md +10 -0
  54. package/docs/runtimes/codebuddy.md +10 -0
  55. package/docs/runtimes/codex.md +10 -0
  56. package/docs/runtimes/copilot.md +10 -0
  57. package/docs/runtimes/cursor.md +10 -0
  58. package/docs/runtimes/gemini.md +10 -0
  59. package/docs/runtimes/kilo.md +10 -0
  60. package/docs/runtimes/openclaw.md +10 -0
  61. package/docs/runtimes/opencode.md +10 -0
  62. package/docs/runtimes/qoder.md +19 -0
  63. package/docs/runtimes/trae.md +10 -0
  64. package/docs/runtimes/windsurf.md +10 -0
  65. package/docs/superpowers/plans/2026-05-29-fec-debug.md +491 -0
  66. package/docs/superpowers/specs/2026-05-29-fec-debug-design.md +340 -0
  67. package/docs/zh-CN/example-prompts.md +124 -0
  68. package/docs/zh-CN/project-structure.md +119 -0
  69. package/docs/zh-TW/README.md +467 -0
  70. package/hooks/hooks.json +71 -0
  71. package/openclaw.plugin.json +26 -0
  72. package/package.json +101 -0
  73. package/skills/TEMPLATE.md +155 -0
  74. package/skills/eval_queries.json +890 -0
  75. package/skills/fec-accessibility-check/SKILL.md +39 -0
  76. package/skills/fec-accessibility-check/references/report-template.md +23 -0
  77. package/skills/fec-accessibility-check/references/screen-reader-testing.md +33 -0
  78. package/skills/fec-api-integration/SKILL.md +78 -0
  79. package/skills/fec-api-integration/references/integration-patterns.md +80 -0
  80. package/skills/fec-browser-storage/SKILL.md +34 -0
  81. package/skills/fec-browser-storage/references/storage-patterns.md +65 -0
  82. package/skills/fec-canvas-threejs/SKILL.md +66 -0
  83. package/skills/fec-canvas-threejs/references/rendering-patterns.md +67 -0
  84. package/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +67 -0
  85. package/skills/fec-code-review/SKILL.md +135 -0
  86. package/skills/fec-code-review/references/report-template.md +29 -0
  87. package/skills/fec-component-testing/SKILL.md +119 -0
  88. package/skills/fec-data-fetching/SKILL.md +62 -0
  89. package/skills/fec-data-fetching/references/query-patterns.md +77 -0
  90. package/skills/fec-debug-framework/SKILL.md +162 -0
  91. package/skills/fec-dependency-upgrade/SKILL.md +34 -0
  92. package/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +56 -0
  93. package/skills/fec-doc-sync/SKILL.md +37 -0
  94. package/skills/fec-e2e-testing/SKILL.md +40 -0
  95. package/skills/fec-e2e-testing/references/e2e-advanced.md +176 -0
  96. package/skills/fec-e2e-testing/references/playwright-patterns.md +95 -0
  97. package/skills/fec-form-handling/SKILL.md +76 -0
  98. package/skills/fec-form-handling/references/advanced-form-patterns.md +72 -0
  99. package/skills/fec-implement-from-design/SKILL.md +122 -0
  100. package/skills/fec-implement-from-design/references/design-plan-template.md +36 -0
  101. package/skills/fec-legacy-to-modern-migration/SKILL.md +180 -0
  102. package/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +41 -0
  103. package/skills/fec-legacy-web-standard/SKILL.md +35 -0
  104. package/skills/fec-legacy-web-standard/references/legacy-patterns.md +85 -0
  105. package/skills/fec-list-virtualization/SKILL.md +34 -0
  106. package/skills/fec-list-virtualization/references/virtualization-patterns.md +52 -0
  107. package/skills/fec-monorepo-project-standard/SKILL.md +142 -0
  108. package/skills/fec-motion-interaction/SKILL.md +66 -0
  109. package/skills/fec-motion-interaction/references/motion-patterns.md +112 -0
  110. package/skills/fec-nextjs-project-standard/SKILL.md +117 -0
  111. package/skills/fec-nuxt-project-standard/SKILL.md +122 -0
  112. package/skills/fec-performance-optimization/SKILL.md +72 -0
  113. package/skills/fec-pwa-implementation/SKILL.md +36 -0
  114. package/skills/fec-pwa-implementation/references/manifest-and-icons.md +53 -0
  115. package/skills/fec-pwa-implementation/references/service-worker-workbox.md +68 -0
  116. package/skills/fec-react-project-standard/SKILL.md +83 -0
  117. package/skills/fec-react-project-standard/references/react-project-details.md +642 -0
  118. package/skills/fec-refactor-clean/SKILL.md +48 -0
  119. package/skills/fec-responsive-layout/SKILL.md +34 -0
  120. package/skills/fec-responsive-layout/references/responsive-layout-patterns.md +59 -0
  121. package/skills/fec-route-protection/SKILL.md +135 -0
  122. package/skills/fec-security-review/SKILL.md +38 -0
  123. package/skills/fec-security-review/references/report-template.md +27 -0
  124. package/skills/fec-security-review/references/security-checklist.md +64 -0
  125. package/skills/fec-source-driven-development/SKILL.md +61 -0
  126. package/skills/fec-state-management/SKILL.md +140 -0
  127. package/skills/fec-state-management/references/state-patterns.md +109 -0
  128. package/skills/fec-storybook-component-doc/SKILL.md +37 -0
  129. package/skills/fec-storybook-component-doc/references/story-patterns.md +118 -0
  130. package/skills/fec-svg-animation/SKILL.md +148 -0
  131. package/skills/fec-tailwind-design-system/SKILL.md +34 -0
  132. package/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +55 -0
  133. package/skills/fec-tdd-workflow/SKILL.md +52 -0
  134. package/skills/fec-testing-strategy/SKILL.md +45 -0
  135. package/skills/fec-typescript-type-safety/SKILL.md +157 -0
  136. package/skills/fec-typescript-type-safety/references/type-safety-patterns.md +102 -0
  137. package/skills/fec-ui-design/SKILL.md +90 -0
  138. package/skills/fec-ui-design/data/product-rules.json +110 -0
  139. package/skills/fec-ui-design/data/stack-ui-rules.json +14 -0
  140. package/skills/fec-ui-design/data/style-archetypes.json +74 -0
  141. package/skills/fec-ui-design/data/ux-quality-rules.json +56 -0
  142. package/skills/fec-ui-design/references/design-intelligence.md +37 -0
  143. package/skills/fec-ui-design/references/master-page-overrides.md +30 -0
  144. package/skills/fec-ui-design/references/pre-delivery-checklist.md +33 -0
  145. package/skills/fec-ui-design/scripts/design-system.mjs +530 -0
  146. package/skills/fec-validation-fix/SKILL.md +48 -0
  147. package/skills/fec-vite-project-standard/SKILL.md +83 -0
  148. package/skills/fec-vue3-project-standard/SKILL.md +49 -0
  149. package/skills/fec-vue3-project-standard/references/vue3-project-details.md +547 -0
  150. package/skills/fec-web-workers/SKILL.md +36 -0
  151. package/skills/fec-web-workers/references/advanced-workers.md +54 -0
  152. package/skills/fec-web-workers/references/basic-worker.md +67 -0
  153. package/skills/metadata.json +1422 -0
  154. package/skills/relations.json +644 -0
  155. package/templates/claude/CLAUDE.md +106 -0
  156. package/templates/claude/settings.json +62 -0
  157. package/templates/codex/AGENTS.md +105 -0
  158. package/templates/codex/config.toml +32 -0
  159. package/templates/openclaw/AGENTS.md +101 -0
  160. package/templates/openclaw/OPENCLAW-CONFIG.md +12 -0
  161. package/templates/shared/rules/fec-agent-workflow.md +54 -0
  162. package/templates/shared/rules/fec-api-layer.md +99 -0
  163. package/templates/shared/rules/fec-ci-cd.md +128 -0
  164. package/templates/shared/rules/fec-code-comments.md +33 -0
  165. package/templates/shared/rules/fec-design-system.md +248 -0
  166. package/templates/shared/rules/fec-error-handling.md +200 -0
  167. package/templates/shared/rules/fec-git-conventions.md +73 -0
  168. package/templates/shared/rules/fec-i18n.md +112 -0
  169. package/templates/shared/rules/fec-naming-conventions.md +120 -0
  170. package/templates/shared/rules/fec-performance.md +101 -0
  171. package/templates/shared/rules/fec-react.md +82 -0
  172. package/templates/shared/rules/fec-refactoring.md +43 -0
  173. package/templates/shared/rules/fec-rendering-patterns.md +183 -0
  174. package/templates/shared/rules/fec-responsive-design.md +227 -0
  175. package/templates/shared/rules/fec-source-driven-development.md +31 -0
  176. package/templates/shared/rules/fec-state-management.md +163 -0
  177. package/templates/shared/rules/fec-testing.md +98 -0
  178. package/templates/shared/rules/fec-typescript.md +355 -0
  179. package/templates/shared/rules/fec-vue.md +64 -0
  180. package/templates/shared/rules/fec-working-modes.md +50 -0
@@ -0,0 +1,180 @@
1
+ ---
2
+ name: fec-legacy-to-modern-migration
3
+ description: Use when planning or implementing an intentional migration from JavaScript, jQuery, HTML/CSS, server-rendered templates, or MPA legacy frontend code to React + TypeScript or Vue 3 + TypeScript while preserving behavior. Do not use for routine legacy bug fixes that stay in the old stack; Chinese triggers include 遗留项目, 技术栈升级, jQuery 迁移.
4
+ ---
5
+
6
+ # 传统前端到现代框架迁移
7
+
8
+ 适用于将 JavaScript + jQuery + HTML/CSS 多页面应用(MPA)或服务端模板渲染项目,迁移至 React + TypeScript 或 Vue 3 + TypeScript 单页面应用(SPA)的场景。
9
+
10
+ ## Purpose
11
+
12
+ 指导将 jQuery/MPA 传统前端项目渐进迁移至 React + TypeScript 或 Vue 3 + TypeScript,提供迁移策略、概念映射、分阶段步骤和实施约束,确保功能等价和风险可控。
13
+
14
+ ## 迁移策略选择
15
+
16
+ | 策略 | 适用情况 | 优点 | 风险 |
17
+ | --------------------------- | ------------------------------------ | ---------------------------- | ---------------------------- |
18
+ | **渐进式(Strangler Fig)** | 大型项目、需持续交付、团队熟悉度不足 | 风险可控、可分批上线、可回滚 | 新旧并存期长、需维护两套代码 |
19
+ | **一次性重写** | 中小型项目、业务稳定、有充足时间窗口 | 目标架构清晰、无历史包袱 | 周期长、上线压力大、回滚困难 |
20
+
21
+ **推荐**:优先考虑渐进式,除非项目规模小且业务简单。
22
+
23
+ ## 概念映射
24
+
25
+ ### jQuery → React
26
+
27
+ | 遗留模式 | React 对应 |
28
+ | ------------------------------------------ | -------------------------------------- |
29
+ | `$(selector).html(content)` | 声明式 JSX + state 驱动渲染 |
30
+ | `$(document).on('click', '.btn', handler)` | `onClick` + 事件委托由 React 处理 |
31
+ | `$.ajax()` / `$.get()` | `fetch` / `axios` + React Query 或 SWR |
32
+ | 全局变量 / 命名空间存储状态 | `useState` / `useContext` / Zustand |
33
+ | `$(el).show()` / `$(el).hide()` | 条件渲染 `{visible && <Component />}` |
34
+ | 手动 DOM 操作 `append` / `remove` | 数据驱动,通过 setState 触发重渲染 |
35
+ | 模板字符串拼接 HTML | JSX 组件 + props |
36
+ | 多页面 + 服务端路由 | React Router 客户端路由 |
37
+
38
+ ### jQuery → Vue 3
39
+
40
+ | 遗留模式 | Vue 3 对应 |
41
+ | ------------------------------------------ | -------------------------------------------------- |
42
+ | `$(selector).html(content)` | 模板 + `ref` / `reactive` 驱动渲染 |
43
+ | `$(document).on('click', '.btn', handler)` | `@click` + 事件修饰符 |
44
+ | `$.ajax()` / `$.get()` | `fetch` / `axios` + VueUse `useFetch` 或 Vue Query |
45
+ | 全局变量 / 命名空间存储状态 | `ref` / `reactive` / Pinia |
46
+ | `$(el).show()` / `$(el).hide()` | `v-show` / `v-if` |
47
+ | 手动 DOM 操作 | 数据驱动,通过响应式更新视图 |
48
+ | 模板字符串拼接 HTML | 单文件组件 `<template>` + props |
49
+ | 多页面 + 服务端路由 | Vue Router 客户端路由 |
50
+
51
+ ### 通用映射
52
+
53
+ | 遗留概念 | 现代对应 |
54
+ | --------------------------------- | ------------------------------------------ |
55
+ | 页面级 JS 入口(每页一个 script) | 路由 + 懒加载页面组件 |
56
+ | 公共 JS 模块(utils、ajax 封装) | `services/`、`utils/`、类型化 API 层 |
57
+ | 内联样式 / 页面级 CSS | CSS Modules / Tailwind / styled-components |
58
+ | 服务端模板变量 | 通过 API 获取 + 前端状态管理 |
59
+ | 表单提交 + 整页刷新 | 表单库 + 客户端校验 + API 调用 |
60
+
61
+ ## 迁移前分析
62
+
63
+ 在动手迁移前,必须完成以下分析并输出**迁移分析报告**:
64
+
65
+ 1. **存量盘点**
66
+ - 页面数量、功能模块数量
67
+ - 依赖的 jQuery 插件及替代方案(如 DataTables → TanStack Table)
68
+ - 现有 API 调用方式、是否有统一封装
69
+ - 是否有服务端模板(JSP/Thymeleaf/EJS 等)需改为纯前端渲染
70
+
71
+ 2. **依赖关系**
72
+ - 页面间共享的 JS/CSS 模块
73
+ - 跨页面复用的业务逻辑
74
+ - 与后端的接口契约(是否需调整)
75
+
76
+ 3. **迁移优先级**
77
+ - 按业务价值、复杂度、耦合度排序
78
+ - 优先迁移独立模块、低耦合页面
79
+ - 识别可复用的工具函数、常量、类型定义
80
+
81
+ ## 分阶段迁移流程
82
+
83
+ ### 阶段 0:准备
84
+
85
+ - 搭建新项目脚手架(Vite + React/Vue + TypeScript)
86
+ - 配置 ESLint、Prettier、测试框架
87
+ - 建立 `services/request.ts` 统一请求层,与现有 API 兼容
88
+ - 将遗留项目中的 `utils`、`constants` 逐步迁移并补充类型
89
+
90
+ ### 阶段 1:基础层
91
+
92
+ - 迁移并类型化 API 调用(`$.ajax` → `axios`/`fetch`)
93
+ - 迁移工具函数(日期、格式化、校验等)
94
+ - 迁移常量、枚举、类型定义
95
+ - 建立路由骨架,占位未迁移页面(重定向或 iframe 嵌入旧页面)
96
+
97
+ ### 阶段 2:按模块/页面迁移
98
+
99
+ - 每次迁移一个完整功能或页面
100
+ - 从简单到复杂:静态页 → 列表页 → 表单页 → 复杂交互页
101
+ - 迁移时提取可复用组件,遵循目标 React 或 Vue 项目的目录结构
102
+ - 每完成一个模块,补充单元测试和 E2E 关键路径
103
+
104
+ ### 阶段 3:收尾
105
+
106
+ - 移除旧代码入口,全面切换至 SPA
107
+ - 配置 404、错误边界、全局错误处理
108
+ - 性能优化(懒加载、代码分割、缓存策略)
109
+ - 文档更新、部署流程调整
110
+
111
+ ## 重构实施要求
112
+
113
+ 迁移时需遵循以下实施约束,确保视觉与交互一致、代码更简洁易维护。
114
+
115
+ ### 图片与图标
116
+
117
+ - 直接使用原项目的图片资源路径,不重新托管或替换
118
+ - 可使用 SVG 图片(`<img src="*.svg" />` 或 CSS `background-image`),**禁止使用内联 SVG**(`<svg>...</svg>` 直接写在组件中)
119
+ - **若原项目使用了 iconfont 或 IcoMoon 图标,重构时继续使用**,保持图标体系一致;不替换为其他图标方案(如独立 SVG、其他图标库)
120
+ - 图标优先使用原项目已有的图标文件(iconfont / IcoMoon / 已有 SVG),必要时可引入 SVG 文件作为独立资源
121
+
122
+ ### 国际化(i18n)
123
+
124
+ - 新栈代码(React / Vue 等)中的用户可见文案须走项目 i18n,不在新代码里硬编码中/英文案
125
+ - 遗留 HTML/JS 中**不要新增**用户可见硬编码文案,除非纯静态且仓库尚无可用 i18n 接入点;改动文案前先查 locales 是否已有条目,并同步主要语言文件
126
+ - key 按页面/模块/语义组织,复用既有 key;仅当旧 key 为对外契约时才做映射过渡,详见项目规则中的 **国际化 (i18n)**(`templates/shared/rules/fec-i18n.md` 内「遗留代码与迁移场景」)
127
+
128
+ ### 样式
129
+
130
+ - 布局样式对齐原项目视觉效果,但**只参考原项目效果,不照搬其 CSS**
131
+ - 优先使用 **flex 弹性布局**,避免 `float`、复杂 `position`、冗余嵌套
132
+ - 避免不合理写法:如 `!important` 滥用、过深选择器、重复定义
133
+ - **组件中禁止使用内联样式**(`style={{ ... }}` / `style="..."`),样式统一放在 CSS Modules、Tailwind 类或样式文件中,便于维护
134
+
135
+ ### 目标
136
+
137
+ - **视觉和交互**:与原项目一致,用户无感知差异
138
+ - **代码质量**:更简洁、易维护,符合目标框架规范
139
+ - **业务功能**:与原项目保持一致,**不得缺失功能**;迁移前后行为等价
140
+
141
+ ## 迁移检查清单
142
+
143
+ 每个迁移单元完成后,确认:
144
+
145
+ - [ ] 业务逻辑与旧实现一致,无功能遗漏,功能完整等价
146
+ - [ ] 类型定义完整,无 `any` 滥用
147
+ - [ ] API 调用使用统一 request 层,错误处理完整
148
+ - [ ] 表单校验、loading、空状态、错误状态已实现
149
+ - [ ] 可访问性:表单有 label、交互可键盘操作
150
+ - [ ] 无 XSS 风险(用户输入已转义或使用安全 API)
151
+ - [ ] 关键路径有测试覆盖
152
+ - [ ] 符合目标框架的项目规范(参考目标 React / Vue 项目约定)
153
+ - [ ] 图片使用原项目资源,无内联 SVG;若原项目用 iconfont/IcoMoon 则继续使用
154
+ - [ ] 样式参考原项目效果但不照搬 CSS,优先 flex 布局,无内联样式
155
+ - [ ] 视觉与交互与原项目一致,代码更简洁易维护
156
+ - [ ] 新代码路径文案已 i18n;遗留层未扩大硬编码;locales 检索与多语言同步已完成(参见 i18n 规则迁移补充清单)
157
+
158
+ ## Constraints
159
+
160
+ - 迁移前必须先输出迁移分析报告,明确策略、优先级和风险
161
+ - 不要在一次迁移中同时改架构、改 UI、改接口
162
+ - 优先保证功能等价,再考虑优化和现代化
163
+ - 迁移过程中保持旧系统可运行,避免大爆炸式上线
164
+ - 遇到 jQuery 插件无现成替代时,可暂时用 iframe 或微前端方式嵌入,待后续替换
165
+ - **图片与图标**:使用原项目图片资源,可用 SVG 文件,禁止内联 SVG;若原项目用 iconfont/IcoMoon 则继续使用
166
+ - **样式**:参考原项目效果不照搬 CSS,优先 flex 布局,组件禁止内联样式
167
+ - **目标**:视觉与交互一致、代码更简洁易维护,业务功能不得缺失
168
+
169
+ ## Detailed References
170
+
171
+ 撰写迁移分析或迁移计划报告时,加载 [references/migration-report-template.md](references/migration-report-template.md)。
172
+
173
+ ## Expected Output
174
+
175
+ - 迁移分析报告保存为 `reports/migration-plan-YYYY-MM-DD-HHmmss.md`,包含策略选择、存量盘点、依赖关系、分阶段步骤、风险与回滚方案
176
+ - 迁移后的业务功能与原项目完全等价,无功能缺失
177
+ - 视觉与交互与原项目一致,用户无感知差异
178
+ - 类型定义完整,无 `any` 滥用,API 调用统一且类型安全
179
+ - 图片使用原项目资源,样式使用 flex 布局,无内联样式
180
+ - 新代码文案已 i18n,关键路径有测试覆盖
@@ -0,0 +1,41 @@
1
+ # 迁移分析报告模板
2
+
3
+ ```markdown
4
+ # 迁移分析报告
5
+
6
+ > 生成时间: YYYY-MM-DD HH:mm
7
+ > 评审工具: frontend-craft
8
+
9
+ ## 策略选择
10
+ - 渐进式 / 一次性重写:
11
+ - 理由:
12
+
13
+ ## 存量盘点
14
+ - 页面数量:
15
+ - 功能模块:
16
+ - jQuery 插件:
17
+ - 服务端模板:
18
+ - API 调用方式:
19
+
20
+ ## 依赖关系
21
+ - 共享 JS/CSS:
22
+ - 跨页面逻辑:
23
+ - 后端接口契约:
24
+
25
+ ## 迁移优先级
26
+ - 第一批:
27
+ - 第二批:
28
+ - 暂缓:
29
+
30
+ ## 分阶段步骤
31
+ - 阶段 0:
32
+ - 阶段 1:
33
+ - 阶段 2:
34
+ - 阶段 3:
35
+
36
+ ## 风险与回滚
37
+ - 风险:
38
+ - 回滚方案:
39
+ ```
40
+
41
+ 迁移分析或计划完成后,将报告保存到 `reports/migration-plan-YYYY-MM-DD-HHmmss.md`,并告知用户报告路径。
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: fec-legacy-web-standard
3
+ description: Use when maintaining or safely modifying existing non-framework frontend code: vanilla JavaScript, jQuery, HTML/CSS, MPA pages, server-rendered templates, legacy plugins, or long-lived code that should stay in its current stack. Use migration skill when planning a move to React/Vue/TypeScript; Chinese triggers include 传统前端, 原生 JS, jQuery.
4
+ ---
5
+
6
+ # 传统前端项目规范(JS + jQuery + HTML)
7
+
8
+ ## Purpose
9
+
10
+ 在不重写技术栈的前提下安全维护 vanilla JS、jQuery、HTML/CSS 和服务端模板项目。
11
+
12
+ ## Procedure
13
+
14
+ 1. 先确认本次改动是维护旧栈还是迁移;迁移到 React/Vue/TypeScript 时切换到现代化迁移 workflow。
15
+ 2. 沿用现有架构和代码风格,优先修复问题,不在一次改动中引入多项现代化。
16
+ 3. JavaScript 用 IIFE/命名空间减少全局污染,事件绑定优先委托到合理容器。
17
+ 4. DOM 更新缓存选择器、批量操作、转义用户输入;Ajax 必须处理 loading、error、空状态和防重复提交。
18
+ 5. HTML/CSS 保持语义、label、alt、BEM/既有命名和低选择器深度。
19
+ 6. 安全重点检查 `.html()`、`innerHTML`、URL 参数渲染、CSRF token 和文件上传。
20
+
21
+ ## Detailed References
22
+
23
+ 涉及 jQuery 命名空间、事件绑定、Ajax、XSS 转义、文件组织和维护清单示例时,加载 [references/legacy-patterns.md](references/legacy-patterns.md)。
24
+
25
+ ## Constraints
26
+
27
+ - 在现有架构内改进,不要引入与项目格格不入的现代框架。
28
+ - 渐进增强优于推倒重来。
29
+ - 禁止用 `innerHTML` / `.html()` 直接插入用户输入。
30
+ - 避免全局变量污染。
31
+ - 每次聚焦一个维护点,避免顺手重构整个模块。
32
+
33
+ ## Expected Output
34
+
35
+ 改动与旧项目风格一致,无全局变量泄漏,事件和 DOM 操作可维护,Ajax 状态完整,用户输入已转义,渐进改进不破坏现有功能。
@@ -0,0 +1,85 @@
1
+ # 传统前端维护模式
2
+
3
+ ## 命名空间
4
+
5
+ ```javascript
6
+ var App = App || {};
7
+ App.UserModule = (function ($) {
8
+ "use strict";
9
+
10
+ function init() {
11
+ bindEvents();
12
+ loadData();
13
+ }
14
+
15
+ function bindEvents() {
16
+ $(document).on("click", ".js-submit-btn", handleSubmit);
17
+ }
18
+
19
+ return { init: init };
20
+ })(jQuery);
21
+ ```
22
+
23
+ ## 事件与 DOM
24
+
25
+ - 事件触发元素用 `.js-*` class,与样式 class 分离。
26
+ - 缓存频繁使用的选择器。
27
+ - 批量 DOM 操作用 `DocumentFragment` 或一次性插入。
28
+ - 页面卸载或模块销毁时解绑事件或调用插件 destroy。
29
+
30
+ ## Ajax
31
+
32
+ ```javascript
33
+ function fetchUserList(params) {
34
+ return $.ajax({
35
+ url: "/api/v1/users",
36
+ method: "GET",
37
+ data: params,
38
+ dataType: "json",
39
+ })
40
+ .done(function (res) {
41
+ if (res.code === 0) renderList(res.data);
42
+ else showError(res.message);
43
+ })
44
+ .fail(function () {
45
+ showError("网络错误,请稍后重试");
46
+ })
47
+ .always(function () {
48
+ hideLoading();
49
+ });
50
+ }
51
+ ```
52
+
53
+ ## XSS 转义
54
+
55
+ ```javascript
56
+ $(".username").text(userData.name);
57
+
58
+ function escapeHtml(str) {
59
+ var div = document.createElement("div");
60
+ div.appendChild(document.createTextNode(str));
61
+ return div.innerHTML;
62
+ }
63
+ ```
64
+
65
+ ## 文件组织
66
+
67
+ ```text
68
+ project/
69
+ ├── css/
70
+ │ ├── common.css
71
+ │ └── pages/user-list.css
72
+ ├── js/
73
+ │ ├── lib/jquery.min.js
74
+ │ ├── common/utils.js
75
+ │ └── pages/user-list.js
76
+ └── pages/
77
+ ```
78
+
79
+ ## 检查清单
80
+
81
+ - 没有全局变量泄漏。
82
+ - 事件绑定在合理容器上。
83
+ - Ajax 处理 loading/error/empty。
84
+ - 用户输入已转义。
85
+ - 未扩大第三方库或框架依赖。
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: fec-list-virtualization
3
+ description: Use when optimizing or reviewing large lists, virtual scrolling, windowing, react-window, TanStack Virtual, variable-height rows, dynamic measurement, infinite scroll, grid virtualization, or scroll performance; Chinese triggers include 虚拟列表, 大列表优化, 滚动性能.
4
+ ---
5
+
6
+ # 列表虚拟化优化
7
+
8
+ ## Purpose
9
+
10
+ 通过窗口化只渲染可视区域,解决大列表 DOM 过多和滚动卡顿。
11
+
12
+ ## Procedure
13
+
14
+ 1. 先确认列表规模和瓶颈:500+ 项、滚动掉帧、DOM 节点过多或内存飙升才引入虚拟化。
15
+ 2. 固定高度列表用 `react-window`;动态高度、跨框架或高级场景用 TanStack Virtual;遗留项目可维护 `react-virtualized`。
16
+ 3. 明确 item size、overscan、容器高度、key、滚动容器和 resize 行为。
17
+ 4. 无限滚动时分离数据分页和 DOM 虚拟化;数据获取可联用数据获取 workflow。
18
+ 5. 验证 DOM 节点数、滚动 FPS、键盘/屏幕阅读器体验和 Ctrl+F/SEO 限制。
19
+
20
+ ## Detailed References
21
+
22
+ 涉及固定高度列表、可变/动态高度、无限滚动、网格虚拟化和性能注意事项时,加载 [references/virtualization-patterns.md](references/virtualization-patterns.md)。
23
+
24
+ ## Constraints
25
+
26
+ - SEO 关键内容不要只存在于虚拟项中。
27
+ - 浏览器原生 Ctrl+F 无法搜索未挂载项目。
28
+ - Row 根元素必须透传虚拟库提供的 style/measure ref。
29
+ - overscan 过大会浪费内存,过小会白屏。
30
+ - 动态高度测量要处理 ResizeObserver 和布局抖动。
31
+
32
+ ## Expected Output
33
+
34
+ 10000+ 项列表滚动接近 60fps,DOM 节点数稳定在可视区域及缓冲区范围,内存从 O(n) 降至 O(visible)。
@@ -0,0 +1,52 @@
1
+ # 虚拟列表模式
2
+
3
+ ## 固定高度列表
4
+
5
+ ```tsx
6
+ import { FixedSizeList as List } from "react-window";
7
+
8
+ const Row = ({ index, style, data }: { index: number; style: React.CSSProperties; data: User[] }) => (
9
+ <div style={style}>{data[index].name}</div>
10
+ );
11
+
12
+ export const UserList = ({ users }: { users: User[] }) => (
13
+ <List height={500} itemCount={users.length} itemSize={48} width="100%" itemData={users}>
14
+ {Row}
15
+ </List>
16
+ );
17
+ ```
18
+
19
+ ## 可变高度
20
+
21
+ ```tsx
22
+ import { VariableSizeList as List } from "react-window";
23
+
24
+ const getItemSize = (index: number) => (items[index].hasSummary ? 120 : 60);
25
+
26
+ <List height={600} itemCount={items.length} itemSize={getItemSize} width="100%">
27
+ {CardRow}
28
+ </List>;
29
+ ```
30
+
31
+ ## 动态高度
32
+
33
+ ```tsx
34
+ const virtualizer = useVirtualizer({
35
+ count: messages.length,
36
+ getScrollElement: () => parentRef.current,
37
+ estimateSize: () => 60,
38
+ overscan: 5,
39
+ });
40
+ ```
41
+
42
+ 动态内容需要测量元素并处理 ResizeObserver。
43
+
44
+ ## 无限滚动
45
+
46
+ - `count` 包含 loader 占位项。
47
+ - 最后一个虚拟项进入视口时调用 `fetchNextPage()`。
48
+ - 不要在 render 中无条件触发请求,使用 effect 或明确状态保护。
49
+
50
+ ## 网格虚拟化
51
+
52
+ 二维网格使用 `FixedSizeGrid` 或 TanStack Virtual 的 row/column 双轴方案,确保单元格 style 透传。
@@ -0,0 +1,142 @@
1
+ ---
2
+ name: fec-monorepo-project-standard
3
+ description: Use when creating, reviewing, or restructuring frontend monorepos with pnpm workspace, Turborepo, Nx, multi-package dependency boundaries, task orchestration, package naming, or package publishing; Chinese triggers include monorepo, workspace, 多包.
4
+ ---
5
+
6
+ # Monorepo 项目规范
7
+
8
+ 适用于使用 pnpm workspace、Turborepo 或 Nx 的多包前端仓库。
9
+
10
+ ## Purpose
11
+
12
+ 规范 Monorepo 项目的目录结构、依赖管理、任务编排和包发布流程,确保多包协作的构建效率和版本一致性。
13
+
14
+ ## Procedure
15
+
16
+ 1. 先确认仓库是否已使用 pnpm workspace、Turborepo 或 Nx,并沿用现有包命名与任务约定。
17
+ 2. 将应用放在 `apps/`,共享库、配置和工具放在 `packages/` 或既有等价目录。
18
+ 3. 内部依赖使用 `workspace:*`,通过依赖图驱动构建顺序。
19
+ 4. 为 build、lint、test 配置可缓存、可并行、可增量的根任务,并明确输入、输出和环境变量。
20
+ 5. 在 Turborepo/Nx 中配置 affected/changed 范围命令,CI 优先跑受影响包,同时保留主干全量验证入口。
21
+ 6. 发布包前检查包边界、循环依赖、exports、peer dependencies 和版本策略。
22
+
23
+ ## 工具选择
24
+
25
+ | 工具 | 适用 | 特点 |
26
+ | ------------------ | ---- | -------------------------- |
27
+ | **pnpm workspace** | 基础 | 依赖提升、链接、脚本聚合 |
28
+ | **Turborepo** | 推荐 | 缓存、并行、依赖图 |
29
+ | **Nx** | 大型 | 增量构建、云缓存、插件生态 |
30
+
31
+ ## 目录结构
32
+
33
+ ### pnpm + Turborepo
34
+
35
+ ```
36
+ ├── package.json # 根 package,workspace 配置
37
+ ├── pnpm-workspace.yaml # workspace 包列表
38
+ ├── turbo.json # Turborepo 配置
39
+ │
40
+ ├── apps/
41
+ │ ├── web/ # 主应用
42
+ │ │ ├── package.json
43
+ │ │ └── ...
44
+ │ ├── admin/ # 管理后台
45
+ │ └── docs/ # 文档站
46
+ │
47
+ ├── packages/
48
+ │ ├── ui/ # 共享 UI 组件
49
+ │ │ ├── package.json
50
+ │ │ └── src/
51
+ │ ├── utils/ # 工具函数
52
+ │ ├── config-eslint/ # 共享 ESLint 配置
53
+ │ └── config-typescript/ # 共享 TS 配置
54
+ │
55
+ └── tooling/ # 构建/测试工具(可选)
56
+ └── scripts/
57
+ ```
58
+
59
+ ### pnpm-workspace.yaml
60
+
61
+ ```yaml
62
+ packages:
63
+ - "apps/*"
64
+ - "packages/*"
65
+ ```
66
+
67
+ ## 依赖管理
68
+
69
+ - 内部包使用 `workspace:*` 协议
70
+ - 根 `package.json` 统一部分依赖版本,子包可覆盖
71
+ - 禁止循环依赖,通过 `pnpm why` 检查
72
+
73
+ ```json
74
+ {
75
+ "dependencies": {
76
+ "@repo/ui": "workspace:*",
77
+ "@repo/utils": "workspace:*"
78
+ }
79
+ }
80
+ ```
81
+
82
+ ## Turborepo 任务编排
83
+
84
+ ```json
85
+ {
86
+ "$schema": "https://turbo.build/schema.json",
87
+ "tasks": {
88
+ "build": {
89
+ "dependsOn": ["^build"],
90
+ "outputs": ["dist/**", ".next/**"]
91
+ },
92
+ "lint": {
93
+ "dependsOn": ["^build"]
94
+ },
95
+ "test": {
96
+ "dependsOn": ["^build"]
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ - `^build` 表示先执行依赖包的 build
103
+ - `outputs` 用于缓存命中判断
104
+ - `inputs` 应包含源码、配置、锁文件和环境相关文件;不要把 `.env` secret 值写入缓存 key
105
+ - 远程缓存要区分可信 CI 与本地开发,避免把含敏感信息的产物上传
106
+
107
+ ## Nx 任务编排
108
+
109
+ ```json
110
+ {
111
+ "targetDefaults": {
112
+ "build": {
113
+ "dependsOn": ["^build"],
114
+ "outputs": ["{projectRoot}/dist"],
115
+ "cache": true
116
+ }
117
+ }
118
+ }
119
+ ```
120
+
121
+ ## 包命名
122
+
123
+ - 内部包:`@org/package-name` 或 `@repo/package-name`
124
+ - 发布到 npm:遵循 `@scope/name` 规范
125
+
126
+ ## Constraints
127
+
128
+ - 子包之间通过 `workspace:*` 引用,不发布到 npm 再安装
129
+ - 共享配置(ESLint、TS)放在 `packages/config-*`,子包 extends
130
+ - 构建顺序由依赖图决定,不手动指定无关依赖
131
+ - 根目录执行 `pnpm -r build` 或 `turbo run build` 时,所有包按序构建
132
+ - 禁止循环依赖,新增包时通过 `pnpm why` 检查依赖链
133
+ - CI cache 只缓存依赖安装目录和任务产物,不缓存未验证的构建状态
134
+ - affected 构建不能替代发布前全量验证;主干或 release 分支仍需完整质量门禁
135
+
136
+ ## Expected Output
137
+
138
+ - Monorepo 目录结构清晰(`apps/` 应用、`packages/` 共享包、`tooling/` 工具)
139
+ - `pnpm-workspace.yaml` 和 `turbo.json` / `nx.json` 配置正确
140
+ - 内部包使用 `workspace:*` 协议,无循环依赖
141
+ - 构建、lint、test 任务可通过根命令一键执行,缓存命中率高
142
+ - CI 能区分 affected 快速反馈和 release 全量验证,缓存配置不会泄露密钥或隐藏依赖边界问题
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: fec-motion-interaction
3
+ description: Use when designing, implementing, or reviewing frontend interaction motion, page transitions, scroll animation, Framer Motion, GSAP, Lottie, CSS animation, motion intensity, animation performance, reduced-motion behavior, or cinematic but accessible UI motion. Do not use for SVG-only path drawing, Canvas/WebGL rendering, or ordinary hover states; Chinese triggers include 动效设计, 交互动效, 页面转场, 滚动动画, Framer Motion, GSAP.
4
+ ---
5
+
6
+ # 交互动效
7
+
8
+ 适用于需要把页面转场、滚动叙事、组件入场、微交互和反馈节奏设计成可维护、可降级、可验证的前端动效任务。需要具体实现模式时加载 [motion-patterns.md](references/motion-patterns.md)。
9
+
10
+ ## Purpose
11
+
12
+ 为前端界面选择合适动效工具、强度和质量门禁。
13
+
14
+ ## Procedure
15
+
16
+ 1. 判断动效职责
17
+ - 先写清动效服务的用户意图:定位、反馈、层级变化、状态确认、叙事引导或品牌记忆。
18
+ - 工具型界面默认克制,优先保障扫描效率;营销页和作品页可增加节奏,但不能遮挡主要信息。
19
+ - 若动效只装饰而不改善理解、反馈或品牌识别,应删掉或改成静态视觉处理。
20
+ - loading、skeleton、toast、错误提示和成功反馈属于状态沟通;动效只能增强反馈节奏,不能替代文本、语义或可见状态。
21
+
22
+ 2. 选择技术路线
23
+ - CSS transition/keyframes:hover、focus、toast、简单入场和小型状态反馈。
24
+ - Framer Motion:React 状态驱动、布局过渡、列表编排和可中断的组件级动画。
25
+ - GSAP:时间轴、滚动触发、复杂序列和跨元素精确编排。
26
+ - Lottie:设计工具输出的图标或空状态动画,按需懒加载。
27
+ - CSS scroll-driven animation:可接受渐进增强且无需旧浏览器一致性时使用。
28
+
29
+ 3. 定义强度等级
30
+ - Level 1-2:只用 150-250ms opacity/transform,适合后台、表单和高频工具。
31
+ - Level 3-4:加入短 stagger、局部 spring 和轻量 reveal,适合仪表盘、设置页和管理台。
32
+ - Level 5-6:加入视差、布局 morph、指针响应,适合产品展示和交互式首页。
33
+ - Level 7+:使用滚动叙事、固定段落或 3D/WebGL 配合,必须单独做移动端和 reduced-motion 降级。
34
+
35
+ 4. 建立性能边界
36
+ - 只高频动画 `transform`、`opacity`,谨慎使用 `filter` 和 `clip-path`。
37
+ - GSAP、Lottie、Three.js、重型动画组件必须动态导入或隔离在叶子组件。
38
+ - 持续动画需要暂停条件:不可见、标签页隐藏、用户关闭、低电量或 reduced motion。
39
+ - 不在滚动事件中同步读写布局;使用 IntersectionObserver、ScrollTimeline 或节流后的 rAF。
40
+
41
+ 5. 设计可访问降级
42
+ - 所有非必要动效读取 `prefers-reduced-motion`,降级为静态、淡入或即时状态。
43
+ - 自动播放或循环动效若超过 5 秒,应提供暂停方式或只在局部非关键区域运行。
44
+ - 不闪烁超过每秒 3 次;不要用动效作为唯一状态提示。
45
+ - focus ring、错误提示、成功反馈必须在无动效时同样清楚。
46
+ - 手势动画必须有点击、键盘或明确控件替代;拖拽、滑动和长按不能成为唯一操作路径。
47
+
48
+ 6. 验证交付
49
+ - 在 375px、768px、1440px 检查动效是否遮挡文案、按钮或表格内容。
50
+ - 检查首次加载 bundle 是否因动效库显著膨胀。
51
+ - 手动开启 reduced motion,确认动画被禁用或弱化。
52
+ - 用性能面板或实际设备确认滚动和关键交互没有明显掉帧。
53
+
54
+ ## Constraints
55
+
56
+ - 不在同一个组件内混用 Framer Motion 和 GSAP 控制同一元素。
57
+ - 不用动效掩盖 loading、empty、error、disabled 等状态缺失。
58
+ - 不为普通后台表格、配置页和高频工作台默认加入大幅视差或滚动劫持。
59
+ - 不动画 `width`、`height`、`top`、`left`、`margin`、`padding` 等会频繁触发布局的属性。
60
+ - 不把大型 Lottie JSON、GSAP 插件或 3D 场景放入首屏同步包。
61
+ - 不让动画改变阅读顺序、焦点顺序或键盘可达性。
62
+ - 不用 skeleton 长时间占位掩盖真实加载失败;超过预期时应转入可理解的 loading、retry 或 error 状态。
63
+
64
+ ## Expected Output
65
+
66
+ 输出应包含动效目的、技术选型、强度等级、降级策略、性能边界和验证结果。完成后交互动效应帮助用户理解状态和层级,在 reduced-motion 与低端设备上仍可用,并且不显著拖慢首屏或滚动体验。