@mybricks/plugin-ai 0.0.1

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 (37) hide show
  1. package/package.json +27 -0
  2. package/src/agents/app.ts +173 -0
  3. package/src/agents/common.ts +111 -0
  4. package/src/agents/index.ts +7 -0
  5. package/src/components/icons/index.less +8 -0
  6. package/src/components/icons/index.tsx +24 -0
  7. package/src/components/messages/index.less +806 -0
  8. package/src/components/messages/index.tsx +236 -0
  9. package/src/context/index.ts +21 -0
  10. package/src/data.ts +5 -0
  11. package/src/index.tsx +84 -0
  12. package/src/mock.ts +1267 -0
  13. package/src/startView/index.less +216 -0
  14. package/src/startView/index.tsx +229 -0
  15. package/src/tools/analyze-and-expand-prd.ts +166 -0
  16. package/src/tools/answer-user.ts +35 -0
  17. package/src/tools/focus-element.ts +47 -0
  18. package/src/tools/generate-page.ts +750 -0
  19. package/src/tools/get-component-info-by-ids.ts +166 -0
  20. package/src/tools/get-component-info.ts +53 -0
  21. package/src/tools/get-components-doc-and-prd.ts +137 -0
  22. package/src/tools/get-focus-mybricks-dsl.ts +26 -0
  23. package/src/tools/get-mybricks-dsl.ts +73 -0
  24. package/src/tools/index.ts +25 -0
  25. package/src/tools/modify-component.ts +385 -0
  26. package/src/tools/type.d.ts +12 -0
  27. package/src/tools/utils.ts +62 -0
  28. package/src/types.d.ts +65 -0
  29. package/src/view/components/header/header.less +17 -0
  30. package/src/view/components/header/header.tsx +15 -0
  31. package/src/view/components/index.ts +3 -0
  32. package/src/view/components/messages/messages.less +228 -0
  33. package/src/view/components/messages/messages.tsx +172 -0
  34. package/src/view/components/sender/sender.less +44 -0
  35. package/src/view/components/sender/sender.tsx +62 -0
  36. package/src/view/index.less +5 -0
  37. package/src/view/index.tsx +18 -0
@@ -0,0 +1,806 @@
1
+ .ai-chat-messages {
2
+ font-size: 12px;
3
+ overflow: auto;
4
+ flex-grow: 1;
5
+ display: flex;
6
+ flex-direction: column;
7
+ scroll-snap-type: y proximity;
8
+
9
+ &::-webkit-scrollbar {
10
+ width: 6px;
11
+ height: 0;
12
+ background-color: transparent
13
+ }
14
+
15
+ &::-webkit-scrollbar-track {
16
+ background-color: transparent
17
+ }
18
+
19
+ &::-webkit-scrollbar-thumb {
20
+ background-color: #c5c5c5;
21
+ border-radius: 6px
22
+ }
23
+
24
+ &:has(.ai-chat-messages-skeleton) {
25
+ padding: 16px
26
+ }
27
+
28
+ .ai-chat-messages-skeleton-header {
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: start;
32
+ gap: 8px;
33
+ margin-bottom: 8px;
34
+
35
+ &.user {
36
+ flex-direction: row-reverse;
37
+ justify-content: end;
38
+
39
+ .uipaas-skeleton-paragraph {
40
+ align-items: end
41
+ }
42
+ }
43
+ }
44
+
45
+ .ai-chat-messages-skeleton-item {
46
+ width: 100%
47
+ }
48
+
49
+ .chat-bubble {
50
+ display: flex;
51
+ flex-direction: column;
52
+ color: #333;
53
+ border-radius: 8px;
54
+ border: 1px solid transparent;
55
+ padding: 16px 16px 0;
56
+
57
+ &:has(.has-popover),
58
+ &:hover {
59
+ .chat-bubble-options {
60
+ opacity: 1
61
+ }
62
+ }
63
+
64
+ .chat-message-container:has(.user-message) {
65
+ padding: 8px 12px
66
+ }
67
+
68
+ .user-message img {
69
+ display: inline-block;
70
+ flex-shrink: 0;
71
+ width: auto;
72
+ height: 60px;
73
+ margin: 0;
74
+ object-fit: cover;
75
+
76
+ +& {
77
+ margin-left: 8px
78
+ }
79
+ }
80
+
81
+ .user-message p:has(img) {
82
+ display: flex;
83
+ align-items: center
84
+ }
85
+ }
86
+
87
+ .chat-bubble-header {
88
+ display: flex;
89
+ align-items: center;
90
+ justify-content: start;
91
+ gap: 8px;
92
+ padding-bottom: 8px;
93
+
94
+ .chat-bubble-header-avatar {
95
+ display: inline-flex;
96
+ align-items: center;
97
+ justify-content: center;
98
+ border-radius: 50%;
99
+ width: 20px;
100
+ height: 20px;
101
+ box-sizing: content-box;
102
+ border: 2px solid #ffffff;
103
+
104
+ .copilot-avatar {
105
+ .user-avatar();
106
+ }
107
+
108
+ .user-avatar {
109
+ width: 20px;
110
+ height: 20px;
111
+ border-radius: 50%
112
+ }
113
+ }
114
+
115
+ &:has(.user-avatar) {
116
+ justify-content: end;
117
+ flex-direction: row-reverse
118
+ }
119
+
120
+ .chat-bubble-header-name {
121
+ font-size: 12px;
122
+ color: #999
123
+ }
124
+ }
125
+
126
+ .chat-message-container {
127
+ user-select: text;
128
+ width: 100%;
129
+ font-size: 12px;
130
+ border-radius: 12px;
131
+ padding: 0;
132
+
133
+ +& {
134
+ margin-top: 8px
135
+ }
136
+
137
+ .chat-box-attachment-image {
138
+ margin-bottom: 0
139
+ }
140
+
141
+ .chat-box-attachment-image-item {
142
+ max-width: 100px;
143
+ width: auto;
144
+ height: auto
145
+ }
146
+ }
147
+
148
+ .chat-bubble-options {
149
+ padding: 10px 10px 0;
150
+ opacity: 0;
151
+
152
+ .chat-bubble-option-container {
153
+ display: flex;
154
+ align-items: center;
155
+ justify-content: start
156
+ }
157
+ }
158
+
159
+ .chat-bubble-option-icon {
160
+ font-size: 12px;
161
+ padding: 4px;
162
+ color: #00000080;
163
+
164
+ +& {
165
+ margin-left: 6px
166
+ }
167
+
168
+ +.chat-bubble-option-more {
169
+ margin-left: 6px
170
+ }
171
+ }
172
+
173
+ .welcome-message {
174
+ .welcome-message-self-introduction {
175
+ margin-top: 8px;
176
+ margin-bottom: 16px
177
+ }
178
+
179
+ .shortcuts {
180
+ display: flex;
181
+ flex-wrap: wrap;
182
+ gap: 8px;
183
+ margin-top: 8px;
184
+
185
+ .shortcuts-item {
186
+ flex-shrink: 0;
187
+ cursor: pointer;
188
+ display: inline-flex;
189
+ align-items: center;
190
+ padding: 4px 8px;
191
+ border: 1px solid #eeeeee;
192
+ border-radius: 4px;
193
+ color: #666;
194
+ background-color: #f3f3f3;
195
+
196
+ .shortcuts-item-label {
197
+ font-size: 12px
198
+ }
199
+
200
+ .shortcuts-item-icon {
201
+ display: inline-flex;
202
+ align-items: center;
203
+ justify-content: center;
204
+ width: 16px;
205
+ height: 16px;
206
+ margin-right: 8px;
207
+ font-size: 12px;
208
+ background: #666;
209
+ border-radius: 2px
210
+ }
211
+
212
+ &.shortcuts-theme-blue {
213
+ color: #0871f0;
214
+ border-color: #d0e5ff;
215
+ background-color: #ecf4ff;
216
+
217
+ .shortcuts-item-icon {
218
+ color: #fff;
219
+ background-color: #2885f6
220
+ }
221
+ }
222
+
223
+ &.shortcuts-theme-orange {
224
+ color: #f9a254;
225
+ border-color: #fae7d5;
226
+ background-color: #fff4e2;
227
+
228
+ .shortcuts-item-icon {
229
+ background-color: #f9a254
230
+ }
231
+ }
232
+
233
+ &.shortcuts-theme-green {
234
+ color: #70bc70;
235
+ border-color: #d4eed4;
236
+ background-color: #ecffec;
237
+
238
+ .shortcuts-item-icon {
239
+ background-color: #70bc70
240
+ }
241
+ }
242
+
243
+ &.shortcuts-theme-gray {
244
+ border-color: transparent;
245
+ transition: .3s;
246
+
247
+ &:hover {
248
+ background-color: #f7f7f7
249
+ }
250
+ }
251
+ }
252
+ }
253
+ }
254
+
255
+ .user-message {
256
+ width: fit-content;
257
+ max-width: calc(100% - 16px);
258
+ align-self: flex-end;
259
+ align-items: end;
260
+ background: #ecf4ff;
261
+ border-radius: 4px;
262
+ padding: 8px;
263
+ border-color: transparent;
264
+
265
+ .chat-bubble-option-container {
266
+ justify-content: end
267
+ }
268
+ }
269
+
270
+ .ai-message {
271
+ width: 100%;
272
+
273
+ &.error-message {
274
+ background-color: #fff2f2;
275
+ border-color: #fd9696;
276
+ color: #f44
277
+ }
278
+ }
279
+ }
280
+
281
+ .ai-chat-markdown {
282
+ color: #333;
283
+ white-space: pre-wrap;
284
+ word-break: break-word;
285
+
286
+ p {
287
+ margin: 8px 0
288
+ }
289
+
290
+ h1,
291
+ h2,
292
+ h3,
293
+ h4,
294
+ h5,
295
+ h6 {
296
+ margin-top: 20px;
297
+ margin-bottom: 10px;
298
+ font-weight: 600;
299
+ line-height: 1.5
300
+ }
301
+
302
+ h1 {
303
+ font-size: 2em;
304
+ border-bottom: 1px solid #eaecef;
305
+ padding-bottom: .3em
306
+ }
307
+
308
+ h2 {
309
+ font-size: 1.5em;
310
+ border-bottom: 1px solid #eaecef;
311
+ padding-bottom: .3em
312
+ }
313
+
314
+ h3 {
315
+ font-size: 1.25em
316
+ }
317
+
318
+ h4 {
319
+ font-size: 1em
320
+ }
321
+
322
+ h5 {
323
+ font-size: .875em
324
+ }
325
+
326
+ h6 {
327
+ font-size: .85em;
328
+ color: #6a737d
329
+ }
330
+
331
+ a {
332
+ color: #0366d6;
333
+ text-decoration: none;
334
+
335
+ &:hover {
336
+ text-decoration: underline
337
+ }
338
+ }
339
+
340
+ img,
341
+ .markdown-image {
342
+ max-width: 100%;
343
+ height: auto;
344
+ margin: 10px 0;
345
+ border-radius: 4px;
346
+ display: block
347
+ }
348
+
349
+ .markdown-image-container {
350
+ display: flex;
351
+ justify-content: flex-start;
352
+ align-items: center;
353
+ width: 100%
354
+ }
355
+
356
+ .markdown-image-clickable {
357
+ cursor: pointer;
358
+ max-width: 100%;
359
+ height: auto
360
+ }
361
+
362
+ .missing-image {
363
+ color: #666;
364
+ background-color: #f3f3f3;
365
+ border: 1px dashed #ccc;
366
+ border-radius: 4px;
367
+ padding: 8px 12px;
368
+ display: inline-block;
369
+ margin: 10px 0
370
+ }
371
+
372
+ blockquote {
373
+ padding: 0 1em;
374
+ color: #6a737d;
375
+ border-left: .25em solid #dfe2e5;
376
+ margin: 16px 0;
377
+
378
+ >p {
379
+ margin-top: 0;
380
+ margin-bottom: 0
381
+ }
382
+ }
383
+
384
+ table {
385
+ width: fit-content;
386
+ border-collapse: separate;
387
+ border-spacing: 0;
388
+ margin: 16px 0;
389
+ overflow-x: auto;
390
+ display: block;
391
+ font-size: 12px;
392
+ border-radius: 4px;
393
+ background-color: #fff;
394
+ border: 1px solid #eaeaea
395
+ }
396
+
397
+ table thead td,
398
+ table th,
399
+ table td {
400
+ padding: 10px 16px;
401
+ border-bottom: 1px solid #eaeaea;
402
+ border-right: none;
403
+ text-align: left;
404
+ word-break: break-word
405
+ }
406
+
407
+ table th:last-child,
408
+ table td:last-child {
409
+ border-right: none
410
+ }
411
+
412
+ table tr:last-child td {
413
+ border-bottom: none
414
+ }
415
+
416
+ table th:first-child {
417
+ border-top-left-radius: 4px
418
+ }
419
+
420
+ table th:last-child {
421
+ border-top-right-radius: 4px
422
+ }
423
+
424
+ table tr:last-child td:first-child {
425
+ border-bottom-left-radius: 4px
426
+ }
427
+
428
+ table tr:last-child td:last-child {
429
+ border-bottom-right-radius: 4px
430
+ }
431
+
432
+ table th {
433
+ background-color: #f6f8fa;
434
+ font-weight: 600;
435
+ border-bottom: 1px solid #eaeaea;
436
+ position: sticky;
437
+ top: 0;
438
+ z-index: 1
439
+ }
440
+
441
+ table tr {
442
+ transition: background-color .2s ease
443
+ }
444
+
445
+ table tr:hover {
446
+ background-color: #f1f8ff !important
447
+ }
448
+
449
+ ol,
450
+ ul {
451
+ margin-block-start: 0;
452
+ margin-block-end: 0;
453
+ margin-inline-start: 0;
454
+ margin-inline-end: 0;
455
+ padding-inline-start: 0;
456
+ margin: 8px 0;
457
+ padding-left: 0;
458
+
459
+ ol,
460
+ li {
461
+ padding-left: 1em
462
+ }
463
+ }
464
+
465
+ li {
466
+ position: relative;
467
+ margin: 4px 0;
468
+ padding-left: 1rem;
469
+ list-style-type: none
470
+ }
471
+
472
+ ul li:before {
473
+ content: "";
474
+ position: absolute;
475
+ left: 4px;
476
+ top: .75em;
477
+ width: 3px;
478
+ height: 3px;
479
+ background-color: currentColor;
480
+ border-radius: 50%
481
+ }
482
+
483
+ ol {
484
+ counter-reset: item
485
+ }
486
+
487
+ ol li {
488
+ padding-left: 0;
489
+ counter-increment: item
490
+ }
491
+
492
+ ol li:before {
493
+ content: counter(item) ".";
494
+ margin-right: 4px
495
+ }
496
+
497
+ >*:first-child {
498
+ margin-top: 0;
499
+
500
+ >*:first-child {
501
+ margin-top: 0
502
+ }
503
+ }
504
+
505
+ >*:last-child {
506
+ margin-bottom: 0;
507
+
508
+ >*:last-child {
509
+ margin-bottom: 0
510
+ }
511
+ }
512
+
513
+ code {
514
+ font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
515
+ background-color: #1b1f230d;
516
+ border-radius: 3px;
517
+ font-size: 85%;
518
+ padding: .2em .4em;
519
+ text-wrap: auto;
520
+ }
521
+
522
+ pre {
523
+ margin: 0;
524
+ overflow: auto;
525
+ white-space: pre-wrap;
526
+ word-break: break-word;
527
+
528
+ code {
529
+ padding: 0;
530
+ background-color: transparent;
531
+ font-size: 100%;
532
+ white-space: pre;
533
+ text-wrap: auto;
534
+ }
535
+ }
536
+
537
+ hr {
538
+ border: 0;
539
+ height: 1px;
540
+ background-color: #eaecef;
541
+ margin: 16px 0
542
+ }
543
+
544
+ .ai-chat-request-resource {
545
+ display: flex;
546
+ align-items: center;
547
+ justify-content: space-between;
548
+ color: #0366d6;
549
+ background-color: #e3f2fd85;
550
+ border-radius: 4px;
551
+ padding: 4px 8px;
552
+ font-size: 12px
553
+ }
554
+
555
+ .ai-chat-request-resource-message {
556
+ display: flex;
557
+ align-items: center;
558
+ gap: 4px
559
+ }
560
+
561
+ .ai-chat-request-resource-button {
562
+ display: flex;
563
+ align-items: center;
564
+ justify-content: center;
565
+ gap: 4px;
566
+ cursor: pointer
567
+ }
568
+
569
+ .ai-chat-request-resource-icon-success {
570
+ font-size: 12px;
571
+ color: #05aa2d
572
+ }
573
+
574
+ .ai-chat-request-resource-icon-failed {
575
+ font-size: 12px;
576
+ color: #d54941
577
+ }
578
+
579
+ .ai-chat-error-code-block {
580
+ display: flex;
581
+ align-items: center;
582
+ justify-content: space-between;
583
+ color: #d54941;
584
+ background-color: #fff0ed;
585
+ border-radius: 4px;
586
+ border: 1px solid #ffd8d2;
587
+ padding: 8px
588
+ }
589
+
590
+ .ai-chat-error-code-block-retry {
591
+ display: flex;
592
+ align-items: center;
593
+ justify-content: center;
594
+ gap: 4px;
595
+ width: 70px;
596
+ min-width: 62px;
597
+ color: #d54941;
598
+ background: #fff;
599
+ cursor: pointer;
600
+ font-size: 12px;
601
+ padding: 0 8px;
602
+ border: 1px solid #ffd8d2;
603
+ border-radius: 4px;
604
+
605
+ span {
606
+ white-space: nowrap
607
+ }
608
+ }
609
+
610
+ .ai-chat-error-code-block-retry:hover {
611
+ border-radius: 4px
612
+ }
613
+
614
+ .ai-chat-error-code-block-message {
615
+ display: flex;
616
+ align-items: center;
617
+ justify-content: center;
618
+ gap: 8px;
619
+ font-size: 12px;
620
+ overflow: hidden;
621
+
622
+ span {
623
+ line-height: 1.25;
624
+ text-overflow: ellipsis;
625
+ overflow: hidden
626
+ }
627
+ }
628
+
629
+ .ai-chat-collapsible-code-block {
630
+ background-color: #f3f3f3;
631
+ border-radius: 4px;
632
+ margin-bottom: 8px;
633
+ padding: 6px;
634
+ transition: all .4s cubic-bezier(.25, .8, .25, 1);
635
+ will-change: padding, height, transform;
636
+ transform-origin: top;
637
+
638
+ &:has(.collapsed) {
639
+ padding: 4px 8px;
640
+ transform: translateY(-1px)
641
+ }
642
+
643
+ .code-header {
644
+ display: flex;
645
+ align-items: center;
646
+ justify-content: space-between;
647
+ user-select: none;
648
+ border-radius: 4px;
649
+ min-height: 22px;
650
+ padding-bottom: 8px;
651
+ box-sizing: content-box;
652
+ transition: padding .4s cubic-bezier(.25, .8, .25, 1);
653
+
654
+ &:has(.collapsed) {
655
+ padding-bottom: 0
656
+ }
657
+
658
+ .code-title {
659
+ margin: 0;
660
+ display: flex;
661
+ align-items: center;
662
+ gap: 8px;
663
+ color: currentColor;
664
+ font-weight: 400
665
+ }
666
+
667
+ .code-title-status {
668
+ display: inline-flex;
669
+ align-items: center;
670
+ justify-content: center;
671
+
672
+ svg {
673
+ width: 10px;
674
+ height: 10px;
675
+ }
676
+
677
+ &.pending {
678
+ transform: translate(-2px);
679
+ }
680
+
681
+ &.success {
682
+ color: #05aa2d;
683
+
684
+ svg {
685
+ width: 14px;
686
+ height: 14px;
687
+ }
688
+ }
689
+
690
+ &.error {
691
+ color: #d54941;
692
+ }
693
+
694
+ &.aborted {
695
+ color: #faad14;
696
+ }
697
+ }
698
+
699
+ .code-toggle-button {
700
+ display: inline-flex;
701
+ align-items: center;
702
+ justify-content: center;
703
+ width: 24px;
704
+ height: 24px;
705
+ cursor: pointer;
706
+ border: none;
707
+ color: #666;
708
+ background-color: transparent;
709
+ border-radius: 4px;
710
+ transition: transform .4s cubic-bezier(.25, .8, .25, 1), color .2s ease;
711
+
712
+ &:hover {
713
+ color: #333
714
+ }
715
+
716
+ &.expanded {
717
+ transform: rotate(0)
718
+ }
719
+
720
+ &.collapsed {
721
+ transform: rotate(-90deg)
722
+ }
723
+ }
724
+ }
725
+
726
+ .code-content {
727
+ background-color: #fff;
728
+ border-radius: 4px;
729
+ width: 100%;
730
+ transition: height .4s cubic-bezier(.25, .8, .25, 1), opacity .3s ease, transform .4s cubic-bezier(.25, .8, .25, 1);
731
+ overflow: hidden;
732
+ transform-origin: top;
733
+
734
+ .code-content-inner {
735
+ padding: 8px 12px
736
+ }
737
+ }
738
+ }
739
+
740
+ .indent-2 {
741
+ margin-left: 1rem
742
+ }
743
+
744
+ .indent-4 {
745
+ margin-left: 2rem
746
+ }
747
+
748
+ .indent-6 {
749
+ margin-left: 3rem
750
+ }
751
+
752
+ .indent-8 {
753
+ margin-left: 4rem
754
+ }
755
+
756
+ li {
757
+ margin-bottom: .25rem
758
+ }
759
+
760
+ strong {
761
+ font-weight: 700
762
+ }
763
+
764
+ em {
765
+ font-style: italic
766
+ }
767
+
768
+ code {
769
+ background-color: #0000000d;
770
+ border-radius: 3px;
771
+ padding: .2em .4em;
772
+ font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
773
+ font-size: 85%;
774
+ text-wrap: auto;
775
+ }
776
+
777
+ .loading-shimmer {
778
+ -webkit-text-fill-color: transparent;
779
+ animation-delay: .5s;
780
+ animation-duration: 3s;
781
+ animation-iteration-count: infinite;
782
+ animation-name: loading-shimmer;
783
+ background: #adadad linear-gradient(to right, #adadad 0, #1a1a1abf 40%, #1a1a1abf 60%, #adadad 100%);
784
+ -webkit-background-clip: text;
785
+ background-clip: text;
786
+ background-repeat: no-repeat;
787
+ background-size: 50% 200%;
788
+ display: inline-block
789
+ }
790
+
791
+ .think {
792
+ display: flex;
793
+ align-items: center;
794
+
795
+ svg {
796
+ width: 10px;
797
+ height: 10px;
798
+ margin-left: 4px;
799
+ }
800
+ }
801
+ }
802
+
803
+ .anchor {
804
+ height: 1px;
805
+ scroll-snap-align: end;
806
+ }