@fjyueke/bify-mcp 1.0.1 → 1.0.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/dist/index.js +688 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -26,9 +26,9 @@ var config = {
26
26
  )
27
27
  },
28
28
  server: {
29
- name: "tify-mcp",
30
- version: "1.0.0",
31
- description: "Provides documentation and example for Tify components"
29
+ name: "bify-mcp",
30
+ version: "1.0.2",
31
+ description: "Provides documentation, examples and Arco conversion for Bify components"
32
32
  }
33
33
  };
34
34
 
@@ -161,6 +161,656 @@ ${content}
161
161
  }
162
162
  };
163
163
 
164
+ // src/services/arco-mapping.ts
165
+ var componentMappings = [
166
+ {
167
+ arcoName: "Cell",
168
+ bifyName: "Cell",
169
+ arcoImport: "@arco-design/mobile-react",
170
+ bifyImport: "@fjyueke/bify-core",
171
+ propMappings: [
172
+ { arcoProp: "label", bifyProp: "title" },
173
+ { arcoProp: "desc", bifyProp: "brief" },
174
+ { arcoProp: "text", bifyProp: "children" },
175
+ { arcoProp: "showArrow", bifyProp: "clickable", transform: () => "true" },
176
+ { arcoProp: "arrow", bifyProp: "rightIcon" },
177
+ { arcoProp: "bordered", bifyProp: "bordered" },
178
+ { arcoProp: "icon", bifyProp: "icon" },
179
+ { arcoProp: "onClick", bifyProp: "onClick" }
180
+ ]
181
+ },
182
+ {
183
+ arcoName: "CellGroup",
184
+ bifyName: "CellGroup",
185
+ arcoImport: "@arco-design/mobile-react",
186
+ bifyImport: "@fjyueke/bify-core",
187
+ propMappings: [
188
+ { arcoProp: "bordered", bifyProp: "bordered" },
189
+ { arcoProp: "onClick", bifyProp: "onClick" }
190
+ ]
191
+ },
192
+ {
193
+ arcoName: "Button",
194
+ bifyName: "Button",
195
+ arcoImport: "@arco-design/mobile-react",
196
+ bifyImport: "@fjyueke/bify-core",
197
+ propMappings: [
198
+ { arcoProp: "type", bifyProp: "type" },
199
+ { arcoProp: "size", bifyProp: "size" },
200
+ { arcoProp: "disabled", bifyProp: "disabled" },
201
+ { arcoProp: "loading", bifyProp: "loading" },
202
+ { arcoProp: "icon", bifyProp: "icon" },
203
+ { arcoProp: "onClick", bifyProp: "onClick" },
204
+ { arcoProp: "className", bifyProp: "className" },
205
+ { arcoProp: "style", bifyProp: "style" }
206
+ ],
207
+ valueMappings: {
208
+ type: {
209
+ ghost: "outlined",
210
+ default: "default",
211
+ primary: "primary"
212
+ },
213
+ size: {
214
+ mini: "mini",
215
+ small: "small",
216
+ medium: "medium",
217
+ large: "large",
218
+ huge: "large"
219
+ }
220
+ }
221
+ },
222
+ {
223
+ arcoName: "Avatar",
224
+ bifyName: "Avatar",
225
+ arcoImport: "@arco-design/mobile-react",
226
+ bifyImport: "@fjyueke/bify-core",
227
+ propMappings: [
228
+ { arcoProp: "size", bifyProp: "size" },
229
+ { arcoProp: "src", bifyProp: "src" },
230
+ { arcoProp: "icon", bifyProp: "icon" }
231
+ ]
232
+ },
233
+ {
234
+ arcoName: "Badge",
235
+ bifyName: "Badge",
236
+ arcoImport: "@arco-design/mobile-react",
237
+ bifyImport: "@fjyueke/bify-core",
238
+ propMappings: [
239
+ { arcoProp: "dot", bifyProp: "dot" },
240
+ { arcoProp: "count", bifyProp: "content" },
241
+ { arcoProp: "maxCount", bifyProp: "max" }
242
+ ]
243
+ },
244
+ {
245
+ arcoName: "Tag",
246
+ bifyName: "Tag",
247
+ arcoImport: "@arco-design/mobile-react",
248
+ bifyImport: "@fjyueke/bify-core",
249
+ propMappings: [
250
+ { arcoProp: "type", bifyProp: "type" },
251
+ { arcoProp: "size", bifyProp: "size" },
252
+ { arcoProp: "closable", bifyProp: "closable" },
253
+ { arcoProp: "onClose", bifyProp: "onClose" }
254
+ ],
255
+ valueMappings: {
256
+ type: {
257
+ default: "default",
258
+ primary: "primary",
259
+ success: "success",
260
+ warning: "warning",
261
+ danger: "danger"
262
+ }
263
+ }
264
+ },
265
+ {
266
+ arcoName: "Switch",
267
+ bifyName: "Switch",
268
+ arcoImport: "@arco-design/mobile-react",
269
+ bifyImport: "@fjyueke/bify-core",
270
+ propMappings: [
271
+ { arcoProp: "checked", bifyProp: "checked" },
272
+ { arcoProp: "disabled", bifyProp: "disabled" },
273
+ { arcoProp: "onChange", bifyProp: "onChange" }
274
+ ]
275
+ },
276
+ {
277
+ arcoName: "Checkbox",
278
+ bifyName: "Checkbox",
279
+ arcoImport: "@arco-design/mobile-react",
280
+ bifyImport: "@fjyueke/bify-core",
281
+ propMappings: [
282
+ { arcoProp: "checked", bifyProp: "checked" },
283
+ { arcoProp: "disabled", bifyProp: "disabled" },
284
+ { arcoProp: "onChange", bifyProp: "onChange" },
285
+ { arcoProp: "label", bifyProp: "children" }
286
+ ]
287
+ },
288
+ {
289
+ arcoName: "CheckboxGroup",
290
+ bifyName: "Checkbox.Group",
291
+ arcoImport: "@arco-design/mobile-react",
292
+ bifyImport: "@fjyueke/bify-core",
293
+ propMappings: [
294
+ { arcoProp: "value", bifyProp: "modelValue" },
295
+ { arcoProp: "onChange", bifyProp: "onChange" }
296
+ ]
297
+ },
298
+ {
299
+ arcoName: "Radio",
300
+ bifyName: "Radio",
301
+ arcoImport: "@arco-design/mobile-react",
302
+ bifyImport: "@fjyueke/bify-core",
303
+ propMappings: [
304
+ { arcoProp: "checked", bifyProp: "checked" },
305
+ { arcoProp: "disabled", bifyProp: "disabled" },
306
+ { arcoProp: "onChange", bifyProp: "onChange" },
307
+ { arcoProp: "label", bifyProp: "children" }
308
+ ]
309
+ },
310
+ {
311
+ arcoName: "RadioGroup",
312
+ bifyName: "Radio.Group",
313
+ arcoImport: "@arco-design/mobile-react",
314
+ bifyImport: "@fjyueke/bify-core",
315
+ propMappings: [
316
+ { arcoProp: "value", bifyProp: "modelValue" },
317
+ { arcoProp: "onChange", bifyProp: "onChange" }
318
+ ]
319
+ },
320
+ {
321
+ arcoName: "Dialog",
322
+ bifyName: "Dialog",
323
+ arcoImport: "@arco-design/mobile-react",
324
+ bifyImport: "@fjyueke/bify-core",
325
+ propMappings: [
326
+ { arcoProp: "visible", bifyProp: "open" },
327
+ { arcoProp: "title", bifyProp: "title" },
328
+ { arcoProp: "content", bifyProp: "children" },
329
+ { arcoProp: "onClose", bifyProp: "onClose" }
330
+ ]
331
+ },
332
+ {
333
+ arcoName: "Toast",
334
+ bifyName: "Toast",
335
+ arcoImport: "@arco-design/mobile-react",
336
+ bifyImport: "@fjyueke/bify-core",
337
+ propMappings: []
338
+ },
339
+ {
340
+ arcoName: "Popup",
341
+ bifyName: "Popup",
342
+ arcoImport: "@arco-design/mobile-react",
343
+ bifyImport: "@fjyueke/bify-core",
344
+ propMappings: [
345
+ { arcoProp: "visible", bifyProp: "open" },
346
+ { arcoProp: "position", bifyProp: "position" },
347
+ { arcoProp: "onClose", bifyProp: "onClose" }
348
+ ]
349
+ },
350
+ {
351
+ arcoName: "Tabs",
352
+ bifyName: "Tabs",
353
+ arcoImport: "@arco-design/mobile-react",
354
+ bifyImport: "@fjyueke/bify-core",
355
+ propMappings: [
356
+ { arcoProp: "activeTab", bifyProp: "active" },
357
+ { arcoProp: "onChange", bifyProp: "onChange" }
358
+ ]
359
+ },
360
+ {
361
+ arcoName: "TabPane",
362
+ bifyName: "Tabs.Tab",
363
+ arcoImport: "@arco-design/mobile-react",
364
+ bifyImport: "@fjyueke/bify-core",
365
+ propMappings: [
366
+ { arcoProp: "title", bifyProp: "title" },
367
+ { arcoProp: "key", bifyProp: "key" }
368
+ ]
369
+ },
370
+ {
371
+ arcoName: "Picker",
372
+ bifyName: "Picker",
373
+ arcoImport: "@arco-design/mobile-react",
374
+ bifyImport: "@fjyueke/bify-core",
375
+ propMappings: [
376
+ { arcoProp: "visible", bifyProp: "open" },
377
+ { arcoProp: "title", bifyProp: "title" },
378
+ { arcoProp: "onClose", bifyProp: "onClose" }
379
+ ]
380
+ },
381
+ {
382
+ arcoName: "DatePicker",
383
+ bifyName: "DatePicker",
384
+ arcoImport: "@arco-design/mobile-react",
385
+ bifyImport: "@fjyueke/bify-core",
386
+ propMappings: [
387
+ { arcoProp: "visible", bifyProp: "open" },
388
+ { arcoProp: "onClose", bifyProp: "onClose" }
389
+ ]
390
+ },
391
+ {
392
+ arcoName: "SearchBar",
393
+ bifyName: "Search",
394
+ arcoImport: "@arco-design/mobile-react",
395
+ bifyImport: "@fjyueke/bify-core",
396
+ propMappings: [
397
+ { arcoProp: "value", bifyProp: "modelValue" },
398
+ { arcoProp: "placeholder", bifyProp: "placeholder" },
399
+ { arcoProp: "onChange", bifyProp: "onChange" },
400
+ { arcoProp: "onSearch", bifyProp: "onSearch" }
401
+ ]
402
+ },
403
+ {
404
+ arcoName: "Field",
405
+ bifyName: "Field",
406
+ arcoImport: "@arco-design/mobile-react",
407
+ bifyImport: "@fjyueke/bify-core",
408
+ propMappings: [
409
+ { arcoProp: "value", bifyProp: "modelValue" },
410
+ { arcoProp: "placeholder", bifyProp: "placeholder" },
411
+ { arcoProp: "label", bifyProp: "label" },
412
+ { arcoProp: "onChange", bifyProp: "onChange" }
413
+ ]
414
+ },
415
+ {
416
+ arcoName: "Textarea",
417
+ bifyName: "Field",
418
+ arcoImport: "@arco-design/mobile-react",
419
+ bifyImport: "@fjyueke/bify-core",
420
+ propMappings: [
421
+ { arcoProp: "value", bifyProp: "modelValue" },
422
+ { arcoProp: "placeholder", bifyProp: "placeholder" },
423
+ { arcoProp: "onChange", bifyProp: "onChange" }
424
+ ]
425
+ },
426
+ {
427
+ arcoName: "Stepper",
428
+ bifyName: "Stepper",
429
+ arcoImport: "@arco-design/mobile-react",
430
+ bifyImport: "@fjyueke/bify-core",
431
+ propMappings: [
432
+ { arcoProp: "value", bifyProp: "modelValue" },
433
+ { arcoProp: "min", bifyProp: "min" },
434
+ { arcoProp: "max", bifyProp: "max" },
435
+ { arcoProp: "step", bifyProp: "step" },
436
+ { arcoProp: "onChange", bifyProp: "onChange" }
437
+ ]
438
+ },
439
+ {
440
+ arcoName: "Slider",
441
+ bifyName: "Slider",
442
+ arcoImport: "@arco-design/mobile-react",
443
+ bifyImport: "@fjyueke/bify-core",
444
+ propMappings: [
445
+ { arcoProp: "value", bifyProp: "modelValue" },
446
+ { arcoProp: "min", bifyProp: "min" },
447
+ { arcoProp: "max", bifyProp: "max" },
448
+ { arcoProp: "onChange", bifyProp: "onChange" }
449
+ ]
450
+ },
451
+ {
452
+ arcoName: "Rate",
453
+ bifyName: "Rate",
454
+ arcoImport: "@arco-design/mobile-react",
455
+ bifyImport: "@fjyueke/bify-core",
456
+ propMappings: [
457
+ { arcoProp: "value", bifyProp: "modelValue" },
458
+ { arcoProp: "max", bifyProp: "count" },
459
+ { arcoProp: "onChange", bifyProp: "onChange" }
460
+ ]
461
+ },
462
+ {
463
+ arcoName: "Uploader",
464
+ bifyName: "Uploader",
465
+ arcoImport: "@arco-design/mobile-react",
466
+ bifyImport: "@fjyueke/bify-core",
467
+ propMappings: [
468
+ { arcoProp: "fileList", bifyProp: "fileList" },
469
+ { arcoProp: "onChange", bifyProp: "onChange" }
470
+ ]
471
+ },
472
+ {
473
+ arcoName: "Image",
474
+ bifyName: "Image",
475
+ arcoImport: "@arco-design/mobile-react",
476
+ bifyImport: "@fjyueke/bify-core",
477
+ propMappings: [
478
+ { arcoProp: "src", bifyProp: "src" },
479
+ { arcoProp: "alt", bifyProp: "alt" }
480
+ ]
481
+ },
482
+ {
483
+ arcoName: "Divider",
484
+ bifyName: "Divider",
485
+ arcoImport: "@arco-design/mobile-react",
486
+ bifyImport: "@fjyueke/bify-core",
487
+ propMappings: [
488
+ { arcoProp: "content", bifyProp: "children" }
489
+ ]
490
+ },
491
+ {
492
+ arcoName: "Loading",
493
+ bifyName: "Loading",
494
+ arcoImport: "@arco-design/mobile-react",
495
+ bifyImport: "@fjyueke/bify-core",
496
+ propMappings: [
497
+ { arcoProp: "type", bifyProp: "type" },
498
+ { arcoProp: "size", bifyProp: "size" }
499
+ ]
500
+ },
501
+ {
502
+ arcoName: "NoticeBar",
503
+ bifyName: "NoticeBar",
504
+ arcoImport: "@arco-design/mobile-react",
505
+ bifyImport: "@fjyueke/bify-core",
506
+ propMappings: [
507
+ { arcoProp: "text", bifyProp: "children" },
508
+ { arcoProp: "leftIcon", bifyProp: "leftIcon" }
509
+ ]
510
+ },
511
+ {
512
+ arcoName: "Progress",
513
+ bifyName: "Progress",
514
+ arcoImport: "@arco-design/mobile-react",
515
+ bifyImport: "@fjyueke/bify-core",
516
+ propMappings: [
517
+ { arcoProp: "percent", bifyProp: "percentage" },
518
+ { arcoProp: "strokeWidth", bifyProp: "strokeWidth" }
519
+ ]
520
+ },
521
+ {
522
+ arcoName: "Skeleton",
523
+ bifyName: "Skeleton",
524
+ arcoImport: "@arco-design/mobile-react",
525
+ bifyImport: "@fjyueke/bify-core",
526
+ propMappings: []
527
+ },
528
+ {
529
+ arcoName: "Grid",
530
+ bifyName: "Grid",
531
+ arcoImport: "@arco-design/mobile-react",
532
+ bifyImport: "@fjyueke/bify-core",
533
+ propMappings: [
534
+ { arcoProp: "columnNum", bifyProp: "columnNum" }
535
+ ]
536
+ },
537
+ {
538
+ arcoName: "Collapse",
539
+ bifyName: "Collapse",
540
+ arcoImport: "@arco-design/mobile-react",
541
+ bifyImport: "@fjyueke/bify-core",
542
+ propMappings: [
543
+ { arcoProp: "defaultActiveKey", bifyProp: "defaultActiveNames" },
544
+ { arcoProp: "activeKey", bifyProp: "activeNames" }
545
+ ]
546
+ },
547
+ {
548
+ arcoName: "CollapseItem",
549
+ bifyName: "Collapse.Item",
550
+ arcoImport: "@arco-design/mobile-react",
551
+ bifyImport: "@fjyueke/bify-core",
552
+ propMappings: [
553
+ { arcoProp: "title", bifyProp: "title" },
554
+ { arcoProp: "name", bifyProp: "name" }
555
+ ]
556
+ },
557
+ {
558
+ arcoName: "PullRefresh",
559
+ bifyName: "PullRefresh",
560
+ arcoImport: "@arco-design/mobile-react",
561
+ bifyImport: "@fjyueke/bify-core",
562
+ propMappings: [
563
+ { arcoProp: "onRefresh", bifyProp: "onRefresh" }
564
+ ]
565
+ },
566
+ {
567
+ arcoName: "NavHeader",
568
+ bifyName: "NavBar",
569
+ arcoImport: "@arco-design/mobile-react",
570
+ bifyImport: "@fjyueke/bify-core",
571
+ propMappings: [
572
+ { arcoProp: "title", bifyProp: "title" },
573
+ { arcoProp: "left", bifyProp: "left" },
574
+ { arcoProp: "right", bifyProp: "right" }
575
+ ]
576
+ },
577
+ {
578
+ arcoName: "CountDown",
579
+ bifyName: "Countdown",
580
+ arcoImport: "@arco-design/mobile-react",
581
+ bifyImport: "@fjyueke/bify-core",
582
+ propMappings: [
583
+ { arcoProp: "endTime", bifyProp: "endTime" }
584
+ ]
585
+ },
586
+ {
587
+ arcoName: "List",
588
+ bifyName: "List",
589
+ arcoImport: "@arco-design/mobile-react",
590
+ bifyImport: "@fjyueke/bify-core",
591
+ propMappings: []
592
+ },
593
+ {
594
+ arcoName: "RefreshControl",
595
+ bifyName: "PullRefresh",
596
+ arcoImport: "@arco-design/mobile-react",
597
+ bifyImport: "@fjyueke/bify-core",
598
+ propMappings: [
599
+ { arcoProp: "onRefresh", bifyProp: "onRefresh" }
600
+ ]
601
+ },
602
+ {
603
+ arcoName: "PickerView",
604
+ bifyName: "PickerView",
605
+ arcoImport: "@arco-design/mobile-react",
606
+ bifyImport: "@fjyueke/bify-core",
607
+ propMappings: []
608
+ }
609
+ ];
610
+ function findMappingByArcoName(arcoName) {
611
+ return componentMappings.find((m) => m.arcoName === arcoName);
612
+ }
613
+ function findAllArcoComponents() {
614
+ return componentMappings.map((m) => m.arcoName);
615
+ }
616
+
617
+ // src/services/arco-converter.ts
618
+ async function convertArcoToBify(arcoCode) {
619
+ let result = arcoCode;
620
+ result = convertImports(result);
621
+ result = convertComponents(result);
622
+ result = convertIconImports(result);
623
+ result = fixCodeFormat(result);
624
+ return result;
625
+ }
626
+ function convertImports(code) {
627
+ let result = code;
628
+ const arcoImportRegex = /import\s+([\s\S]*?)\s+from\s+['"]@arco-design\/mobile-react['"]/g;
629
+ const matches = [...code.matchAll(arcoImportRegex)];
630
+ const bifyCoreComponents = [];
631
+ const bifyIconComponents = [];
632
+ const remainingComponents = [];
633
+ for (const match of matches) {
634
+ const importContent = match[1].trim();
635
+ const namedImportRegex = /\{([\s\S]*?)\}/;
636
+ const namedMatch = importContent.match(namedImportRegex);
637
+ if (namedMatch) {
638
+ const components = namedMatch[1].split(",").map((c) => c.trim()).filter((c) => c);
639
+ for (const component of components) {
640
+ const mapping = findMappingByArcoName(component);
641
+ if (mapping) {
642
+ if (mapping.bifyImport === "@fjyueke/bify-icons") {
643
+ bifyIconComponents.push(component);
644
+ } else {
645
+ bifyCoreComponents.push(mapping.bifyName || component);
646
+ }
647
+ } else {
648
+ remainingComponents.push(component);
649
+ }
650
+ }
651
+ } else {
652
+ remainingComponents.push(importContent);
653
+ }
654
+ result = result.replace(match[0], "");
655
+ }
656
+ result = result.trim();
657
+ if (bifyCoreComponents.length > 0) {
658
+ const uniqueCoreComponents = [...new Set(bifyCoreComponents)];
659
+ const coreImport = `import { ${uniqueCoreComponents.join(", ")} } from "@fjyueke/bify-core"
660
+ `;
661
+ result = coreImport + result;
662
+ }
663
+ if (bifyIconComponents.length > 0) {
664
+ const uniqueIconComponents = [...new Set(bifyIconComponents)];
665
+ const iconImport = `import { ${uniqueIconComponents.join(", ")} } from "@fjyueke/bify-icons"
666
+ `;
667
+ result = iconImport + result;
668
+ }
669
+ return result;
670
+ }
671
+ function convertComponents(code) {
672
+ let result = code;
673
+ const arcoComponents = findAllArcoComponents();
674
+ for (const arcoComponent of arcoComponents) {
675
+ const mapping = findMappingByArcoName(arcoComponent);
676
+ if (!mapping || !mapping.bifyName) continue;
677
+ const bifyComponent = mapping.bifyName;
678
+ const componentRegex = new RegExp(
679
+ `<${arcoComponent}([^>]*)\\/?>`,
680
+ "g"
681
+ );
682
+ result = result.replace(componentRegex, (match, props) => {
683
+ let newProps = props;
684
+ newProps = applyPropMappings(newProps, mapping);
685
+ newProps = applyValueMappings(newProps, mapping);
686
+ return `<${bifyComponent}${newProps}/>`;
687
+ });
688
+ const closingComponentRegex = new RegExp(
689
+ `<${arcoComponent}([^>]*)>([sS]*?)</${arcoComponent}>`,
690
+ "g"
691
+ );
692
+ result = result.replace(closingComponentRegex, (match, props, children) => {
693
+ let newProps = props;
694
+ newProps = applyPropMappings(newProps, mapping);
695
+ newProps = applyValueMappings(newProps, mapping);
696
+ return `<${bifyComponent}${newProps}>${children}</${bifyComponent}>`;
697
+ });
698
+ }
699
+ return result;
700
+ }
701
+ function applyPropMappings(props, mapping) {
702
+ let result = props;
703
+ for (const propMapping of mapping.propMappings) {
704
+ const propRegex = new RegExp(
705
+ `${propMapping.arcoProp}=(["'])(.*?)\\1`,
706
+ "g"
707
+ );
708
+ result = result.replace(propRegex, (match, quote, value) => {
709
+ if (propMapping.transform) {
710
+ const transformedValue = propMapping.transform(value);
711
+ return `${propMapping.bifyProp}=${quote}${transformedValue}${quote}`;
712
+ }
713
+ return `${propMapping.bifyProp}=${quote}${value}${quote}`;
714
+ });
715
+ const booleanPropRegex = new RegExp(`\\b${propMapping.arcoProp}\\b`, "g");
716
+ if (propMapping.transform) {
717
+ result = result.replace(booleanPropRegex, `${propMapping.bifyProp}=${propMapping.transform("")}`);
718
+ } else {
719
+ result = result.replace(booleanPropRegex, propMapping.bifyProp);
720
+ }
721
+ }
722
+ return result;
723
+ }
724
+ function applyValueMappings(props, mapping) {
725
+ if (!mapping.valueMappings) return props;
726
+ let result = props;
727
+ for (const [propName, valueMap] of Object.entries(mapping.valueMappings)) {
728
+ const propRegex = new RegExp(
729
+ `${propName}=(["'])(.*?)\\1`,
730
+ "g"
731
+ );
732
+ result = result.replace(propRegex, (match, quote, value) => {
733
+ const mappedValue = valueMap[value] || value;
734
+ return `${propName}=${quote}${mappedValue}${quote}`;
735
+ });
736
+ }
737
+ return result;
738
+ }
739
+ function convertIconImports(code) {
740
+ let result = code;
741
+ const arcoIconRegex = /import\s+Icon(\w+)\s+from\s+['"]@arco-design\/mobile-react\/es\/icon\/Icon(\w+)['"]/g;
742
+ result = result.replace(arcoIconRegex, 'import { Icon$1 } from "@fjyueke/bify-icons"');
743
+ const arcoIconsImportRegex = /import\s+\{([^}]+)\}\s+from\s+['"]@arco-design\/mobile-react\/es\/icon['"]/g;
744
+ result = result.replace(arcoIconsImportRegex, 'import { $1 } from "@fjyueke/bify-icons"');
745
+ return result;
746
+ }
747
+ function fixCodeFormat(code) {
748
+ let result = code;
749
+ result = result.replace(/\n{3,}/g, "\n\n");
750
+ result = result.replace(/import\s+\{\s*\}\s+from/g, "");
751
+ const lines = result.split("\n");
752
+ const nonEmptyLines = lines.filter((line) => line.trim() !== "");
753
+ result = nonEmptyLines.join("\n");
754
+ return result.trim();
755
+ }
756
+ async function getArcoConversionHelp() {
757
+ const availableComponents = componentMappings.filter((m) => m.bifyName).map((m) => `- ${m.arcoName} \u2192 ${m.bifyName}`).join("\n");
758
+ const valueMappingExamples = componentMappings.filter((m) => m.valueMappings).map((m) => {
759
+ const mappings = Object.entries(m.valueMappings).map(([prop, values]) => {
760
+ const valuePairs = Object.entries(values).map(([from, to]) => `${from} \u2192 ${to}`).join(", ");
761
+ return ` - ${prop}: ${valuePairs}`;
762
+ }).join("\n");
763
+ return `**${m.arcoName}**
764
+ ${mappings}`;
765
+ }).join("\n\n");
766
+ return `## Arco Mobile \u2192 Bify \u4EE3\u7801\u8F6C\u6362
767
+
768
+ ### \u652F\u6301\u7684\u7EC4\u4EF6 (${componentMappings.length} \u4E2A)
769
+
770
+ ${availableComponents}
771
+
772
+ ### \u503C\u6620\u5C04\u793A\u4F8B
773
+
774
+ ${valueMappingExamples || "\u6682\u65E0"}
775
+
776
+ ### \u4F7F\u7528\u65B9\u5F0F
777
+
778
+ \`\`\`tsx
779
+ // Arco Mobile \u4EE3\u7801
780
+ import { Cell, CellGroup, Button } from '@arco-design/mobile-react';
781
+
782
+ <CellGroup>
783
+ <Cell label="\u6807\u9898" desc="\u63CF\u8FF0" showArrow>\u5185\u5BB9</Cell>
784
+ </CellGroup>
785
+ <Button type="primary" ghost>\u6309\u94AE</Button>
786
+
787
+ // \u8F6C\u6362\u4E3A Bify \u4EE3\u7801
788
+ import { Cell, CellGroup, Button } from '@fjyueke/bify-core';
789
+
790
+ <CellGroup>
791
+ <Cell title="\u6807\u9898" brief="\u63CF\u8FF0" clickable>\u5185\u5BB9</Cell>
792
+ </CellGroup>
793
+ <Button type="primary" outlined>\u6309\u94AE</Button>
794
+ \`\`\`
795
+
796
+ ### \u5C5E\u6027\u6620\u5C04\u793A\u4F8B
797
+
798
+ | Arco \u5C5E\u6027 | Bify \u5C5E\u6027 | \u8BF4\u660E |
799
+ |-----------|-----------|------|
800
+ | \`label\` | \`title\` | \u5355\u5143\u683C\u6807\u9898 |
801
+ | \`desc\` | \`brief\` | \u5355\u5143\u683C\u63CF\u8FF0 |
802
+ | \`showArrow\` | \`clickable\` | \u662F\u5426\u663E\u793A\u7BAD\u5934 |
803
+ | \`visible\` | \`open\` | \u5F39\u7A97\u663E\u793A\u72B6\u6001 |
804
+ | \`value\` | \`modelValue\` | \u8868\u5355\u503C\u7ED1\u5B9A |
805
+ | \`ghost\` | \`outlined\` | \u9542\u7A7A\u6309\u94AE\u6837\u5F0F |
806
+ | \`max\` | \`count\` | Rate \u6700\u5927\u6570\u91CF |
807
+ | \`percent\` | \`percentage\` | Progress \u767E\u5206\u6BD4 |
808
+
809
+ ### \u8C03\u7528\u65B9\u5F0F
810
+
811
+ \u4F7F\u7528 \`convert-arco-to-bify\` \u5DE5\u5177\uFF0C\u4F20\u5165 Arco Mobile \u4EE3\u7801\u5373\u53EF\u83B7\u5F97\u8F6C\u6362\u540E\u7684 Bify \u4EE3\u7801\u3002`;
812
+ }
813
+
164
814
  // src/tools/components.ts
165
815
  function registerTifyTools(server) {
166
816
  server.tool(
@@ -228,6 +878,41 @@ function registerTifyTools(server) {
228
878
  };
229
879
  }
230
880
  );
881
+ server.tool(
882
+ "convert-arco-to-bify",
883
+ "Converts Arco Mobile React code to Bify code",
884
+ { arcoCode: z.string() },
885
+ async (args) => {
886
+ const convertedCode = await convertArcoToBify(args.arcoCode);
887
+ return {
888
+ content: [
889
+ {
890
+ type: "text",
891
+ text: `## \u8F6C\u6362\u7ED3\u679C
892
+
893
+ \`\`\`tsx
894
+ ${convertedCode}
895
+ \`\`\``
896
+ }
897
+ ]
898
+ };
899
+ }
900
+ );
901
+ server.tool(
902
+ "get-arco-conversion-help",
903
+ "Gets help information for Arco Mobile to Bify conversion",
904
+ async () => {
905
+ const help = await getArcoConversionHelp();
906
+ return {
907
+ content: [
908
+ {
909
+ type: "text",
910
+ text: help
911
+ }
912
+ ]
913
+ };
914
+ }
915
+ );
231
916
  }
232
917
 
233
918
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fjyueke/bify-mcp",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "description": "MCP UI builder by Bify",
6
6
  "license": "MIT",