figma-cache-toolchain 1.4.2 → 1.4.3

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 (2) hide show
  1. package/README.md +154 -98
  2. package/package.json +5 -4
package/README.md CHANGED
@@ -1,98 +1,154 @@
1
- # figma-cache-toolchain
2
-
3
- 闈㈠悜**涓氬姟椤圭洰**鐨?Figma 鏈湴缂撳瓨锛氶摼鎺ユ爣鍑嗗寲銆侀」鐩唴 **`figma-cache/`** 绱㈠紩涓庢牎楠屻€侀浂渚濊禆 Node CLI銆?*涓嶇粦瀹?*鍏蜂綋 UI 妗嗘灦锛涙爤鐩稿叧鐢?Cursor Agent 鎸?**`@AGENT-SETUP-PROMPT.md`** 鐢熸垚 **`figma-cache.config.js`** 涓?**`.cursor/rules/02-figma-<鏍?-adapter.mdc`**銆?
4
-
5
- ## 鍥㈤槦璇存槑涓庢彁绀鸿瘝锛堢粰鍚屼簨锛?
6
-
7
- **`figma-cache/colleague-guide-zh.md`**锛氫娇鐢ㄥ満鏅€佸崟鏉?澶氭潯閾炬帴銆佹笎杩涘紡鍏宠仈鐨?**Cursor 鎻愮ず璇嶆ā鏉?*銆佸崌绾ц鏄庣瓑銆?
8
-
9
- 姣忔墽琛屼竴娆?**`npx figma-cache cursor init`**锛屼細鎶婂寘鍐呮渶鏂扮増**鍚屾鍐欏叆**椤圭洰涓嬬殑 **`figma-cache/colleague-guide-zh.md`**锛堢洰褰曠敱 **`FIGMA_CACHE_DIR`** 鍐冲畾锛岄粯璁?`figma-cache/`锛夛紝**鏃犻渶**浠?`node_modules` 鎵嬫妱锛涗笌鍚屼簨鐩存帴鐪嬩粨搴撻噷璇ユ枃浠跺嵆鍙€?
10
-
11
- ---
12
-
13
- ## 鍥涙鎺ュ叆锛堝潎鍦ㄤ笟鍔¢」鐩牴鐩綍锛?
14
-
15
- ### 1. 瀹夎
16
-
17
- ```bash
18
- npm i -D figma-cache-toolchain
19
- ```
20
-
21
- ### 2. 鍒濆鍖?Cursor 涓庝换鍔′功锛堝苟鍚屾鍥㈤槦璇存槑锛?
22
-
23
- ```bash
24
- npx figma-cache cursor init
25
- ```
26
-
27
- - 鍐欏叆鎴栬烦杩囷紙宸插瓨鍦ㄤ笖鏈?`--force`锛夛細`.cursor/rules/`銆乣.cursor/skills/`銆乣figma-cache.config.example.js`銆?
28
- - **姣忔**鍒锋柊锛?*`AGENT-SETUP-PROMPT.md`**锛堥」鐩牴锛夈€?*`figma-cache/colleague-guide-zh.md`**锛堢紦瀛樼洰褰曚笅锛夈€?
29
- - 缁堢浼氭彁绀猴細鍏?**`@AGENT-SETUP-PROMPT.md`** 浜ょ粰 Agent锛?*Agent 瀹屾垚鍚庡啀**鍋氱 4 姝ャ€?
30
-
31
- ### 3. 浜ょ粰 Cursor Agent
32
-
33
- 鍦ㄥ璇濅腑 **`@AGENT-SETUP-PROMPT.md`**锛岃鏄庛€屾寜璇ユ枃妗f墽琛屻€嶃€侫gent 浼氭帹鏂爤銆佺敓鎴?鍚堝苟閰嶇疆涓?Adapter銆佽ˉ鍏?**`figma:cache:*`** scripts 绛夈€?
34
-
35
- ### 4. 鍒濆鍖栨湰鍦扮储寮曪紙涓?`cursor init` 涓嶅悓锛?
36
-
37
- 鍒涘缓 **`figma-cache/index.json`**锛堢┖绱㈠紩锛夌瓑锛屼緵鍚庣画 `ensure` / `get` 鍐欏叆鑺傜偣锛?
38
-
39
- ```bash
40
- npm run figma:cache:init
41
- ```
42
-
43
- 鑻ユ棤瀵瑰簲 script锛歚npx figma-cache init`銆傜劧鍚庡彲鎸夐渶 **`npm run figma:cache:validate`**銆?
44
-
45
- **璇存槑**锛氬彂甯冪殑 npm 鍖?*涓嶅惈**浣犱笟鍔′粨搴撻噷鐨?**`figma-cache/files/`** 涓?**`index.json`**锛涙暟鎹敱涓婅堪 init 涓庡悗缁懡浠ゅ湪鏈湴鐢熸垚銆?
46
-
47
- ---
48
-
49
- ## 鍗囩骇 npm 鍖呭悗鎺ㄨ崘娴佺▼锛堜笟鍔¢」鐩級
50
-
51
- 宸插湪鐢ㄦ湰鍖呮椂锛?*姣忓崌涓€娆$増鏈?*寤鸿鍦ㄤ笟鍔′粨搴撴牴鎸変笅闈㈠仛涓€閬嶏紝閬垮厤妯℃澘涓庨厤缃暱鏈熻惤鍚庛€?
52
-
53
- ### 1. 鍗囩骇渚濊禆
54
-
55
- ```bash
56
- npm i -D figma-cache-toolchain@latest
57
- ```
58
-
59
- 锛堟垨閿佸畾鍏蜂綋鐗堟湰鍙枫€傦級
60
-
61
- ### 2. 鍒锋柊 Cursor 妯℃澘涓庤鏄庢枃浠?
62
-
63
- ```bash
64
- npx figma-cache cursor init
65
- ```
66
-
67
- - 浼氬埛鏂伴」鐩牴 **`AGENT-SETUP-PROMPT.md`**銆?*`FIGMA_CACHE_DIR/colleague-guide-zh.md`**锛屽苟鏇存柊锛堟垨璺宠繃锛?*`.cursor/`** 涓庢牴鐩綍 **`figma-cache.config.example.js`**銆?
68
- - 鑻ラ渶**寮哄埗瑕嗙洊**宸插瓨鍦ㄧ殑 `.cursor` 妯℃澘锛屼娇鐢?**`npx figma-cache cursor init --force`**锛堜細瑕嗙洊宸叉湁瑙勫垯鏂囦欢锛屾厧鐢級銆?
69
-
70
- ### 3. 瀵归綈 `figma-cache.config.js`锛堝悆杩涙柊鑳藉姏锛?
71
-
72
- - **鑻ユ寮忛厤缃槸 `require` 鍖呭唴绀轰緥**锛氫竴鑸?*涓嶅繀鏀规枃浠?*锛屽崌绾у悗閲嶆柊 `require` 鍗冲姞杞芥柊閫昏緫銆?
73
- - **鑻ユ寮忛厤缃槸褰撳垵澶嶅埗/鑷啓鐨?*锛氭牴鐩綍鐨?**`figma-cache.config.example.js`** 宸叉槸**鏈€鏂板鐓?*锛岃**鍚堝苟**杩?**`figma-cache.config.js`**锛堜緥濡?1.4+ 鐨?**`docs/figma-flow-readme.md`**銆乣postEnsure` 鐨?**`ctx`** 鎵╁睍绛夛級锛?*鍕挎暣鏂囦欢瑕嗙洊**瀵艰嚧涓㈠け鑷畾涔夐挬瀛愩€?
74
- - 鍙湪 Cursor 閲?**`@figma-cache.config.example.js`** + **`@figma-cache.config.js`** + **`@AGENT-SETUP-PROMPT.md`**锛岃 Agent銆屾寜浠诲姟涔︽鏌ヨˉ缂?+ 鍚堝苟绀轰緥鏂板閮ㄥ垎銆嶏紱澶ф壒閲忛摼鎺ヤ笌涓氬姟娴佺▼鏂囨。鍐欐硶瑙?**`figma-cache/colleague-guide-zh.md` 搂5.9锝灺?.10**銆?
75
-
76
- ### 4. 绱㈠紩涓庢牎楠?
77
-
78
- - **宸叉湁** **`figma-cache/index.json`**锛氶€氬父**涓嶅繀**鍐嶈窇 **`figma:cache:init`**銆?
79
- - 鎵ц **`npm run figma:cache:validate`**锛堟垨 **`npx figma-cache validate`**锛夈€?
80
- - 闃呰 **`CHANGELOG.md`**锛坣pm 鍖呭唴鎴?GitHub锛変簡瑙g牬鍧忔€у彉鏇达紙鑻ユ湁锛夈€?
81
-
82
- ### 5. 鎻愪氦涓庡崗浣?
83
-
84
- 灏嗘湰娆″崌绾ф秹鍙婄殑 **`package.json` / lock**銆佽嫢鍚堝苟杩囧垯 **`figma-cache.config.js`**銆佷互鍙婂埛鏂板悗鐨?**`AGENT-SETUP-PROMPT.md` / `.cursor/` / `figma-cache/colleague-guide-zh.md`** 绛夋寜鍥㈤槦瑙勮寖鎻愪氦锛?*`figma-cache/files/`** 鏄惁鍏ュ簱浠嶆寜鍘熷洟闃熺害瀹氥€?
85
-
86
- ---
87
-
88
- ## 鏇村畬鏁寸殑璇存槑鍦ㄥ摢
89
-
90
- | 闇€姹?| 鏂囨。锛堥殢鍖呭湪 `node_modules/figma-cache-toolchain/figma-cache/`锛?|
91
- |------|------------------------------------------------------------------|
92
- | scripts 鍏ㄩ噺 JSON銆佺幆澧冨彉閲忋€佹棤 npm 澶嶅埗鎺ュ叆銆佸洖濉€佺淮鎶ゅ彂鐗?| 鍖呭唴 **`figma-cache/README.md`** |
93
- | 閾炬帴閿鍒?| **`link-normalization-spec.md`** |
94
- | Flow 杈圭被鍨?| **`flow-edge-taxonomy.md`** |
95
-
96
- npm 鍖呴椤靛嵆鏈枃浠讹紱**缁存姢鑰呭彂鐗堟祦绋?*鍐欏湪 **`figma-cache/README.md`** 鏂囨湯銆屽寘缁存姢鑰呫€嶄笌浠撳簱 **`CHANGELOG.md`**銆?
97
-
98
- 甯哥敤鐜鍙橀噺鑺傞€夛細`FIGMA_CACHE_DIR`銆乣FIGMA_CACHE_INDEX_FILE`銆乣FIGMA_ITERATIONS_DIR`銆乣FIGMA_CACHE_STALE_DAYS`銆乣FIGMA_DEFAULT_FLOW`銆乣FIGMA_CACHE_PROJECT_CONFIG`銆乣FIGMA_CACHE_FLOW_README`锛堢ず渚嬮挬瀛愬啓銆屾祦绋嬫€昏銆峬d 鐨勮矾寰勶級鈥?閲婁箟涓庡畬鏁磋〃瑙?**`figma-cache/README.md`**銆?
1
+ # figma-cache-toolchain
2
+
3
+ 面向业务项目的 Figma 本地缓存工具链:提供链接标准化、索引管理、缓存读写、校验与流程维护能力。该工具链聚焦“Figma -> 本地通用缓存”数据层,不直接绑定具体 UI 框架。
4
+
5
+ ## 快速接入(4 步)
6
+
7
+ 以下步骤建议在业务项目根目录执行。
8
+
9
+ ### 1) 安装
10
+
11
+ ```bash
12
+ npm i -D figma-cache-toolchain
13
+ ```
14
+
15
+ ### 2) 初始化 Cursor 模板与任务书
16
+
17
+ ```bash
18
+ npx figma-cache cursor init
19
+ ```
20
+
21
+ 该命令会:
22
+
23
+ - 写入或跳过(已存在且未使用 `--force`)`.cursor/rules/`、`.cursor/skills/`、`figma-cache.config.example.js`
24
+ - 每次刷新根目录 `AGENT-SETUP-PROMPT.md`
25
+ - 同步刷新 `figma-cache/colleague-guide-zh.md`
26
+
27
+ ### 3) 交给 Cursor Agent 执行一次项目接入
28
+
29
+ Cursor 对话中引用 `@AGENT-SETUP-PROMPT.md`,并让 Agent 按文档执行。
30
+
31
+ 通常会完成:
32
+
33
+ - 推断技术栈并生成/合并 Adapter 规则
34
+ - 合并或生成 `figma-cache.config.js`
35
+ - 补全 `figma:cache:*` 相关 scripts
36
+
37
+ ### 4) 初始化本地缓存索引
38
+
39
+ ```bash
40
+ npm run figma:cache:init
41
+ ```
42
+
43
+ 若项目尚未配置 scripts,可临时使用:
44
+
45
+ ```bash
46
+ npx figma-cache init
47
+ ```
48
+
49
+ 随后建议执行一次:
50
+
51
+ ```bash
52
+ npm run figma:cache:validate
53
+ ```
54
+
55
+ > `cursor init` 与 `figma-cache init` 是两件事:
56
+ > - `cursor init` 负责模板与任务书
57
+ > - `figma-cache init` 负责创建本地空索引
58
+
59
+ ---
60
+
61
+ ## 日常使用方式
62
+
63
+ 日常通常只需把 Figma 链接发给 Agent,Agent 会按规则自动执行:
64
+
65
+ 1. 查询本地缓存是否命中
66
+ 2. 信息不足时调用 MCP 拉取最小必要数据
67
+ 3. 回写 `figma-cache/` 缓存文件
68
+ 4. 执行 `upsert/ensure` 后自动 `validate`
69
+
70
+ 你一般不需要手工跑命令,命令主要用于排障、迁移和验收。
71
+
72
+ ---
73
+
74
+ ## 升级 npm 包后的推荐流程(业务项目)
75
+
76
+ ### 1) 升级依赖
77
+
78
+ ```bash
79
+ npm i -D figma-cache-toolchain@latest
80
+ ```
81
+
82
+ ### 2) 刷新模板与说明文档
83
+
84
+ ```bash
85
+ npx figma-cache cursor init
86
+ ```
87
+
88
+ ### 3) 对齐 `figma-cache.config.js`
89
+
90
+ - 若你的正式配置是 `require` 包内示例:通常只需重新加载即可。
91
+ - 若你的正式配置是历史复制版/自定义版:请与最新 `figma-cache.config.example.js` 做增量合并,避免整文件覆盖导致自定义钩子丢失。
92
+
93
+ ### 4) 校验
94
+
95
+ ```bash
96
+ npm run figma:cache:validate
97
+ ```
98
+
99
+ 并结合 `CHANGELOG.md` 检查是否存在破坏性变更。
100
+
101
+ ---
102
+
103
+ ## 常用文档入口
104
+
105
+ - `figma-cache/README.md`:完整脚本、环境变量、回填与维护说明
106
+ - `figma-cache/colleague-guide-zh.md`:团队协作指南与提示词模板
107
+ - `figma-cache/link-normalization-spec.md`:Figma 链接标准化规范
108
+ - `figma-cache/flow-edge-taxonomy.md`:流程边类型约定
109
+ - `AGENT-SETUP-PROMPT.md`:项目接入任务书(由 `cursor init` 每次刷新)
110
+
111
+ ---
112
+
113
+ ## 常用命令(参考)
114
+
115
+ ```bash
116
+ npm run figma:cache:init
117
+ npm run figma:cache:config
118
+ npm run figma:cache:get -- "<figma-url>"
119
+ npm run figma:cache:ensure -- "<figma-url>" --source=manual --completeness=layout,text,tokens,interactions
120
+ npm run figma:cache:upsert -- "<figma-url>" --source=figma-mcp --completeness=layout,text,tokens,interactions
121
+ npm run figma:cache:validate
122
+ npm run figma:cache:budget
123
+ npm run figma:cache:stale
124
+ npm run figma:cache:backfill
125
+ ```
126
+
127
+ ---
128
+
129
+ ## 防乱码约定(Windows / PowerShell)
130
+
131
+ 为避免中文文档出现乱码,请统一遵循:
132
+
133
+ - 文本文件统一使用 UTF-8 编码(建议与仓库既有风格保持一致)
134
+ - Node 写文件必须显式指定 `utf8`
135
+ - PowerShell 写文件必须显式指定编码,例如:
136
+
137
+ ```powershell
138
+ Set-Content -Path .\README.md -Value $text -Encoding utf8
139
+ Out-File -FilePath .\README.md -InputObject $text -Encoding utf8
140
+ ```
141
+
142
+ - 不要把终端里已经乱码的内容直接复制回文件再保存
143
+ - 文档改动后,至少回读抽查 20 行,确认中文可读
144
+
145
+ ---
146
+
147
+ ## 维护者说明
148
+
149
+ 维护本工具链源码时,请优先参考:
150
+
151
+ - 根目录 `CHANGELOG.md`
152
+ - `figma-cache/README.md` 的维护说明
153
+
154
+ 修改 `cursor-bootstrap/` 模板或 CLI 行为后,请按发布流程更新版本并发布,以便消费方通过 `cursor init` 获取最新模板。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "figma-cache-toolchain",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Figma link normalization, local cache index, validation, and Node CLI (framework-agnostic core).",
5
5
  "homepage": "https://www.npmjs.com/package/figma-cache-toolchain",
6
6
  "keywords": [
@@ -28,8 +28,8 @@
28
28
  "registry": "https://registry.npmjs.org/"
29
29
  },
30
30
  "scripts": {
31
- "test": "node tests/smoke.js",
32
- "prepack": "node bin/figma-cache.js validate",
31
+ "test": "npm run docs:encoding:check && node tests/smoke.js",
32
+ "prepack": "npm run docs:encoding:check && node bin/figma-cache.js validate",
33
33
  "figma:cache:normalize": "node bin/figma-cache.js normalize",
34
34
  "figma:cache:get": "node bin/figma-cache.js get",
35
35
  "figma:cache:upsert": "node bin/figma-cache.js upsert",
@@ -46,7 +46,8 @@
46
46
  "figma:cache:flow:chain": "node bin/figma-cache.js flow chain",
47
47
  "figma:cache:flow:show": "node bin/figma-cache.js flow show",
48
48
  "figma:cache:flow:mermaid": "node bin/figma-cache.js flow mermaid",
49
- "figma:cache:cursor:init": "node bin/figma-cache.js cursor init"
49
+ "figma:cache:cursor:init": "node bin/figma-cache.js cursor init",
50
+ "docs:encoding:check": "node scripts/check-doc-encoding.js"
50
51
  },
51
52
  "volta": {
52
53
  "node": "16.20.2"