mocode-ai 1.3.9 → 1.4.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/README.md +78 -70
- package/README.zh-CN.md +81 -73
- package/bin/mocode-agent-host.js +1 -1
- package/dist/agent/core.js +226 -293
- package/dist/agent/index.js +14 -10
- package/dist/agent/mode.js +3 -3
- package/dist/agent/runtime-context.js +45 -0
- package/dist/agent/spawn.js +101 -86
- package/dist/agent/tool-helpers.js +134 -0
- package/dist/agent/trace-state.js +118 -0
- package/dist/agents/coordinator.js +6 -1
- package/dist/changeset/index.js +9 -8
- package/dist/config/index.js +109 -77
- package/dist/config/presets.js +3 -1
- package/dist/config/profiles.js +125 -0
- package/dist/context/age-aware.js +2 -4
- package/dist/context/artifacts.js +6 -13
- package/dist/context/budget.js +6 -8
- package/dist/context/classifier.js +1 -2
- package/dist/context/encoders/code.js +2 -6
- package/dist/context/encoders/command.js +1 -3
- package/dist/context/encoders/search.js +1 -3
- package/dist/context/index.js +1 -1
- package/dist/context/lifecycle.js +5 -3
- package/dist/context/pipeline.js +1 -1
- package/dist/context/relevance.js +2 -4
- package/dist/context/token-calibration.js +13 -18
- package/dist/host/stdio.js +73 -12
- package/dist/i18n/index.js +96 -44
- package/dist/index.js +1 -1
- package/dist/llm/index.js +39 -23
- package/dist/llm/provider.js +23 -0
- package/dist/llm/providers/anthropic.js +12 -18
- package/dist/llm/tool-schema.js +48 -0
- package/dist/mcp/client.js +70 -25
- package/dist/mcp/config.js +1 -3
- package/dist/mcp/index.js +3 -1
- package/dist/memory/reflect.js +3 -6
- package/dist/memory/store.js +10 -12
- package/dist/permissions/index.js +66 -22
- package/dist/pet/bridge.js +2 -2
- package/dist/repl/commands/appearance.js +72 -0
- package/dist/repl/commands/compact.js +114 -0
- package/dist/repl/commands/context.js +17 -0
- package/dist/repl/commands/image.js +71 -0
- package/dist/repl/commands/memory.js +51 -0
- package/dist/repl/commands/mode.js +47 -0
- package/dist/repl/commands/model.js +435 -0
- package/dist/repl/commands/pet.js +70 -0
- package/dist/repl/commands/registry.js +46 -0
- package/dist/repl/commands/session.js +102 -0
- package/dist/repl/commands/skill.js +95 -0
- package/dist/repl/commands/system.js +202 -0
- package/dist/repl/commands/tool-group.js +233 -0
- package/dist/repl/commands/types.js +4 -0
- package/dist/repl/commands.js +324 -0
- package/dist/repl/index.js +5 -2577
- package/dist/repl/message-format.js +151 -0
- package/dist/repl/running-input.js +147 -0
- package/dist/repl/runtime.js +816 -0
- package/dist/repl/status-bar.js +161 -0
- package/dist/rollback/index.js +44 -14
- package/dist/runtime/browser-manager.js +1 -1
- package/dist/runtime/dev-server-manager.js +1 -1
- package/dist/runtime/input-injector.js +313 -0
- package/dist/runtime/screen-capture.js +89 -0
- package/dist/runtime/screen-pipeline.js +223 -0
- package/dist/sandbox/index.js +1 -1
- package/dist/sandbox/policy.js +8 -2
- package/dist/session/compact.js +22 -34
- package/dist/session/index.js +2 -2
- package/dist/session/notes.js +39 -5
- package/dist/session/persist.js +14 -8
- package/dist/session/scheduler.js +3 -4
- package/dist/session/trace-metrics.js +6 -3
- package/dist/skills/activation.js +10 -5
- package/dist/skills/discover.js +5 -17
- package/dist/skills/index.js +1 -1
- package/dist/skills/runner.js +28 -44
- package/dist/skills/toolmap.js +5 -2
- package/dist/tools/builtins/browser.js +17 -3
- package/dist/tools/builtins/computer.js +322 -0
- package/dist/tools/builtins/dev-server.js +1 -3
- package/dist/tools/builtins/edit-file.js +21 -7
- package/dist/tools/builtins/grep.js +1 -1
- package/dist/tools/builtins/index.js +28 -25
- package/dist/tools/builtins/memory-forget.js +1 -1
- package/dist/tools/builtins/memory-graph.js +4 -7
- package/dist/tools/builtins/memory-list.js +2 -6
- package/dist/tools/builtins/memory-save.js +8 -2
- package/dist/tools/builtins/memory-search.js +4 -4
- package/dist/tools/builtins/note-append.js +14 -3
- package/dist/tools/builtins/plan-update.js +40 -9
- package/dist/tools/builtins/run-command.js +8 -8
- package/dist/tools/builtins/screenshot.js +11 -87
- package/dist/tools/builtins/task.js +29 -40
- package/dist/tools/builtins/use-skill.js +1 -1
- package/dist/tools/builtins/view-image.js +5 -3
- package/dist/tools/builtins/web-fetch.js +1 -3
- package/dist/tools/builtins/web-search.js +3 -7
- package/dist/tools/builtins/write-file.js +4 -2
- package/dist/tools/constants.js +50 -37
- package/dist/tools/policy.js +221 -0
- package/dist/tools/registry.js +40 -19
- package/dist/tools/resource-lock.js +4 -2
- package/dist/tools/router.js +143 -0
- package/dist/tools/validation.js +6 -5
- package/dist/ui/batch.js +63 -23
- package/dist/ui/clipboard.js +17 -5
- package/dist/ui/content.js +166 -13
- package/dist/ui/diff.js +61 -19
- package/dist/ui/fuzzy.js +35 -2
- package/dist/ui/intervention.js +2 -4
- package/dist/ui/layout-internal/content-write.js +587 -0
- package/dist/ui/layout-internal/core.js +590 -0
- package/dist/ui/layout-internal/input-paint.js +365 -0
- package/dist/ui/layout-internal/screen.js +128 -0
- package/dist/ui/layout-internal/scroll.js +152 -0
- package/dist/ui/layout-internal/selection.js +229 -0
- package/dist/ui/layout-internal/state.js +82 -0
- package/dist/ui/layout-internal/statusbar.js +351 -0
- package/dist/ui/layout-types.js +1 -0
- package/dist/ui/layout.js +3 -2288
- package/dist/ui/markdown.js +10 -2
- package/dist/ui/prompt-internal/editor.js +945 -0
- package/dist/ui/prompt-internal/paste.js +52 -0
- package/dist/ui/prompt-internal/pickers.js +519 -0
- package/dist/ui/prompt-internal/types.js +1 -0
- package/dist/ui/prompt.js +4 -1506
- package/dist/ui/render.js +87 -2
- package/dist/verification/affected.js +11 -5
- package/dist/verification/discovery.js +1 -3
- package/dist/verification/profile.js +11 -3
- package/package.json +11 -2
package/dist/ui/diff.js
CHANGED
|
@@ -8,21 +8,64 @@ const HEAD_INDENT = ' ';
|
|
|
8
8
|
const BODY_INDENT = ' ';
|
|
9
9
|
/** 扩展名 / 文件名 → cli-highlight(hljs)语言 id;未命中则不高亮(纯文本)。 */
|
|
10
10
|
const LANG_BY_EXT = {
|
|
11
|
-
'.ts': 'typescript',
|
|
12
|
-
'.
|
|
13
|
-
'.
|
|
14
|
-
'.
|
|
15
|
-
'.
|
|
16
|
-
'.
|
|
17
|
-
'.
|
|
18
|
-
'.
|
|
19
|
-
'.
|
|
20
|
-
'.
|
|
21
|
-
'.
|
|
22
|
-
'.
|
|
23
|
-
'.
|
|
24
|
-
'.
|
|
25
|
-
'.
|
|
11
|
+
'.ts': 'typescript',
|
|
12
|
+
'.tsx': 'typescript',
|
|
13
|
+
'.mts': 'typescript',
|
|
14
|
+
'.cts': 'typescript',
|
|
15
|
+
'.js': 'javascript',
|
|
16
|
+
'.jsx': 'javascript',
|
|
17
|
+
'.mjs': 'javascript',
|
|
18
|
+
'.cjs': 'javascript',
|
|
19
|
+
'.py': 'python',
|
|
20
|
+
'.pyw': 'python',
|
|
21
|
+
'.pyi': 'python',
|
|
22
|
+
'.json': 'json',
|
|
23
|
+
'.json5': 'json',
|
|
24
|
+
'.md': 'markdown',
|
|
25
|
+
'.markdown': 'markdown',
|
|
26
|
+
'.sh': 'bash',
|
|
27
|
+
'.bash': 'bash',
|
|
28
|
+
'.zsh': 'bash',
|
|
29
|
+
'.fish': 'bash',
|
|
30
|
+
'.yml': 'yaml',
|
|
31
|
+
'.yaml': 'yaml',
|
|
32
|
+
'.css': 'css',
|
|
33
|
+
'.scss': 'scss',
|
|
34
|
+
'.less': 'less',
|
|
35
|
+
'.html': 'xml',
|
|
36
|
+
'.htm': 'xml',
|
|
37
|
+
'.xml': 'xml',
|
|
38
|
+
'.svg': 'xml',
|
|
39
|
+
'.go': 'go',
|
|
40
|
+
'.rs': 'rust',
|
|
41
|
+
'.java': 'java',
|
|
42
|
+
'.kt': 'kotlin',
|
|
43
|
+
'.kts': 'kotlin',
|
|
44
|
+
'.c': 'cpp',
|
|
45
|
+
'.h': 'cpp',
|
|
46
|
+
'.cpp': 'cpp',
|
|
47
|
+
'.cc': 'cpp',
|
|
48
|
+
'.hpp': 'cpp',
|
|
49
|
+
'.cxx': 'cpp',
|
|
50
|
+
'.cs': 'csharp',
|
|
51
|
+
'.rb': 'ruby',
|
|
52
|
+
'.php': 'php',
|
|
53
|
+
'.swift': 'swift',
|
|
54
|
+
'.sql': 'sql',
|
|
55
|
+
'.lua': 'lua',
|
|
56
|
+
'.r': 'r',
|
|
57
|
+
'.dart': 'dart',
|
|
58
|
+
'.scala': 'scala',
|
|
59
|
+
'.groovy': 'groovy',
|
|
60
|
+
'.toml': 'ini',
|
|
61
|
+
'.ini': 'ini',
|
|
62
|
+
'.cfg': 'ini',
|
|
63
|
+
'.conf': 'ini',
|
|
64
|
+
'.properties': 'ini',
|
|
65
|
+
'.dockerfile': 'dockerfile',
|
|
66
|
+
dockerfile: 'dockerfile',
|
|
67
|
+
makefile: 'makefile',
|
|
68
|
+
'.mk': 'makefile',
|
|
26
69
|
};
|
|
27
70
|
function langForPath(p) {
|
|
28
71
|
const lower = p.toLowerCase();
|
|
@@ -44,7 +87,7 @@ const paint = (key) => (s) => `${ui[key]}${s}${ui.reset}`;
|
|
|
44
87
|
const THEME = {
|
|
45
88
|
default: plain,
|
|
46
89
|
keyword: paint('magenta'),
|
|
47
|
-
|
|
90
|
+
built_in: paint('cyan'),
|
|
48
91
|
type: paint('cyan'),
|
|
49
92
|
literal: paint('cyan'),
|
|
50
93
|
number: paint('green'),
|
|
@@ -132,8 +175,7 @@ export function lineDiff(oldS, newS) {
|
|
|
132
175
|
dp[i] = new Uint16Array(m + 1);
|
|
133
176
|
for (let i = n - 1; i >= 0; i--) {
|
|
134
177
|
for (let j = m - 1; j >= 0; j--) {
|
|
135
|
-
dp[i][j] =
|
|
136
|
-
a[i] === b[j] ? dp[i + 1][j + 1] + 1 : Math.max(dp[i + 1][j], dp[i][j + 1]);
|
|
178
|
+
dp[i][j] = a[i] === b[j] ? dp[i + 1][j + 1] + 1 : Math.max(dp[i + 1][j], dp[i][j + 1]);
|
|
137
179
|
}
|
|
138
180
|
}
|
|
139
181
|
const out = [];
|
|
@@ -209,7 +251,7 @@ function lineWord(n) {
|
|
|
209
251
|
* - diff 过大(超 MAX_FULL_DIFF_LINES)时仅显头行 + 「file too large, diff omitted」。
|
|
210
252
|
*/
|
|
211
253
|
export function renderFileChange(opts) {
|
|
212
|
-
const { path,
|
|
254
|
+
const { path, oldStr, newStr } = opts;
|
|
213
255
|
const startLine = opts.startLine ?? 1;
|
|
214
256
|
const lang = langForPath(path);
|
|
215
257
|
const pathDisp = path; // 路径原样展示(不做截断,长路径由 contentWrite 折行)
|
package/dist/ui/fuzzy.js
CHANGED
|
@@ -16,8 +16,41 @@
|
|
|
16
16
|
*/
|
|
17
17
|
/** 词/路径边界:命中紧跟在这些字符之后算"词首",加分。 */
|
|
18
18
|
const BOUNDARY = new Set([
|
|
19
|
-
' ',
|
|
20
|
-
'
|
|
19
|
+
' ',
|
|
20
|
+
'\t',
|
|
21
|
+
'\n',
|
|
22
|
+
'-',
|
|
23
|
+
'_',
|
|
24
|
+
'/',
|
|
25
|
+
'\\',
|
|
26
|
+
':',
|
|
27
|
+
'.',
|
|
28
|
+
',',
|
|
29
|
+
';',
|
|
30
|
+
'(',
|
|
31
|
+
')',
|
|
32
|
+
'[',
|
|
33
|
+
']',
|
|
34
|
+
'{',
|
|
35
|
+
'}',
|
|
36
|
+
'<',
|
|
37
|
+
'>',
|
|
38
|
+
'"',
|
|
39
|
+
"'",
|
|
40
|
+
'`',
|
|
41
|
+
'=',
|
|
42
|
+
'+',
|
|
43
|
+
'|',
|
|
44
|
+
'&',
|
|
45
|
+
'?',
|
|
46
|
+
'!',
|
|
47
|
+
'#',
|
|
48
|
+
'@',
|
|
49
|
+
'$',
|
|
50
|
+
'%',
|
|
51
|
+
'^',
|
|
52
|
+
'~',
|
|
53
|
+
'*',
|
|
21
54
|
]);
|
|
22
55
|
function isUpper(ch) {
|
|
23
56
|
return !!ch && ch >= 'A' && ch <= 'Z';
|
package/dist/ui/intervention.js
CHANGED
|
@@ -13,13 +13,11 @@ const customLabel = () => t('intervention.custom');
|
|
|
13
13
|
export async function promptIntervention(req) {
|
|
14
14
|
// 非 TTY 降级:不阻塞,自动选默认。日志走 stderr(不污染 stdout 内容流)。
|
|
15
15
|
if (!layout.isActive()) {
|
|
16
|
-
const kind = req.type === 'choice'
|
|
17
|
-
? t('intervention.defaultChoice')
|
|
18
|
-
: t('intervention.emptyInput');
|
|
16
|
+
const kind = req.type === 'choice' ? t('intervention.defaultChoice') : t('intervention.emptyInput');
|
|
19
17
|
stderr.write(`${t('intervention.nonInteractive', { title: req.title, kind })}\n`);
|
|
20
18
|
if (req.type === 'choice') {
|
|
21
19
|
const first = req.options?.[0];
|
|
22
|
-
const value = typeof first === 'string' ? first : first?.label ?? '';
|
|
20
|
+
const value = typeof first === 'string' ? first : (first?.label ?? '');
|
|
23
21
|
return { action: 'selected', value };
|
|
24
22
|
}
|
|
25
23
|
return { action: 'submitted', value: req.seed ?? '' };
|