mocode-ai 0.5.10 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/repl/index.js +2 -1
- package/dist/ui/layout.js +3 -1
- package/dist/ui/theme.js +23 -0
- package/package.json +1 -1
package/dist/repl/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { runAgent } from '../agent/index.js';
|
|
|
8
8
|
import { getAgentMode, setAgentMode, onModeChange } from '../agent/mode.js';
|
|
9
9
|
import { togglePet, killPetProcess, listSkins, setSkin, sendState } from '../pet/bridge.js';
|
|
10
10
|
import { setSandboxRoot } from '../sandbox/root.js';
|
|
11
|
-
import { ui, setTheme, getTheme, listThemes, themeExists } from '../ui/theme.js';
|
|
11
|
+
import { ui, setTheme, getTheme, listThemes, themeExists, applyTerminalBackground } from '../ui/theme.js';
|
|
12
12
|
import { bannerLines, displayWidth, padEndDisplay, summarizeToolCall, summarizeToolResult } from '../ui/render.js';
|
|
13
13
|
import * as layout from '../ui/layout.js';
|
|
14
14
|
import * as mouse from '../ui/mouse.js';
|
|
@@ -1310,6 +1310,7 @@ export async function startRepl(initialHistory, sessionId, updateNotice = null,
|
|
|
1310
1310
|
// 切:setTheme → 重算状态行(新色)→ 清内容重绘(历史 / 横幅,镜像启动 + /resume)→ 确认 → 持久化。
|
|
1311
1311
|
// markdown MEMO 按 themeVersion 自动失效,故 renderHistory 取新色;状态栏 / 输入框由 continue 回 INPUT 态时读 getter 刷。
|
|
1312
1312
|
setTheme(name);
|
|
1313
|
+
applyTerminalBackground();
|
|
1313
1314
|
refreshStatusBase(history);
|
|
1314
1315
|
layout.clearContent();
|
|
1315
1316
|
if (history.some((m) => m.role === 'user')) {
|
package/dist/ui/layout.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { stdin, stdout } from 'node:process';
|
|
2
2
|
import { charWidth, displayWidth, truncateDisplay, truncateDisplayHead, truncateAnsi, ansiDisplayWidth, wrapByDisplayWidth, fmtElapsed, stripAnsi, sliceByDisplayCol, } from './render.js';
|
|
3
|
-
import { ui } from './theme.js';
|
|
3
|
+
import { ui, applyTerminalBackground, resetTerminalBackground } from './theme.js';
|
|
4
4
|
import * as content from './content.js';
|
|
5
5
|
import * as mouse from './mouse.js';
|
|
6
6
|
import { shiftBatchesAfter } from './batch.js';
|
|
@@ -1886,6 +1886,7 @@ export function enterAltScreen() {
|
|
|
1886
1886
|
return;
|
|
1887
1887
|
active = true;
|
|
1888
1888
|
stdout.write(esc.altOn);
|
|
1889
|
+
applyTerminalBackground();
|
|
1889
1890
|
stdout.write(esc.mouseOn); // 完整鼠标追踪(按下/拖动/释放/滚轮)→ mouse.swallow 重组 → handleMouseEvent
|
|
1890
1891
|
mouse.setHandler(handleMouseEvent);
|
|
1891
1892
|
setRegion(6); // 1 虚拟空 + 1 spinner行 + 1 上线 + 1 输入 + 1 下线 + 1 model行(两行式底栏)
|
|
@@ -1943,6 +1944,7 @@ export function exitAltScreen() {
|
|
|
1943
1944
|
if (!active)
|
|
1944
1945
|
return;
|
|
1945
1946
|
active = false;
|
|
1947
|
+
resetTerminalBackground();
|
|
1946
1948
|
stopTurnTimer(); // 兜底清走时计时器(防异常退出泄漏)
|
|
1947
1949
|
turnStart = null;
|
|
1948
1950
|
scrollLockUntil = 0; // 清轮首滚动锁(防状态泄漏到下次进 alt 屏)
|
package/dist/ui/theme.js
CHANGED
|
@@ -33,6 +33,7 @@ const DEFAULT = {
|
|
|
33
33
|
// diff 行底色:One Dark bg #282c34 上加 ~14% 亮度的对应色,够辨识但不刺眼
|
|
34
34
|
addBg: '\x1B[48;2;44;62;42m', // 偏暗绿(One Dark green(152,195,121)暗化)
|
|
35
35
|
delBg: '\x1B[48;2;62;38;42m', // 偏暗红(One Dark red(224,108,117)暗化)
|
|
36
|
+
terminalBg: 'rgb:28/2c/34', // One Dark 经典深底,偏蓝灰的黑
|
|
36
37
|
};
|
|
37
38
|
/**
|
|
38
39
|
* 内建主题表。default=One Dark、light=Solarized Light、solarized=Solarized Dark、
|
|
@@ -58,6 +59,7 @@ const THEMES = {
|
|
|
58
59
|
// 比直接用 base1 更柔,跟深 fg(red/green)对比充足
|
|
59
60
|
addBg: '\x1B[48;2;220;235;205m',
|
|
60
61
|
delBg: '\x1B[48;2;245;218;215m',
|
|
62
|
+
terminalBg: 'rgb:1a/1e/24', // 深黑底带微蓝,与 light 主题文字反差大
|
|
61
63
|
},
|
|
62
64
|
solarized: {
|
|
63
65
|
red: '\x1B[38;2;220;50;47m',
|
|
@@ -74,6 +76,7 @@ const THEMES = {
|
|
|
74
76
|
// diff 行底色:Solarized Dark base03(0,43,54)上加对应色族暗 tint
|
|
75
77
|
addBg: '\x1B[48;2;20;50;38m',
|
|
76
78
|
delBg: '\x1B[48;2;55;30;30m',
|
|
79
|
+
terminalBg: 'rgb:00/2b/36', // Solarized Dark base03,深青黑
|
|
77
80
|
},
|
|
78
81
|
gruvbox: {
|
|
79
82
|
red: '\x1B[38;2;251;73;52m',
|
|
@@ -90,6 +93,7 @@ const THEMES = {
|
|
|
90
93
|
// diff 行底色:Gruvbox dark bg(40,40,40)上贴暗 bg0_a 风格
|
|
91
94
|
addBg: '\x1B[48;2;40;55;30m',
|
|
92
95
|
delBg: '\x1B[48;2;70;35;30m',
|
|
96
|
+
terminalBg: 'rgb:28/28/28', // Gruvbox 深黑底,带微暖色调
|
|
93
97
|
},
|
|
94
98
|
nord: {
|
|
95
99
|
red: '\x1B[38;2;191;97;106m',
|
|
@@ -106,6 +110,7 @@ const THEMES = {
|
|
|
106
110
|
// diff 行底色:Nord polar night(46,52,64)上贴对应色族暗 tint
|
|
107
111
|
addBg: '\x1B[48;2;46;66;52m',
|
|
108
112
|
delBg: '\x1B[48;2;72;46;52m',
|
|
113
|
+
terminalBg: 'rgb:2e/34/40', // Nord Polar Night 深灰蓝
|
|
109
114
|
},
|
|
110
115
|
orange: {
|
|
111
116
|
// 秋季/南瓜橙:深暖底(#231c16 系)+ accent 主强调走橙色;yellow 槽也偏橙
|
|
@@ -125,6 +130,7 @@ const THEMES = {
|
|
|
125
130
|
// diff 行底色:暖深棕底上贴对应色族暗 tint,跟 fg 配对柔和可辨
|
|
126
131
|
addBg: '\x1B[48;2;55;70;35m',
|
|
127
132
|
delBg: '\x1B[48;2;78;42;32m',
|
|
133
|
+
terminalBg: 'rgb:23/1c/16', // 深暖棕黑,带橙色调
|
|
128
134
|
},
|
|
129
135
|
rose: {
|
|
130
136
|
// 玫红:深紫底 + accent 玫粉作主强调;magenta 槽与 accent 同源(主题色),
|
|
@@ -143,6 +149,7 @@ const THEMES = {
|
|
|
143
149
|
// diff 行底色:深紫底贴对应色族暗 tint,绿暗化偏橄榄、红暗化偏紫红
|
|
144
150
|
addBg: '\x1B[48;2;50;60;42m',
|
|
145
151
|
delBg: '\x1B[48;2;75;40;52m',
|
|
152
|
+
terminalBg: 'rgb:1e/14/1c', // 深紫黑底,带玫红暖调
|
|
146
153
|
},
|
|
147
154
|
emerald: {
|
|
148
155
|
// 翡翠绿:深绿底 + accent 翡翠绿作主强调;green 槽与 accent 同源(主题色),
|
|
@@ -161,6 +168,7 @@ const THEMES = {
|
|
|
161
168
|
// diff 行底色:深绿底贴对应色族暗 tint,绿暗化偏深绿、红暗化偏暗红
|
|
162
169
|
addBg: '\x1B[48;2;30;55;40m',
|
|
163
170
|
delBg: '\x1B[48;2;60;40;40m',
|
|
171
|
+
terminalBg: 'rgb:10/1e/18', // 深绿黑底,翡翠色调
|
|
164
172
|
},
|
|
165
173
|
amber: {
|
|
166
174
|
// 琥珀金黄:深棕底 + accent 琥珀金黄作主强调;yellow 槽与 accent 同源(主题色),
|
|
@@ -179,6 +187,7 @@ const THEMES = {
|
|
|
179
187
|
// diff 行底色:深棕底贴对应色族暗 tint,绿暗化偏橄榄、红暗化偏暗棕红
|
|
180
188
|
addBg: '\x1B[48;2;50;55;25m',
|
|
181
189
|
delBg: '\x1B[48;2;70;40;28m',
|
|
190
|
+
terminalBg: 'rgb:1e/18/0e', // 深棕黑底,琥珀金黄调
|
|
182
191
|
},
|
|
183
192
|
lavender: {
|
|
184
193
|
// 薰衣草淡紫:深紫底 + accent 淡紫作主强调;magenta 槽与 accent 同源(主题色),
|
|
@@ -197,6 +206,7 @@ const THEMES = {
|
|
|
197
206
|
// diff 行底色:深紫底贴对应色族暗 tint,绿暗化偏冷绿、红暗化偏冷紫红
|
|
198
207
|
addBg: '\x1B[48;2;38;46;42m',
|
|
199
208
|
delBg: '\x1B[48;2;60;40;55m',
|
|
209
|
+
terminalBg: 'rgb:18/14/24', // 深紫黑底,薰衣草冷调
|
|
200
210
|
},
|
|
201
211
|
sunset: {
|
|
202
212
|
// 日落珊瑚:深棕红底 + accent 珊瑚红作主强调;red 槽与 accent 同源(主题色);
|
|
@@ -215,6 +225,7 @@ const THEMES = {
|
|
|
215
225
|
// diff 行底色:深棕红底贴对应色族暗 tint,绿暗化偏橄榄、红暗化偏暗棕红
|
|
216
226
|
addBg: '\x1B[48;2;50;55;30m',
|
|
217
227
|
delBg: '\x1B[48;2;75;32;30m',
|
|
228
|
+
terminalBg: 'rgb:20/12/10', // 深棕红黑底,珊瑚暖调
|
|
218
229
|
},
|
|
219
230
|
};
|
|
220
231
|
let currentName = 'default';
|
|
@@ -222,6 +233,18 @@ let version = 0;
|
|
|
222
233
|
function currentPalette() {
|
|
223
234
|
return THEMES[currentName] ?? DEFAULT;
|
|
224
235
|
}
|
|
236
|
+
/** Apply the active theme's dark background to the terminal window (OSC 11). */
|
|
237
|
+
export function applyTerminalBackground() {
|
|
238
|
+
if (!isTTY)
|
|
239
|
+
return;
|
|
240
|
+
stdout.write(`\x1B]11;${currentPalette().terminalBg}\x07`);
|
|
241
|
+
}
|
|
242
|
+
/** Ask the terminal to restore its default background color. */
|
|
243
|
+
export function resetTerminalBackground() {
|
|
244
|
+
if (!isTTY)
|
|
245
|
+
return;
|
|
246
|
+
stdout.write('\x1B]111\x07');
|
|
247
|
+
}
|
|
225
248
|
/** 取某颜色字段的当前 ANSI 码(经 isTTY 门控)。 */
|
|
226
249
|
function color(key) {
|
|
227
250
|
return wrap(currentPalette()[key] ?? DEFAULT[key]);
|