@dev-workflow/skill 0.1.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 (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +80 -0
  3. package/bin/cli.mjs +9 -0
  4. package/package.json +39 -0
  5. package/skills/artifact/README.md +23 -0
  6. package/skills/execution/devFlow/SKILL.md +341 -0
  7. package/skills/execution/devFlow/agents/openai.yaml +7 -0
  8. package/skills/execution/devFlow/domains/backend/references/api-tech.md +173 -0
  9. package/skills/execution/devFlow/domains/backend/scripts/check_api_tech_doc.mjs +170 -0
  10. package/skills/execution/devFlow/domains/backend/scripts/check_api_tech_doc.test.mjs +89 -0
  11. package/skills/execution/devFlow/domains/backend/templates/api-tech.md +164 -0
  12. package/skills/execution/devFlow/domains/frontend/references/contract-check.md +270 -0
  13. package/skills/execution/devFlow/domains/frontend/references/foundation-freeze.md +92 -0
  14. package/skills/execution/devFlow/domains/frontend/references/lightweight-flow.md +55 -0
  15. package/skills/execution/devFlow/domains/frontend/references/page-build.md +268 -0
  16. package/skills/execution/devFlow/domains/frontend/references/page-tech.md +414 -0
  17. package/skills/execution/devFlow/domains/frontend/references/product-design-specs/field-common.md +69 -0
  18. package/skills/execution/devFlow/domains/frontend/references/product-design-specs/fields-complex.md +105 -0
  19. package/skills/execution/devFlow/domains/frontend/references/product-design-specs/fields-id-code.md +44 -0
  20. package/skills/execution/devFlow/domains/frontend/references/product-design-specs/fields-number-date.md +106 -0
  21. package/skills/execution/devFlow/domains/frontend/references/product-design-specs/fields-relation.md +144 -0
  22. package/skills/execution/devFlow/domains/frontend/references/product-design-specs/fields-selectors.md +102 -0
  23. package/skills/execution/devFlow/domains/frontend/references/product-design-specs/fields-text.md +130 -0
  24. package/skills/execution/devFlow/domains/frontend/references/product-design-specs/index.md +42 -0
  25. package/skills/execution/devFlow/domains/frontend/references/product-design-specs/interaction.md +61 -0
  26. package/skills/execution/devFlow/domains/frontend/scripts/check_page_tech_doc.mjs +82 -0
  27. package/skills/execution/devFlow/domains/frontend/scripts/contract_check_static.mjs +145 -0
  28. package/skills/execution/devFlow/domains/frontend/scripts/generate_foundation_summary.mjs +224 -0
  29. package/skills/execution/devFlow/domains/frontend/templates/contract-report.md +66 -0
  30. package/skills/execution/devFlow/domains/frontend/templates/mini-plan-l0.md +7 -0
  31. package/skills/execution/devFlow/domains/frontend/templates/mini-plan-l1.md +9 -0
  32. package/skills/execution/devFlow/domains/frontend/templates/page-build/component.tsx.tpl +8 -0
  33. package/skills/execution/devFlow/domains/frontend/templates/page-build/constants.ts.tpl +5 -0
  34. package/skills/execution/devFlow/domains/frontend/templates/page-build/index.ts.tpl +1 -0
  35. package/skills/execution/devFlow/domains/frontend/templates/page-build/route.tsx.tpl +11 -0
  36. package/skills/execution/devFlow/domains/frontend/templates/page-build/service.ts.tpl +17 -0
  37. package/skills/execution/devFlow/domains/frontend/templates/page-build/types.ts.tpl +11 -0
  38. package/skills/execution/devFlow/domains/frontend/templates/page-tech.md +103 -0
  39. package/skills/execution/devFlow/domains/requirement/references/prd-review.md +129 -0
  40. package/skills/execution/devFlow/domains/requirement/templates/prd-review.md +57 -0
  41. package/skills/execution/figmaSync/SKILL.md +349 -0
  42. package/skills/execution/figmaSync/chapters/apply.md +177 -0
  43. package/skills/execution/figmaSync/chapters/plan.md +359 -0
  44. package/skills/execution/figmaSync/chapters/prepare.md +47 -0
  45. package/skills/execution/figmaSync/examples/native-css.md +129 -0
  46. package/skills/execution/figmaSync/examples/plan-doc-sample.md +39 -0
  47. package/skills/execution/figmaSync/scripts/_shared/session-log.mjs +82 -0
  48. package/skills/execution/figmaSync/scripts/_shared/token-resolver.mjs +132 -0
  49. package/skills/execution/figmaSync/scripts/_shared/token-source.mjs +145 -0
  50. package/skills/execution/figmaSync/scripts/figma-sync-report.mjs +448 -0
  51. package/skills/execution/figmaSync/scripts/icon-inventory.mjs +165 -0
  52. package/skills/execution/figmaSync/scripts/lookup-var.mjs +184 -0
  53. package/skills/execution/figmaSync/scripts/match-token.mjs +210 -0
  54. package/skills/execution/figmaSync/scripts/prepare-check.mjs +290 -0
  55. package/skills/execution/figmaSync/scripts/verify-plan.mjs +458 -0
  56. package/skills/execution/figmaSync/snapshots/README.md +13 -0
  57. package/skills/execution/figmaSync/snapshots/last-sync.md +1538 -0
  58. package/skills/execution/figmaSync/templates/PLAN.md.tpl +227 -0
  59. package/skills/review/consistency-checker/SKILL.md +112 -0
  60. package/skills/review/consistency-checker/rules/README.md +16 -0
  61. package/src/cli/agents.mjs +16 -0
  62. package/src/cli/copy.mjs +95 -0
  63. package/src/cli/install.mjs +131 -0
  64. package/src/cli/prompts.mjs +66 -0
  65. package/tools/lark/README.md +78 -0
  66. package/tools/lark/references/lark-doc.md +156 -0
  67. package/tools/lark/references/lark-read.md +235 -0
  68. package/tools/lark/references/prepare.md +147 -0
  69. package/tools/lark/scripts/lark_api.mjs +404 -0
  70. package/tools/lark/scripts/lark_api.test.mjs +63 -0
  71. package/tools/lark/scripts/lark_check_permissions.mjs +52 -0
  72. package/tools/lark/scripts/lark_publish_doc.mjs +299 -0
  73. package/tools/lark/scripts/lark_read_docx.mjs +328 -0
  74. package/tools/lark/scripts/markdown_to_lark_blocks.mjs +397 -0
@@ -0,0 +1,177 @@
1
+ # `figmaSync apply [path/to/PLAN.md]`
2
+
3
+ 基于 `figmaSync plan` 产出的 PLAN.md 与 `figma-plan.css` 实施页面编码。
4
+
5
+ ## apply 边界
6
+
7
+ apply 阶段只能实施已审核 PLAN.md 覆盖的视觉和布局内容,并遵守
8
+ `ADMIN_FE_WORKFLOW.md`。
9
+
10
+ 允许:
11
+
12
+ - 布局。
13
+ - CSS。
14
+ - Apex UI 组件选型和 props。
15
+ - 局部展示结构。
16
+ - PLAN.md 偏离记录。
17
+
18
+ 禁止:
19
+
20
+ - 重新规划路由。
21
+ - 重写 service 契约。
22
+ - 改变核心状态模型。
23
+ - 修改权限逻辑。
24
+ - 修改 Wujie bridge。
25
+ - 手动编辑 `src/routeTree.gen.ts`。
26
+ - 因 Figma 图层结构重拆业务组件。
27
+
28
+ ## 执行步骤
29
+
30
+ ### Step 1 — 解析 PLAN.md 位置
31
+
32
+ - 用户给了路径 → 用之。
33
+ - 没给路径 → AI 主动询问,禁止猜测。
34
+ - 路径不存在 / 不是 PLAN.md → 中断。
35
+
36
+ ### Step 2 — frontmatter 锚点校验
37
+
38
+ 读 PLAN.md frontmatter,对以下锚点做实时比对:
39
+
40
+ | 字段 | 校验做法 | 失配处理 |
41
+ | ------------------- | ---------------------------------------------------------- | -------------------------------------------------- |
42
+ | `apexUiVersion` | 与 `@frontend/apex-ui--react/package.json` version 比较 | 提示 Apex UI 已变化,询问是否继续 |
43
+ | `themeHash` | 重新计算 `theme/dark/*.css` 摘要 | 提示 /theme 已变化,建议重跑 plan 或确认继续 |
44
+ | `cssDraftPath` | 文件是否存在 | 缺失则中断,因为 apply 需要审核过的 CSS 草案 |
45
+ | `cssDraftHash` | 重新计算 figma-plan.css 摘要 | 提示 CSS 草案已变化,询问是否继续 |
46
+ | `figmaMetadataHash` | 默认信任 PLAN.md;仅在用户怀疑设计稿改动时重新调 Figma MCP | 不一致则提示设计稿已变化,建议重跑 plan 或确认继续 |
47
+
48
+ 任何失配都不自动继续。AI 必须在回复里列出失配项,并询问用户是否继续。
49
+
50
+ ### Step 3 — Session 边界
51
+
52
+ ```bash
53
+ pnpm figma:report --reset
54
+ ```
55
+
56
+ ### Step 4 — 复述关键决策
57
+
58
+ 读完 frontmatter + 正文,复述最多 5 行关键决策:
59
+
60
+ - 目标文件及主要拆分(依据 §3 组件与模块拆分规划)。
61
+ - CSS 草案文件及拆分安排。
62
+ - Apex UI / common component 复用。
63
+ - CSS variables 命中情况。
64
+ - 待确认的未命中样式或 icon。
65
+ - foundation-summary 中的允许/禁止修改范围。
66
+
67
+ 得到用户确认后再动手。
68
+
69
+ ### Step 5 — 工作树状态检查
70
+
71
+ ```bash
72
+ git status
73
+ ```
74
+
75
+ 列出未提交改动,避免覆盖他人工作。
76
+
77
+ ### Step 6 — 将 CSS 草案迁移为正式样式文件
78
+
79
+ 根据 PLAN.md `## 6. 实施步骤` 逐步执行。
80
+
81
+ 常见迁移方式:
82
+
83
+ - route 页面:迁移为 `route.css` 或同目录 `styles.css`。
84
+ - 组件私有样式:迁移到组件旁 CSS 文件。
85
+ - 已有 CSS 文件:按 PLAN.md 审核结果合并。
86
+
87
+ 约束:
88
+
89
+ - 不引入 Panda CSS。
90
+ - 不引入 styled-system。
91
+ - class 使用 kebab-case。
92
+ - 能由 Apex UI props 表达的样式不写 CSS 覆盖。
93
+ - 迁移前必须按 PLAN.md 的样式归属复核每条 CSS:
94
+ - `Apex UI props`:删除 CSS 覆盖,改用组件 prop 或内置状态。
95
+ - `业务组件 CSS`:只迁移到对应业务组件私有 class。
96
+ - `页面 CSS`:只迁移页面布局、容器、间距、定位、响应式等样式。
97
+ - `待确认`:未获用户确认前不迁移为正式 CSS。
98
+ - Apex
99
+ UI 组件自管样式不得进入正式 CSS,包括状态色、状态背景、状态边框、内置圆角、内置字号、hover/active/disabled/selected 状态。
100
+ - 常见 prop 接管示例:
101
+ - `Button` 使用 `type`、`size`、`disabled`、`loading`、`icon`。
102
+ - `Tag` 使用 `color`、`variant`、`size`、`icon`。
103
+ - `Tabs` 使用 `type`、`activeKey`、`disabled`。
104
+ - `Input`、`Select`、`DatePicker` 使用 `size`、`status`、`disabled`。
105
+ - `Table` 使用 `size`、`loading`、`pagination`、`scroll`、列宽和固定列。
106
+ - `Pagination` 使用 `showSizeChanger`、`disabled`、`pageSizeOptions`。
107
+ - `Drawer`、`Modal` 使用 `size`、`mask` 和按钮 props。
108
+ - `figma-plan.css` 不直接作为生产 CSS 接入,除非 PLAN.md 明确要求且用户确认。
109
+
110
+ ### Step 7 — 偏离记录
111
+
112
+ 实施过程中发现 PLAN.md 决策需要修改,必须同时:
113
+
114
+ 1. 在代码里写正确版本。
115
+ 2. 在 PLAN.md `## 8. 实施偏离记录` 章节追加:
116
+
117
+ ```text
118
+ - <ISO 时间戳> · <章节> · <原决策> → <新决策> · 原因:<一句话>
119
+ ```
120
+
121
+ 3. 在最终回复里粘出追加内容。
122
+
123
+ ### Step 8 — 处理 plan 阶段盲区
124
+
125
+ PLAN.md `## 9. 盲区与待补调` 若有 `TOO_LARGE_SKIPPED` 节点:
126
+
127
+ - apply 阶段动手前补调 `get_design_context`。
128
+ - 新信息追加到 PLAN.md `## 3. CSS 变量映射表` 与 `## 9. 盲区与待补调`。
129
+
130
+ ### Step 9 — 收尾验证
131
+
132
+ 按顺序执行:
133
+
134
+ ```bash
135
+ pnpm figma:report --command=apply --plan=<PLAN.md 路径> --target-dir=<PLAN.md 同目录>
136
+ pnpm typecheck
137
+ pnpm format:check
138
+ pnpm lint
139
+ ```
140
+
141
+ 如果 `format:check` 失败,运行:
142
+
143
+ ```bash
144
+ pnpm format
145
+ pnpm format:check
146
+ ```
147
+
148
+ 再重新跑必要验证。
149
+
150
+ ### Step 10 — 提交建议
151
+
152
+ 不直接 commit;最终回复给出建议命令:
153
+
154
+ ```bash
155
+ git add <changed-files> <PLAN.md> <正式 CSS 文件>
156
+ git commit -m "feat(<page>): implement figma plan"
157
+ ```
158
+
159
+ ## 输出契约
160
+
161
+ AI 最终回复必须包含:
162
+
163
+ 1. frontmatter 锚点校验结果。
164
+ 2. 实施文件清单。
165
+ 3. CSS 草案迁移结果。
166
+ 4. 偏离记录。
167
+ 5. session 报告内容。
168
+ 6. typecheck / format:check / lint 结果。
169
+ 7. 建议 commit 命令。
170
+
171
+ ## 失败处理
172
+
173
+ - CSS 草案缺失 → 中断。
174
+ - CSS 草案含 Panda 相关内容 → 中断。
175
+ - frontmatter 锚点失配且用户未明确确认继续 → 中断。
176
+ - 出现 PLAN.md 未覆盖的样式 / 组件 → 追加偏离记录。
177
+ - pre-commit 失败 → 修复后重新尝试,禁止 `--no-verify`。
@@ -0,0 +1,359 @@
1
+ # `figmaSync plan <figma-url>`
2
+
3
+ 输入 Figma URL(含 `node-id`),输出可审核的落地计划:
4
+
5
+ - `PLAN.md`
6
+ - `figma-plan.css`
7
+ - `figma-snapshot.png`
8
+ - `session-report-plan.md`
9
+
10
+ `plan` 阶段允许创建审核文档和 CSS 草案,但不接入业务代码。
11
+
12
+ ## 代码事实优先原则
13
+
14
+ `figmaSync plan` 必须以真实代码文件为事实来源,不能根据 Figma 图层或
15
+ `page-tech.md` 重新拆业务结构。
16
+
17
+ 必须读取:
18
+
19
+ - route 文件。
20
+ - 页面局部 components。
21
+ - service 文件和函数签名。
22
+ - types 定义。
23
+ - constants 定义。
24
+ - 最新 `foundation-summary.md`,或重新扫描生成。
25
+
26
+ 允许修改范围:
27
+
28
+ - 布局。
29
+ - CSS。
30
+ - Apex UI 组件选型和 props。
31
+ - 局部展示结构。
32
+ - PLAN.md、figma-plan.css、figma-snapshot.png、session report。
33
+
34
+ 禁止修改范围:
35
+
36
+ - 路由路径。
37
+ - service 契约。
38
+ - API 请求基础封装。
39
+ - 类型语义。
40
+ - 页面核心状态模型。
41
+ - 业务组件边界。
42
+ - 权限逻辑。
43
+ - Wujie bridge。
44
+ - `src/routeTree.gen.ts`。
45
+
46
+ ## 执行步骤
47
+
48
+ ### Step 1 — Session 边界
49
+
50
+ ```bash
51
+ pnpm figma:report --reset
52
+ ```
53
+
54
+ 清空 `.session-log.jsonl`,避免上一轮命中数据污染本次报告。
55
+
56
+ ### Step 2 — 扫描项目目录和目标基建
57
+
58
+ 禁止 AI 自行猜测目录约定。先做:
59
+
60
+ ```bash
61
+ ls src/
62
+ ls src/routes 2>/dev/null || ls src/pages 2>/dev/null
63
+ find src/common -maxdepth 3 -type f 2>/dev/null
64
+ ```
65
+
66
+ 根据扫描结果给出只列实际存在的目录作为路径候选,并提示当前路由约定:
67
+
68
+ | 路由库 | 推荐 targetFile 文件名 |
69
+ | ---------------------------- | -------------------------------- |
70
+ | TanStack Router (file-based) | `src/routes/<feature>/route.tsx` |
71
+ | Next.js App Router | `app/<feature>/page.tsx` |
72
+ | React Router | `src/pages/<feature>/index.tsx` |
73
+
74
+ 如果用户指定目标页面目录,必须读取:
75
+
76
+ ```bash
77
+ find <target-route-dir> -maxdepth 4 -type f
78
+ sed -n '1,220p' <target-route-dir>/route.tsx
79
+ sed -n '1,220p' <target-route-dir>/types.ts 2>/dev/null
80
+ sed -n '1,220p' <target-route-dir>/constants.ts 2>/dev/null
81
+ ```
82
+
83
+ 如果存在 service 文件,必须读取 service 签名;如果存在
84
+ `foundation-summary.md`,必须读取它并说明其是否最新。
85
+
86
+ 如果缺少 `foundation-summary.md`,优先运行:
87
+
88
+ ```bash
89
+ node .agent/skills/devFlow/scripts/generate_foundation_summary.mjs --route-dir <target-route-dir> --service <service-file>
90
+ ```
91
+
92
+ 如果无法确定 service 文件,可以先生成 route 目录快照,并把 service 缺口写入 PLAN.md 待确认项。
93
+
94
+ ### Step 3 — 询问用户存放位置
95
+
96
+ 把 Step 2 的候选列出,问用户:
97
+
98
+ > 项目当前是 [TanStack Router]。PLAN.md 与 figma-plan.css 落地路径候选:①
99
+ > `src/routes/<feature>/PLAN.md` ② `src/features/<feature>/PLAN.md` ③ 自定义
100
+
101
+ 拿到路径后确认:
102
+
103
+ - 路径目录是否存在?不存在则提示是否创建。
104
+ - 路径已有 PLAN.md 或 figma-plan.css?需要确认是覆盖还是放弃。
105
+
106
+ ### Step 4 — Figma MCP 试探
107
+
108
+ ```
109
+ mcp__figma-remote-mcp__whoami
110
+ ```
111
+
112
+ 失败则中断,提示用户登录 Figma MCP。
113
+
114
+ ### Step 5 — 解析 Figma 节点
115
+
116
+ 按顺序调用:
117
+
118
+ 1. `get_metadata`:拿节点层级树骨架。
119
+ 2. `get_screenshot`:保存为 `figma-snapshot.png` 到 PLAN.md 同目录。
120
+ 3. `get_variable_defs`:拿设计稿 variables 字典。
121
+ 4. `get_design_context`:拿节点参考代码和样式信息。
122
+
123
+ 若 `get_design_context` 返回 too-large:
124
+
125
+ - 从 metadata 中挑选语义节点递归抓取。
126
+ - 递归深度最多 2 层。
127
+ - 未抓到的节点写入 PLAN.md `## 9. 盲区与待补调`。
128
+
129
+ ### Step 6 — Icon / assets 扫描
130
+
131
+ 运行:
132
+
133
+ ```bash
134
+ node .agent/skills/figmaSync/scripts/icon-inventory.mjs --pretty
135
+ ```
136
+
137
+ 扫描范围只允许来自真实存在的目录:
138
+
139
+ - `assets/`
140
+ - `icons/`
141
+ - `public/`
142
+ - `src/**/assets/`
143
+ - `src/**/icons/`
144
+
145
+ 从 Figma metadata / design_context 中提取 icon 需求,并在 PLAN.md 输出:
146
+
147
+ - 可使用 icon:Figma 节点、nodeId、语义、匹配仓库 icon、匹配依据。
148
+ - 缺少 icon:Figma 节点、nodeId、语义、缺失原因、建议用户提供的导入方案。
149
+
150
+ 若存在缺少 icon,plan 阶段必须暂停并请用户确认处理方式。未确认时
151
+ `figma:verify-plan` 应失败。
152
+
153
+ ### Step 7 — Apex UI 与 common component 复用
154
+
155
+ 优先阅读:
156
+
157
+ - `node_modules/@frontend/apex-ui--react/dist/llms.txt`
158
+ - `node_modules/@frontend/apex-ui--react/dist/llm/<component>.txt`
159
+ - `src/common/**`
160
+ - 目标业务目录附近已有组件
161
+
162
+ PLAN.md `## 2. 组件映射决策` 必须说明:
163
+
164
+ - Figma 节点。
165
+ - 目标实现。
166
+ - 是否使用 Apex UI。
167
+ - 是否使用 common component。
168
+ - 是否需要自定义 CSS。
169
+ - 样式归属:`Apex UI props`、`业务组件 CSS`、`页面 CSS`、`待确认`。
170
+ - 不复用的原因。
171
+
172
+ #### Step 7.5 — 样式归属判定
173
+
174
+ 在进入 CSS 变量匹配和 `figma-plan.css` 生成前,必须逐个节点判断样式归属。
175
+
176
+ 判定顺序:
177
+
178
+ 1. **Apex UI 组件自管样式**
179
+ - 已映射到 Apex UI 组件,且 Figma 样式可以由组件 props 或内置状态表达。
180
+ - 写入 PLAN.md 组件映射,不写入 `figma-plan.css`。
181
+ - 示例:`Button type="primary"` 控制主按钮颜色;`Tag color="error"`
182
+ 控制错误标签颜色; `Tabs type="capsule"`
183
+ 控制胶囊页签;`Input status="error"` 控制输入框错误态;
184
+ `Table size="large"` 控制行高。
185
+ 2. **业务组件自管样式**
186
+ - 目标实现是已有业务组件,样式来自业务状态映射或业务私有 class。
187
+ - 可进入 `figma-plan.css`,但只能写业务组件私有 class。
188
+ - 若业务组件内部使用 Apex UI 组件,组件状态色、尺寸、圆角仍必须交给 Apex UI
189
+ props。
190
+ 3. **页面布局样式**
191
+ - 页面级容器、grid、flex、gap、padding、position、overflow、responsive、局部尺寸约束。
192
+ - 可进入 `figma-plan.css`,使用 `/theme` variables。
193
+ 4. **待确认样式**
194
+ - 无法判断归属,或既不是 Apex UI props 又不确定是否应该新增业务样式。
195
+ - 写入 PLAN.md 待确认;CSS 草案只写 TODO 注释。
196
+
197
+ 禁止行为:
198
+
199
+ - 不得把 Apex UI 组件实例中的 `fill`、`stroke`、`text color`、`radius`、`font`
200
+ 直接复制到 `figma-plan.css`。
201
+ - 不得为 Apex
202
+ UI 状态色写页面 CSS 覆盖,例如主按钮、错误标签、选中页签、输入框错误态。
203
+ - 不得因为 Figma component token 名称和 `/theme`
204
+ 能匹配,就把组件内部样式转成业务 CSS。
205
+
206
+ PLAN.md 的 `## 2. 组件映射决策` 必须体现最终归属;`## 5. CSS 草案审核`
207
+ 必须说明 CSS 草案是否剔除了 Apex UI 自管样式。
208
+
209
+ ### Step 8 — 组件/模块拆分规划
210
+
211
+ 对于复杂的 Figma 设计稿,直接落地在一个文件中维护困难,必须在 plan 阶段明确**组件与样式的拆分计划**。此时需分两种情况处理:
212
+
213
+ 1. **已有基建文件**:扫描目标目录及周边,如果发现已存在的组件拆分结构(如
214
+ `List`、`Header`、`ItemCard`
215
+ 等),则分析 Figma 节点并将其映射到现有的拆分边界上。计划中说明复用哪些已有的组件骨架,以及对应 CSS 的存放位置。不能因为 Figma 图层结构改变业务组件边界。
216
+ 2. **无基建文件**:如果是一个全新的复杂页面,必须提示用户先执行
217
+ `$devFlow page-build`。只有 Human 明确确认允许轻量 plan 时,才能基于设计稿提出临时视觉拆分;该拆分只能作为待确认建议,不能直接作为业务骨架事实。
218
+
219
+ 在 PLAN.md `## 3. 组件与模块拆分规划` 必须详细列出:
220
+
221
+ - 采用哪种拆分策略(基于基建 / 自行拆分)。
222
+ - 每个拆分出的子模块/组件所对应的文件路径及 CSS 拆分安排。
223
+ - 现有基建事实来源:route、components、service、types、constants 或
224
+ `foundation-summary.md`。
225
+ - figmaSync 允许修改和禁止修改的范围。
226
+
227
+ ### Step 9 — CSS 变量匹配
228
+
229
+ 对每个出现的样式值,按以下顺序处理:
230
+
231
+ | 来源 | 路径 | PLAN.md 命中方式 |
232
+ | ---------------------------------------------- | --------------------------------- | -------------------------- |
233
+ | `get_variable_defs` 字典直接命中 | 记录 `cssVariable` 与 `themePath` | `Fast Path 0 (variables)` |
234
+ | 节点 CSS 含 `var(--xxx)` 但 variables 字典没给 | 跑 `lookup-var.mjs` | `Fast Path 1 (lookup-var)` |
235
+ | 设计师写死裸 `#hex` / `Npx` | 跑 `match-token.mjs` | `Slow Path (value-match)` |
236
+ | 未命中 | 写入 CSS 草案 TODO 注释和确认清单 | `未命中` |
237
+
238
+ 仅对归属为 `业务组件 CSS` 或 `页面 CSS` 的样式执行本步骤。归属为 `Apex UI props`
239
+ 的样式不进入变量匹配表的 CSS 草案实现清单;如需记录来源,只在 PLAN.md 组件映射备注中说明由哪个 prop 接管。
240
+
241
+ PLAN.md `## 3. CSS 变量映射表` 必须记录:
242
+
243
+ - 来源(Figma)
244
+ - 类型
245
+ - CSS variable
246
+ - `/theme` 路径
247
+ - 原始值
248
+ - 命中方式
249
+ - nodeId
250
+ - designContextStatus
251
+
252
+ designContextStatus 取值约定:
253
+
254
+ - `OK` — `get_design_context` 成功返回。
255
+ - `RECURSED` — 因 too-large 递归到子节点拿到的。
256
+ - `TOO_LARGE_SKIPPED` — 递归 2 层仍 too-large,apply 阶段必须补调。
257
+
258
+ ### Step 10 — 生成 `figma-plan.css`
259
+
260
+ 在 PLAN.md 同目录生成 `figma-plan.css`。
261
+
262
+ 要求:
263
+
264
+ - 只作为审核草案,不在 plan 阶段接入业务代码。对于拆分了多个组件的情况,可在草案中利用注释(如
265
+ `/* --- Header Component --- */`)对不同模块的 CSS 做出逻辑上的隔离,方便 apply 阶段拆分到不同文件。
266
+ - class 使用 kebab-case。
267
+ - Apex UI props 能处理的样式不写 CSS 覆盖。
268
+ - 只写归属为 `业务组件 CSS` 或 `页面 CSS` 的样式。
269
+ - Apex
270
+ UI 组件自管色值、边框、圆角、字号、hover/active/disabled/selected 状态不得写入 CSS 草案。
271
+ - 命中变量时使用 `var(--xxx)`。
272
+ - 未命中变量时写 TODO 注释。
273
+
274
+ 示例:
275
+
276
+ ```css
277
+ .client-page {
278
+ min-height: 100%;
279
+ background: var(--fill-neutral-primary);
280
+ }
281
+
282
+ .client-page__toolbar {
283
+ display: flex;
284
+ align-items: center;
285
+ gap: var(--spacing-12);
286
+ }
287
+
288
+ /* TODO(figmaSync): unmatched border color #d7d9df from node 10:18; needs user confirmation */
289
+ ```
290
+
291
+ ### Step 11 — 计算 frontmatter 锚点
292
+
293
+ ```bash
294
+ # figmaMetadataHash
295
+ node -e "import('node:crypto').then(c => process.stdin.on('data', d => console.log(c.createHash('sha256').update(d).digest('hex'))))" < /tmp/figma-metadata.json
296
+
297
+ # themeHash
298
+ shasum -a 256 theme/dark/primitives.css theme/dark/aliases.css
299
+
300
+ # cssDraftHash
301
+ shasum -a 256 <PLAN.md 同目录>/figma-plan.css
302
+
303
+ # apexUiVersion
304
+ node -p "require('@frontend/apex-ui--react/package.json').version"
305
+ ```
306
+
307
+ 填入 frontmatter:
308
+
309
+ ```yaml
310
+ figmaMetadataHash: <get_metadata JSON 的 sha256>
311
+ figmaSnapshotPath: ./figma-snapshot.png
312
+ apexUiVersion: <版本号>
313
+ themeHash: <theme/dark CSS 的 sha256 摘要>
314
+ cssDraftPath: ./figma-plan.css
315
+ cssDraftHash: <figma-plan.css sha256>
316
+ plannedAt: <ISO 时间戳>
317
+ ```
318
+
319
+ ### Step 12 — 按模板落盘 PLAN.md
320
+
321
+ 按 `templates/PLAN.md.tpl` 填充模板,写到 Step 3 用户指定的路径。
322
+
323
+ 禁止删改模板里的章节标题,`verify-plan` 与 `figma:report` 依赖标题定位。
324
+
325
+ ### Step 13 — 反向校验
326
+
327
+ 落盘 PLAN.md 和 figma-plan.css 后立即跑:
328
+
329
+ ```bash
330
+ pnpm figma:verify-plan <path/to/PLAN.md>
331
+ ```
332
+
333
+ FAIL 必须修正后再继续。
334
+
335
+ 常见 fail:
336
+
337
+ - `## 4. CSS 变量映射表` 里的 CSS variable 不在 `/theme`。
338
+ - `figma-plan.css` 不存在。
339
+ - `figma-plan.css` 出现 Panda 相关内容。
340
+ - 缺失 icon 未确认。
341
+ - Apex UI prop 不存在。
342
+
343
+ ### Step 14 — 生成 session 报告
344
+
345
+ ```bash
346
+ pnpm figma:report \
347
+ --command=plan \
348
+ --plan=<PLAN.md 路径> \
349
+ --target-dir=<PLAN.md 所在目录>
350
+ ```
351
+
352
+ 最终回复必须包含:
353
+
354
+ 1. PLAN.md 路径。
355
+ 2. figma-plan.css 路径。
356
+ 3. verify-plan 结果。
357
+ 4. session-report-plan.md 摘要。
358
+ 5. 读取到的基建事实和 foundation-summary 状态。
359
+ 6. 未命中变量、缺失 icon、待用户确认事项。
@@ -0,0 +1,47 @@
1
+ # `figmaSync prepare`
2
+
3
+ 一键检查 figmaSync 原生 CSS 工作流依赖的技术栈与资源是否齐全。
4
+
5
+ ## 执行步骤
6
+
7
+ 1. 运行检查脚本:
8
+
9
+ ```bash
10
+ pnpm figma:prepare
11
+ ```
12
+
13
+ 2. 阅读输出的三级清单:
14
+
15
+ - ❌ `blocker`:必须修复,否则后续 plan / apply 会失败
16
+ - ⚠️ `warning`:可不立即修,但 figmaSync 体验受影响
17
+ - ℹ️ `info`:诊断信息,无需动作
18
+
19
+ 3. 对每条 blocker / warning,按 `fix → ...`
20
+ 提示修复。修复后重跑直至没有 blocker。
21
+
22
+ 4. Figma MCP 可用性脚本无法自动测,AI 在执行 `figmaSync plan` 前必须主动调用
23
+ `mcp__figma-remote-mcp__whoami` 试探。若失败,停止并提示用户登录 Figma MCP。
24
+
25
+ ## 检查范围
26
+
27
+ - Node 与 pnpm。
28
+ - `@frontend/apex-ui--react` 是否安装。
29
+ - `theme/dark/primitives.css` 与 `theme/dark/aliases.css` 是否存在。
30
+ - `pnpm figma:report` 与 `pnpm figma:verify-plan` 是否存在。
31
+ - Apex UI llm 文档是否可读。
32
+ - `src/common`、`assets`、`public`、`src/**/assets`、`src/**/icons`
33
+ 等复用资产目录是否存在。
34
+ - `.gitignore` 是否忽略 figmaSync session 文件。
35
+
36
+ ## 输出契约
37
+
38
+ - 全绿或仅 warning:可以开始 plan / apply。
39
+ - 有 blocker:AI 必须停止,把 blocker 列表和 fix 提示告知用户,不进入 plan /
40
+ apply。
41
+
42
+ ## 何时跑
43
+
44
+ - 新项目首次集成 figmaSync 时。
45
+ - 新成员 clone 项目后第一次跑 figmaSync 前。
46
+ - `/theme`、Apex UI、figmaSync 脚本升级后。
47
+ - plan / apply 出现变量匹配或报告异常时。
@@ -0,0 +1,129 @@
1
+ # 原生 CSS 草案模式
2
+
3
+ figmaSync plan 阶段生成 `figma-plan.css`,用于让用户在编码前审核样式结构。
4
+
5
+ ## 1. 页面根与区块 class
6
+
7
+ ```css
8
+ .client-page {
9
+ min-height: 100%;
10
+ background: var(--fill-neutral-primary);
11
+ }
12
+
13
+ .client-page__header {
14
+ display: flex;
15
+ align-items: center;
16
+ justify-content: space-between;
17
+ gap: var(--spacing-16);
18
+ }
19
+ ```
20
+
21
+ ## 2. Apex UI 样式边界
22
+
23
+ 能通过 Apex UI props 表达的样式不写 CSS 覆盖。先判断样式归属,再决定是否进入
24
+ `figma-plan.css`。
25
+
26
+ ```tsx
27
+ <Button
28
+ type="primary"
29
+ size="medium"
30
+ />
31
+ ```
32
+
33
+ ### 正确:组件自管样式交给 props
34
+
35
+ ```tsx
36
+ <Tag
37
+ variant="filled"
38
+ color="error"
39
+ size="sm"
40
+ />
41
+
42
+ <Input
43
+ size="small"
44
+ status="error"
45
+ />
46
+
47
+ <Tabs
48
+ type="capsule"
49
+ activeKey={activeKey}
50
+ />
51
+
52
+ <Table
53
+ size="large"
54
+ scroll={{ x: 'fill-content' }}
55
+ />
56
+ ```
57
+
58
+ ### 错误:把组件内部状态色写进页面 CSS
59
+
60
+ ```css
61
+ /* 错误:Tag 的 error 颜色应由 <Tag color="error" /> 控制 */
62
+ .metric-delta {
63
+ background: var(--fill-error-alpha-secondary);
64
+ color: var(--text-error-primary);
65
+ }
66
+
67
+ /* 错误:Button 的 primary 颜色应由 <Button type="primary" /> 控制 */
68
+ .toolbar-submit {
69
+ background: var(--fill-brand-primary);
70
+ color: var(--text-neutral-primary);
71
+ }
72
+
73
+ /* 错误:Input 的 error 边框应由 <Input status="error" /> 控制 */
74
+ .filter-input {
75
+ border-color: var(--stroke-error-primary);
76
+ }
77
+ ```
78
+
79
+ ### 正确:页面 CSS 只承载布局
80
+
81
+ ```css
82
+ .client-page__toolbar {
83
+ display: flex;
84
+ align-items: center;
85
+ justify-content: space-between;
86
+ gap: var(--spacing-12);
87
+ }
88
+
89
+ .metric-delta {
90
+ position: absolute;
91
+ right: var(--spacing-12);
92
+ bottom: var(--spacing-12);
93
+ }
94
+ ```
95
+
96
+ ## 3. 未命中变量
97
+
98
+ 无法匹配 `/theme` 的样式必须写 TODO 注释,等待用户审核。
99
+
100
+ ```css
101
+ /* TODO(figmaSync): unmatched color #123456 from node 10:18; needs user confirmation */
102
+ .client-page__custom-card {
103
+ border-color: #123456;
104
+ }
105
+ ```
106
+
107
+ ## 4. 状态样式
108
+
109
+ 状态 class 使用明确命名,不生成运行时样式函数。
110
+
111
+ ```css
112
+ .client-page__row {
113
+ background: var(--fill-neutral-primary);
114
+ }
115
+
116
+ .client-page__row:hover {
117
+ background: var(--fill-neutral-secondary);
118
+ }
119
+
120
+ .client-page__row.is-selected {
121
+ background: var(--fill-brand-tertiary);
122
+ }
123
+ ```
124
+
125
+ ## 5. 文件流转
126
+
127
+ - plan 阶段:生成 `figma-plan.css`,只做审核。
128
+ - apply 阶段:把审核通过的 CSS 草案迁移为正式 CSS 文件。
129
+ - 禁止把 CSS 草案绕过审核直接接入业务代码。