ADAPT-Chase commited on
Commit
8344751
·
verified ·
1 Parent(s): 74496a2

Add files using upload-large-folder tool

Browse files
projects/ui/qwen-code/packages/cli/src/ui/themes/ansi.ts ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { type ColorsTheme, Theme } from './theme.js';
8
+ import { darkSemanticColors } from './semantic-tokens.js';
9
+
10
+ const ansiColors: ColorsTheme = {
11
+ type: 'dark',
12
+ Background: 'black',
13
+ Foreground: 'white',
14
+ LightBlue: 'bluebright',
15
+ AccentBlue: 'blue',
16
+ AccentPurple: 'magenta',
17
+ AccentCyan: 'cyan',
18
+ AccentGreen: 'green',
19
+ AccentYellow: 'yellow',
20
+ AccentRed: 'red',
21
+ DiffAdded: '#003300',
22
+ DiffRemoved: '#4D0000',
23
+ Comment: 'gray',
24
+ Gray: 'gray',
25
+ GradientColors: ['cyan', 'green'],
26
+ };
27
+
28
+ export const ANSI: Theme = new Theme(
29
+ 'ANSI',
30
+ 'dark', // Consistent with its color palette base
31
+ {
32
+ hljs: {
33
+ display: 'block',
34
+ overflowX: 'auto',
35
+ padding: '0.5em',
36
+ background: 'black', // Mapped from #1E1E1E
37
+ color: 'white', // Mapped from #DCDCDC
38
+ },
39
+ 'hljs-keyword': {
40
+ color: 'blue', // Mapped from #569CD6
41
+ },
42
+ 'hljs-literal': {
43
+ color: 'blue', // Mapped from #569CD6
44
+ },
45
+ 'hljs-symbol': {
46
+ color: 'blue', // Mapped from #569CD6
47
+ },
48
+ 'hljs-name': {
49
+ color: 'blue', // Mapped from #569CD6
50
+ },
51
+ 'hljs-link': {
52
+ color: 'blue', // Mapped from #569CD6
53
+ // textDecoration is ignored by Theme class
54
+ },
55
+ 'hljs-built_in': {
56
+ color: 'cyan', // Mapped from #4EC9B0
57
+ },
58
+ 'hljs-type': {
59
+ color: 'cyan', // Mapped from #4EC9B0
60
+ },
61
+ 'hljs-number': {
62
+ color: 'green', // Mapped from #B8D7A3
63
+ },
64
+ 'hljs-class': {
65
+ color: 'green', // Mapped from #B8D7A3
66
+ },
67
+ 'hljs-string': {
68
+ color: 'yellow', // Mapped from #D69D85
69
+ },
70
+ 'hljs-meta-string': {
71
+ color: 'yellow', // Mapped from #D69D85
72
+ },
73
+ 'hljs-regexp': {
74
+ color: 'red', // Mapped from #9A5334
75
+ },
76
+ 'hljs-template-tag': {
77
+ color: 'red', // Mapped from #9A5334
78
+ },
79
+ 'hljs-subst': {
80
+ color: 'white', // Mapped from #DCDCDC
81
+ },
82
+ 'hljs-function': {
83
+ color: 'white', // Mapped from #DCDCDC
84
+ },
85
+ 'hljs-title': {
86
+ color: 'white', // Mapped from #DCDCDC
87
+ },
88
+ 'hljs-params': {
89
+ color: 'white', // Mapped from #DCDCDC
90
+ },
91
+ 'hljs-formula': {
92
+ color: 'white', // Mapped from #DCDCDC
93
+ },
94
+ 'hljs-comment': {
95
+ color: 'green', // Mapped from #57A64A
96
+ // fontStyle is ignored by Theme class
97
+ },
98
+ 'hljs-quote': {
99
+ color: 'green', // Mapped from #57A64A
100
+ // fontStyle is ignored by Theme class
101
+ },
102
+ 'hljs-doctag': {
103
+ color: 'green', // Mapped from #608B4E
104
+ },
105
+ 'hljs-meta': {
106
+ color: 'gray', // Mapped from #9B9B9B
107
+ },
108
+ 'hljs-meta-keyword': {
109
+ color: 'gray', // Mapped from #9B9B9B
110
+ },
111
+ 'hljs-tag': {
112
+ color: 'gray', // Mapped from #9B9B9B
113
+ },
114
+ 'hljs-variable': {
115
+ color: 'magenta', // Mapped from #BD63C5
116
+ },
117
+ 'hljs-template-variable': {
118
+ color: 'magenta', // Mapped from #BD63C5
119
+ },
120
+ 'hljs-attr': {
121
+ color: 'bluebright', // Mapped from #9CDCFE
122
+ },
123
+ 'hljs-attribute': {
124
+ color: 'bluebright', // Mapped from #9CDCFE
125
+ },
126
+ 'hljs-builtin-name': {
127
+ color: 'bluebright', // Mapped from #9CDCFE
128
+ },
129
+ 'hljs-section': {
130
+ color: 'yellow', // Mapped from gold
131
+ },
132
+ 'hljs-emphasis': {
133
+ // fontStyle is ignored by Theme class
134
+ },
135
+ 'hljs-strong': {
136
+ // fontWeight is ignored by Theme class
137
+ },
138
+ 'hljs-bullet': {
139
+ color: 'yellow', // Mapped from #D7BA7D
140
+ },
141
+ 'hljs-selector-tag': {
142
+ color: 'yellow', // Mapped from #D7BA7D
143
+ },
144
+ 'hljs-selector-id': {
145
+ color: 'yellow', // Mapped from #D7BA7D
146
+ },
147
+ 'hljs-selector-class': {
148
+ color: 'yellow', // Mapped from #D7BA7D
149
+ },
150
+ 'hljs-selector-attr': {
151
+ color: 'yellow', // Mapped from #D7BA7D
152
+ },
153
+ 'hljs-selector-pseudo': {
154
+ color: 'yellow', // Mapped from #D7BA7D
155
+ },
156
+ },
157
+ ansiColors,
158
+ darkSemanticColors,
159
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/atom-one-dark.ts ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { type ColorsTheme, Theme } from './theme.js';
8
+ import { darkSemanticColors } from './semantic-tokens.js';
9
+
10
+ const atomOneDarkColors: ColorsTheme = {
11
+ type: 'dark',
12
+ Background: '#282c34',
13
+ Foreground: '#abb2bf',
14
+ LightBlue: '#61aeee',
15
+ AccentBlue: '#61aeee',
16
+ AccentPurple: '#c678dd',
17
+ AccentCyan: '#56b6c2',
18
+ AccentGreen: '#98c379',
19
+ AccentYellow: '#e6c07b',
20
+ AccentRed: '#e06c75',
21
+ DiffAdded: '#39544E',
22
+ DiffRemoved: '#562B2F',
23
+ Comment: '#5c6370',
24
+ Gray: '#5c6370',
25
+ GradientColors: ['#61aeee', '#98c379'],
26
+ };
27
+
28
+ export const AtomOneDark: Theme = new Theme(
29
+ 'Atom One',
30
+ 'dark',
31
+ {
32
+ hljs: {
33
+ display: 'block',
34
+ overflowX: 'auto',
35
+ padding: '0.5em',
36
+ color: atomOneDarkColors.Foreground,
37
+ background: atomOneDarkColors.Background,
38
+ },
39
+ 'hljs-comment': {
40
+ color: atomOneDarkColors.Comment,
41
+ fontStyle: 'italic',
42
+ },
43
+ 'hljs-quote': {
44
+ color: atomOneDarkColors.Comment,
45
+ fontStyle: 'italic',
46
+ },
47
+ 'hljs-doctag': {
48
+ color: atomOneDarkColors.AccentPurple,
49
+ },
50
+ 'hljs-keyword': {
51
+ color: atomOneDarkColors.AccentPurple,
52
+ },
53
+ 'hljs-formula': {
54
+ color: atomOneDarkColors.AccentPurple,
55
+ },
56
+ 'hljs-section': {
57
+ color: atomOneDarkColors.AccentRed,
58
+ },
59
+ 'hljs-name': {
60
+ color: atomOneDarkColors.AccentRed,
61
+ },
62
+ 'hljs-selector-tag': {
63
+ color: atomOneDarkColors.AccentRed,
64
+ },
65
+ 'hljs-deletion': {
66
+ color: atomOneDarkColors.AccentRed,
67
+ },
68
+ 'hljs-subst': {
69
+ color: atomOneDarkColors.AccentRed,
70
+ },
71
+ 'hljs-literal': {
72
+ color: atomOneDarkColors.AccentCyan,
73
+ },
74
+ 'hljs-string': {
75
+ color: atomOneDarkColors.AccentGreen,
76
+ },
77
+ 'hljs-regexp': {
78
+ color: atomOneDarkColors.AccentGreen,
79
+ },
80
+ 'hljs-addition': {
81
+ color: atomOneDarkColors.AccentGreen,
82
+ },
83
+ 'hljs-attribute': {
84
+ color: atomOneDarkColors.AccentGreen,
85
+ },
86
+ 'hljs-meta-string': {
87
+ color: atomOneDarkColors.AccentGreen,
88
+ },
89
+ 'hljs-built_in': {
90
+ color: atomOneDarkColors.AccentYellow,
91
+ },
92
+ 'hljs-class .hljs-title': {
93
+ color: atomOneDarkColors.AccentYellow,
94
+ },
95
+ 'hljs-attr': {
96
+ color: atomOneDarkColors.AccentYellow,
97
+ },
98
+ 'hljs-variable': {
99
+ color: atomOneDarkColors.AccentYellow,
100
+ },
101
+ 'hljs-template-variable': {
102
+ color: atomOneDarkColors.AccentYellow,
103
+ },
104
+ 'hljs-type': {
105
+ color: atomOneDarkColors.AccentYellow,
106
+ },
107
+ 'hljs-selector-class': {
108
+ color: atomOneDarkColors.AccentYellow,
109
+ },
110
+ 'hljs-selector-attr': {
111
+ color: atomOneDarkColors.AccentYellow,
112
+ },
113
+ 'hljs-selector-pseudo': {
114
+ color: atomOneDarkColors.AccentYellow,
115
+ },
116
+ 'hljs-number': {
117
+ color: atomOneDarkColors.AccentYellow,
118
+ },
119
+ 'hljs-symbol': {
120
+ color: atomOneDarkColors.AccentBlue,
121
+ },
122
+ 'hljs-bullet': {
123
+ color: atomOneDarkColors.AccentBlue,
124
+ },
125
+ 'hljs-link': {
126
+ color: atomOneDarkColors.AccentBlue,
127
+ textDecoration: 'underline',
128
+ },
129
+ 'hljs-meta': {
130
+ color: atomOneDarkColors.AccentBlue,
131
+ },
132
+ 'hljs-selector-id': {
133
+ color: atomOneDarkColors.AccentBlue,
134
+ },
135
+ 'hljs-title': {
136
+ color: atomOneDarkColors.AccentBlue,
137
+ },
138
+ 'hljs-emphasis': {
139
+ fontStyle: 'italic',
140
+ },
141
+ 'hljs-strong': {
142
+ fontWeight: 'bold',
143
+ },
144
+ },
145
+ atomOneDarkColors,
146
+ darkSemanticColors,
147
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/ayu-light.ts ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { type ColorsTheme, Theme } from './theme.js';
8
+ import { lightSemanticColors } from './semantic-tokens.js';
9
+
10
+ const ayuLightColors: ColorsTheme = {
11
+ type: 'light',
12
+ Background: '#f8f9fa',
13
+ Foreground: '#5c6166',
14
+ LightBlue: '#55b4d4',
15
+ AccentBlue: '#399ee6',
16
+ AccentPurple: '#a37acc',
17
+ AccentCyan: '#4cbf99',
18
+ AccentGreen: '#86b300',
19
+ AccentYellow: '#f2ae49',
20
+ AccentRed: '#f07171',
21
+ DiffAdded: '#C6EAD8',
22
+ DiffRemoved: '#FFCCCC',
23
+ Comment: '#ABADB1',
24
+ Gray: '#a6aaaf',
25
+ GradientColors: ['#399ee6', '#86b300'],
26
+ };
27
+
28
+ export const AyuLight: Theme = new Theme(
29
+ 'Ayu Light',
30
+ 'light',
31
+ {
32
+ hljs: {
33
+ display: 'block',
34
+ overflowX: 'auto',
35
+ padding: '0.5em',
36
+ background: ayuLightColors.Background,
37
+ color: ayuLightColors.Foreground,
38
+ },
39
+ 'hljs-comment': {
40
+ color: ayuLightColors.Comment,
41
+ fontStyle: 'italic',
42
+ },
43
+ 'hljs-quote': {
44
+ color: ayuLightColors.AccentCyan,
45
+ fontStyle: 'italic',
46
+ },
47
+ 'hljs-string': {
48
+ color: ayuLightColors.AccentGreen,
49
+ },
50
+ 'hljs-constant': {
51
+ color: ayuLightColors.AccentCyan,
52
+ },
53
+ 'hljs-number': {
54
+ color: ayuLightColors.AccentPurple,
55
+ },
56
+ 'hljs-keyword': {
57
+ color: ayuLightColors.AccentYellow,
58
+ },
59
+ 'hljs-selector-tag': {
60
+ color: ayuLightColors.AccentYellow,
61
+ },
62
+ 'hljs-attribute': {
63
+ color: ayuLightColors.AccentYellow,
64
+ },
65
+ 'hljs-variable': {
66
+ color: ayuLightColors.Foreground,
67
+ },
68
+ 'hljs-variable.language': {
69
+ color: ayuLightColors.LightBlue,
70
+ fontStyle: 'italic',
71
+ },
72
+ 'hljs-title': {
73
+ color: ayuLightColors.AccentBlue,
74
+ },
75
+ 'hljs-section': {
76
+ color: ayuLightColors.AccentGreen,
77
+ fontWeight: 'bold',
78
+ },
79
+ 'hljs-type': {
80
+ color: ayuLightColors.LightBlue,
81
+ },
82
+ 'hljs-class .hljs-title': {
83
+ color: ayuLightColors.AccentBlue,
84
+ },
85
+ 'hljs-tag': {
86
+ color: ayuLightColors.LightBlue,
87
+ },
88
+ 'hljs-name': {
89
+ color: ayuLightColors.AccentBlue,
90
+ },
91
+ 'hljs-builtin-name': {
92
+ color: ayuLightColors.AccentYellow,
93
+ },
94
+ 'hljs-meta': {
95
+ color: ayuLightColors.AccentYellow,
96
+ },
97
+ 'hljs-symbol': {
98
+ color: ayuLightColors.AccentRed,
99
+ },
100
+ 'hljs-bullet': {
101
+ color: ayuLightColors.AccentYellow,
102
+ },
103
+ 'hljs-regexp': {
104
+ color: ayuLightColors.AccentCyan,
105
+ },
106
+ 'hljs-link': {
107
+ color: ayuLightColors.LightBlue,
108
+ },
109
+ 'hljs-deletion': {
110
+ color: ayuLightColors.AccentRed,
111
+ },
112
+ 'hljs-addition': {
113
+ color: ayuLightColors.AccentGreen,
114
+ },
115
+ 'hljs-emphasis': {
116
+ fontStyle: 'italic',
117
+ },
118
+ 'hljs-strong': {
119
+ fontWeight: 'bold',
120
+ },
121
+ 'hljs-literal': {
122
+ color: ayuLightColors.AccentCyan,
123
+ },
124
+ 'hljs-built_in': {
125
+ color: ayuLightColors.AccentRed,
126
+ },
127
+ 'hljs-doctag': {
128
+ color: ayuLightColors.AccentRed,
129
+ },
130
+ 'hljs-template-variable': {
131
+ color: ayuLightColors.AccentCyan,
132
+ },
133
+ 'hljs-selector-id': {
134
+ color: ayuLightColors.AccentRed,
135
+ },
136
+ },
137
+ ayuLightColors,
138
+ lightSemanticColors,
139
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/ayu.ts ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { type ColorsTheme, Theme } from './theme.js';
8
+ import { darkSemanticColors } from './semantic-tokens.js';
9
+
10
+ const ayuDarkColors: ColorsTheme = {
11
+ type: 'dark',
12
+ Background: '#0b0e14',
13
+ Foreground: '#bfbdb6',
14
+ LightBlue: '#59C2FF',
15
+ AccentBlue: '#39BAE6',
16
+ AccentPurple: '#D2A6FF',
17
+ AccentCyan: '#95E6CB',
18
+ AccentGreen: '#AAD94C',
19
+ AccentYellow: '#FFB454',
20
+ AccentRed: '#F26D78',
21
+ DiffAdded: '#293022',
22
+ DiffRemoved: '#3D1215',
23
+ Comment: '#646A71',
24
+ Gray: '#3D4149',
25
+ GradientColors: ['#FFB454', '#F26D78'],
26
+ };
27
+
28
+ export const AyuDark: Theme = new Theme(
29
+ 'Ayu',
30
+ 'dark',
31
+ {
32
+ hljs: {
33
+ display: 'block',
34
+ overflowX: 'auto',
35
+ padding: '0.5em',
36
+ background: ayuDarkColors.Background,
37
+ color: ayuDarkColors.Foreground,
38
+ },
39
+ 'hljs-keyword': {
40
+ color: ayuDarkColors.AccentYellow,
41
+ },
42
+ 'hljs-literal': {
43
+ color: ayuDarkColors.AccentPurple,
44
+ },
45
+ 'hljs-symbol': {
46
+ color: ayuDarkColors.AccentCyan,
47
+ },
48
+ 'hljs-name': {
49
+ color: ayuDarkColors.LightBlue,
50
+ },
51
+ 'hljs-link': {
52
+ color: ayuDarkColors.AccentBlue,
53
+ },
54
+ 'hljs-function .hljs-keyword': {
55
+ color: ayuDarkColors.AccentYellow,
56
+ },
57
+ 'hljs-subst': {
58
+ color: ayuDarkColors.Foreground,
59
+ },
60
+ 'hljs-string': {
61
+ color: ayuDarkColors.AccentGreen,
62
+ },
63
+ 'hljs-title': {
64
+ color: ayuDarkColors.AccentYellow,
65
+ },
66
+ 'hljs-type': {
67
+ color: ayuDarkColors.AccentBlue,
68
+ },
69
+ 'hljs-attribute': {
70
+ color: ayuDarkColors.AccentYellow,
71
+ },
72
+ 'hljs-bullet': {
73
+ color: ayuDarkColors.AccentYellow,
74
+ },
75
+ 'hljs-addition': {
76
+ color: ayuDarkColors.AccentGreen,
77
+ },
78
+ 'hljs-variable': {
79
+ color: ayuDarkColors.Foreground,
80
+ },
81
+ 'hljs-template-tag': {
82
+ color: ayuDarkColors.AccentYellow,
83
+ },
84
+ 'hljs-template-variable': {
85
+ color: ayuDarkColors.AccentYellow,
86
+ },
87
+ 'hljs-comment': {
88
+ color: ayuDarkColors.Comment,
89
+ fontStyle: 'italic',
90
+ },
91
+ 'hljs-quote': {
92
+ color: ayuDarkColors.AccentCyan,
93
+ fontStyle: 'italic',
94
+ },
95
+ 'hljs-deletion': {
96
+ color: ayuDarkColors.AccentRed,
97
+ },
98
+ 'hljs-meta': {
99
+ color: ayuDarkColors.AccentYellow,
100
+ },
101
+ 'hljs-doctag': {
102
+ fontWeight: 'bold',
103
+ },
104
+ 'hljs-strong': {
105
+ fontWeight: 'bold',
106
+ },
107
+ 'hljs-emphasis': {
108
+ fontStyle: 'italic',
109
+ },
110
+ },
111
+ ayuDarkColors,
112
+ darkSemanticColors,
113
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/color-utils.test.ts ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { describe, it, expect } from 'vitest';
8
+ import {
9
+ isValidColor,
10
+ resolveColor,
11
+ CSS_NAME_TO_HEX_MAP,
12
+ INK_SUPPORTED_NAMES,
13
+ } from './color-utils.js';
14
+
15
+ describe('Color Utils', () => {
16
+ describe('isValidColor', () => {
17
+ it('should validate hex colors', () => {
18
+ expect(isValidColor('#ff0000')).toBe(true);
19
+ expect(isValidColor('#00ff00')).toBe(true);
20
+ expect(isValidColor('#0000ff')).toBe(true);
21
+ expect(isValidColor('#fff')).toBe(true);
22
+ expect(isValidColor('#000')).toBe(true);
23
+ expect(isValidColor('#FF0000')).toBe(true); // Case insensitive
24
+ });
25
+
26
+ it('should validate Ink-supported color names', () => {
27
+ expect(isValidColor('black')).toBe(true);
28
+ expect(isValidColor('red')).toBe(true);
29
+ expect(isValidColor('green')).toBe(true);
30
+ expect(isValidColor('yellow')).toBe(true);
31
+ expect(isValidColor('blue')).toBe(true);
32
+ expect(isValidColor('cyan')).toBe(true);
33
+ expect(isValidColor('magenta')).toBe(true);
34
+ expect(isValidColor('white')).toBe(true);
35
+ expect(isValidColor('gray')).toBe(true);
36
+ expect(isValidColor('grey')).toBe(true);
37
+ expect(isValidColor('blackbright')).toBe(true);
38
+ expect(isValidColor('redbright')).toBe(true);
39
+ expect(isValidColor('greenbright')).toBe(true);
40
+ expect(isValidColor('yellowbright')).toBe(true);
41
+ expect(isValidColor('bluebright')).toBe(true);
42
+ expect(isValidColor('cyanbright')).toBe(true);
43
+ expect(isValidColor('magentabright')).toBe(true);
44
+ expect(isValidColor('whitebright')).toBe(true);
45
+ });
46
+
47
+ it('should validate Ink-supported color names case insensitive', () => {
48
+ expect(isValidColor('BLACK')).toBe(true);
49
+ expect(isValidColor('Red')).toBe(true);
50
+ expect(isValidColor('GREEN')).toBe(true);
51
+ });
52
+
53
+ it('should validate CSS color names', () => {
54
+ expect(isValidColor('darkkhaki')).toBe(true);
55
+ expect(isValidColor('coral')).toBe(true);
56
+ expect(isValidColor('teal')).toBe(true);
57
+ expect(isValidColor('tomato')).toBe(true);
58
+ expect(isValidColor('turquoise')).toBe(true);
59
+ expect(isValidColor('violet')).toBe(true);
60
+ expect(isValidColor('wheat')).toBe(true);
61
+ expect(isValidColor('whitesmoke')).toBe(true);
62
+ expect(isValidColor('yellowgreen')).toBe(true);
63
+ });
64
+
65
+ it('should validate CSS color names case insensitive', () => {
66
+ expect(isValidColor('DARKKHAKI')).toBe(true);
67
+ expect(isValidColor('Coral')).toBe(true);
68
+ expect(isValidColor('TEAL')).toBe(true);
69
+ });
70
+
71
+ it('should reject invalid color names', () => {
72
+ expect(isValidColor('invalidcolor')).toBe(false);
73
+ expect(isValidColor('notacolor')).toBe(false);
74
+ expect(isValidColor('')).toBe(false);
75
+ });
76
+ });
77
+
78
+ describe('resolveColor', () => {
79
+ it('should resolve hex colors', () => {
80
+ expect(resolveColor('#ff0000')).toBe('#ff0000');
81
+ expect(resolveColor('#00ff00')).toBe('#00ff00');
82
+ expect(resolveColor('#0000ff')).toBe('#0000ff');
83
+ expect(resolveColor('#fff')).toBe('#fff');
84
+ expect(resolveColor('#000')).toBe('#000');
85
+ });
86
+
87
+ it('should resolve Ink-supported color names', () => {
88
+ expect(resolveColor('black')).toBe('black');
89
+ expect(resolveColor('red')).toBe('red');
90
+ expect(resolveColor('green')).toBe('green');
91
+ expect(resolveColor('yellow')).toBe('yellow');
92
+ expect(resolveColor('blue')).toBe('blue');
93
+ expect(resolveColor('cyan')).toBe('cyan');
94
+ expect(resolveColor('magenta')).toBe('magenta');
95
+ expect(resolveColor('white')).toBe('white');
96
+ expect(resolveColor('gray')).toBe('gray');
97
+ expect(resolveColor('grey')).toBe('grey');
98
+ });
99
+
100
+ it('should resolve CSS color names to hex', () => {
101
+ expect(resolveColor('darkkhaki')).toBe('#bdb76b');
102
+ expect(resolveColor('coral')).toBe('#ff7f50');
103
+ expect(resolveColor('teal')).toBe('#008080');
104
+ expect(resolveColor('tomato')).toBe('#ff6347');
105
+ expect(resolveColor('turquoise')).toBe('#40e0d0');
106
+ expect(resolveColor('violet')).toBe('#ee82ee');
107
+ expect(resolveColor('wheat')).toBe('#f5deb3');
108
+ expect(resolveColor('whitesmoke')).toBe('#f5f5f5');
109
+ expect(resolveColor('yellowgreen')).toBe('#9acd32');
110
+ });
111
+
112
+ it('should handle case insensitive color names', () => {
113
+ expect(resolveColor('DARKKHAKI')).toBe('#bdb76b');
114
+ expect(resolveColor('Coral')).toBe('#ff7f50');
115
+ expect(resolveColor('TEAL')).toBe('#008080');
116
+ });
117
+
118
+ it('should return undefined for invalid colors', () => {
119
+ expect(resolveColor('invalidcolor')).toBeUndefined();
120
+ expect(resolveColor('notacolor')).toBeUndefined();
121
+ expect(resolveColor('')).toBeUndefined();
122
+ });
123
+ });
124
+
125
+ describe('CSS_NAME_TO_HEX_MAP', () => {
126
+ it('should contain expected CSS color mappings', () => {
127
+ expect(CSS_NAME_TO_HEX_MAP['darkkhaki']).toBe('#bdb76b');
128
+ expect(CSS_NAME_TO_HEX_MAP['coral']).toBe('#ff7f50');
129
+ expect(CSS_NAME_TO_HEX_MAP['teal']).toBe('#008080');
130
+ expect(CSS_NAME_TO_HEX_MAP['tomato']).toBe('#ff6347');
131
+ expect(CSS_NAME_TO_HEX_MAP['turquoise']).toBe('#40e0d0');
132
+ });
133
+
134
+ it('should not contain Ink-supported color names', () => {
135
+ expect(CSS_NAME_TO_HEX_MAP['black']).toBeUndefined();
136
+ expect(CSS_NAME_TO_HEX_MAP['red']).toBeUndefined();
137
+ expect(CSS_NAME_TO_HEX_MAP['green']).toBeUndefined();
138
+ expect(CSS_NAME_TO_HEX_MAP['blue']).toBeUndefined();
139
+ });
140
+ });
141
+
142
+ describe('INK_SUPPORTED_NAMES', () => {
143
+ it('should contain all Ink-supported color names', () => {
144
+ expect(INK_SUPPORTED_NAMES.has('black')).toBe(true);
145
+ expect(INK_SUPPORTED_NAMES.has('red')).toBe(true);
146
+ expect(INK_SUPPORTED_NAMES.has('green')).toBe(true);
147
+ expect(INK_SUPPORTED_NAMES.has('yellow')).toBe(true);
148
+ expect(INK_SUPPORTED_NAMES.has('blue')).toBe(true);
149
+ expect(INK_SUPPORTED_NAMES.has('cyan')).toBe(true);
150
+ expect(INK_SUPPORTED_NAMES.has('magenta')).toBe(true);
151
+ expect(INK_SUPPORTED_NAMES.has('white')).toBe(true);
152
+ expect(INK_SUPPORTED_NAMES.has('gray')).toBe(true);
153
+ expect(INK_SUPPORTED_NAMES.has('grey')).toBe(true);
154
+ expect(INK_SUPPORTED_NAMES.has('blackbright')).toBe(true);
155
+ expect(INK_SUPPORTED_NAMES.has('redbright')).toBe(true);
156
+ expect(INK_SUPPORTED_NAMES.has('greenbright')).toBe(true);
157
+ expect(INK_SUPPORTED_NAMES.has('yellowbright')).toBe(true);
158
+ expect(INK_SUPPORTED_NAMES.has('bluebright')).toBe(true);
159
+ expect(INK_SUPPORTED_NAMES.has('cyanbright')).toBe(true);
160
+ expect(INK_SUPPORTED_NAMES.has('magentabright')).toBe(true);
161
+ expect(INK_SUPPORTED_NAMES.has('whitebright')).toBe(true);
162
+ });
163
+
164
+ it('should not contain CSS color names', () => {
165
+ expect(INK_SUPPORTED_NAMES.has('darkkhaki')).toBe(false);
166
+ expect(INK_SUPPORTED_NAMES.has('coral')).toBe(false);
167
+ expect(INK_SUPPORTED_NAMES.has('teal')).toBe(false);
168
+ });
169
+ });
170
+
171
+ describe('Consistency between validation and resolution', () => {
172
+ it('should have consistent behavior between isValidColor and resolveColor', () => {
173
+ // Test that any color that isValidColor returns true for can be resolved
174
+ const testColors = [
175
+ '#ff0000',
176
+ '#00ff00',
177
+ '#0000ff',
178
+ '#fff',
179
+ '#000',
180
+ 'black',
181
+ 'red',
182
+ 'green',
183
+ 'yellow',
184
+ 'blue',
185
+ 'cyan',
186
+ 'magenta',
187
+ 'white',
188
+ 'gray',
189
+ 'grey',
190
+ 'darkkhaki',
191
+ 'coral',
192
+ 'teal',
193
+ 'tomato',
194
+ 'turquoise',
195
+ 'violet',
196
+ 'wheat',
197
+ 'whitesmoke',
198
+ 'yellowgreen',
199
+ ];
200
+
201
+ for (const color of testColors) {
202
+ expect(isValidColor(color)).toBe(true);
203
+ expect(resolveColor(color)).toBeDefined();
204
+ }
205
+
206
+ // Test that invalid colors are consistently rejected
207
+ const invalidColors = [
208
+ 'invalidcolor',
209
+ 'notacolor',
210
+ '',
211
+ '#gg0000',
212
+ '#ff00',
213
+ ];
214
+
215
+ for (const color of invalidColors) {
216
+ expect(isValidColor(color)).toBe(false);
217
+ expect(resolveColor(color)).toBeUndefined();
218
+ }
219
+ });
220
+ });
221
+ });
projects/ui/qwen-code/packages/cli/src/ui/themes/color-utils.ts ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ // Mapping from common CSS color names (lowercase) to hex codes (lowercase)
8
+ // Excludes names directly supported by Ink
9
+ export const CSS_NAME_TO_HEX_MAP: Readonly<Record<string, string>> = {
10
+ aliceblue: '#f0f8ff',
11
+ antiquewhite: '#faebd7',
12
+ aqua: '#00ffff',
13
+ aquamarine: '#7fffd4',
14
+ azure: '#f0ffff',
15
+ beige: '#f5f5dc',
16
+ bisque: '#ffe4c4',
17
+ blanchedalmond: '#ffebcd',
18
+ blueviolet: '#8a2be2',
19
+ brown: '#a52a2a',
20
+ burlywood: '#deb887',
21
+ cadetblue: '#5f9ea0',
22
+ chartreuse: '#7fff00',
23
+ chocolate: '#d2691e',
24
+ coral: '#ff7f50',
25
+ cornflowerblue: '#6495ed',
26
+ cornsilk: '#fff8dc',
27
+ crimson: '#dc143c',
28
+ darkblue: '#00008b',
29
+ darkcyan: '#008b8b',
30
+ darkgoldenrod: '#b8860b',
31
+ darkgray: '#a9a9a9',
32
+ darkgrey: '#a9a9a9',
33
+ darkgreen: '#006400',
34
+ darkkhaki: '#bdb76b',
35
+ darkmagenta: '#8b008b',
36
+ darkolivegreen: '#556b2f',
37
+ darkorange: '#ff8c00',
38
+ darkorchid: '#9932cc',
39
+ darkred: '#8b0000',
40
+ darksalmon: '#e9967a',
41
+ darkseagreen: '#8fbc8f',
42
+ darkslateblue: '#483d8b',
43
+ darkslategray: '#2f4f4f',
44
+ darkslategrey: '#2f4f4f',
45
+ darkturquoise: '#00ced1',
46
+ darkviolet: '#9400d3',
47
+ deeppink: '#ff1493',
48
+ deepskyblue: '#00bfff',
49
+ dimgray: '#696969',
50
+ dimgrey: '#696969',
51
+ dodgerblue: '#1e90ff',
52
+ firebrick: '#b22222',
53
+ floralwhite: '#fffaf0',
54
+ forestgreen: '#228b22',
55
+ fuchsia: '#ff00ff',
56
+ gainsboro: '#dcdcdc',
57
+ ghostwhite: '#f8f8ff',
58
+ gold: '#ffd700',
59
+ goldenrod: '#daa520',
60
+ greenyellow: '#adff2f',
61
+ honeydew: '#f0fff0',
62
+ hotpink: '#ff69b4',
63
+ indianred: '#cd5c5c',
64
+ indigo: '#4b0082',
65
+ ivory: '#fffff0',
66
+ khaki: '#f0e68c',
67
+ lavender: '#e6e6fa',
68
+ lavenderblush: '#fff0f5',
69
+ lawngreen: '#7cfc00',
70
+ lemonchiffon: '#fffacd',
71
+ lightblue: '#add8e6',
72
+ lightcoral: '#f08080',
73
+ lightcyan: '#e0ffff',
74
+ lightgoldenrodyellow: '#fafad2',
75
+ lightgray: '#d3d3d3',
76
+ lightgrey: '#d3d3d3',
77
+ lightgreen: '#90ee90',
78
+ lightpink: '#ffb6c1',
79
+ lightsalmon: '#ffa07a',
80
+ lightseagreen: '#20b2aa',
81
+ lightskyblue: '#87cefa',
82
+ lightslategray: '#778899',
83
+ lightslategrey: '#778899',
84
+ lightsteelblue: '#b0c4de',
85
+ lightyellow: '#ffffe0',
86
+ lime: '#00ff00',
87
+ limegreen: '#32cd32',
88
+ linen: '#faf0e6',
89
+ maroon: '#800000',
90
+ mediumaquamarine: '#66cdaa',
91
+ mediumblue: '#0000cd',
92
+ mediumorchid: '#ba55d3',
93
+ mediumpurple: '#9370db',
94
+ mediumseagreen: '#3cb371',
95
+ mediumslateblue: '#7b68ee',
96
+ mediumspringgreen: '#00fa9a',
97
+ mediumturquoise: '#48d1cc',
98
+ mediumvioletred: '#c71585',
99
+ midnightblue: '#191970',
100
+ mintcream: '#f5fffa',
101
+ mistyrose: '#ffe4e1',
102
+ moccasin: '#ffe4b5',
103
+ navajowhite: '#ffdead',
104
+ navy: '#000080',
105
+ oldlace: '#fdf5e6',
106
+ olive: '#808000',
107
+ olivedrab: '#6b8e23',
108
+ orange: '#ffa500',
109
+ orangered: '#ff4500',
110
+ orchid: '#da70d6',
111
+ palegoldenrod: '#eee8aa',
112
+ palegreen: '#98fb98',
113
+ paleturquoise: '#afeeee',
114
+ palevioletred: '#db7093',
115
+ papayawhip: '#ffefd5',
116
+ peachpuff: '#ffdab9',
117
+ peru: '#cd853f',
118
+ pink: '#ffc0cb',
119
+ plum: '#dda0dd',
120
+ powderblue: '#b0e0e6',
121
+ purple: '#800080',
122
+ rebeccapurple: '#663399',
123
+ rosybrown: '#bc8f8f',
124
+ royalblue: '#4169e1',
125
+ saddlebrown: '#8b4513',
126
+ salmon: '#fa8072',
127
+ sandybrown: '#f4a460',
128
+ seagreen: '#2e8b57',
129
+ seashell: '#fff5ee',
130
+ sienna: '#a0522d',
131
+ silver: '#c0c0c0',
132
+ skyblue: '#87ceeb',
133
+ slateblue: '#6a5acd',
134
+ slategray: '#708090',
135
+ slategrey: '#708090',
136
+ snow: '#fffafa',
137
+ springgreen: '#00ff7f',
138
+ steelblue: '#4682b4',
139
+ tan: '#d2b48c',
140
+ teal: '#008080',
141
+ thistle: '#d8bfd8',
142
+ tomato: '#ff6347',
143
+ turquoise: '#40e0d0',
144
+ violet: '#ee82ee',
145
+ wheat: '#f5deb3',
146
+ whitesmoke: '#f5f5f5',
147
+ yellowgreen: '#9acd32',
148
+ };
149
+
150
+ // Define the set of Ink's named colors for quick lookup
151
+ export const INK_SUPPORTED_NAMES = new Set([
152
+ 'black',
153
+ 'red',
154
+ 'green',
155
+ 'yellow',
156
+ 'blue',
157
+ 'cyan',
158
+ 'magenta',
159
+ 'white',
160
+ 'gray',
161
+ 'grey',
162
+ 'blackbright',
163
+ 'redbright',
164
+ 'greenbright',
165
+ 'yellowbright',
166
+ 'bluebright',
167
+ 'cyanbright',
168
+ 'magentabright',
169
+ 'whitebright',
170
+ ]);
171
+
172
+ /**
173
+ * Checks if a color string is valid (hex, Ink-supported color name, or CSS color name).
174
+ * This function uses the same validation logic as the Theme class's _resolveColor method
175
+ * to ensure consistency between validation and resolution.
176
+ * @param color The color string to validate.
177
+ * @returns True if the color is valid.
178
+ */
179
+ export function isValidColor(color: string): boolean {
180
+ const lowerColor = color.toLowerCase();
181
+
182
+ // 1. Check if it's a hex code
183
+ if (lowerColor.startsWith('#')) {
184
+ return /^#[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$/.test(color);
185
+ }
186
+
187
+ // 2. Check if it's an Ink supported name
188
+ if (INK_SUPPORTED_NAMES.has(lowerColor)) {
189
+ return true;
190
+ }
191
+
192
+ // 3. Check if it's a known CSS name we can map to hex
193
+ if (CSS_NAME_TO_HEX_MAP[lowerColor]) {
194
+ return true;
195
+ }
196
+
197
+ // 4. Not a valid color
198
+ return false;
199
+ }
200
+
201
+ /**
202
+ * Resolves a CSS color value (name or hex) into an Ink-compatible color string.
203
+ * @param colorValue The raw color string (e.g., 'blue', '#ff0000', 'darkkhaki').
204
+ * @returns An Ink-compatible color string (hex or name), or undefined if not resolvable.
205
+ */
206
+ export function resolveColor(colorValue: string): string | undefined {
207
+ const lowerColor = colorValue.toLowerCase();
208
+
209
+ // 1. Check if it's already a hex code and valid
210
+ if (lowerColor.startsWith('#')) {
211
+ if (/^#[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$/.test(colorValue)) {
212
+ return lowerColor;
213
+ } else {
214
+ return undefined;
215
+ }
216
+ }
217
+ // 2. Check if it's an Ink supported name (lowercase)
218
+ else if (INK_SUPPORTED_NAMES.has(lowerColor)) {
219
+ return lowerColor; // Use Ink name directly
220
+ }
221
+ // 3. Check if it's a known CSS name we can map to hex
222
+ else if (CSS_NAME_TO_HEX_MAP[lowerColor]) {
223
+ return CSS_NAME_TO_HEX_MAP[lowerColor]; // Use mapped hex
224
+ }
225
+
226
+ // 4. Could not resolve
227
+ console.warn(
228
+ `[ColorUtils] Could not resolve color "${colorValue}" to an Ink-compatible format.`,
229
+ );
230
+ return undefined;
231
+ }
projects/ui/qwen-code/packages/cli/src/ui/themes/default-light.ts ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { lightTheme, Theme } from './theme.js';
8
+ import { lightSemanticColors } from './semantic-tokens.js';
9
+
10
+ export const DefaultLight: Theme = new Theme(
11
+ 'Default Light',
12
+ 'light',
13
+ {
14
+ hljs: {
15
+ display: 'block',
16
+ overflowX: 'auto',
17
+ padding: '0.5em',
18
+ background: lightTheme.Background,
19
+ color: lightTheme.Foreground,
20
+ },
21
+ 'hljs-comment': {
22
+ color: lightTheme.Comment,
23
+ },
24
+ 'hljs-quote': {
25
+ color: lightTheme.Comment,
26
+ },
27
+ 'hljs-variable': {
28
+ color: lightTheme.Foreground,
29
+ },
30
+ 'hljs-keyword': {
31
+ color: lightTheme.AccentBlue,
32
+ },
33
+ 'hljs-selector-tag': {
34
+ color: lightTheme.AccentBlue,
35
+ },
36
+ 'hljs-built_in': {
37
+ color: lightTheme.AccentBlue,
38
+ },
39
+ 'hljs-name': {
40
+ color: lightTheme.AccentBlue,
41
+ },
42
+ 'hljs-tag': {
43
+ color: lightTheme.AccentBlue,
44
+ },
45
+ 'hljs-string': {
46
+ color: lightTheme.AccentRed,
47
+ },
48
+ 'hljs-title': {
49
+ color: lightTheme.AccentRed,
50
+ },
51
+ 'hljs-section': {
52
+ color: lightTheme.AccentRed,
53
+ },
54
+ 'hljs-attribute': {
55
+ color: lightTheme.AccentRed,
56
+ },
57
+ 'hljs-literal': {
58
+ color: lightTheme.AccentRed,
59
+ },
60
+ 'hljs-template-tag': {
61
+ color: lightTheme.AccentRed,
62
+ },
63
+ 'hljs-template-variable': {
64
+ color: lightTheme.AccentRed,
65
+ },
66
+ 'hljs-type': {
67
+ color: lightTheme.AccentRed,
68
+ },
69
+ 'hljs-addition': {
70
+ color: lightTheme.AccentGreen,
71
+ },
72
+ 'hljs-deletion': {
73
+ color: lightTheme.AccentRed,
74
+ },
75
+ 'hljs-selector-attr': {
76
+ color: lightTheme.AccentCyan,
77
+ },
78
+ 'hljs-selector-pseudo': {
79
+ color: lightTheme.AccentCyan,
80
+ },
81
+ 'hljs-meta': {
82
+ color: lightTheme.AccentCyan,
83
+ },
84
+ 'hljs-doctag': {
85
+ color: lightTheme.Gray,
86
+ },
87
+ 'hljs-attr': {
88
+ color: lightTheme.AccentRed,
89
+ },
90
+ 'hljs-symbol': {
91
+ color: lightTheme.AccentCyan,
92
+ },
93
+ 'hljs-bullet': {
94
+ color: lightTheme.AccentCyan,
95
+ },
96
+ 'hljs-link': {
97
+ color: lightTheme.AccentCyan,
98
+ },
99
+ 'hljs-emphasis': {
100
+ fontStyle: 'italic',
101
+ },
102
+ 'hljs-strong': {
103
+ fontWeight: 'bold',
104
+ },
105
+ },
106
+ lightTheme,
107
+ lightSemanticColors,
108
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/default.ts ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { darkTheme, Theme } from './theme.js';
8
+ import { darkSemanticColors } from './semantic-tokens.js';
9
+
10
+ export const DefaultDark: Theme = new Theme(
11
+ 'Default',
12
+ 'dark',
13
+ {
14
+ hljs: {
15
+ display: 'block',
16
+ overflowX: 'auto',
17
+ padding: '0.5em',
18
+ background: darkTheme.Background,
19
+ color: darkTheme.Foreground,
20
+ },
21
+ 'hljs-keyword': {
22
+ color: darkTheme.AccentBlue,
23
+ },
24
+ 'hljs-literal': {
25
+ color: darkTheme.AccentBlue,
26
+ },
27
+ 'hljs-symbol': {
28
+ color: darkTheme.AccentBlue,
29
+ },
30
+ 'hljs-name': {
31
+ color: darkTheme.AccentBlue,
32
+ },
33
+ 'hljs-link': {
34
+ color: darkTheme.AccentBlue,
35
+ textDecoration: 'underline',
36
+ },
37
+ 'hljs-built_in': {
38
+ color: darkTheme.AccentCyan,
39
+ },
40
+ 'hljs-type': {
41
+ color: darkTheme.AccentCyan,
42
+ },
43
+ 'hljs-number': {
44
+ color: darkTheme.AccentGreen,
45
+ },
46
+ 'hljs-class': {
47
+ color: darkTheme.AccentGreen,
48
+ },
49
+ 'hljs-string': {
50
+ color: darkTheme.AccentYellow,
51
+ },
52
+ 'hljs-meta-string': {
53
+ color: darkTheme.AccentYellow,
54
+ },
55
+ 'hljs-regexp': {
56
+ color: darkTheme.AccentRed,
57
+ },
58
+ 'hljs-template-tag': {
59
+ color: darkTheme.AccentRed,
60
+ },
61
+ 'hljs-subst': {
62
+ color: darkTheme.Foreground,
63
+ },
64
+ 'hljs-function': {
65
+ color: darkTheme.Foreground,
66
+ },
67
+ 'hljs-title': {
68
+ color: darkTheme.Foreground,
69
+ },
70
+ 'hljs-params': {
71
+ color: darkTheme.Foreground,
72
+ },
73
+ 'hljs-formula': {
74
+ color: darkTheme.Foreground,
75
+ },
76
+ 'hljs-comment': {
77
+ color: darkTheme.Comment,
78
+ fontStyle: 'italic',
79
+ },
80
+ 'hljs-quote': {
81
+ color: darkTheme.Comment,
82
+ fontStyle: 'italic',
83
+ },
84
+ 'hljs-doctag': {
85
+ color: darkTheme.Comment,
86
+ },
87
+ 'hljs-meta': {
88
+ color: darkTheme.Gray,
89
+ },
90
+ 'hljs-meta-keyword': {
91
+ color: darkTheme.Gray,
92
+ },
93
+ 'hljs-tag': {
94
+ color: darkTheme.Gray,
95
+ },
96
+ 'hljs-variable': {
97
+ color: darkTheme.AccentPurple,
98
+ },
99
+ 'hljs-template-variable': {
100
+ color: darkTheme.AccentPurple,
101
+ },
102
+ 'hljs-attr': {
103
+ color: darkTheme.LightBlue,
104
+ },
105
+ 'hljs-attribute': {
106
+ color: darkTheme.LightBlue,
107
+ },
108
+ 'hljs-builtin-name': {
109
+ color: darkTheme.LightBlue,
110
+ },
111
+ 'hljs-section': {
112
+ color: darkTheme.AccentYellow,
113
+ },
114
+ 'hljs-emphasis': {
115
+ fontStyle: 'italic',
116
+ },
117
+ 'hljs-strong': {
118
+ fontWeight: 'bold',
119
+ },
120
+ 'hljs-bullet': {
121
+ color: darkTheme.AccentYellow,
122
+ },
123
+ 'hljs-selector-tag': {
124
+ color: darkTheme.AccentYellow,
125
+ },
126
+ 'hljs-selector-id': {
127
+ color: darkTheme.AccentYellow,
128
+ },
129
+ 'hljs-selector-class': {
130
+ color: darkTheme.AccentYellow,
131
+ },
132
+ 'hljs-selector-attr': {
133
+ color: darkTheme.AccentYellow,
134
+ },
135
+ 'hljs-selector-pseudo': {
136
+ color: darkTheme.AccentYellow,
137
+ },
138
+ 'hljs-addition': {
139
+ backgroundColor: '#144212',
140
+ display: 'inline-block',
141
+ width: '100%',
142
+ },
143
+ 'hljs-deletion': {
144
+ backgroundColor: '#600',
145
+ display: 'inline-block',
146
+ width: '100%',
147
+ },
148
+ },
149
+ darkTheme,
150
+ darkSemanticColors,
151
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/dracula.ts ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { type ColorsTheme, Theme } from './theme.js';
8
+ import { darkSemanticColors } from './semantic-tokens.js';
9
+
10
+ const draculaColors: ColorsTheme = {
11
+ type: 'dark',
12
+ Background: '#282a36',
13
+ Foreground: '#f8f8f2',
14
+ LightBlue: '#8be9fd',
15
+ AccentBlue: '#8be9fd',
16
+ AccentPurple: '#ff79c6',
17
+ AccentCyan: '#8be9fd',
18
+ AccentGreen: '#50fa7b',
19
+ AccentYellow: '#f1fa8c',
20
+ AccentRed: '#ff5555',
21
+ DiffAdded: '#11431d',
22
+ DiffRemoved: '#6e1818',
23
+ Comment: '#6272a4',
24
+ Gray: '#6272a4',
25
+ GradientColors: ['#ff79c6', '#8be9fd'],
26
+ };
27
+
28
+ export const Dracula: Theme = new Theme(
29
+ 'Dracula',
30
+ 'dark',
31
+ {
32
+ hljs: {
33
+ display: 'block',
34
+ overflowX: 'auto',
35
+ padding: '0.5em',
36
+ background: draculaColors.Background,
37
+ color: draculaColors.Foreground,
38
+ },
39
+ 'hljs-keyword': {
40
+ color: draculaColors.AccentBlue,
41
+ fontWeight: 'bold',
42
+ },
43
+ 'hljs-selector-tag': {
44
+ color: draculaColors.AccentBlue,
45
+ fontWeight: 'bold',
46
+ },
47
+ 'hljs-literal': {
48
+ color: draculaColors.AccentBlue,
49
+ fontWeight: 'bold',
50
+ },
51
+ 'hljs-section': {
52
+ color: draculaColors.AccentBlue,
53
+ fontWeight: 'bold',
54
+ },
55
+ 'hljs-link': {
56
+ color: draculaColors.AccentBlue,
57
+ },
58
+ 'hljs-function .hljs-keyword': {
59
+ color: draculaColors.AccentPurple,
60
+ },
61
+ 'hljs-subst': {
62
+ color: draculaColors.Foreground,
63
+ },
64
+ 'hljs-string': {
65
+ color: draculaColors.AccentYellow,
66
+ },
67
+ 'hljs-title': {
68
+ color: draculaColors.AccentYellow,
69
+ fontWeight: 'bold',
70
+ },
71
+ 'hljs-name': {
72
+ color: draculaColors.AccentYellow,
73
+ fontWeight: 'bold',
74
+ },
75
+ 'hljs-type': {
76
+ color: draculaColors.AccentYellow,
77
+ fontWeight: 'bold',
78
+ },
79
+ 'hljs-attribute': {
80
+ color: draculaColors.AccentYellow,
81
+ },
82
+ 'hljs-symbol': {
83
+ color: draculaColors.AccentYellow,
84
+ },
85
+ 'hljs-bullet': {
86
+ color: draculaColors.AccentYellow,
87
+ },
88
+ 'hljs-addition': {
89
+ color: draculaColors.AccentGreen,
90
+ },
91
+ 'hljs-variable': {
92
+ color: draculaColors.AccentYellow,
93
+ },
94
+ 'hljs-template-tag': {
95
+ color: draculaColors.AccentYellow,
96
+ },
97
+ 'hljs-template-variable': {
98
+ color: draculaColors.AccentYellow,
99
+ },
100
+ 'hljs-comment': {
101
+ color: draculaColors.Comment,
102
+ },
103
+ 'hljs-quote': {
104
+ color: draculaColors.Comment,
105
+ },
106
+ 'hljs-deletion': {
107
+ color: draculaColors.AccentRed,
108
+ },
109
+ 'hljs-meta': {
110
+ color: draculaColors.Comment,
111
+ },
112
+ 'hljs-doctag': {
113
+ fontWeight: 'bold',
114
+ },
115
+ 'hljs-strong': {
116
+ fontWeight: 'bold',
117
+ },
118
+ 'hljs-emphasis': {
119
+ fontStyle: 'italic',
120
+ },
121
+ },
122
+ draculaColors,
123
+ darkSemanticColors,
124
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/github-dark.ts ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { type ColorsTheme, Theme } from './theme.js';
8
+ import { darkSemanticColors } from './semantic-tokens.js';
9
+
10
+ const githubDarkColors: ColorsTheme = {
11
+ type: 'dark',
12
+ Background: '#24292e',
13
+ Foreground: '#d1d5da',
14
+ LightBlue: '#79B8FF',
15
+ AccentBlue: '#79B8FF',
16
+ AccentPurple: '#B392F0',
17
+ AccentCyan: '#9ECBFF',
18
+ AccentGreen: '#85E89D',
19
+ AccentYellow: '#FFAB70',
20
+ AccentRed: '#F97583',
21
+ DiffAdded: '#3C4636',
22
+ DiffRemoved: '#502125',
23
+ Comment: '#6A737D',
24
+ Gray: '#6A737D',
25
+ GradientColors: ['#79B8FF', '#85E89D'],
26
+ };
27
+
28
+ export const GitHubDark: Theme = new Theme(
29
+ 'GitHub',
30
+ 'dark',
31
+ {
32
+ hljs: {
33
+ display: 'block',
34
+ overflowX: 'auto',
35
+ padding: '0.5em',
36
+ color: githubDarkColors.Foreground,
37
+ background: githubDarkColors.Background,
38
+ },
39
+ 'hljs-comment': {
40
+ color: githubDarkColors.Comment,
41
+ fontStyle: 'italic',
42
+ },
43
+ 'hljs-quote': {
44
+ color: githubDarkColors.Comment,
45
+ fontStyle: 'italic',
46
+ },
47
+ 'hljs-keyword': {
48
+ color: githubDarkColors.AccentRed,
49
+ fontWeight: 'bold',
50
+ },
51
+ 'hljs-selector-tag': {
52
+ color: githubDarkColors.AccentRed,
53
+ fontWeight: 'bold',
54
+ },
55
+ 'hljs-subst': {
56
+ color: githubDarkColors.Foreground,
57
+ },
58
+ 'hljs-number': {
59
+ color: githubDarkColors.LightBlue,
60
+ },
61
+ 'hljs-literal': {
62
+ color: githubDarkColors.LightBlue,
63
+ },
64
+ 'hljs-variable': {
65
+ color: githubDarkColors.AccentYellow,
66
+ },
67
+ 'hljs-template-variable': {
68
+ color: githubDarkColors.AccentYellow,
69
+ },
70
+ 'hljs-tag .hljs-attr': {
71
+ color: githubDarkColors.AccentYellow,
72
+ },
73
+ 'hljs-string': {
74
+ color: githubDarkColors.AccentCyan,
75
+ },
76
+ 'hljs-doctag': {
77
+ color: githubDarkColors.AccentCyan,
78
+ },
79
+ 'hljs-title': {
80
+ color: githubDarkColors.AccentPurple,
81
+ fontWeight: 'bold',
82
+ },
83
+ 'hljs-section': {
84
+ color: githubDarkColors.AccentPurple,
85
+ fontWeight: 'bold',
86
+ },
87
+ 'hljs-selector-id': {
88
+ color: githubDarkColors.AccentPurple,
89
+ fontWeight: 'bold',
90
+ },
91
+ 'hljs-type': {
92
+ color: githubDarkColors.AccentGreen,
93
+ fontWeight: 'bold',
94
+ },
95
+ 'hljs-class .hljs-title': {
96
+ color: githubDarkColors.AccentGreen,
97
+ fontWeight: 'bold',
98
+ },
99
+ 'hljs-tag': {
100
+ color: githubDarkColors.AccentGreen,
101
+ },
102
+ 'hljs-name': {
103
+ color: githubDarkColors.AccentGreen,
104
+ },
105
+ 'hljs-attribute': {
106
+ color: githubDarkColors.LightBlue,
107
+ },
108
+ 'hljs-regexp': {
109
+ color: githubDarkColors.AccentCyan,
110
+ },
111
+ 'hljs-link': {
112
+ color: githubDarkColors.AccentCyan,
113
+ },
114
+ 'hljs-symbol': {
115
+ color: githubDarkColors.AccentPurple,
116
+ },
117
+ 'hljs-bullet': {
118
+ color: githubDarkColors.AccentPurple,
119
+ },
120
+ 'hljs-built_in': {
121
+ color: githubDarkColors.LightBlue,
122
+ },
123
+ 'hljs-builtin-name': {
124
+ color: githubDarkColors.LightBlue,
125
+ },
126
+ 'hljs-meta': {
127
+ color: githubDarkColors.LightBlue,
128
+ fontWeight: 'bold',
129
+ },
130
+ 'hljs-deletion': {
131
+ background: '#86181D',
132
+ color: githubDarkColors.AccentRed,
133
+ },
134
+ 'hljs-addition': {
135
+ background: '#144620',
136
+ color: githubDarkColors.AccentGreen,
137
+ },
138
+ 'hljs-emphasis': {
139
+ fontStyle: 'italic',
140
+ },
141
+ 'hljs-strong': {
142
+ fontWeight: 'bold',
143
+ },
144
+ },
145
+ githubDarkColors,
146
+ darkSemanticColors,
147
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/github-light.ts ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { type ColorsTheme, Theme } from './theme.js';
8
+ import { lightSemanticColors } from './semantic-tokens.js';
9
+
10
+ const githubLightColors: ColorsTheme = {
11
+ type: 'light',
12
+ Background: '#f8f8f8',
13
+ Foreground: '#24292E',
14
+ LightBlue: '#0086b3',
15
+ AccentBlue: '#458',
16
+ AccentPurple: '#900',
17
+ AccentCyan: '#009926',
18
+ AccentGreen: '#008080',
19
+ AccentYellow: '#990073',
20
+ AccentRed: '#d14',
21
+ DiffAdded: '#C6EAD8',
22
+ DiffRemoved: '#FFCCCC',
23
+ Comment: '#998',
24
+ Gray: '#999',
25
+ GradientColors: ['#458', '#008080'],
26
+ };
27
+
28
+ export const GitHubLight: Theme = new Theme(
29
+ 'GitHub Light',
30
+ 'light',
31
+ {
32
+ hljs: {
33
+ display: 'block',
34
+ overflowX: 'auto',
35
+ padding: '0.5em',
36
+ color: githubLightColors.Foreground,
37
+ background: githubLightColors.Background,
38
+ },
39
+ 'hljs-comment': {
40
+ color: githubLightColors.Comment,
41
+ fontStyle: 'italic',
42
+ },
43
+ 'hljs-quote': {
44
+ color: githubLightColors.Comment,
45
+ fontStyle: 'italic',
46
+ },
47
+ 'hljs-keyword': {
48
+ color: githubLightColors.Foreground,
49
+ fontWeight: 'bold',
50
+ },
51
+ 'hljs-selector-tag': {
52
+ color: githubLightColors.Foreground,
53
+ fontWeight: 'bold',
54
+ },
55
+ 'hljs-subst': {
56
+ color: githubLightColors.Foreground,
57
+ fontWeight: 'normal',
58
+ },
59
+ 'hljs-number': {
60
+ color: githubLightColors.AccentGreen,
61
+ },
62
+ 'hljs-literal': {
63
+ color: githubLightColors.AccentGreen,
64
+ },
65
+ 'hljs-variable': {
66
+ color: githubLightColors.AccentGreen,
67
+ },
68
+ 'hljs-template-variable': {
69
+ color: githubLightColors.AccentGreen,
70
+ },
71
+ 'hljs-tag .hljs-attr': {
72
+ color: githubLightColors.AccentGreen,
73
+ },
74
+ 'hljs-string': {
75
+ color: githubLightColors.AccentRed,
76
+ },
77
+ 'hljs-doctag': {
78
+ color: githubLightColors.AccentRed,
79
+ },
80
+ 'hljs-title': {
81
+ color: githubLightColors.AccentPurple,
82
+ fontWeight: 'bold',
83
+ },
84
+ 'hljs-section': {
85
+ color: githubLightColors.AccentPurple,
86
+ fontWeight: 'bold',
87
+ },
88
+ 'hljs-selector-id': {
89
+ color: githubLightColors.AccentPurple,
90
+ fontWeight: 'bold',
91
+ },
92
+ 'hljs-type': {
93
+ color: githubLightColors.AccentBlue,
94
+ fontWeight: 'bold',
95
+ },
96
+ 'hljs-class .hljs-title': {
97
+ color: githubLightColors.AccentBlue,
98
+ fontWeight: 'bold',
99
+ },
100
+ 'hljs-tag': {
101
+ color: githubLightColors.AccentBlue,
102
+ fontWeight: 'normal',
103
+ },
104
+ 'hljs-name': {
105
+ color: githubLightColors.AccentBlue,
106
+ fontWeight: 'normal',
107
+ },
108
+ 'hljs-attribute': {
109
+ color: githubLightColors.AccentBlue,
110
+ fontWeight: 'normal',
111
+ },
112
+ 'hljs-regexp': {
113
+ color: githubLightColors.AccentCyan,
114
+ },
115
+ 'hljs-link': {
116
+ color: githubLightColors.AccentCyan,
117
+ },
118
+ 'hljs-symbol': {
119
+ color: githubLightColors.AccentYellow,
120
+ },
121
+ 'hljs-bullet': {
122
+ color: githubLightColors.AccentYellow,
123
+ },
124
+ 'hljs-built_in': {
125
+ color: githubLightColors.LightBlue,
126
+ },
127
+ 'hljs-builtin-name': {
128
+ color: githubLightColors.LightBlue,
129
+ },
130
+ 'hljs-meta': {
131
+ color: githubLightColors.Gray,
132
+ fontWeight: 'bold',
133
+ },
134
+ 'hljs-deletion': {
135
+ background: '#fdd',
136
+ },
137
+ 'hljs-addition': {
138
+ background: '#dfd',
139
+ },
140
+ 'hljs-emphasis': {
141
+ fontStyle: 'italic',
142
+ },
143
+ 'hljs-strong': {
144
+ fontWeight: 'bold',
145
+ },
146
+ },
147
+ githubLightColors,
148
+ lightSemanticColors,
149
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/googlecode.ts ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { lightTheme, Theme, type ColorsTheme } from './theme.js';
8
+ import { lightSemanticColors } from './semantic-tokens.js';
9
+
10
+ const googleCodeColors: ColorsTheme = {
11
+ type: 'light',
12
+ Background: 'white',
13
+ Foreground: '#444',
14
+ LightBlue: '#066',
15
+ AccentBlue: '#008',
16
+ AccentPurple: '#606',
17
+ AccentCyan: '#066',
18
+ AccentGreen: '#080',
19
+ AccentYellow: '#660',
20
+ AccentRed: '#800',
21
+ DiffAdded: '#C6EAD8',
22
+ DiffRemoved: '#FEDEDE',
23
+ Comment: '#5f6368',
24
+ Gray: lightTheme.Gray,
25
+ GradientColors: ['#066', '#606'],
26
+ };
27
+
28
+ export const GoogleCode: Theme = new Theme(
29
+ 'Google Code',
30
+ 'light',
31
+ {
32
+ hljs: {
33
+ display: 'block',
34
+ overflowX: 'auto',
35
+ padding: '0.5em',
36
+ background: googleCodeColors.Background,
37
+ color: googleCodeColors.Foreground,
38
+ },
39
+ 'hljs-comment': {
40
+ color: googleCodeColors.AccentRed,
41
+ },
42
+ 'hljs-quote': {
43
+ color: googleCodeColors.AccentRed,
44
+ },
45
+ 'hljs-keyword': {
46
+ color: googleCodeColors.AccentBlue,
47
+ },
48
+ 'hljs-selector-tag': {
49
+ color: googleCodeColors.AccentBlue,
50
+ },
51
+ 'hljs-section': {
52
+ color: googleCodeColors.AccentBlue,
53
+ },
54
+ 'hljs-title': {
55
+ color: googleCodeColors.AccentPurple,
56
+ },
57
+ 'hljs-name': {
58
+ color: googleCodeColors.AccentBlue,
59
+ },
60
+ 'hljs-variable': {
61
+ color: googleCodeColors.AccentYellow,
62
+ },
63
+ 'hljs-template-variable': {
64
+ color: googleCodeColors.AccentYellow,
65
+ },
66
+ 'hljs-string': {
67
+ color: googleCodeColors.AccentGreen,
68
+ },
69
+ 'hljs-selector-attr': {
70
+ color: googleCodeColors.AccentGreen,
71
+ },
72
+ 'hljs-selector-pseudo': {
73
+ color: googleCodeColors.AccentGreen,
74
+ },
75
+ 'hljs-regexp': {
76
+ color: googleCodeColors.AccentGreen,
77
+ },
78
+ 'hljs-literal': {
79
+ color: googleCodeColors.AccentCyan,
80
+ },
81
+ 'hljs-symbol': {
82
+ color: googleCodeColors.AccentCyan,
83
+ },
84
+ 'hljs-bullet': {
85
+ color: googleCodeColors.AccentCyan,
86
+ },
87
+ 'hljs-meta': {
88
+ color: googleCodeColors.AccentCyan,
89
+ },
90
+ 'hljs-number': {
91
+ color: googleCodeColors.AccentCyan,
92
+ },
93
+ 'hljs-link': {
94
+ color: googleCodeColors.AccentCyan,
95
+ },
96
+ 'hljs-doctag': {
97
+ color: googleCodeColors.AccentPurple,
98
+ fontWeight: 'bold',
99
+ },
100
+ 'hljs-type': {
101
+ color: googleCodeColors.AccentPurple,
102
+ },
103
+ 'hljs-attr': {
104
+ color: googleCodeColors.AccentPurple,
105
+ },
106
+ 'hljs-built_in': {
107
+ color: googleCodeColors.AccentPurple,
108
+ },
109
+ 'hljs-builtin-name': {
110
+ color: googleCodeColors.AccentPurple,
111
+ },
112
+ 'hljs-params': {
113
+ color: googleCodeColors.AccentPurple,
114
+ },
115
+ 'hljs-attribute': {
116
+ color: googleCodeColors.Foreground,
117
+ },
118
+ 'hljs-subst': {
119
+ color: googleCodeColors.Foreground,
120
+ },
121
+ 'hljs-formula': {
122
+ backgroundColor: '#eee',
123
+ fontStyle: 'italic',
124
+ },
125
+ 'hljs-selector-id': {
126
+ color: googleCodeColors.AccentYellow,
127
+ },
128
+ 'hljs-selector-class': {
129
+ color: googleCodeColors.AccentYellow,
130
+ },
131
+ 'hljs-addition': {
132
+ backgroundColor: '#baeeba',
133
+ },
134
+ 'hljs-deletion': {
135
+ backgroundColor: '#ffc8bd',
136
+ },
137
+ 'hljs-strong': {
138
+ fontWeight: 'bold',
139
+ },
140
+ 'hljs-emphasis': {
141
+ fontStyle: 'italic',
142
+ },
143
+ },
144
+ googleCodeColors,
145
+ lightSemanticColors,
146
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/no-color.ts ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { Theme, ColorsTheme } from './theme.js';
8
+ import { SemanticColors } from './semantic-tokens.js';
9
+
10
+ const noColorColorsTheme: ColorsTheme = {
11
+ type: 'ansi',
12
+ Background: '',
13
+ Foreground: '',
14
+ LightBlue: '',
15
+ AccentBlue: '',
16
+ AccentPurple: '',
17
+ AccentCyan: '',
18
+ AccentGreen: '',
19
+ AccentYellow: '',
20
+ AccentRed: '',
21
+ DiffAdded: '',
22
+ DiffRemoved: '',
23
+ Comment: '',
24
+ Gray: '',
25
+ };
26
+
27
+ const noColorSemanticColors: SemanticColors = {
28
+ text: {
29
+ primary: '',
30
+ secondary: '',
31
+ link: '',
32
+ accent: '',
33
+ },
34
+ background: {
35
+ primary: '',
36
+ diff: {
37
+ added: '',
38
+ removed: '',
39
+ },
40
+ },
41
+ border: {
42
+ default: '',
43
+ focused: '',
44
+ },
45
+ ui: {
46
+ comment: '',
47
+ symbol: '',
48
+ gradient: [],
49
+ },
50
+ status: {
51
+ error: '',
52
+ success: '',
53
+ warning: '',
54
+ },
55
+ };
56
+
57
+ export const NoColorTheme: Theme = new Theme(
58
+ 'NoColor',
59
+ 'dark',
60
+ {
61
+ hljs: {
62
+ display: 'block',
63
+ overflowX: 'auto',
64
+ padding: '0.5em',
65
+ },
66
+ 'hljs-keyword': {},
67
+ 'hljs-literal': {},
68
+ 'hljs-symbol': {},
69
+ 'hljs-name': {},
70
+ 'hljs-link': {
71
+ textDecoration: 'underline',
72
+ },
73
+ 'hljs-built_in': {},
74
+ 'hljs-type': {},
75
+ 'hljs-number': {},
76
+ 'hljs-class': {},
77
+ 'hljs-string': {},
78
+ 'hljs-meta-string': {},
79
+ 'hljs-regexp': {},
80
+ 'hljs-template-tag': {},
81
+ 'hljs-subst': {},
82
+ 'hljs-function': {},
83
+ 'hljs-title': {},
84
+ 'hljs-params': {},
85
+ 'hljs-formula': {},
86
+ 'hljs-comment': {
87
+ fontStyle: 'italic',
88
+ },
89
+ 'hljs-quote': {
90
+ fontStyle: 'italic',
91
+ },
92
+ 'hljs-doctag': {},
93
+ 'hljs-meta': {},
94
+ 'hljs-meta-keyword': {},
95
+ 'hljs-tag': {},
96
+ 'hljs-variable': {},
97
+ 'hljs-template-variable': {},
98
+ 'hljs-attr': {},
99
+ 'hljs-attribute': {},
100
+ 'hljs-builtin-name': {},
101
+ 'hljs-section': {},
102
+ 'hljs-emphasis': {
103
+ fontStyle: 'italic',
104
+ },
105
+ 'hljs-strong': {
106
+ fontWeight: 'bold',
107
+ },
108
+ 'hljs-bullet': {},
109
+ 'hljs-selector-tag': {},
110
+ 'hljs-selector-id': {},
111
+ 'hljs-selector-class': {},
112
+ 'hljs-selector-attr': {},
113
+ 'hljs-selector-pseudo': {},
114
+ 'hljs-addition': {
115
+ display: 'inline-block',
116
+ width: '100%',
117
+ },
118
+ 'hljs-deletion': {
119
+ display: 'inline-block',
120
+ width: '100%',
121
+ },
122
+ },
123
+ noColorColorsTheme,
124
+ noColorSemanticColors,
125
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/qwen-dark.ts ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { type ColorsTheme, Theme } from './theme.js';
8
+ import { darkSemanticColors } from './semantic-tokens.js';
9
+
10
+ const qwenDarkColors: ColorsTheme = {
11
+ type: 'dark',
12
+ Background: '#0b0e14',
13
+ Foreground: '#bfbdb6',
14
+ LightBlue: '#59C2FF',
15
+ AccentBlue: '#39BAE6',
16
+ AccentPurple: '#D2A6FF',
17
+ AccentCyan: '#95E6CB',
18
+ AccentGreen: '#AAD94C',
19
+ AccentYellow: '#FFD700',
20
+ AccentRed: '#F26D78',
21
+ DiffAdded: '#AAD94C',
22
+ DiffRemoved: '#F26D78',
23
+ Comment: '#646A71',
24
+ Gray: '#3D4149',
25
+ GradientColors: ['#FFD700', '#da7959'],
26
+ };
27
+
28
+ export const QwenDark: Theme = new Theme(
29
+ 'Qwen Dark',
30
+ 'dark',
31
+ {
32
+ hljs: {
33
+ display: 'block',
34
+ overflowX: 'auto',
35
+ padding: '0.5em',
36
+ background: qwenDarkColors.Background,
37
+ color: qwenDarkColors.Foreground,
38
+ },
39
+ 'hljs-keyword': {
40
+ color: qwenDarkColors.AccentYellow,
41
+ },
42
+ 'hljs-literal': {
43
+ color: qwenDarkColors.AccentPurple,
44
+ },
45
+ 'hljs-symbol': {
46
+ color: qwenDarkColors.AccentCyan,
47
+ },
48
+ 'hljs-name': {
49
+ color: qwenDarkColors.LightBlue,
50
+ },
51
+ 'hljs-link': {
52
+ color: qwenDarkColors.AccentBlue,
53
+ },
54
+ 'hljs-function .hljs-keyword': {
55
+ color: qwenDarkColors.AccentYellow,
56
+ },
57
+ 'hljs-subst': {
58
+ color: qwenDarkColors.Foreground,
59
+ },
60
+ 'hljs-string': {
61
+ color: qwenDarkColors.AccentGreen,
62
+ },
63
+ 'hljs-title': {
64
+ color: qwenDarkColors.AccentYellow,
65
+ },
66
+ 'hljs-type': {
67
+ color: qwenDarkColors.AccentBlue,
68
+ },
69
+ 'hljs-attribute': {
70
+ color: qwenDarkColors.AccentYellow,
71
+ },
72
+ 'hljs-bullet': {
73
+ color: qwenDarkColors.AccentYellow,
74
+ },
75
+ 'hljs-addition': {
76
+ color: qwenDarkColors.AccentGreen,
77
+ },
78
+ 'hljs-variable': {
79
+ color: qwenDarkColors.Foreground,
80
+ },
81
+ 'hljs-template-tag': {
82
+ color: qwenDarkColors.AccentYellow,
83
+ },
84
+ 'hljs-template-variable': {
85
+ color: qwenDarkColors.AccentYellow,
86
+ },
87
+ 'hljs-comment': {
88
+ color: qwenDarkColors.Comment,
89
+ fontStyle: 'italic',
90
+ },
91
+ 'hljs-quote': {
92
+ color: qwenDarkColors.AccentCyan,
93
+ fontStyle: 'italic',
94
+ },
95
+ 'hljs-deletion': {
96
+ color: qwenDarkColors.AccentRed,
97
+ },
98
+ 'hljs-meta': {
99
+ color: qwenDarkColors.AccentYellow,
100
+ },
101
+ 'hljs-doctag': {
102
+ fontWeight: 'bold',
103
+ },
104
+ 'hljs-strong': {
105
+ fontWeight: 'bold',
106
+ },
107
+ 'hljs-emphasis': {
108
+ fontStyle: 'italic',
109
+ },
110
+ },
111
+ qwenDarkColors,
112
+ darkSemanticColors,
113
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/qwen-light.ts ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { type ColorsTheme, Theme } from './theme.js';
8
+ import { lightSemanticColors } from './semantic-tokens.js';
9
+
10
+ const qwenLightColors: ColorsTheme = {
11
+ type: 'light',
12
+ Background: '#f8f9fa',
13
+ Foreground: '#5c6166',
14
+ LightBlue: '#55b4d4',
15
+ AccentBlue: '#399ee6',
16
+ AccentPurple: '#a37acc',
17
+ AccentCyan: '#4cbf99',
18
+ AccentGreen: '#86b300',
19
+ AccentYellow: '#f2ae49',
20
+ AccentRed: '#f07171',
21
+ DiffAdded: '#86b300',
22
+ DiffRemoved: '#f07171',
23
+ Comment: '#ABADB1',
24
+ Gray: '#CCCFD3',
25
+ GradientColors: ['#399ee6', '#86b300'],
26
+ };
27
+
28
+ export const QwenLight: Theme = new Theme(
29
+ 'Qwen Light',
30
+ 'light',
31
+ {
32
+ hljs: {
33
+ display: 'block',
34
+ overflowX: 'auto',
35
+ padding: '0.5em',
36
+ background: qwenLightColors.Background,
37
+ color: qwenLightColors.Foreground,
38
+ },
39
+ 'hljs-comment': {
40
+ color: qwenLightColors.Comment,
41
+ fontStyle: 'italic',
42
+ },
43
+ 'hljs-quote': {
44
+ color: qwenLightColors.AccentCyan,
45
+ fontStyle: 'italic',
46
+ },
47
+ 'hljs-string': {
48
+ color: qwenLightColors.AccentGreen,
49
+ },
50
+ 'hljs-constant': {
51
+ color: qwenLightColors.AccentCyan,
52
+ },
53
+ 'hljs-number': {
54
+ color: qwenLightColors.AccentPurple,
55
+ },
56
+ 'hljs-keyword': {
57
+ color: qwenLightColors.AccentYellow,
58
+ },
59
+ 'hljs-selector-tag': {
60
+ color: qwenLightColors.AccentYellow,
61
+ },
62
+ 'hljs-attribute': {
63
+ color: qwenLightColors.AccentYellow,
64
+ },
65
+ 'hljs-variable': {
66
+ color: qwenLightColors.Foreground,
67
+ },
68
+ 'hljs-variable.language': {
69
+ color: qwenLightColors.LightBlue,
70
+ fontStyle: 'italic',
71
+ },
72
+ 'hljs-title': {
73
+ color: qwenLightColors.AccentBlue,
74
+ },
75
+ 'hljs-section': {
76
+ color: qwenLightColors.AccentGreen,
77
+ fontWeight: 'bold',
78
+ },
79
+ 'hljs-type': {
80
+ color: qwenLightColors.LightBlue,
81
+ },
82
+ 'hljs-class .hljs-title': {
83
+ color: qwenLightColors.AccentBlue,
84
+ },
85
+ 'hljs-tag': {
86
+ color: qwenLightColors.LightBlue,
87
+ },
88
+ 'hljs-name': {
89
+ color: qwenLightColors.AccentBlue,
90
+ },
91
+ 'hljs-builtin-name': {
92
+ color: qwenLightColors.AccentYellow,
93
+ },
94
+ 'hljs-meta': {
95
+ color: qwenLightColors.AccentYellow,
96
+ },
97
+ 'hljs-symbol': {
98
+ color: qwenLightColors.AccentRed,
99
+ },
100
+ 'hljs-bullet': {
101
+ color: qwenLightColors.AccentYellow,
102
+ },
103
+ 'hljs-regexp': {
104
+ color: qwenLightColors.AccentCyan,
105
+ },
106
+ 'hljs-link': {
107
+ color: qwenLightColors.LightBlue,
108
+ },
109
+ 'hljs-deletion': {
110
+ color: qwenLightColors.AccentRed,
111
+ },
112
+ 'hljs-addition': {
113
+ color: qwenLightColors.AccentGreen,
114
+ },
115
+ 'hljs-emphasis': {
116
+ fontStyle: 'italic',
117
+ },
118
+ 'hljs-strong': {
119
+ fontWeight: 'bold',
120
+ },
121
+ 'hljs-literal': {
122
+ color: qwenLightColors.AccentCyan,
123
+ },
124
+ 'hljs-built_in': {
125
+ color: qwenLightColors.AccentRed,
126
+ },
127
+ 'hljs-doctag': {
128
+ color: qwenLightColors.AccentRed,
129
+ },
130
+ 'hljs-template-variable': {
131
+ color: qwenLightColors.AccentCyan,
132
+ },
133
+ 'hljs-selector-id': {
134
+ color: qwenLightColors.AccentRed,
135
+ },
136
+ },
137
+ qwenLightColors,
138
+ lightSemanticColors,
139
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/semantic-tokens.ts ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { lightTheme, darkTheme, ansiTheme } from './theme.js';
8
+
9
+ export interface SemanticColors {
10
+ text: {
11
+ primary: string;
12
+ secondary: string;
13
+ link: string;
14
+ accent: string;
15
+ };
16
+ background: {
17
+ primary: string;
18
+ diff: {
19
+ added: string;
20
+ removed: string;
21
+ };
22
+ };
23
+ border: {
24
+ default: string;
25
+ focused: string;
26
+ };
27
+ ui: {
28
+ comment: string;
29
+ symbol: string;
30
+ gradient: string[] | undefined;
31
+ };
32
+ status: {
33
+ error: string;
34
+ success: string;
35
+ warning: string;
36
+ };
37
+ }
38
+
39
+ export const lightSemanticColors: SemanticColors = {
40
+ text: {
41
+ primary: lightTheme.Foreground,
42
+ secondary: lightTheme.Gray,
43
+ link: lightTheme.AccentBlue,
44
+ accent: lightTheme.AccentPurple,
45
+ },
46
+ background: {
47
+ primary: lightTheme.Background,
48
+ diff: {
49
+ added: lightTheme.DiffAdded,
50
+ removed: lightTheme.DiffRemoved,
51
+ },
52
+ },
53
+ border: {
54
+ default: lightTheme.Gray,
55
+ focused: lightTheme.AccentBlue,
56
+ },
57
+ ui: {
58
+ comment: lightTheme.Comment,
59
+ symbol: lightTheme.Gray,
60
+ gradient: lightTheme.GradientColors,
61
+ },
62
+ status: {
63
+ error: lightTheme.AccentRed,
64
+ success: lightTheme.AccentGreen,
65
+ warning: lightTheme.AccentYellow,
66
+ },
67
+ };
68
+
69
+ export const darkSemanticColors: SemanticColors = {
70
+ text: {
71
+ primary: darkTheme.Foreground,
72
+ secondary: darkTheme.Gray,
73
+ link: darkTheme.AccentBlue,
74
+ accent: darkTheme.AccentPurple,
75
+ },
76
+ background: {
77
+ primary: darkTheme.Background,
78
+ diff: {
79
+ added: darkTheme.DiffAdded,
80
+ removed: darkTheme.DiffRemoved,
81
+ },
82
+ },
83
+ border: {
84
+ default: darkTheme.Gray,
85
+ focused: darkTheme.AccentBlue,
86
+ },
87
+ ui: {
88
+ comment: darkTheme.Comment,
89
+ symbol: darkTheme.Gray,
90
+ gradient: darkTheme.GradientColors,
91
+ },
92
+ status: {
93
+ error: darkTheme.AccentRed,
94
+ success: darkTheme.AccentGreen,
95
+ warning: darkTheme.AccentYellow,
96
+ },
97
+ };
98
+
99
+ export const ansiSemanticColors: SemanticColors = {
100
+ text: {
101
+ primary: ansiTheme.Foreground,
102
+ secondary: ansiTheme.Gray,
103
+ link: ansiTheme.AccentBlue,
104
+ accent: ansiTheme.AccentPurple,
105
+ },
106
+ background: {
107
+ primary: ansiTheme.Background,
108
+ diff: {
109
+ added: ansiTheme.DiffAdded,
110
+ removed: ansiTheme.DiffRemoved,
111
+ },
112
+ },
113
+ border: {
114
+ default: ansiTheme.Gray,
115
+ focused: ansiTheme.AccentBlue,
116
+ },
117
+ ui: {
118
+ comment: ansiTheme.Comment,
119
+ symbol: ansiTheme.Gray,
120
+ gradient: ansiTheme.GradientColors,
121
+ },
122
+ status: {
123
+ error: ansiTheme.AccentRed,
124
+ success: ansiTheme.AccentGreen,
125
+ warning: ansiTheme.AccentYellow,
126
+ },
127
+ };
projects/ui/qwen-code/packages/cli/src/ui/themes/shades-of-purple.ts ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * Shades of Purple Theme — for Highlight.js.
9
+ * @author Ahmad Awais <https://twitter.com/mrahmadawais/>
10
+ */
11
+ import { type ColorsTheme, Theme } from './theme.js';
12
+ import { darkSemanticColors } from './semantic-tokens.js';
13
+
14
+ const shadesOfPurpleColors: ColorsTheme = {
15
+ type: 'dark',
16
+ // Required colors for ColorsTheme interface
17
+ Background: '#2d2b57', // Main background
18
+ Foreground: '#e3dfff', // Default text color (hljs, hljs-subst)
19
+ LightBlue: '#847ace', // Light blue/purple accent
20
+ AccentBlue: '#a599e9', // Borders, secondary blue
21
+ AccentPurple: '#ac65ff', // Comments (main purple)
22
+ AccentCyan: '#a1feff', // Names
23
+ AccentGreen: '#A5FF90', // Strings and many others
24
+ AccentYellow: '#fad000', // Title, main yellow
25
+ AccentRed: '#ff628c', // Error/deletion accent
26
+ DiffAdded: '#383E45',
27
+ DiffRemoved: '#572244',
28
+ Comment: '#B362FF', // Comment color (same as AccentPurple)
29
+ Gray: '#726c86', // Gray color
30
+ GradientColors: ['#4d21fc', '#847ace', '#ff628c'],
31
+ };
32
+
33
+ // Additional colors from CSS that don't fit in the ColorsTheme interface
34
+ const additionalColors = {
35
+ AccentYellowAlt: '#f8d000', // Attr yellow (slightly different)
36
+ AccentOrange: '#fb9e00', // Keywords, built_in, meta
37
+ AccentPink: '#fa658d', // Numbers, literals
38
+ AccentLightPurple: '#c991ff', // For params and properties
39
+ AccentDarkPurple: '#6943ff', // For operators
40
+ AccentTeal: '#2ee2fa', // For special constructs
41
+ };
42
+
43
+ export const ShadesOfPurple = new Theme(
44
+ 'Shades Of Purple',
45
+ 'dark',
46
+ {
47
+ // Base styles
48
+ hljs: {
49
+ display: 'block',
50
+ overflowX: 'auto',
51
+ background: shadesOfPurpleColors.Background,
52
+ color: shadesOfPurpleColors.Foreground,
53
+ },
54
+
55
+ // Title elements
56
+ 'hljs-title': {
57
+ color: shadesOfPurpleColors.AccentYellow,
58
+ fontWeight: 'normal',
59
+ },
60
+
61
+ // Names
62
+ 'hljs-name': {
63
+ color: shadesOfPurpleColors.AccentCyan,
64
+ fontWeight: 'normal',
65
+ },
66
+
67
+ // Tags
68
+ 'hljs-tag': {
69
+ color: shadesOfPurpleColors.Foreground,
70
+ },
71
+
72
+ // Attributes
73
+ 'hljs-attr': {
74
+ color: additionalColors.AccentYellowAlt,
75
+ fontStyle: 'italic',
76
+ },
77
+
78
+ // Built-ins, selector tags, sections
79
+ 'hljs-built_in': {
80
+ color: additionalColors.AccentOrange,
81
+ },
82
+ 'hljs-selector-tag': {
83
+ color: additionalColors.AccentOrange,
84
+ fontWeight: 'normal',
85
+ },
86
+ 'hljs-section': {
87
+ color: additionalColors.AccentOrange,
88
+ },
89
+
90
+ // Keywords
91
+ 'hljs-keyword': {
92
+ color: additionalColors.AccentOrange,
93
+ fontWeight: 'normal',
94
+ },
95
+
96
+ // Default text and substitutions
97
+ 'hljs-subst': {
98
+ color: shadesOfPurpleColors.Foreground,
99
+ },
100
+
101
+ // Strings and related elements (all green)
102
+ 'hljs-string': {
103
+ color: shadesOfPurpleColors.AccentGreen,
104
+ },
105
+ 'hljs-attribute': {
106
+ color: shadesOfPurpleColors.AccentGreen,
107
+ },
108
+ 'hljs-symbol': {
109
+ color: shadesOfPurpleColors.AccentGreen,
110
+ },
111
+ 'hljs-bullet': {
112
+ color: shadesOfPurpleColors.AccentGreen,
113
+ },
114
+ 'hljs-addition': {
115
+ color: shadesOfPurpleColors.AccentGreen,
116
+ },
117
+ 'hljs-code': {
118
+ color: shadesOfPurpleColors.AccentGreen,
119
+ },
120
+ 'hljs-regexp': {
121
+ color: shadesOfPurpleColors.AccentGreen,
122
+ },
123
+ 'hljs-selector-class': {
124
+ color: shadesOfPurpleColors.AccentGreen,
125
+ },
126
+ 'hljs-selector-attr': {
127
+ color: shadesOfPurpleColors.AccentGreen,
128
+ },
129
+ 'hljs-selector-pseudo': {
130
+ color: shadesOfPurpleColors.AccentGreen,
131
+ },
132
+ 'hljs-template-tag': {
133
+ color: shadesOfPurpleColors.AccentGreen,
134
+ },
135
+ 'hljs-quote': {
136
+ color: shadesOfPurpleColors.AccentGreen,
137
+ },
138
+ 'hljs-deletion': {
139
+ color: shadesOfPurpleColors.AccentRed,
140
+ },
141
+
142
+ // Meta elements
143
+ 'hljs-meta': {
144
+ color: additionalColors.AccentOrange,
145
+ },
146
+ 'hljs-meta-string': {
147
+ color: additionalColors.AccentOrange,
148
+ },
149
+
150
+ // Comments
151
+ 'hljs-comment': {
152
+ color: shadesOfPurpleColors.AccentPurple,
153
+ },
154
+
155
+ // Literals and numbers
156
+ 'hljs-literal': {
157
+ color: additionalColors.AccentPink,
158
+ fontWeight: 'normal',
159
+ },
160
+ 'hljs-number': {
161
+ color: additionalColors.AccentPink,
162
+ },
163
+
164
+ // Emphasis and strong
165
+ 'hljs-emphasis': {
166
+ fontStyle: 'italic',
167
+ },
168
+ 'hljs-strong': {
169
+ fontWeight: 'bold',
170
+ },
171
+
172
+ // Diff-specific classes
173
+ 'hljs-diff': {
174
+ color: shadesOfPurpleColors.Foreground,
175
+ },
176
+ 'hljs-meta.hljs-diff': {
177
+ color: shadesOfPurpleColors.AccentBlue,
178
+ },
179
+ 'hljs-ln': {
180
+ color: shadesOfPurpleColors.Gray,
181
+ },
182
+
183
+ // Additional elements that might be needed
184
+ 'hljs-type': {
185
+ color: shadesOfPurpleColors.AccentYellow,
186
+ fontWeight: 'normal',
187
+ },
188
+ 'hljs-variable': {
189
+ color: shadesOfPurpleColors.AccentYellow,
190
+ },
191
+ 'hljs-template-variable': {
192
+ color: shadesOfPurpleColors.AccentGreen,
193
+ },
194
+ 'hljs-function .hljs-keyword': {
195
+ color: additionalColors.AccentOrange,
196
+ },
197
+ 'hljs-link': {
198
+ color: shadesOfPurpleColors.LightBlue,
199
+ },
200
+ 'hljs-doctag': {
201
+ fontWeight: 'bold',
202
+ },
203
+
204
+ // Function parameters
205
+ 'hljs-params': {
206
+ color: additionalColors.AccentLightPurple,
207
+ fontStyle: 'italic',
208
+ },
209
+
210
+ // Class definitions
211
+ 'hljs-class': {
212
+ color: shadesOfPurpleColors.AccentCyan,
213
+ fontWeight: 'bold',
214
+ },
215
+
216
+ // Function definitions
217
+ 'hljs-function': {
218
+ color: shadesOfPurpleColors.AccentCyan,
219
+ },
220
+
221
+ // Object properties
222
+ 'hljs-property': {
223
+ color: shadesOfPurpleColors.AccentBlue,
224
+ },
225
+
226
+ // Operators
227
+ 'hljs-operator': {
228
+ color: additionalColors.AccentDarkPurple,
229
+ },
230
+
231
+ // Punctuation (if supported by the parser)
232
+ 'hljs-punctuation': {
233
+ color: shadesOfPurpleColors.Gray,
234
+ },
235
+
236
+ // CSS ID selectors
237
+ 'hljs-selector-id': {
238
+ color: shadesOfPurpleColors.AccentYellow,
239
+ fontWeight: 'bold',
240
+ },
241
+
242
+ // Character literals
243
+ 'hljs-char': {
244
+ color: shadesOfPurpleColors.AccentGreen,
245
+ },
246
+
247
+ // Escape sequences
248
+ 'hljs-escape': {
249
+ color: additionalColors.AccentPink,
250
+ fontWeight: 'bold',
251
+ },
252
+
253
+ // Meta keywords
254
+ 'hljs-meta-keyword': {
255
+ color: additionalColors.AccentOrange,
256
+ fontWeight: 'bold',
257
+ },
258
+
259
+ // Built-in names
260
+ 'hljs-builtin-name': {
261
+ color: additionalColors.AccentTeal,
262
+ },
263
+
264
+ // Modules
265
+ 'hljs-module': {
266
+ color: shadesOfPurpleColors.AccentCyan,
267
+ },
268
+
269
+ // Namespaces
270
+ 'hljs-namespace': {
271
+ color: shadesOfPurpleColors.LightBlue,
272
+ },
273
+
274
+ // Important annotations
275
+ 'hljs-important': {
276
+ color: shadesOfPurpleColors.AccentRed,
277
+ fontWeight: 'bold',
278
+ },
279
+
280
+ // Formulas (for LaTeX, etc.)
281
+ 'hljs-formula': {
282
+ color: shadesOfPurpleColors.AccentCyan,
283
+ fontStyle: 'italic',
284
+ },
285
+
286
+ // Language-specific additions
287
+ // Python decorators
288
+ 'hljs-decorator': {
289
+ color: additionalColors.AccentTeal,
290
+ fontWeight: 'bold',
291
+ },
292
+
293
+ // Ruby symbols
294
+ 'hljs-symbol.ruby': {
295
+ color: additionalColors.AccentPink,
296
+ },
297
+
298
+ // SQL keywords
299
+ 'hljs-keyword.sql': {
300
+ color: additionalColors.AccentOrange,
301
+ textTransform: 'uppercase',
302
+ },
303
+
304
+ // Markdown specific
305
+ 'hljs-section.markdown': {
306
+ color: shadesOfPurpleColors.AccentYellow,
307
+ fontWeight: 'bold',
308
+ },
309
+
310
+ // JSON keys
311
+ 'hljs-attr.json': {
312
+ color: shadesOfPurpleColors.AccentCyan,
313
+ },
314
+
315
+ // XML/HTML specific
316
+ 'hljs-tag .hljs-name': {
317
+ color: shadesOfPurpleColors.AccentRed,
318
+ },
319
+ 'hljs-tag .hljs-attr': {
320
+ color: additionalColors.AccentYellowAlt,
321
+ },
322
+
323
+ // Line highlighting (if line numbers are enabled)
324
+ 'hljs.hljs-line-numbers': {
325
+ borderRight: `1px solid ${shadesOfPurpleColors.Gray}`,
326
+ },
327
+ 'hljs.hljs-line-numbers .hljs-ln-numbers': {
328
+ color: shadesOfPurpleColors.Gray,
329
+ paddingRight: '1em',
330
+ },
331
+ 'hljs.hljs-line-numbers .hljs-ln-code': {
332
+ paddingLeft: '1em',
333
+ },
334
+
335
+ // Selection styling
336
+ 'hljs::selection': {
337
+ background: shadesOfPurpleColors.AccentBlue + '40', // 40 = 25% opacity
338
+ },
339
+ 'hljs ::-moz-selection': {
340
+ background: shadesOfPurpleColors.AccentBlue + '40',
341
+ },
342
+
343
+ // Highlighted lines (for emphasis)
344
+ 'hljs .hljs-highlight': {
345
+ background: shadesOfPurpleColors.AccentPurple + '20', // 20 = 12.5% opacity
346
+ display: 'block',
347
+ width: '100%',
348
+ },
349
+ },
350
+ shadesOfPurpleColors,
351
+ darkSemanticColors,
352
+ );
projects/ui/qwen-code/packages/cli/src/ui/themes/theme-manager.test.ts ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ // Patch: Unset NO_COLOR at the very top before any imports
8
+ if (process.env['NO_COLOR'] !== undefined) {
9
+ delete process.env['NO_COLOR'];
10
+ }
11
+
12
+ import { describe, it, expect, beforeEach } from 'vitest';
13
+ import { themeManager, DEFAULT_THEME } from './theme-manager.js';
14
+ import { CustomTheme } from './theme.js';
15
+
16
+ const validCustomTheme: CustomTheme = {
17
+ type: 'custom',
18
+ name: 'MyCustomTheme',
19
+ Background: '#000000',
20
+ Foreground: '#ffffff',
21
+ LightBlue: '#89BDCD',
22
+ AccentBlue: '#3B82F6',
23
+ AccentPurple: '#8B5CF6',
24
+ AccentCyan: '#06B6D4',
25
+ AccentGreen: '#3CA84B',
26
+ AccentYellow: 'yellow',
27
+ AccentRed: 'red',
28
+ DiffAdded: 'green',
29
+ DiffRemoved: 'red',
30
+ Comment: 'gray',
31
+ Gray: 'gray',
32
+ };
33
+
34
+ describe('ThemeManager', () => {
35
+ beforeEach(() => {
36
+ // Reset themeManager state
37
+ themeManager.loadCustomThemes({});
38
+ themeManager.setActiveTheme(DEFAULT_THEME.name);
39
+ });
40
+
41
+ it('should load valid custom themes', () => {
42
+ themeManager.loadCustomThemes({ MyCustomTheme: validCustomTheme });
43
+ expect(themeManager.getCustomThemeNames()).toContain('MyCustomTheme');
44
+ expect(themeManager.isCustomTheme('MyCustomTheme')).toBe(true);
45
+ });
46
+
47
+ it('should set and get the active theme', () => {
48
+ expect(themeManager.getActiveTheme().name).toBe(DEFAULT_THEME.name);
49
+ themeManager.setActiveTheme('Ayu');
50
+ expect(themeManager.getActiveTheme().name).toBe('Ayu');
51
+ });
52
+
53
+ it('should set and get a custom active theme', () => {
54
+ themeManager.loadCustomThemes({ MyCustomTheme: validCustomTheme });
55
+ themeManager.setActiveTheme('MyCustomTheme');
56
+ expect(themeManager.getActiveTheme().name).toBe('MyCustomTheme');
57
+ });
58
+
59
+ it('should return false when setting a non-existent theme', () => {
60
+ expect(themeManager.setActiveTheme('NonExistentTheme')).toBe(false);
61
+ expect(themeManager.getActiveTheme().name).toBe(DEFAULT_THEME.name);
62
+ });
63
+
64
+ it('should list available themes including custom themes', () => {
65
+ themeManager.loadCustomThemes({ MyCustomTheme: validCustomTheme });
66
+ const available = themeManager.getAvailableThemes();
67
+ expect(
68
+ available.some(
69
+ (t: { name: string; isCustom?: boolean }) =>
70
+ t.name === 'MyCustomTheme' && t.isCustom,
71
+ ),
72
+ ).toBe(true);
73
+ });
74
+
75
+ it('should get a theme by name', () => {
76
+ expect(themeManager.getTheme('Ayu')).toBeDefined();
77
+ themeManager.loadCustomThemes({ MyCustomTheme: validCustomTheme });
78
+ expect(themeManager.getTheme('MyCustomTheme')).toBeDefined();
79
+ });
80
+
81
+ it('should fall back to default theme if active theme is invalid', () => {
82
+ (themeManager as unknown as { activeTheme: unknown }).activeTheme = {
83
+ name: 'NonExistent',
84
+ type: 'custom',
85
+ };
86
+ expect(themeManager.getActiveTheme().name).toBe(DEFAULT_THEME.name);
87
+ });
88
+
89
+ it('should return NoColorTheme if NO_COLOR is set', () => {
90
+ const original = process.env['NO_COLOR'];
91
+ process.env['NO_COLOR'] = '1';
92
+ expect(themeManager.getActiveTheme().name).toBe('NoColor');
93
+ if (original === undefined) {
94
+ delete process.env['NO_COLOR'];
95
+ } else {
96
+ process.env['NO_COLOR'] = original;
97
+ }
98
+ });
99
+ });
projects/ui/qwen-code/packages/cli/src/ui/themes/theme-manager.ts ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { AyuDark } from './ayu.js';
8
+ import { AyuLight } from './ayu-light.js';
9
+ import { AtomOneDark } from './atom-one-dark.js';
10
+ import { Dracula } from './dracula.js';
11
+ import { GitHubDark } from './github-dark.js';
12
+ import { GitHubLight } from './github-light.js';
13
+ import { GoogleCode } from './googlecode.js';
14
+ import { DefaultLight } from './default-light.js';
15
+ import { DefaultDark } from './default.js';
16
+ import { ShadesOfPurple } from './shades-of-purple.js';
17
+ import { XCode } from './xcode.js';
18
+ import { QwenLight } from './qwen-light.js';
19
+ import { QwenDark } from './qwen-dark.js';
20
+ import {
21
+ Theme,
22
+ ThemeType,
23
+ CustomTheme,
24
+ createCustomTheme,
25
+ validateCustomTheme,
26
+ } from './theme.js';
27
+ import { SemanticColors } from './semantic-tokens.js';
28
+ import { ANSI } from './ansi.js';
29
+ import { ANSILight } from './ansi-light.js';
30
+ import { NoColorTheme } from './no-color.js';
31
+ import process from 'node:process';
32
+
33
+ export interface ThemeDisplay {
34
+ name: string;
35
+ type: ThemeType;
36
+ isCustom?: boolean;
37
+ }
38
+
39
+ export const DEFAULT_THEME: Theme = QwenDark;
40
+
41
+ class ThemeManager {
42
+ private readonly availableThemes: Theme[];
43
+ private activeTheme: Theme;
44
+ private customThemes: Map<string, Theme> = new Map();
45
+
46
+ constructor() {
47
+ this.availableThemes = [
48
+ AyuDark,
49
+ AyuLight,
50
+ AtomOneDark,
51
+ Dracula,
52
+ DefaultLight,
53
+ DefaultDark,
54
+ GitHubDark,
55
+ GitHubLight,
56
+ GoogleCode,
57
+ QwenLight,
58
+ QwenDark,
59
+ ShadesOfPurple,
60
+ XCode,
61
+ ANSI,
62
+ ANSILight,
63
+ ];
64
+ this.activeTheme = DEFAULT_THEME;
65
+ }
66
+
67
+ /**
68
+ * Loads custom themes from settings.
69
+ * @param customThemesSettings Custom themes from settings.
70
+ */
71
+ loadCustomThemes(customThemesSettings?: Record<string, CustomTheme>): void {
72
+ this.customThemes.clear();
73
+
74
+ if (!customThemesSettings) {
75
+ return;
76
+ }
77
+
78
+ for (const [name, customThemeConfig] of Object.entries(
79
+ customThemesSettings,
80
+ )) {
81
+ const validation = validateCustomTheme(customThemeConfig);
82
+ if (validation.isValid) {
83
+ if (validation.warning) {
84
+ console.warn(`Theme "${name}": ${validation.warning}`);
85
+ }
86
+ const themeWithDefaults: CustomTheme = {
87
+ ...DEFAULT_THEME.colors,
88
+ ...customThemeConfig,
89
+ name: customThemeConfig.name || name,
90
+ type: 'custom',
91
+ };
92
+
93
+ try {
94
+ const theme = createCustomTheme(themeWithDefaults);
95
+ this.customThemes.set(name, theme);
96
+ } catch (error) {
97
+ console.warn(`Failed to load custom theme "${name}":`, error);
98
+ }
99
+ } else {
100
+ console.warn(`Invalid custom theme "${name}": ${validation.error}`);
101
+ }
102
+ }
103
+ // If the current active theme is a custom theme, keep it if still valid
104
+ if (
105
+ this.activeTheme &&
106
+ this.activeTheme.type === 'custom' &&
107
+ this.customThemes.has(this.activeTheme.name)
108
+ ) {
109
+ this.activeTheme = this.customThemes.get(this.activeTheme.name)!;
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Sets the active theme.
115
+ * @param themeName The name of the theme to set as active.
116
+ * @returns True if the theme was successfully set, false otherwise.
117
+ */
118
+ setActiveTheme(themeName: string | undefined): boolean {
119
+ const theme = this.findThemeByName(themeName);
120
+ if (!theme) {
121
+ return false;
122
+ }
123
+ this.activeTheme = theme;
124
+ return true;
125
+ }
126
+
127
+ /**
128
+ * Gets the currently active theme.
129
+ * @returns The active theme.
130
+ */
131
+ getActiveTheme(): Theme {
132
+ if (process.env['NO_COLOR']) {
133
+ return NoColorTheme;
134
+ }
135
+ // Ensure the active theme is always valid (fall back to default if not)
136
+ if (!this.activeTheme || !this.findThemeByName(this.activeTheme.name)) {
137
+ this.activeTheme = DEFAULT_THEME;
138
+ }
139
+ return this.activeTheme;
140
+ }
141
+
142
+ /**
143
+ * Gets the semantic colors for the active theme.
144
+ * @returns The semantic colors.
145
+ */
146
+ getSemanticColors(): SemanticColors {
147
+ return this.getActiveTheme().semanticColors;
148
+ }
149
+
150
+ /**
151
+ * Gets a list of custom theme names.
152
+ * @returns Array of custom theme names.
153
+ */
154
+ getCustomThemeNames(): string[] {
155
+ return Array.from(this.customThemes.keys());
156
+ }
157
+
158
+ /**
159
+ * Checks if a theme name is a custom theme.
160
+ * @param themeName The theme name to check.
161
+ * @returns True if the theme is custom.
162
+ */
163
+ isCustomTheme(themeName: string): boolean {
164
+ return this.customThemes.has(themeName);
165
+ }
166
+
167
+ /**
168
+ * Returns a list of available theme names.
169
+ */
170
+ getAvailableThemes(): ThemeDisplay[] {
171
+ const builtInThemes = this.availableThemes.map((theme) => ({
172
+ name: theme.name,
173
+ type: theme.type,
174
+ isCustom: false,
175
+ }));
176
+
177
+ const customThemes = Array.from(this.customThemes.values()).map(
178
+ (theme) => ({
179
+ name: theme.name,
180
+ type: theme.type,
181
+ isCustom: true,
182
+ }),
183
+ );
184
+
185
+ // Separate Qwen themes
186
+ const qwenThemes = builtInThemes.filter(
187
+ (theme) => theme.name === QwenLight.name || theme.name === QwenDark.name,
188
+ );
189
+ const otherBuiltInThemes = builtInThemes.filter(
190
+ (theme) => theme.name !== QwenLight.name && theme.name !== QwenDark.name,
191
+ );
192
+
193
+ // Sort other themes by type and then name
194
+ const sortedOtherThemes = [...otherBuiltInThemes, ...customThemes].sort(
195
+ (a, b) => {
196
+ const typeOrder = (type: ThemeType): number => {
197
+ switch (type) {
198
+ case 'dark':
199
+ return 1;
200
+ case 'light':
201
+ return 2;
202
+ case 'ansi':
203
+ return 3;
204
+ case 'custom':
205
+ return 4; // Custom themes at the end
206
+ default:
207
+ return 5;
208
+ }
209
+ };
210
+
211
+ const typeComparison = typeOrder(a.type) - typeOrder(b.type);
212
+ if (typeComparison !== 0) {
213
+ return typeComparison;
214
+ }
215
+ return a.name.localeCompare(b.name);
216
+ },
217
+ );
218
+
219
+ // Combine Qwen themes first, then sorted others
220
+ return [...qwenThemes, ...sortedOtherThemes];
221
+ }
222
+
223
+ /**
224
+ * Gets a theme by name.
225
+ * @param themeName The name of the theme to get.
226
+ * @returns The theme if found, undefined otherwise.
227
+ */
228
+ getTheme(themeName: string): Theme | undefined {
229
+ return this.findThemeByName(themeName);
230
+ }
231
+
232
+ findThemeByName(themeName: string | undefined): Theme | undefined {
233
+ if (!themeName) {
234
+ return DEFAULT_THEME;
235
+ }
236
+
237
+ // First check built-in themes
238
+ const builtInTheme = this.availableThemes.find(
239
+ (theme) => theme.name === themeName,
240
+ );
241
+ if (builtInTheme) {
242
+ return builtInTheme;
243
+ }
244
+
245
+ // Then check custom themes
246
+ return this.customThemes.get(themeName);
247
+ }
248
+ }
249
+
250
+ // Export an instance of the ThemeManager
251
+ export const themeManager = new ThemeManager();
projects/ui/qwen-code/packages/cli/src/ui/themes/theme.test.ts ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import { describe, it, expect } from 'vitest';
8
+ import * as themeModule from './theme.js';
9
+ import { themeManager } from './theme-manager.js';
10
+
11
+ const { validateCustomTheme } = themeModule;
12
+ type CustomTheme = themeModule.CustomTheme;
13
+
14
+ describe('validateCustomTheme', () => {
15
+ const validTheme: CustomTheme = {
16
+ type: 'custom',
17
+ name: 'My Custom Theme',
18
+ Background: '#FFFFFF',
19
+ Foreground: '#000000',
20
+ LightBlue: '#ADD8E6',
21
+ AccentBlue: '#0000FF',
22
+ AccentPurple: '#800080',
23
+ AccentCyan: '#00FFFF',
24
+ AccentGreen: '#008000',
25
+ AccentYellow: '#FFFF00',
26
+ AccentRed: '#FF0000',
27
+ DiffAdded: '#00FF00',
28
+ DiffRemoved: '#FF0000',
29
+ Comment: '#808080',
30
+ Gray: '#808080',
31
+ };
32
+
33
+ it('should return isValid: true for a valid theme', () => {
34
+ const result = validateCustomTheme(validTheme);
35
+ expect(result.isValid).toBe(true);
36
+ expect(result.error).toBeUndefined();
37
+ });
38
+
39
+ it('should return isValid: false for a theme with an invalid name', () => {
40
+ const invalidTheme = { ...validTheme, name: ' ' };
41
+ const result = validateCustomTheme(invalidTheme);
42
+ expect(result.isValid).toBe(false);
43
+ expect(result.error).toBe('Invalid theme name: ');
44
+ });
45
+
46
+ it('should return isValid: true for a theme missing optional DiffAdded and DiffRemoved colors', () => {
47
+ const legacyTheme: Partial<CustomTheme> = { ...validTheme };
48
+ delete legacyTheme.DiffAdded;
49
+ delete legacyTheme.DiffRemoved;
50
+ const result = validateCustomTheme(legacyTheme);
51
+ expect(result.isValid).toBe(true);
52
+ expect(result.error).toBeUndefined();
53
+ });
54
+
55
+ it('should return isValid: false for a theme with a very long name', () => {
56
+ const invalidTheme = { ...validTheme, name: 'a'.repeat(51) };
57
+ const result = validateCustomTheme(invalidTheme);
58
+ expect(result.isValid).toBe(false);
59
+ expect(result.error).toBe(`Invalid theme name: ${'a'.repeat(51)}`);
60
+ });
61
+ });
62
+
63
+ describe('themeManager.loadCustomThemes', () => {
64
+ const baseTheme: Omit<CustomTheme, 'DiffAdded' | 'DiffRemoved'> & {
65
+ DiffAdded?: string;
66
+ DiffRemoved?: string;
67
+ } = {
68
+ type: 'custom',
69
+ name: 'Test Theme',
70
+ Background: '#FFF',
71
+ Foreground: '#000',
72
+ LightBlue: '#ADD8E6',
73
+ AccentBlue: '#00F',
74
+ AccentPurple: '#808',
75
+ AccentCyan: '#0FF',
76
+ AccentGreen: '#080',
77
+ AccentYellow: '#FF0',
78
+ AccentRed: '#F00',
79
+ Comment: '#888',
80
+ Gray: '#888',
81
+ };
82
+
83
+ it('should use values from DEFAULT_THEME when DiffAdded and DiffRemoved are not provided', () => {
84
+ const legacyTheme: Partial<CustomTheme> = { ...baseTheme };
85
+ delete legacyTheme.DiffAdded;
86
+ delete legacyTheme.DiffRemoved;
87
+
88
+ themeManager.loadCustomThemes({ 'Legacy Custom Theme': legacyTheme });
89
+ const result = themeManager.getTheme('Legacy Custom Theme')!;
90
+
91
+ // Should use DEFAULT_THEME (QwenDark) values for missing fields
92
+ expect(result.colors.DiffAdded).toBe('#AAD94C');
93
+ expect(result.colors.DiffRemoved).toBe('#F26D78');
94
+ expect(result.colors.AccentBlue).toBe(legacyTheme.AccentBlue);
95
+ expect(result.name).toBe(legacyTheme.name);
96
+ });
97
+ });