figma-cache-toolchain 1.4.3 → 1.4.5
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.
- package/LICENSE +21 -21
- package/README.md +154 -154
- package/README.owner.md +37 -0
- package/cursor-bootstrap/AGENT-SETUP-PROMPT.md +53 -62
- package/cursor-bootstrap/examples/README.md +5 -3
- package/cursor-bootstrap/figma-cache.config.example.js +238 -138
- package/cursor-bootstrap/rules/01-figma-cache-core.mdc +42 -5
- package/cursor-bootstrap/skills/figma-mcp-local-cache/SKILL.md +10 -5
- package/figma-cache/{README.md → docs/README.md} +44 -20
- package/figma-cache/docs/colleague-guide-zh.md +199 -0
- package/figma-cache/docs/figma-cache-adapter-hint.md +14 -0
- package/figma-cache/docs/quick-start-zh.md +42 -0
- package/figma-cache/figma-cache.js +250 -881
- package/figma-cache/js/backfill-cli.js +50 -0
- package/figma-cache/js/budget-cli.js +108 -0
- package/figma-cache/js/cursor-bootstrap-cli.js +178 -0
- package/figma-cache/js/entry-files.js +149 -0
- package/figma-cache/js/flow-cli.js +227 -0
- package/figma-cache/js/index-store.js +86 -0
- package/figma-cache/js/project-config.js +97 -0
- package/figma-cache/js/upsert-core.js +156 -0
- package/figma-cache/js/validate-cli.js +233 -0
- package/package.json +72 -55
- package/figma-cache/colleague-guide-zh.md +0 -206
- /package/figma-cache/{flow-edge-taxonomy.md → docs/flow-edge-taxonomy.md} +0 -0
- /package/figma-cache/{link-normalization-spec.md → docs/link-normalization-spec.md} +0 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 李民章
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
面向业务项目的 Figma
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
npm
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
###
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
-
|
|
152
|
-
- `figma-cache/
|
|
153
|
-
|
|
154
|
-
|
|
1
|
+
# figma-cache-toolchain
|
|
2
|
+
|
|
3
|
+
面向业务项目的 Figma 本地缓存工具链:默认采用“本地缓存优先 + 按需 MCP + 最小调用集 + 严格证据校验 + validate 闭环”,提供链接标准化、索引与流程关系维护、缓存读写、校验与预算分析能力。该工具链聚焦“Figma -> 本地通用缓存”数据层,不直接绑定具体 UI 框架。
|
|
4
|
+
|
|
5
|
+
- npm 包:`figma-cache-toolchain`
|
|
6
|
+
- Git 仓库:<https://github.com/907086379/figma-cache-toolchain.git>
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 这份 README 面向谁
|
|
11
|
+
|
|
12
|
+
- npm 用户:把工具链接入业务项目并日常使用
|
|
13
|
+
- git 用户:在仓库内开发、测试、提交改动
|
|
14
|
+
|
|
15
|
+
> npm 发布由仓库维护者负责;普通用户和贡献者无需执行 `npm publish`。
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## npm 用户快速开始
|
|
20
|
+
|
|
21
|
+
### 1) 安装
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm i -D figma-cache-toolchain
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 2) 初始化 Cursor 模板与任务书
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx figma-cache cursor init
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
该命令会:
|
|
34
|
+
|
|
35
|
+
- 写入或跳过(已存在且未使用 `--force`)`.cursor/rules/`、`.cursor/skills/`
|
|
36
|
+
- 确保根目录存在 `figma-cache.config.js`
|
|
37
|
+
- 刷新根目录 `AGENT-SETUP-PROMPT.md`
|
|
38
|
+
- 同步刷新 `figma-cache/docs/colleague-guide-zh.md`
|
|
39
|
+
|
|
40
|
+
### 3) 初始化本地缓存索引
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm run figma:cache:init
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
若项目还没配置 scripts,可临时使用:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx figma-cache init
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 4) 执行校验
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm run figma:cache:validate
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 团队协作建议(来自同事指南精简版)
|
|
61
|
+
|
|
62
|
+
- 默认执行链:**先查缓存** -> 按需 MCP -> 原始回包写 `mcp-raw/` -> `upsert/ensure` -> `validate`
|
|
63
|
+
- 当 `source=figma-mcp` 时,`mcp-raw` 证据不完整会被门禁拦截,不能只写骨架宣称成功
|
|
64
|
+
- 默认 completeness:`layout,text,tokens,interactions,states,accessibility`
|
|
65
|
+
- `flow` 仅在关系关键词命中或多链接明确串联意图时自动追加
|
|
66
|
+
- 回报建议包含:缓存状态、来源(Local/MCP)、MCP 调用次数、输出文件清单
|
|
67
|
+
- 团队可直接复用 `figma-cache/docs/colleague-guide-zh.md` 中的主提示词模板
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 默认 completeness 与 token 开销
|
|
72
|
+
|
|
73
|
+
默认 completeness:`layout,text,tokens,interactions,states,accessibility`(默认不含 `flow/assets`)。
|
|
74
|
+
|
|
75
|
+
- `flow` 默认关闭,避免常规场景冗余
|
|
76
|
+
- 自动追加 `flow` 仅命中白名单时触发:
|
|
77
|
+
- 关系关键词:`关联`、`流程`、`跳转`、`前后页`、`上一步`、`下一步`、`分支`、`链路`、`路径`、`from/to`、`next`、`branch`
|
|
78
|
+
- 同轮或断续出现多个 Figma 链接,且明确存在先后/串联意图(如 A->B)
|
|
79
|
+
- 以下场景不自动追加 `flow`:单链接且无关系意图、仅视觉微调/文案修改、仅资产导出
|
|
80
|
+
- `assets` 仍按需开启,避免资产留档体积膨胀
|
|
81
|
+
- token 开销通常在启用 `flow` 且节点复杂时上升更明显
|
|
82
|
+
- 触发自动补 `flow` 时,建议在执行日志/回复中记录触发原因(关键词命中或多链接串联意图),便于审计
|
|
83
|
+
|
|
84
|
+
按需覆盖示例:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# 常规场景
|
|
88
|
+
npm run figma:cache:upsert -- "<figma-url>" --source=figma-mcp --completeness=layout,text,tokens,interactions,states,accessibility
|
|
89
|
+
|
|
90
|
+
# 关联节点/同轮或断续多链接串联场景(自动或显式)
|
|
91
|
+
npm run figma:cache:upsert -- "<figma-url>" --source=figma-mcp --completeness=layout,text,tokens,interactions,states,accessibility,flow
|
|
92
|
+
|
|
93
|
+
# 同时需要资产留档
|
|
94
|
+
npm run figma:cache:upsert -- "<figma-url>" --source=figma-mcp --completeness=layout,text,tokens,interactions,states,accessibility,flow,assets
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 常用命令
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm run figma:cache:init
|
|
103
|
+
npm run figma:cache:config
|
|
104
|
+
npm run figma:cache:get -- "<figma-url>"
|
|
105
|
+
npm run figma:cache:ensure -- "<figma-url>" --source=manual --completeness=layout,text,tokens,interactions,states,accessibility
|
|
106
|
+
npm run figma:cache:upsert -- "<figma-url>" --source=figma-mcp --completeness=layout,text,tokens,interactions,states,accessibility
|
|
107
|
+
npm run figma:cache:validate
|
|
108
|
+
npm run figma:cache:budget
|
|
109
|
+
npm run figma:cache:stale
|
|
110
|
+
npm run figma:cache:backfill
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
严格证据模式(默认开启):
|
|
114
|
+
|
|
115
|
+
- 当 `source=figma-mcp` 时,`upsert/ensure` 会先校验 `mcp-raw` 证据映射
|
|
116
|
+
- 仅在你明确需要先落索引骨架时,才使用 `--allow-skeleton-with-figma-mcp`
|
|
117
|
+
- `validate` 会校验 `coverageSummary.evidence`,缺失或 TODO 占位会失败
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## git 用户(仓库开发)
|
|
122
|
+
|
|
123
|
+
### 1) 克隆并安装依赖
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
git clone https://github.com/907086379/figma-cache-toolchain.git
|
|
127
|
+
cd figma-cache-toolchain
|
|
128
|
+
npm ci
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 2) 本地自检
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npm run docs:encoding:check
|
|
135
|
+
npm test
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 3) 提交前建议
|
|
139
|
+
|
|
140
|
+
- 确认 `README.md`、`figma-cache/docs/*.md` 编码为 UTF-8 无 BOM
|
|
141
|
+
- 变更 CLI 行为后,同步更新文档与示例命令
|
|
142
|
+
- 只提交与本次任务相关文件
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 文档入口
|
|
147
|
+
|
|
148
|
+
- `figma-cache/docs/README.md`:完整脚本、环境变量、回填与维护说明
|
|
149
|
+
- `figma-cache/docs/colleague-guide-zh.md`:团队协作指南与提示词模板
|
|
150
|
+
- `figma-cache/docs/quick-start-zh.md`:一页式同事速查卡(3 分钟上手)
|
|
151
|
+
- `figma-cache/docs/link-normalization-spec.md`:链接标准化规范
|
|
152
|
+
- `figma-cache/docs/flow-edge-taxonomy.md`:流程边类型约定
|
|
153
|
+
- `AGENT-SETUP-PROMPT.md`:项目接入任务书(`cursor init` 会刷新)
|
|
154
|
+
- `docs/mobile-native-adapter-template.md`:iOS/Android 双端适配模板与最小转换脚本说明
|
package/README.owner.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# README.owner.md(仅本地,发布者自用)
|
|
2
|
+
|
|
3
|
+
这份文档仅供仓库维护者本地查看,不提交仓库。
|
|
4
|
+
|
|
5
|
+
## 目的
|
|
6
|
+
|
|
7
|
+
- 固化发版前检查动作,减少漏项。
|
|
8
|
+
- 统一版本升级、打包验证、发布与回滚口径。
|
|
9
|
+
|
|
10
|
+
## 发版前检查
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm run docs:encoding:check
|
|
14
|
+
npm test
|
|
15
|
+
npm run figma:cache:validate
|
|
16
|
+
npm pack --dry-run
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 建议发版流程(维护者)
|
|
20
|
+
|
|
21
|
+
1. 更新代码与文档,确认工作区干净。
|
|
22
|
+
2. 更新 `CHANGELOG.md`(把 Unreleased 归并到新版本)。
|
|
23
|
+
3. 升级版本:`npm version patch|minor|major`(或手动同步 `package.json` 与 `package-lock.json`)。
|
|
24
|
+
4. 本地再次执行:`npm test && npm pack --dry-run`。
|
|
25
|
+
5. 推送提交与 tag:`git push` + `git push --tags`。
|
|
26
|
+
6. 发布:`npm publish`。
|
|
27
|
+
7. 发布后记录“版本号 -> 关键变更 -> 回滚方式”。
|
|
28
|
+
|
|
29
|
+
## 回滚预案(示例)
|
|
30
|
+
|
|
31
|
+
- npm:必要时执行 `npm deprecate` 标注问题版本。
|
|
32
|
+
- git:基于 tag 快速定位并 hotfix。
|
|
33
|
+
|
|
34
|
+
## 备注
|
|
35
|
+
|
|
36
|
+
- 对外 README 仅保留 npm/git 用户需要的信息。
|
|
37
|
+
- 这份文件由 `.gitignore` 忽略。
|
|
@@ -1,63 +1,54 @@
|
|
|
1
|
-
# Figma Cache:请 Agent 一次性完成项目适配
|
|
2
|
-
|
|
3
|
-
> **给 Cursor Agent 的指令**:你正在操作的是**用户业务项目**的根目录。以下文件应已存在(由 `npx figma-cache cursor init` 从 npm 包 **`{{NPM_PACKAGE_NAME}}`** 复制到当前仓库根):
|
|
4
|
-
> - `.cursor/rules/01-figma-cache-core.mdc`
|
|
5
|
-
> - `.cursor/rules/02-figma-stack-adapter.mdc`(**占位**,任务完成后需删除)
|
|
6
|
-
> - `.cursor/rules/figma-local-cache-first.mdc`(可选保留)
|
|
7
|
-
> - `.cursor/skills/figma-mcp-local-cache/SKILL.md`
|
|
8
|
-
> - `figma-cache.config.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
## 可选参考(仅在用户需要 Vue2+Vuetify2 时)
|
|
55
|
-
|
|
56
|
-
包内附带参考文本(**不在 init 时复制到 .cursor**):
|
|
57
|
-
`node_modules/{{NPM_PACKAGE_NAME}}/cursor-bootstrap/examples/vue2-vuetify2-adapter.reference.mdc`
|
|
58
|
-
若用户明确要求该栈,可读入后改写为第 3 步的 Adapter 规则内容。
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
1
|
+
# Figma Cache:请 Agent 一次性完成项目适配
|
|
2
|
+
|
|
3
|
+
> **给 Cursor Agent 的指令**:你正在操作的是**用户业务项目**的根目录。以下文件应已存在(由 `npx figma-cache cursor init` 从 npm 包 **`{{NPM_PACKAGE_NAME}}`** 复制到当前仓库根):
|
|
4
|
+
> - `.cursor/rules/01-figma-cache-core.mdc`
|
|
5
|
+
> - `.cursor/rules/02-figma-stack-adapter.mdc`(**占位**,任务完成后需删除)
|
|
6
|
+
> - `.cursor/rules/figma-local-cache-first.mdc`(可选保留)
|
|
7
|
+
> - `.cursor/skills/figma-mcp-local-cache/SKILL.md`
|
|
8
|
+
> - `figma-cache.config.js`(示例 `postEnsure`:目录级 adapter hint + 可选 `docs/figma-flow-readme.md`)
|
|
9
|
+
> - (兼容旧项目)`figma-cache.config.example.js` 可能存在;仅当内容被用户自定义且无法安全迁移时保留
|
|
10
|
+
|
|
11
|
+
## 你必须完成的任务(按顺序执行,尽量少问用户)
|
|
12
|
+
|
|
13
|
+
1. **读取工程事实**
|
|
14
|
+
阅读 `package.json` 及存在的构建配置(如 `vite.config.*`、`vue.config.js`、`next.config.*`、`tsconfig.json` 等),**自行推断** UI 技术栈(框架、组件库、样式方案、状态管理若有则记录)。仅在关键信息完全无法从仓库推断时,再向用户提一个极简问题。
|
|
15
|
+
|
|
16
|
+
2. **检查并合并 `figma-cache.config.js`**
|
|
17
|
+
- 若根目录**不存在** `figma-cache.config.js`:基于当前文件创建完整配置,并实现与栈匹配的 `hooks.postEnsure`。
|
|
18
|
+
- 若**已存在** `figma-cache.config.js`:**合并**而非盲目覆盖——保留用户已有非 figma-cache 字段,仅补充或调整 `hooks.postEnsure` 及与 figma-cache 相关的导出;冲突时以「不破坏用户现有逻辑」优先并注释说明。
|
|
19
|
+
- 默认建议:`FIGMA_CACHE_ADAPTER_DOC_MODE=cache-root`(目录级单文件,减少重复);仅在团队明确需要节点文档时改为 `node`。
|
|
20
|
+
|
|
21
|
+
3. **清理 legacy example(若安全)**
|
|
22
|
+
若根目录存在 `figma-cache.config.example.js` 且其内容与 `figma-cache.config.js` 等价(或为未改动模板),请删除该 example 文件,避免后续协作混淆。
|
|
23
|
+
|
|
24
|
+
4. **生成栈专属 Adapter 规则**
|
|
25
|
+
新建 **`.cursor/rules/02-figma-<栈简名>-adapter.mdc`**(`alwaysApply: false`)。内容须与 **`01-figma-cache-core.mdc`** 边界一致:只约束「在通用缓存可读之后如何写业务 UI」;**禁止**要求在 `meta.json` / `raw.json` / `spec.md` 中写入框架专有实现。
|
|
26
|
+
|
|
27
|
+
5. **删除占位规则**
|
|
28
|
+
确认第 4 步文件已写入且无语法问题后,**删除** `.cursor/rules/02-figma-stack-adapter.mdc`。若用户在 Cursor 设置里固定引用了该文件名,请在汇报中提示用户改为引用新的 `02-figma-<栈>-adapter.mdc`。
|
|
29
|
+
|
|
30
|
+
6. **补全 npm scripts(若缺失)**
|
|
31
|
+
若 `package.json` 中没有任何 `figma:cache:*` 脚本,请追加一组,命令使用 **`npx figma-cache`** 或 **`figma-cache`**(与项目是否已安装本包、以及 `node_modules/.bin` 是否可用一致即可,优先 `npx figma-cache` 以减少环境差异)。至少包含:`init`、`config`、`validate`、`ensure`、`get`(名称与 `figma-cache --help` 或包内 **`figma-cache/docs/README.md`** 中 scripts 示例一致即可)。
|
|
32
|
+
|
|
33
|
+
7. **收尾**
|
|
34
|
+
- 用简短列表向用户汇报:新建/修改/删除了哪些路径。
|
|
35
|
+
- 若项目根**尚无** `figma-cache/index.json`,提示用户执行:`npm run figma:cache:init`(若已加 script)或 `npx figma-cache init`(与 `cursor init` 不同,用于创建空索引与缓存目录)。
|
|
36
|
+
- 提示用户在本项目根执行:`npm run figma:cache:validate`(若已加 script)或 `npx figma-cache validate`。
|
|
37
|
+
- 说明:后续 Figma 相关对话将主要由 **01 Core + 新 Adapter + Skill** 驱动。
|
|
38
|
+
- **可选**:若项目已通过 `cursor init` 同步 `figma-cache/docs/colleague-guide-zh.md`,提示团队默认只使用 **§5.1「最推荐主提示词」**,只有特殊诉求再追加 **§5.2** 的一句附加要求。
|
|
39
|
+
|
|
40
|
+
## 硬约束(违反则视为未完成)
|
|
41
|
+
|
|
42
|
+
- **不要**修改 `node_modules/{{NPM_PACKAGE_NAME}}/` 下已发布包内文件(应无此必要)。
|
|
43
|
+
- **不要**修改 `figma-cache/figma-cache.js` 或破坏 Core「框架中立」语义。
|
|
44
|
+
- **不要**把业务路由名、具体组件库 API 写进 `figma-cache/files/**` 下的 `meta.json` / `raw.json` / `spec.md`。
|
|
45
|
+
|
|
46
|
+
## 可选参考(仅在用户需要 Vue2+Vuetify2 时)
|
|
47
|
+
|
|
48
|
+
包内附带参考文本(**不在 init 时复制到 .cursor**):
|
|
49
|
+
`node_modules/{{NPM_PACKAGE_NAME}}/cursor-bootstrap/examples/vue2-vuetify2-adapter.reference.mdc`
|
|
50
|
+
若用户明确要求该栈,可读入后改写为第 4 步的 Adapter 规则内容。
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
62
54
|
**开始执行:**读完本文件后立刻按上述顺序操作仓库文件,直至全部完成。
|
|
63
|
-
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
# 栈相关参考(不随 `cursor init` 复制)
|
|
1
|
+
# 栈相关参考(不随 `cursor init` 复制)
|
|
2
2
|
|
|
3
|
-
本目录存放 **可选** 的完整 Adapter 示例,供人工或 Agent 对照;**通用默认**请使用 `cursor init` 生成的 `02-figma-stack-adapter.mdc` 与根目录 `figma-cache.config.
|
|
3
|
+
本目录存放 **可选** 的完整 Adapter 示例,供人工或 Agent 对照;**通用默认**请使用 `cursor init` 生成的 `02-figma-stack-adapter.mdc` 与根目录 `figma-cache.config.js`。
|
|
4
4
|
|
|
5
5
|
| 文件 | 说明 |
|
|
6
6
|
|------|------|
|
|
7
7
|
| `vue2-vuetify2-adapter.reference.mdc` | 历史 Vue 2 + Vuetify 2 表现层规则全文,可复制为 `.cursor/rules/02-figma-vuetify2-adapter.mdc` 并按项目改名 |
|
|
8
8
|
|
|
9
|
-
将参考规则复制进 `.cursor/rules/`
|
|
9
|
+
将参考规则复制进 `.cursor/rules/` 后,建议同步 `figma-cache.config.js` 的 adapter 提示策略:默认使用 `FIGMA_CACHE_ADAPTER_DOC_MODE=cache-root`(目录级单文件),仅在明确需要节点文档时改为 `node`。
|
|
10
|
+
|
|
11
|
+
|