mocode-ai 1.2.8 → 1.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/agent/core.js +126 -43
  2. package/dist/config/index.js +31 -6
  3. package/dist/config/presets.js +36 -1
  4. package/dist/context/budget.js +0 -15
  5. package/dist/llm/index.js +33 -0
  6. package/dist/repl/index.js +57 -13
  7. package/dist/session/compact.js +237 -13
  8. package/dist/session/notes.js +63 -0
  9. package/dist/session/scheduler.js +5 -9
  10. package/dist/tools/constants.js +7 -0
  11. package/package.json +1 -1
  12. package/dist/__trace_manual_test__.js +0 -1
  13. package/dist/agent/core.d.ts +0 -112
  14. package/dist/agent/index.d.ts +0 -19
  15. package/dist/agent/mode.d.ts +0 -29
  16. package/dist/agent/retry-classifier.js +0 -64
  17. package/dist/agent/spawn.d.ts +0 -36
  18. package/dist/attachments/image.d.ts +0 -22
  19. package/dist/commands/config.d.ts +0 -8
  20. package/dist/commands/skill.js +0 -230
  21. package/dist/config/file.d.ts +0 -23
  22. package/dist/config/index.d.ts +0 -114
  23. package/dist/config/presets.d.ts +0 -57
  24. package/dist/context/budget.d.ts +0 -79
  25. package/dist/context/classifier.d.ts +0 -14
  26. package/dist/context/encoders/_util.d.ts +0 -11
  27. package/dist/context/encoders/code.d.ts +0 -2
  28. package/dist/context/encoders/doc.d.ts +0 -14
  29. package/dist/context/encoders/graph.d.ts +0 -11
  30. package/dist/context/encoders/graph.js +0 -81
  31. package/dist/context/encoders/index.d.ts +0 -2
  32. package/dist/context/encoders/log.d.ts +0 -2
  33. package/dist/context/encoders/log.js +0 -2
  34. package/dist/context/encoders/memory.d.ts +0 -2
  35. package/dist/context/encoders/passthrough.d.ts +0 -11
  36. package/dist/context/encoders/search.d.ts +0 -2
  37. package/dist/context/encoders/summary.d.ts +0 -12
  38. package/dist/context/encoders/table.d.ts +0 -2
  39. package/dist/context/encoders/tree.d.ts +0 -2
  40. package/dist/context/index.d.ts +0 -6
  41. package/dist/context/lifecycle.d.ts +0 -51
  42. package/dist/context/pipeline.d.ts +0 -9
  43. package/dist/context/registry.d.ts +0 -9
  44. package/dist/context/relevance.d.ts +0 -65
  45. package/dist/context/types.d.ts +0 -36
  46. package/dist/foo.js +0 -28
  47. package/dist/foo.test.js +0 -12
  48. package/dist/index.d.ts +0 -1
  49. package/dist/llm/capabilities.d.ts +0 -19
  50. package/dist/llm/index.d.ts +0 -111
  51. package/dist/memory/discover.d.ts +0 -15
  52. package/dist/memory/index.d.ts +0 -13
  53. package/dist/memory/reflect.d.ts +0 -34
  54. package/dist/memory/store.d.ts +0 -124
  55. package/dist/pet/bridge.d.ts +0 -73
  56. package/dist/pet/protocol.d.ts +0 -83
  57. package/dist/pet/state.d.ts +0 -28
  58. package/dist/plan/active.d.ts +0 -23
  59. package/dist/plan/active.js +0 -45
  60. package/dist/plan/index.d.ts +0 -13
  61. package/dist/plan/index.js +0 -33
  62. package/dist/plan/state.d.ts +0 -2
  63. package/dist/plan/state.js +0 -11
  64. package/dist/plan/store.d.ts +0 -78
  65. package/dist/plan/store.js +0 -429
  66. package/dist/project-skill/index.js +0 -95
  67. package/dist/project-skill/initializer.js +0 -178
  68. package/dist/project-snapshot/index.js +0 -85
  69. package/dist/project-snapshot/llm-snapshot.js +0 -150
  70. package/dist/project-snapshot/static-files.js +0 -87
  71. package/dist/repl/index.d.ts +0 -22
  72. package/dist/rollback/index.d.ts +0 -79
  73. package/dist/sandbox/command.d.ts +0 -3
  74. package/dist/sandbox/index.d.ts +0 -4
  75. package/dist/sandbox/jail.d.ts +0 -17
  76. package/dist/sandbox/policy.d.ts +0 -21
  77. package/dist/sandbox/root.d.ts +0 -5
  78. package/dist/session/compact.d.ts +0 -92
  79. package/dist/session/index.d.ts +0 -13
  80. package/dist/session/notes-plan.js +0 -41
  81. package/dist/session/persist.d.ts +0 -30
  82. package/dist/session/scheduler.d.ts +0 -53
  83. package/dist/skills/discover.d.ts +0 -33
  84. package/dist/skills/index.d.ts +0 -13
  85. package/dist/skills/skill-eval.js +0 -345
  86. package/dist/skills/skill-improve.js +0 -221
  87. package/dist/skills/stats.js +0 -102
  88. package/dist/tools/builtins/apply-patch.js +0 -174
  89. package/dist/tools/builtins/ask-human.d.ts +0 -9
  90. package/dist/tools/builtins/codegraph.d.ts +0 -2
  91. package/dist/tools/builtins/codegraph.js +0 -128
  92. package/dist/tools/builtins/edit-file.d.ts +0 -2
  93. package/dist/tools/builtins/glob.d.ts +0 -2
  94. package/dist/tools/builtins/grep.d.ts +0 -2
  95. package/dist/tools/builtins/index.d.ts +0 -2
  96. package/dist/tools/builtins/memory-forget.d.ts +0 -2
  97. package/dist/tools/builtins/memory-list.d.ts +0 -2
  98. package/dist/tools/builtins/memory-save.d.ts +0 -2
  99. package/dist/tools/builtins/memory-search.d.ts +0 -2
  100. package/dist/tools/builtins/memory-update.d.ts +0 -2
  101. package/dist/tools/builtins/project-skill-update.js +0 -102
  102. package/dist/tools/builtins/read-file.d.ts +0 -2
  103. package/dist/tools/builtins/run-command.d.ts +0 -2
  104. package/dist/tools/builtins/switch-mode.d.ts +0 -2
  105. package/dist/tools/builtins/switch-mode.js +0 -44
  106. package/dist/tools/builtins/task.d.ts +0 -2
  107. package/dist/tools/builtins/todolist.d.ts +0 -2
  108. package/dist/tools/builtins/todolist.js +0 -411
  109. package/dist/tools/builtins/use-skill.d.ts +0 -2
  110. package/dist/tools/builtins/web-fetch.d.ts +0 -2
  111. package/dist/tools/builtins/web-search.d.ts +0 -2
  112. package/dist/tools/builtins/write-file.d.ts +0 -2
  113. package/dist/tools/constants.d.ts +0 -52
  114. package/dist/tools/registry.d.ts +0 -18
  115. package/dist/tools/retry.js +0 -137
  116. package/dist/tools/types.d.ts +0 -42
  117. package/dist/ui/batch.d.ts +0 -67
  118. package/dist/ui/clipboard.d.ts +0 -9
  119. package/dist/ui/content.d.ts +0 -55
  120. package/dist/ui/diff.d.ts +0 -34
  121. package/dist/ui/intervention.d.ts +0 -46
  122. package/dist/ui/layout.d.ts +0 -225
  123. package/dist/ui/markdown.d.ts +0 -46
  124. package/dist/ui/mouse.d.ts +0 -29
  125. package/dist/ui/prompt.d.ts +0 -61
  126. package/dist/ui/render.d.ts +0 -60
  127. package/dist/ui/spinner.d.ts +0 -26
  128. package/dist/ui/theme.d.ts +0 -47
  129. package/dist/ui/thinking.js +0 -80
@@ -1,60 +0,0 @@
1
- /**
2
- * 清空整屏 + 滚动缓冲(向上滚动可见的历史输出),光标归位。
3
- * 进入会话时调用,让终端只剩当前 agent 对话。非 TTY 时空操作。
4
- */
5
- export declare function clearScreen(): void;
6
- export declare function charWidth(cp: number): number;
7
- export declare function displayWidth(str: string): number;
8
- /**
9
- * 毫秒 → Claude Code 式耗时串:运行中状态行走时与轮次结束摘要行共用。
10
- * <10s 显 1 位小数(3.2s);10-59s 整数(12s);≥60s m+s(3m 3s);≥1h h+m(1h 2m)。
11
- */
12
- export declare function fmtElapsed(ms: number): string;
13
- /** 去除 SGR 颜色转义(\x1B[…m),用于度量带色串的真实可见宽度。 */
14
- export declare function stripAnsi(s: string): string;
15
- /** 按显示列范围 [start, end) 截取纯文本(不含 ANSI,按 charWidth 计位,CJK/宽字符占 2)。
16
- * 跨宽字符边界时整字符归入(w+cw>start 即含入),供鼠标选区文本提取用。 */
17
- export declare function sliceByDisplayCol(str: string, start: number, end: number): string;
18
- /** 把可视列(0-based)反推为 str 内的字符偏移(JS 字符串下标,UTF-16 code unit)。
19
- * 点击落在宽字符的"列中段"时归到该字符之前的偏移(停在它左侧边界)——与终端光标行为一致。
20
- * visCol 大于串的显示宽度时返回 str.length(点行末的"右边")。
21
- * 输入框点击定位专用;与 sliceByDisplayCol 互为逆,但语义只关心单点、不关心区间。 */
22
- export declare function visColToCharCol(str: string, visCol: number): number;
23
- /** 带色串的可见显示宽度(先去 ANSI 再按 displayWidth 度量)。 */
24
- export declare function ansiDisplayWidth(s: string): number;
25
- /** 按显示宽度右补空格。 */
26
- export declare function padEndDisplay(str: string, width: number): string;
27
- /** 带色串按可见宽度右补空格(先剥离 ANSI 算真实宽度,空格补在串末,不破坏颜色码)。 */
28
- export declare function padEndAnsi(str: string, width: number): string;
29
- /** 带色串按可见宽度截断(保留中间 ANSI 码,超出末尾加 …,补 reset 防 … 继承颜色)。 */
30
- export declare function truncateAnsi(str: string, width: number): string;
31
- /** 按显示宽度截断,超出加 …。 */
32
- export declare function truncateDisplay(str: string, width: number): string;
33
- /**
34
- * 按显示宽度从头部截断(保留尾部),超出前缀加 …。
35
- * 用于单行只读预览需要始终看到最新内容的场景(如运行态输入回显:光标恒在文本末尾,
36
- * 超长时应保留刚打的字,而非 truncateDisplay 那样保留开头、把刚打的内容截没)。
37
- */
38
- export declare function truncateDisplayHead(str: string, width: number): string;
39
- /**
40
- * 按显示宽度把文本软折行为多行(供输入框软换行):每行可见宽度 ≤ width。
41
- * 宽字符(CJK / emoji = 2)在剩余宽度放不下时整字折到下行(留尾部空格,与终端自动折行一致),
42
- * 而非劈开半个字。零宽字符(组合符等)不计宽度、附在当前行。空串返回 [''](占一行)。
43
- * 输入文本应全为可见字符(无控制码 / SGR)。
44
- */
45
- export declare function wrapByDisplayWidth(text: string, width: number): string[];
46
- export interface BannerInfo {
47
- model: string;
48
- baseURL: string;
49
- cwd: string;
50
- tools: string;
51
- }
52
- /** 横幅纯文本(带 ANSI 颜色,不写出)——供 TUI 经 contentWrite 写入内容区以跟踪续写位。
53
- * 无边框:左侧实心小熊 + 右侧标题/信息(模型/目录),末尾一行提示。 */
54
- export declare function bannerString(info: BannerInfo): string;
55
- /** 启动横幅:小熊 logo + 标题/信息 + 一行提示。纯渲染,不依赖 config / 业务。 */
56
- export declare function printBanner(info: BannerInfo): void;
57
- /** 把工具调用的 JSON 参数提炼成人可读的一行(路径 / 模式 / 命令)。 */
58
- export declare function summarizeToolCall(name: string, argsRaw: string): string;
59
- /** 工具结果的人可读一行预览(行数 / 匹配数 / 首行);喂回 LLM 的全文不变。 */
60
- export declare function summarizeToolResult(name: string, output: string): string;
@@ -1,26 +0,0 @@
1
- /**
2
- * 等待动画:在 await 长操作(chat / 工具执行 / 压缩)时旋转,避免「卡死」错觉。
3
- *
4
- * 两种渲染模式:
5
- * - onFrame 回调(TUI 态):帧经回调刷状态行(layout.drawStatusBar),内容区保持静止、底栏转圈;
6
- * 不在内容行用 \r\x1B[K 原地刷(那会擦内容、与滚动区域冲突)。
7
- * - 无回调(非 TTY / 旧路径):\r\x1B[K 原地刷 braille 帧;非 TTY 退化为启动时打印一行静态提示。
8
- *
9
- * stop() 仅在确实旋转过(有 timer)时清场,避免对从未 start 的实例误清状态行。
10
- */
11
- export declare class Spinner {
12
- private readonly onFrame?;
13
- private timer;
14
- private frame;
15
- private msg;
16
- constructor(onFrame?: ((msg: string, frame: string | null) => void) | undefined);
17
- start(msg: string): void;
18
- private render;
19
- stop(): void;
20
- /**
21
- * 暂停当前活跃 spinner(供 ask_human 介入面板进入前停转,避免 onFrame 覆盖面板)。
22
- * 未转则 no-op(stop 内 `!this.timer` 守护);停转时 onFrame(msg,null) 触发 clearLiveAtCursor 清续写位帧。
23
- * 不 resume——ask_human 的活儿就是面板本身,退出后 agent 的 spinner.stop() 是 no-op,下一轮 start 自然重启。
24
- */
25
- static pauseCurrent(): void;
26
- }
@@ -1,47 +0,0 @@
1
- /** 可切换的颜色字段(属性 bold/dim/reverse/reset 跨主题不变,不在此)。 */
2
- export interface Palette {
3
- red: string;
4
- green: string;
5
- yellow: string;
6
- blue: string;
7
- magenta: string;
8
- cyan: string;
9
- gray: string;
10
- brightCyan: string;
11
- brightMagenta: string;
12
- /** 用户消息满宽背景色(上滑时易辨认)。 */
13
- userBg: string;
14
- /** diff 新增行整行底色——浅深主题下都柔和可辨,跟绿字 fg 配对;SGR 自洽,每行 reset 闭合。 */
15
- addBg: string;
16
- /** diff 删除行整行底色——同 addBg,跟红字 fg 配对。 */
17
- delBg: string;
18
- }
19
- export type ColorKey = keyof Palette;
20
- /**
21
- * 切主题。name 未知则回退 default(不抛——启动时 config.theme 可能是用户填的任意值)。
22
- * 仅当实际变更时自增 version(供缓存失效)。 */
23
- export declare function setTheme(name: string): void;
24
- export declare function getTheme(): string;
25
- export declare function listThemes(): string[];
26
- export declare function themeExists(name: string): boolean;
27
- /** 主题版本号,每次 setTheme 实际变更自增;供 markdown MEMO 等缓存按版本失效。 */
28
- export declare function getThemeVersion(): number;
29
- export declare const ui: {
30
- isTTY: boolean;
31
- reset: string;
32
- bold: string;
33
- dim: string;
34
- reverse: string;
35
- readonly red: string;
36
- readonly green: string;
37
- readonly yellow: string;
38
- readonly blue: string;
39
- readonly magenta: string;
40
- readonly cyan: string;
41
- readonly gray: string;
42
- readonly brightCyan: string;
43
- readonly brightMagenta: string;
44
- readonly userBg: string;
45
- readonly addBg: string;
46
- readonly delBg: string;
47
- };
@@ -1,80 +0,0 @@
1
- import { renderMarkdown } from './markdown.js';
2
- import { ui } from './theme.js';
3
- const records = new Map();
4
- const absLineToId = new Map();
5
- let liveRaw = '';
6
- let nextId = 0;
7
- /** 流式写入推理;首次写入会结束此前的正文 Markdown 段,确保两者能独立折叠。 */
8
- export function writeThinking(delta, layout) {
9
- if (!delta)
10
- return;
11
- if (!liveRaw)
12
- layout.beginMarkdownSegment();
13
- liveRaw += delta;
14
- layout.contentWriteMd(delta);
15
- }
16
- /** 推理流结束:将实时 Markdown 段替换为可点击的一行摘要。 */
17
- export function finishThinking(layout) {
18
- if (!liveRaw)
19
- return;
20
- const raw = liveRaw;
21
- liveRaw = '';
22
- const lineCount = raw.split('\n').length;
23
- const summary = ` ${ui.bold}${ui.accent}▸${ui.reset} ${ui.dim}Thought · ${lineCount} lines (click to expand)${ui.reset}`;
24
- const summaryAbsIdx = layout.collapseMarkdownSegment(summary);
25
- if (summaryAbsIdx == null)
26
- return;
27
- const id = `t${++nextId}`;
28
- records.set(id, { id, summaryAbsIdx, raw, expanded: false, expandedLineCount: 0 });
29
- absLineToId.set(summaryAbsIdx, id);
30
- }
31
- /** 返回指定缓冲绝对行命中的推理记录;非摘要行返回 null。 */
32
- export function findThinkingByAbsLine(absLine) {
33
- return absLineToId.get(absLine) ?? null;
34
- }
35
- /** 切换摘要行下的完整推理内容。 */
36
- export function toggleThinking(id, layout) {
37
- const record = records.get(id);
38
- if (!record)
39
- return;
40
- if (record.expanded) {
41
- layout.contentDeleteFrom(record.summaryAbsIdx + 1, record.expandedLineCount);
42
- record.expanded = false;
43
- record.expandedLineCount = 0;
44
- return;
45
- }
46
- const rendered = renderMarkdown(record.raw, layout.contentCols());
47
- const maxLines = 200;
48
- const lines = rendered.slice(0, maxLines);
49
- if (rendered.length > maxLines) {
50
- lines.push(`${ui.dim} … (${rendered.length - maxLines} more lines)${ui.reset}`);
51
- }
52
- if (lines.length === 0)
53
- return;
54
- layout.contentInsertAfter(record.summaryAbsIdx, lines);
55
- record.expanded = true;
56
- record.expandedLineCount = lines.length;
57
- }
58
- /** 缓冲中段插删后同步摘要绝对行索引。 */
59
- export function shiftThinkingsAfter(absIdx, delta) {
60
- if (delta === 0)
61
- return;
62
- const next = new Map();
63
- for (const [idx, id] of absLineToId) {
64
- const shifted = idx > absIdx ? idx + delta : idx;
65
- if (shifted >= 0)
66
- next.set(shifted, id);
67
- const record = records.get(id);
68
- if (record && idx > absIdx)
69
- record.summaryAbsIdx = shifted;
70
- }
71
- absLineToId.clear();
72
- for (const [idx, id] of next)
73
- absLineToId.set(idx, id);
74
- }
75
- /** 内容区整体清空时清掉折叠状态与尚未结束的流。 */
76
- export function resetThinkings() {
77
- records.clear();
78
- absLineToId.clear();
79
- liveRaw = '';
80
- }