mocode-ai 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -28
- package/dist/agent/core.js +9 -4
- package/dist/config/index.js +1 -0
- package/dist/context/encoders/_util.js +40 -0
- package/dist/context/encoders/code.js +77 -0
- package/dist/context/encoders/doc.js +28 -0
- package/dist/context/encoders/graph.js +31 -0
- package/dist/context/encoders/index.js +24 -2
- package/dist/context/encoders/log.js +52 -0
- package/dist/context/encoders/memory.js +63 -0
- package/dist/context/encoders/search.js +69 -0
- package/dist/context/encoders/summary.js +26 -0
- package/dist/context/encoders/table.js +64 -0
- package/dist/context/encoders/tree.js +86 -0
- package/dist/repl/index.js +12 -12
- package/dist/session/compact.js +49 -18
- package/dist/ui/layout.js +148 -50
- package/dist/ui/prompt.js +4 -4
- package/dist/ui/render.js +20 -0
- package/package.json +1 -1
package/dist/ui/prompt.js
CHANGED
|
@@ -328,9 +328,7 @@ export async function promptWithSlashMenu(opts) {
|
|
|
328
328
|
layout.scrollBy(-5);
|
|
329
329
|
return;
|
|
330
330
|
}
|
|
331
|
-
//
|
|
332
|
-
if (layout.isScrolled())
|
|
333
|
-
layout.resetScroll();
|
|
331
|
+
// 滚动回看时打字 / 编辑不回尾(保持历史视图,便于边看历史边编辑);仅 Enter 提交时回尾(见下方 submit 前)。
|
|
334
332
|
// Ctrl+C 已在 onKey 顶部统一处理(清空或退出);Ctrl+D:空缓冲退出,否则忽略
|
|
335
333
|
if (key.ctrl && key.name === 'd') {
|
|
336
334
|
if (lines.every((l) => l === '') && cl === 0 && cc === 0)
|
|
@@ -358,8 +356,10 @@ export async function promptWithSlashMenu(opts) {
|
|
|
358
356
|
insertNewline();
|
|
359
357
|
return;
|
|
360
358
|
}
|
|
361
|
-
// 提交(键盘 plain Enter)
|
|
359
|
+
// 提交(键盘 plain Enter):回尾(若滚动回看)再发送——发消息时跳到底部开始 agent 输出
|
|
362
360
|
if (isReturn && !key.shift && !key.meta && !key.ctrl) {
|
|
361
|
+
if (layout.isScrolled())
|
|
362
|
+
layout.resetScroll();
|
|
363
363
|
submit();
|
|
364
364
|
return;
|
|
365
365
|
}
|
package/dist/ui/render.js
CHANGED
|
@@ -140,6 +140,26 @@ export function truncateDisplay(str, width) {
|
|
|
140
140
|
}
|
|
141
141
|
return out + '…';
|
|
142
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* 按显示宽度从头部截断(保留尾部),超出前缀加 …。
|
|
145
|
+
* 用于单行只读预览需要始终看到最新内容的场景(如运行态输入回显:光标恒在文本末尾,
|
|
146
|
+
* 超长时应保留刚打的字,而非 truncateDisplay 那样保留开头、把刚打的内容截没)。
|
|
147
|
+
*/
|
|
148
|
+
export function truncateDisplayHead(str, width) {
|
|
149
|
+
if (displayWidth(str) <= width)
|
|
150
|
+
return str;
|
|
151
|
+
const chars = Array.from(str);
|
|
152
|
+
let w = 0;
|
|
153
|
+
const kept = [];
|
|
154
|
+
for (let i = chars.length - 1; i >= 0; i--) {
|
|
155
|
+
const cw = charWidth(chars[i].codePointAt(0) ?? 0);
|
|
156
|
+
if (w + cw + 1 > width)
|
|
157
|
+
break; // +1 留给前导的 …
|
|
158
|
+
kept.unshift(chars[i]);
|
|
159
|
+
w += cw;
|
|
160
|
+
}
|
|
161
|
+
return '…' + kept.join('');
|
|
162
|
+
}
|
|
143
163
|
/**
|
|
144
164
|
* 按显示宽度把文本软折行为多行(供输入框软换行):每行可见宽度 ≤ width。
|
|
145
165
|
* 宽字符(CJK / emoji = 2)在剩余宽度放不下时整字折到下行(留尾部空格,与终端自动折行一致),
|