figma-cache-toolchain 2.0.3 → 2.0.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/README.md +197 -170
- package/cursor-bootstrap/AGENT-SETUP-PROMPT.md +75 -43
- package/cursor-bootstrap/examples/README.md +26 -15
- package/cursor-bootstrap/examples/ui-adapter.contract.template.json +90 -0
- package/cursor-bootstrap/examples/ui-execution-template.fast.md +11 -0
- package/cursor-bootstrap/examples/ui-execution-template.strict.md +13 -0
- package/cursor-bootstrap/examples/ui-override.template.json +26 -0
- package/cursor-bootstrap/figma-cache.config.example.js +51 -9
- package/cursor-bootstrap/managed-files.json +40 -40
- package/cursor-bootstrap/skills/figma-ui-dual-mode-execution/SKILL.md +55 -37
- package/figma-cache/adapters/recipes/button.recipe.json +24 -0
- package/figma-cache/adapters/recipes/card.recipe.json +24 -0
- package/figma-cache/adapters/recipes/checkbox.recipe.json +24 -0
- package/figma-cache/adapters/recipes/input.recipe.json +24 -0
- package/figma-cache/adapters/recipes/modal.recipe.json +25 -0
- package/figma-cache/adapters/recipes/radio.recipe.json +23 -0
- package/figma-cache/adapters/recipes/select.recipe.json +24 -0
- package/figma-cache/adapters/recipes/table.recipe.json +25 -0
- package/figma-cache/adapters/recipes/tabs.recipe.json +24 -0
- package/figma-cache/adapters/recipes/tooltip.recipe.json +24 -0
- package/figma-cache/docs/README.md +323 -237
- package/figma-cache/docs/p0-ui-preflight-handoff.md +207 -0
- package/figma-cache/docs/ui-1to1-optimization-roadmap.md +182 -0
- package/figma-cache/docs/ui-1to1-report.schema.json +104 -0
- package/figma-cache/figma-cache.js +639 -562
- package/figma-cache/js/contract-check-cli.js +466 -0
- package/figma-cache/js/cursor-bootstrap-cli.js +22 -0
- package/figma-cache/js/ui-facts-normalizer.js +233 -0
- package/package.json +93 -73
- package/scripts/cross-project-e2e.js +594 -0
- package/scripts/ui-1to1-audit.js +431 -0
- package/scripts/ui-auto-acceptance.js +248 -0
- package/scripts/ui-preflight.js +289 -0
- package/scripts/ui-profile.js +46 -0
- package/scripts/ui-report-aggregate.js +124 -0
|
@@ -1,562 +1,639 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/* eslint-disable no-console */
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const { createRequire } = require("module");
|
|
6
|
-
const { URL } = require("url");
|
|
7
|
-
const { handleFlowCommand } = require("./js/flow-cli");
|
|
8
|
-
const { validateMcpRawEvidence, validateIndex } = require("./js/validate-cli");
|
|
9
|
-
const { buildBudgetReport } = require("./js/budget-cli");
|
|
10
|
-
const { createIndexStore } = require("./js/index-store");
|
|
11
|
-
const { copyCursorBootstrap } = require("./js/cursor-bootstrap-cli");
|
|
12
|
-
const { createEntryFilesService } = require("./js/entry-files");
|
|
13
|
-
const { backfillFromIterations } = require("./js/backfill-cli");
|
|
14
|
-
const { createUpsertService } = require("./js/upsert-core");
|
|
15
|
-
const { createProjectConfigService } = require("./js/project-config");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
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
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
const
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
},
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
console.log(
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
);
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { createRequire } = require("module");
|
|
6
|
+
const { URL } = require("url");
|
|
7
|
+
const { handleFlowCommand } = require("./js/flow-cli");
|
|
8
|
+
const { validateMcpRawEvidence, validateIndex } = require("./js/validate-cli");
|
|
9
|
+
const { buildBudgetReport } = require("./js/budget-cli");
|
|
10
|
+
const { createIndexStore } = require("./js/index-store");
|
|
11
|
+
const { copyCursorBootstrap } = require("./js/cursor-bootstrap-cli");
|
|
12
|
+
const { createEntryFilesService } = require("./js/entry-files");
|
|
13
|
+
const { backfillFromIterations } = require("./js/backfill-cli");
|
|
14
|
+
const { createUpsertService } = require("./js/upsert-core");
|
|
15
|
+
const { createProjectConfigService } = require("./js/project-config");
|
|
16
|
+
const { buildContractCheckReport } = require("./js/contract-check-cli");
|
|
17
|
+
|
|
18
|
+
const ROOT = process.cwd();
|
|
19
|
+
const NORMALIZATION_VERSION = 1;
|
|
20
|
+
const SCHEMA_VERSION = 2;
|
|
21
|
+
const DEFAULT_COMPLETENESS = Object.freeze([
|
|
22
|
+
"layout",
|
|
23
|
+
"text",
|
|
24
|
+
"tokens",
|
|
25
|
+
"interactions",
|
|
26
|
+
"states",
|
|
27
|
+
"accessibility",
|
|
28
|
+
]);
|
|
29
|
+
const COMPLETENESS_ALL_DIMENSIONS = Object.freeze([
|
|
30
|
+
"layout",
|
|
31
|
+
"text",
|
|
32
|
+
"tokens",
|
|
33
|
+
"interactions",
|
|
34
|
+
"states",
|
|
35
|
+
"accessibility",
|
|
36
|
+
"flow",
|
|
37
|
+
"assets",
|
|
38
|
+
]);
|
|
39
|
+
const COMPLETENESS_TOOL_REQUIREMENTS = Object.freeze({
|
|
40
|
+
layout: Object.freeze([
|
|
41
|
+
Object.freeze(["get_metadata", "get_design_context"]),
|
|
42
|
+
]),
|
|
43
|
+
text: Object.freeze([Object.freeze(["get_design_context"])]),
|
|
44
|
+
tokens: Object.freeze([Object.freeze(["get_variable_defs"])]),
|
|
45
|
+
interactions: Object.freeze([Object.freeze(["get_design_context"])]),
|
|
46
|
+
states: Object.freeze([Object.freeze(["get_design_context"])]),
|
|
47
|
+
accessibility: Object.freeze([Object.freeze(["get_design_context"])]),
|
|
48
|
+
flow: Object.freeze([Object.freeze(["get_design_context"])]),
|
|
49
|
+
assets: Object.freeze([Object.freeze(["get_design_context"])]),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
function parsePositiveInt(input, fallback) {
|
|
53
|
+
const n = Number(input);
|
|
54
|
+
return Number.isFinite(n) && n > 0 ? Math.floor(n) : fallback;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function normalizeSlash(input) {
|
|
58
|
+
return input.replace(/\\/g, "/");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function resolveMaybeAbsolutePath(input) {
|
|
62
|
+
if (path.isAbsolute(input)) {
|
|
63
|
+
return path.normalize(input);
|
|
64
|
+
}
|
|
65
|
+
return path.join(ROOT, input);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function toProjectRelativeOrAbsolute(absPath) {
|
|
69
|
+
const relative = path.relative(ROOT, absPath);
|
|
70
|
+
if (!relative.startsWith("..") && !path.isAbsolute(relative)) {
|
|
71
|
+
return normalizeSlash(relative);
|
|
72
|
+
}
|
|
73
|
+
return normalizeSlash(absPath);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const CACHE_DIR_INPUT = process.env.FIGMA_CACHE_DIR || "figma-cache";
|
|
77
|
+
const ITERATIONS_DIR_INPUT =
|
|
78
|
+
process.env.FIGMA_ITERATIONS_DIR || "library/figma-iterations";
|
|
79
|
+
const INDEX_FILE_NAME = process.env.FIGMA_CACHE_INDEX_FILE || "index.json";
|
|
80
|
+
const DEFAULT_FLOW_ID = process.env.FIGMA_DEFAULT_FLOW || "";
|
|
81
|
+
const DEFAULT_STALE_DAYS = parsePositiveInt(
|
|
82
|
+
process.env.FIGMA_CACHE_STALE_DAYS,
|
|
83
|
+
14,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const CACHE_DIR = resolveMaybeAbsolutePath(CACHE_DIR_INPUT);
|
|
87
|
+
/** 与 `figma-cache/figma-cache.js` 同级的 `cursor-bootstrap/`(随 npm 包分发) */
|
|
88
|
+
const CURSOR_BOOTSTRAP_DIR = path.join(__dirname, "..", "cursor-bootstrap");
|
|
89
|
+
const ITERATIONS_DIR = resolveMaybeAbsolutePath(ITERATIONS_DIR_INPUT);
|
|
90
|
+
|
|
91
|
+
/** 当前安装包在 package.json 里的 name(用于写入 AGENT-SETUP-PROMPT.md) */
|
|
92
|
+
function readSelfNpmPackageName() {
|
|
93
|
+
try {
|
|
94
|
+
const pkgPath = path.join(__dirname, "..", "package.json");
|
|
95
|
+
const raw = fs.readFileSync(pkgPath, "utf8");
|
|
96
|
+
const j = JSON.parse(raw);
|
|
97
|
+
return j && j.name ? String(j.name) : "figma-cache-toolchain";
|
|
98
|
+
} catch {
|
|
99
|
+
return "figma-cache-toolchain";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const INDEX_PATH = path.isAbsolute(INDEX_FILE_NAME)
|
|
103
|
+
? INDEX_FILE_NAME
|
|
104
|
+
: path.join(CACHE_DIR, INDEX_FILE_NAME);
|
|
105
|
+
const CACHE_BASE_FOR_STORAGE = toProjectRelativeOrAbsolute(CACHE_DIR);
|
|
106
|
+
|
|
107
|
+
const indexStore = createIndexStore({
|
|
108
|
+
fs,
|
|
109
|
+
CACHE_DIR,
|
|
110
|
+
INDEX_PATH,
|
|
111
|
+
SCHEMA_VERSION,
|
|
112
|
+
NORMALIZATION_VERSION,
|
|
113
|
+
});
|
|
114
|
+
const {
|
|
115
|
+
ensureCacheDir,
|
|
116
|
+
buildEmptyIndex,
|
|
117
|
+
normalizeIndexShape,
|
|
118
|
+
readIndex,
|
|
119
|
+
writeIndex,
|
|
120
|
+
getItem,
|
|
121
|
+
} = indexStore;
|
|
122
|
+
|
|
123
|
+
const projectConfigService = createProjectConfigService({
|
|
124
|
+
fs,
|
|
125
|
+
path,
|
|
126
|
+
ROOT,
|
|
127
|
+
createRequire,
|
|
128
|
+
resolveMaybeAbsolutePath,
|
|
129
|
+
normalizeSlash,
|
|
130
|
+
});
|
|
131
|
+
const { loadProjectConfig, runPostEnsureHook, getProjectConfigPath } =
|
|
132
|
+
projectConfigService;
|
|
133
|
+
|
|
134
|
+
const upsertService = createUpsertService({
|
|
135
|
+
URL,
|
|
136
|
+
NORMALIZATION_VERSION,
|
|
137
|
+
CACHE_BASE_FOR_STORAGE,
|
|
138
|
+
DEFAULT_COMPLETENESS,
|
|
139
|
+
normalizeCompletenessList,
|
|
140
|
+
normalizeIndexShape,
|
|
141
|
+
readIndex,
|
|
142
|
+
getItem,
|
|
143
|
+
writeIndex,
|
|
144
|
+
});
|
|
145
|
+
const { normalizeFigmaUrl, previewUpsertByUrl, upsertByUrl } = upsertService;
|
|
146
|
+
|
|
147
|
+
function resolveFlowIdFromArgs(rest) {
|
|
148
|
+
const flowArg = rest.find((x) => x.startsWith("--flow="));
|
|
149
|
+
if (flowArg) {
|
|
150
|
+
return flowArg.split("=")[1];
|
|
151
|
+
}
|
|
152
|
+
if (DEFAULT_FLOW_ID) {
|
|
153
|
+
return DEFAULT_FLOW_ID;
|
|
154
|
+
}
|
|
155
|
+
return "";
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function normalizeCompletenessList(input) {
|
|
159
|
+
if (!Array.isArray(input)) {
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
const seen = new Set();
|
|
163
|
+
const output = [];
|
|
164
|
+
input.forEach((entry) => {
|
|
165
|
+
const value = String(entry || "").trim();
|
|
166
|
+
if (!value || seen.has(value)) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
seen.add(value);
|
|
170
|
+
output.push(value);
|
|
171
|
+
});
|
|
172
|
+
return output;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const entryFilesService = createEntryFilesService({
|
|
176
|
+
fs,
|
|
177
|
+
path,
|
|
178
|
+
resolveMaybeAbsolutePath,
|
|
179
|
+
normalizeCompletenessList,
|
|
180
|
+
completenessAllDimensions: COMPLETENESS_ALL_DIMENSIONS,
|
|
181
|
+
runPostEnsureHook,
|
|
182
|
+
});
|
|
183
|
+
const { ensureEntryFilesAndHook } = entryFilesService;
|
|
184
|
+
|
|
185
|
+
function parseCompletenessFromArgs(args) {
|
|
186
|
+
const completenessArg = args.find((x) => x.startsWith("--completeness="));
|
|
187
|
+
if (!completenessArg) {
|
|
188
|
+
return {
|
|
189
|
+
completeness: [...DEFAULT_COMPLETENESS],
|
|
190
|
+
fromCliArg: false,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
completeness: normalizeCompletenessList(
|
|
195
|
+
completenessArg.split("=").slice(1).join("=").split(","),
|
|
196
|
+
),
|
|
197
|
+
fromCliArg: true,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** @returns {string} */
|
|
202
|
+
function inferCliExample() {
|
|
203
|
+
const n = normalizeSlash(String(process.argv[1] || ""));
|
|
204
|
+
if (/\/bin\/figma-cache\.js$/i.test(n)) {
|
|
205
|
+
return "node bin/figma-cache.js";
|
|
206
|
+
}
|
|
207
|
+
if (/\/figma-cache\/figma-cache\.js$/i.test(n)) {
|
|
208
|
+
return "node figma-cache/figma-cache.js";
|
|
209
|
+
}
|
|
210
|
+
return "figma-cache";
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function printStale(days) {
|
|
214
|
+
const index = readIndex();
|
|
215
|
+
const now = Date.now();
|
|
216
|
+
const threshold = days * 24 * 60 * 60 * 1000;
|
|
217
|
+
const keys = Object.keys(index.items || {});
|
|
218
|
+
const stale = keys.filter((cacheKey) => {
|
|
219
|
+
const item = index.items[cacheKey];
|
|
220
|
+
const ts = item.syncedAt ? Date.parse(item.syncedAt) : NaN;
|
|
221
|
+
if (Number.isNaN(ts)) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
return now - ts > threshold;
|
|
225
|
+
});
|
|
226
|
+
if (!stale.length) {
|
|
227
|
+
console.log(`No stale entries (>${days}d).`);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
console.log(`Stale entries (>${days}d):`);
|
|
231
|
+
stale.forEach((key) => {
|
|
232
|
+
console.log(`- ${key}`);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function safeReadJson(absPath) {
|
|
237
|
+
try {
|
|
238
|
+
return JSON.parse(fs.readFileSync(absPath, "utf8"));
|
|
239
|
+
} catch {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function safeReadText(absPath) {
|
|
245
|
+
try {
|
|
246
|
+
return fs.readFileSync(absPath, "utf8");
|
|
247
|
+
} catch {
|
|
248
|
+
return "";
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function safeFileSize(absPath) {
|
|
253
|
+
try {
|
|
254
|
+
return fs.statSync(absPath).size;
|
|
255
|
+
} catch {
|
|
256
|
+
return 0;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function runUpsertLikeCommand(commandName, args, shouldEnsureFiles) {
|
|
261
|
+
const url = args[0];
|
|
262
|
+
const sourceArg = args.find((x) => x.startsWith("--source="));
|
|
263
|
+
const source = sourceArg ? sourceArg.split("=")[1] : "manual";
|
|
264
|
+
const allowSkeletonWithFigmaMcp = args.includes(
|
|
265
|
+
"--allow-skeleton-with-figma-mcp",
|
|
266
|
+
);
|
|
267
|
+
const { completeness } = parseCompletenessFromArgs(args);
|
|
268
|
+
|
|
269
|
+
const preview = previewUpsertByUrl(url, { source, completeness });
|
|
270
|
+
if (source === "figma-mcp") {
|
|
271
|
+
const mcpErrors = validateMcpRawEvidence(
|
|
272
|
+
preview.normalized.cacheKey,
|
|
273
|
+
preview.item,
|
|
274
|
+
completeness,
|
|
275
|
+
{ allowSkeletonWithFigmaMcp },
|
|
276
|
+
{
|
|
277
|
+
fs,
|
|
278
|
+
path,
|
|
279
|
+
resolveMaybeAbsolutePath,
|
|
280
|
+
safeReadJson,
|
|
281
|
+
normalizeSlash,
|
|
282
|
+
normalizeCompletenessList,
|
|
283
|
+
completenessToolRequirements: COMPLETENESS_TOOL_REQUIREMENTS,
|
|
284
|
+
},
|
|
285
|
+
);
|
|
286
|
+
if (mcpErrors.length) {
|
|
287
|
+
console.error(
|
|
288
|
+
`${commandName} failed: source=figma-mcp but MCP raw evidence is incomplete`,
|
|
289
|
+
);
|
|
290
|
+
mcpErrors.forEach((err) => console.error(`- ${err}`));
|
|
291
|
+
process.exit(2);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const result = upsertByUrl(url, { source, completeness });
|
|
296
|
+
if (shouldEnsureFiles) {
|
|
297
|
+
ensureEntryFilesAndHook(result.normalized.cacheKey, result.item);
|
|
298
|
+
console.log(
|
|
299
|
+
JSON.stringify(
|
|
300
|
+
{
|
|
301
|
+
cacheKey: result.normalized.cacheKey,
|
|
302
|
+
ensured: true,
|
|
303
|
+
paths: result.item.paths,
|
|
304
|
+
},
|
|
305
|
+
null,
|
|
306
|
+
2,
|
|
307
|
+
),
|
|
308
|
+
);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
console.log(
|
|
313
|
+
JSON.stringify(
|
|
314
|
+
{
|
|
315
|
+
cacheKey: result.normalized.cacheKey,
|
|
316
|
+
scope: result.item.scope,
|
|
317
|
+
syncedAt: result.item.syncedAt,
|
|
318
|
+
},
|
|
319
|
+
null,
|
|
320
|
+
2,
|
|
321
|
+
),
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function parseContractCheckArgs(args) {
|
|
326
|
+
return {
|
|
327
|
+
cacheKey: (() => {
|
|
328
|
+
const item = args.find((x) => x.startsWith("--cacheKey="));
|
|
329
|
+
return item ? item.split("=").slice(1).join("=").trim() : "";
|
|
330
|
+
})(),
|
|
331
|
+
warnUnmappedTokens: args.includes("--warn-unmapped-tokens"),
|
|
332
|
+
warnUnmappedStates: args.includes("--warn-unmapped-states"),
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function runContractCheck(args) {
|
|
337
|
+
const options = parseContractCheckArgs(args);
|
|
338
|
+
const contractPath = resolveMaybeAbsolutePath(
|
|
339
|
+
process.env.FIGMA_CACHE_ADAPTER_CONTRACT ||
|
|
340
|
+
"figma-cache/adapters/ui-adapter.contract.json",
|
|
341
|
+
);
|
|
342
|
+
|
|
343
|
+
const report = buildContractCheckReport(
|
|
344
|
+
{
|
|
345
|
+
...options,
|
|
346
|
+
contractPath,
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
index: readIndex(),
|
|
350
|
+
contract: safeReadJson(contractPath),
|
|
351
|
+
readJsonOrNull: safeReadJson,
|
|
352
|
+
readTextOrEmpty: safeReadText,
|
|
353
|
+
resolveMaybeAbsolutePath,
|
|
354
|
+
normalizeSlash,
|
|
355
|
+
},
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
if (!report.ok) {
|
|
359
|
+
console.error("contract-check failed:");
|
|
360
|
+
report.hardErrors.forEach((error) => console.error(`- ${error}`));
|
|
361
|
+
if (report.warnings.length) {
|
|
362
|
+
console.error("\nWarnings:");
|
|
363
|
+
report.warnings.forEach((warning) => console.error(`- ${warning}`));
|
|
364
|
+
}
|
|
365
|
+
process.exit(2);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
console.log(
|
|
369
|
+
JSON.stringify(
|
|
370
|
+
{
|
|
371
|
+
ok: true,
|
|
372
|
+
contract: normalizeSlash(contractPath),
|
|
373
|
+
checkedItems: report.checkedItems,
|
|
374
|
+
checkedCacheKeys: report.checkedCacheKeys,
|
|
375
|
+
warnings: report.warnings,
|
|
376
|
+
},
|
|
377
|
+
null,
|
|
378
|
+
2,
|
|
379
|
+
),
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function run() {
|
|
384
|
+
const [, , cmd, ...args] = process.argv;
|
|
385
|
+
if (!cmd) {
|
|
386
|
+
const ex = inferCliExample();
|
|
387
|
+
const defaultCompletenessText = DEFAULT_COMPLETENESS.join(",");
|
|
388
|
+
console.log("Usage:");
|
|
389
|
+
console.log(
|
|
390
|
+
` (invoke examples: ${ex} | node bin/figma-cache.js | node figma-cache/figma-cache.js)`,
|
|
391
|
+
);
|
|
392
|
+
console.log(` ${ex} normalize <figmaUrl>`);
|
|
393
|
+
console.log(` ${ex} get <figmaUrl>`);
|
|
394
|
+
console.log(
|
|
395
|
+
` ${ex} upsert <figmaUrl> [--source=manual] [--completeness=a,b] [--allow-skeleton-with-figma-mcp] (default completeness=${defaultCompletenessText})`,
|
|
396
|
+
);
|
|
397
|
+
console.log(` ${ex} validate`);
|
|
398
|
+
console.log(` ${ex} stale [--days=14]`);
|
|
399
|
+
console.log(` ${ex} backfill`);
|
|
400
|
+
console.log(
|
|
401
|
+
` ${ex} budget [--mcp-only] [--cacheKey=<fileKey#nodeId>] [--limit=50]`,
|
|
402
|
+
);
|
|
403
|
+
console.log(
|
|
404
|
+
` ${ex} ensure <figmaUrl> [--source=manual] [--completeness=a,b] [--allow-skeleton-with-figma-mcp] (default completeness=${defaultCompletenessText})`,
|
|
405
|
+
);
|
|
406
|
+
console.log(` ${ex} init`);
|
|
407
|
+
console.log(` ${ex} config`);
|
|
408
|
+
console.log(
|
|
409
|
+
` ${ex} contract-check [--cacheKey=<fileKey#nodeId>] [--warn-unmapped-tokens] [--warn-unmapped-states]`,
|
|
410
|
+
);
|
|
411
|
+
console.log(
|
|
412
|
+
" (optional) figma-cache.config.js | .figmacacherc.js | FIGMA_CACHE_PROJECT_CONFIG -> hooks.postEnsure after ensure",
|
|
413
|
+
);
|
|
414
|
+
console.log(` ${ex} flow init --id=<flowId> [--title=...]`);
|
|
415
|
+
console.log(
|
|
416
|
+
`${ex} flow add-node --flow=<flowId> <figmaUrl> [--ensure] [--source=manual] [--completeness=a,b]`,
|
|
417
|
+
);
|
|
418
|
+
console.log(
|
|
419
|
+
`${ex} flow link --flow=<flowId> <fromUrl> <toUrl> --type=next_step [--note=...]`,
|
|
420
|
+
);
|
|
421
|
+
console.log(
|
|
422
|
+
`${ex} flow chain --flow=<flowId> <url1> <url2> ... [--type=next_step|related]`,
|
|
423
|
+
);
|
|
424
|
+
console.log(` ${ex} flow show --flow=<flowId>`);
|
|
425
|
+
console.log(` ${ex} flow mermaid --flow=<flowId>`);
|
|
426
|
+
console.log(
|
|
427
|
+
`${ex} cursor init [--overwrite] [--force] # default safe mode; --overwrite forces replacement; --force keeps legacy behavior (no overwrite)`,
|
|
428
|
+
);
|
|
429
|
+
process.exit(1);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if (cmd === "cursor") {
|
|
433
|
+
const sub = args[0];
|
|
434
|
+
if (sub !== "init") {
|
|
435
|
+
console.error(
|
|
436
|
+
"Usage: figma-cache cursor init [--overwrite] [--force] # --overwrite replaces existing templates; --force keeps legacy no-overwrite behavior",
|
|
437
|
+
);
|
|
438
|
+
process.exit(1);
|
|
439
|
+
}
|
|
440
|
+
const hasOverwrite = args.includes("--overwrite");
|
|
441
|
+
const hasForce = args.includes("--force");
|
|
442
|
+
if (hasOverwrite && hasForce) {
|
|
443
|
+
console.error("Do not use --overwrite and --force together. Choose one mode.");
|
|
444
|
+
process.exit(1);
|
|
445
|
+
}
|
|
446
|
+
const overwrite = hasOverwrite;
|
|
447
|
+
copyCursorBootstrap({ overwrite, legacyForce: hasForce }, {
|
|
448
|
+
fs,
|
|
449
|
+
path,
|
|
450
|
+
ROOT,
|
|
451
|
+
CACHE_DIR,
|
|
452
|
+
CURSOR_BOOTSTRAP_DIR,
|
|
453
|
+
normalizeSlash,
|
|
454
|
+
readSelfNpmPackageName,
|
|
455
|
+
packageDir: __dirname,
|
|
456
|
+
});
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
if (cmd === "normalize") {
|
|
461
|
+
const url = args[0];
|
|
462
|
+
const normalized = normalizeFigmaUrl(url);
|
|
463
|
+
console.log(JSON.stringify(normalized, null, 2));
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (cmd === "get") {
|
|
468
|
+
const url = args[0];
|
|
469
|
+
const normalized = normalizeFigmaUrl(url);
|
|
470
|
+
const index = readIndex();
|
|
471
|
+
const item = getItem(index, normalized.cacheKey);
|
|
472
|
+
console.log(
|
|
473
|
+
JSON.stringify(
|
|
474
|
+
{
|
|
475
|
+
found: !!item,
|
|
476
|
+
cacheKey: normalized.cacheKey,
|
|
477
|
+
item: item || null,
|
|
478
|
+
},
|
|
479
|
+
null,
|
|
480
|
+
2,
|
|
481
|
+
),
|
|
482
|
+
);
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (cmd === "upsert") {
|
|
487
|
+
runUpsertLikeCommand("upsert", args, false);
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
if (cmd === "ensure") {
|
|
492
|
+
runUpsertLikeCommand("ensure", args, true);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if (cmd === "validate") {
|
|
497
|
+
const index = readIndex();
|
|
498
|
+
const errors = validateIndex(index, {
|
|
499
|
+
fs,
|
|
500
|
+
path,
|
|
501
|
+
normalizeIndexShape,
|
|
502
|
+
normalizeCompletenessList,
|
|
503
|
+
resolveMaybeAbsolutePath,
|
|
504
|
+
safeReadJson,
|
|
505
|
+
normalizeSlash,
|
|
506
|
+
completenessToolRequirements: COMPLETENESS_TOOL_REQUIREMENTS,
|
|
507
|
+
});
|
|
508
|
+
if (!errors.length) {
|
|
509
|
+
console.log("Validation passed.");
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
console.error("Validation failed:");
|
|
513
|
+
errors.forEach((err) => console.error(`- ${err}`));
|
|
514
|
+
process.exit(2);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (cmd === "contract-check") {
|
|
518
|
+
runContractCheck(args);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (cmd === "stale") {
|
|
523
|
+
const daysArg = args.find((x) => x.startsWith("--days="));
|
|
524
|
+
const days = daysArg ? Number(daysArg.split("=")[1]) : DEFAULT_STALE_DAYS;
|
|
525
|
+
printStale(days);
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
if (cmd === "backfill") {
|
|
530
|
+
backfillFromIterations(
|
|
531
|
+
{ iterationsDir: ITERATIONS_DIR },
|
|
532
|
+
{
|
|
533
|
+
fs,
|
|
534
|
+
path,
|
|
535
|
+
upsertByUrl,
|
|
536
|
+
},
|
|
537
|
+
);
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
if (cmd === "budget") {
|
|
542
|
+
const mcpOnly = args.includes("--mcp-only");
|
|
543
|
+
const cacheKeyArg = args.find((x) => x.startsWith("--cacheKey="));
|
|
544
|
+
const limitArg = args.find((x) => x.startsWith("--limit="));
|
|
545
|
+
const cacheKey = cacheKeyArg
|
|
546
|
+
? cacheKeyArg.split("=").slice(1).join("=")
|
|
547
|
+
: "";
|
|
548
|
+
const limit = limitArg ? limitArg.split("=")[1] : "";
|
|
549
|
+
const report = buildBudgetReport(
|
|
550
|
+
{ mcpOnly, cacheKey, limit },
|
|
551
|
+
{
|
|
552
|
+
path,
|
|
553
|
+
normalizeIndexShape,
|
|
554
|
+
readIndex,
|
|
555
|
+
resolveMaybeAbsolutePath,
|
|
556
|
+
safeReadJson,
|
|
557
|
+
safeFileSize,
|
|
558
|
+
},
|
|
559
|
+
);
|
|
560
|
+
console.log(JSON.stringify(report, null, 2));
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
if (cmd === "config") {
|
|
565
|
+
const cfg = loadProjectConfig();
|
|
566
|
+
const hooks = cfg && cfg.hooks;
|
|
567
|
+
console.log(
|
|
568
|
+
JSON.stringify(
|
|
569
|
+
{
|
|
570
|
+
root: normalizeSlash(ROOT),
|
|
571
|
+
cacheDir: normalizeSlash(CACHE_DIR),
|
|
572
|
+
indexPath: normalizeSlash(INDEX_PATH),
|
|
573
|
+
iterationsDir: normalizeSlash(ITERATIONS_DIR),
|
|
574
|
+
staleDays: DEFAULT_STALE_DAYS,
|
|
575
|
+
defaultFlowId: DEFAULT_FLOW_ID || null,
|
|
576
|
+
defaultCompleteness: [...DEFAULT_COMPLETENESS],
|
|
577
|
+
normalizationVersion: NORMALIZATION_VERSION,
|
|
578
|
+
projectConfigPath: getProjectConfigPath(),
|
|
579
|
+
hooks: {
|
|
580
|
+
postEnsure: !!(hooks && typeof hooks.postEnsure === "function"),
|
|
581
|
+
},
|
|
582
|
+
},
|
|
583
|
+
null,
|
|
584
|
+
2,
|
|
585
|
+
),
|
|
586
|
+
);
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
if (cmd === "init") {
|
|
591
|
+
ensureCacheDir();
|
|
592
|
+
if (fs.existsSync(INDEX_PATH)) {
|
|
593
|
+
console.log(
|
|
594
|
+
JSON.stringify(
|
|
595
|
+
{
|
|
596
|
+
created: false,
|
|
597
|
+
reason: "index_exists",
|
|
598
|
+
indexPath: normalizeSlash(INDEX_PATH),
|
|
599
|
+
},
|
|
600
|
+
null,
|
|
601
|
+
2,
|
|
602
|
+
),
|
|
603
|
+
);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
writeIndex(buildEmptyIndex());
|
|
607
|
+
console.log(
|
|
608
|
+
JSON.stringify(
|
|
609
|
+
{
|
|
610
|
+
created: true,
|
|
611
|
+
indexPath: normalizeSlash(INDEX_PATH),
|
|
612
|
+
},
|
|
613
|
+
null,
|
|
614
|
+
2,
|
|
615
|
+
),
|
|
616
|
+
);
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
if (cmd === "flow") {
|
|
621
|
+
handleFlowCommand(args, {
|
|
622
|
+
resolveFlowIdFromArgs,
|
|
623
|
+
parseCompletenessFromArgs,
|
|
624
|
+
normalizeIndexShape,
|
|
625
|
+
readIndex,
|
|
626
|
+
writeIndex,
|
|
627
|
+
normalizeFigmaUrl,
|
|
628
|
+
getItem,
|
|
629
|
+
upsertByUrl,
|
|
630
|
+
ensureEntryFilesAndHook,
|
|
631
|
+
});
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
console.error(`Unknown command: ${cmd}`);
|
|
636
|
+
process.exit(1);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
run();
|