@ww_nero/mini-cli 1.0.80 → 1.0.82
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 +40 -40
- package/package.json +38 -38
- package/src/chat.js +1150 -1150
- package/src/config.js +342 -387
- package/src/index.js +39 -39
- package/src/llm.js +147 -147
- package/src/prompt/tool.js +18 -18
- package/src/request.js +338 -328
- package/src/tools/bash.js +144 -144
- package/src/tools/edit.js +137 -137
- package/src/tools/index.js +74 -74
- package/src/tools/mcp.js +503 -503
- package/src/tools/read.js +44 -44
- package/src/tools/skills.js +49 -49
- package/src/tools/todos.js +90 -90
- package/src/tools/write.js +66 -66
- package/src/utils/cliOptions.js +9 -9
- package/src/utils/git.js +89 -89
- package/src/utils/history.js +181 -181
- package/src/utils/model.js +131 -131
- package/src/utils/output.js +75 -75
- package/src/utils/renderer.js +102 -102
- package/src/utils/settings.js +77 -77
- package/src/utils/skills.js +250 -250
- package/src/utils/think.js +214 -214
package/src/tools/index.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
const bash = require('./bash');
|
|
2
|
-
const read = require('./read');
|
|
3
|
-
const write = require('./write');
|
|
4
|
-
const edit = require('./edit');
|
|
5
|
-
const todos = require('./todos');
|
|
6
|
-
const skills = require('./skills');
|
|
7
|
-
const { createMcpManager } = require('./mcp');
|
|
8
|
-
const { loadSettings } = require('../config');
|
|
9
|
-
|
|
10
|
-
const TOOL_MODULES = [bash, read, write, edit, todos, skills];
|
|
11
|
-
|
|
12
|
-
const createToolRuntime = async (workspaceRoot, options = {}) => {
|
|
13
|
-
const defaultToolNames = TOOL_MODULES.map((tool) => tool.name);
|
|
14
|
-
const { settings } = loadSettings({ defaultTools: defaultToolNames });
|
|
15
|
-
const enabledTools = new Set(settings.tools && settings.tools.length > 0 ? settings.tools : defaultToolNames);
|
|
16
|
-
const enabledMcps = Array.isArray(settings.mcps) ? settings.mcps : [];
|
|
17
|
-
|
|
18
|
-
const context = {
|
|
19
|
-
workspaceRoot,
|
|
20
|
-
outputMaxLength: settings.outputMaxLength,
|
|
21
|
-
executionTimeout: settings.executionTimeout,
|
|
22
|
-
serviceBootWindow: settings.serviceBootWindow,
|
|
23
|
-
largeFileLineThreshold: settings.largeFileLineThreshold,
|
|
24
|
-
...options
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const tools = [];
|
|
28
|
-
const handlers = {};
|
|
29
|
-
const enabledToolNames = []; // 记录实际启用的工具名称
|
|
30
|
-
|
|
31
|
-
const registerTool = (toolModule) => {
|
|
32
|
-
if (!enabledTools.has(toolModule.name)) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const schema = typeof toolModule.schema === 'function' ? toolModule.schema(context) : toolModule.schema;
|
|
36
|
-
if (schema) {
|
|
37
|
-
tools.push(schema);
|
|
38
|
-
enabledToolNames.push(toolModule.name); // 记录启用的工具
|
|
39
|
-
}
|
|
40
|
-
handlers[toolModule.name] = async (params = {}) => toolModule.handler(params, context);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
TOOL_MODULES.forEach(registerTool);
|
|
44
|
-
|
|
45
|
-
const mcpManager = await createMcpManager(workspaceRoot, enabledMcps, {
|
|
46
|
-
mcpToolTimeout: settings.mcpToolTimeout
|
|
47
|
-
});
|
|
48
|
-
let mcpConfigPath = null;
|
|
49
|
-
const mcpToolNames = new Set(); // 记录所有 MCP 工具名称
|
|
50
|
-
const enabledMcpNames = []; // 记录启用的 MCP 服务器名称
|
|
51
|
-
if (mcpManager) {
|
|
52
|
-
mcpManager.getTools().forEach((mcpTool) => {
|
|
53
|
-
tools.push(mcpTool.schema);
|
|
54
|
-
handlers[mcpTool.name] = mcpTool.handler;
|
|
55
|
-
if (mcpTool.isMcpTool) {
|
|
56
|
-
mcpToolNames.add(mcpTool.name);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
mcpConfigPath = mcpManager.getConfigPath();
|
|
60
|
-
enabledMcpNames.push(...mcpManager.getEnabledServerNames()); // 获取启用的 MCP 名称
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const dispose = async () => {
|
|
64
|
-
if (mcpManager && typeof mcpManager.dispose === 'function') {
|
|
65
|
-
await mcpManager.dispose();
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
return { tools, handlers, dispose, mcpConfigPath, mcpToolNames, enabledToolNames, enabledMcpNames };
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
module.exports = {
|
|
73
|
-
createToolRuntime
|
|
74
|
-
};
|
|
1
|
+
const bash = require('./bash');
|
|
2
|
+
const read = require('./read');
|
|
3
|
+
const write = require('./write');
|
|
4
|
+
const edit = require('./edit');
|
|
5
|
+
const todos = require('./todos');
|
|
6
|
+
const skills = require('./skills');
|
|
7
|
+
const { createMcpManager } = require('./mcp');
|
|
8
|
+
const { loadSettings } = require('../config');
|
|
9
|
+
|
|
10
|
+
const TOOL_MODULES = [bash, read, write, edit, todos, skills];
|
|
11
|
+
|
|
12
|
+
const createToolRuntime = async (workspaceRoot, options = {}) => {
|
|
13
|
+
const defaultToolNames = TOOL_MODULES.map((tool) => tool.name);
|
|
14
|
+
const { settings } = loadSettings({ defaultTools: defaultToolNames });
|
|
15
|
+
const enabledTools = new Set(settings.tools && settings.tools.length > 0 ? settings.tools : defaultToolNames);
|
|
16
|
+
const enabledMcps = Array.isArray(settings.mcps) ? settings.mcps : [];
|
|
17
|
+
|
|
18
|
+
const context = {
|
|
19
|
+
workspaceRoot,
|
|
20
|
+
outputMaxLength: settings.outputMaxLength,
|
|
21
|
+
executionTimeout: settings.executionTimeout,
|
|
22
|
+
serviceBootWindow: settings.serviceBootWindow,
|
|
23
|
+
largeFileLineThreshold: settings.largeFileLineThreshold,
|
|
24
|
+
...options
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const tools = [];
|
|
28
|
+
const handlers = {};
|
|
29
|
+
const enabledToolNames = []; // 记录实际启用的工具名称
|
|
30
|
+
|
|
31
|
+
const registerTool = (toolModule) => {
|
|
32
|
+
if (!enabledTools.has(toolModule.name)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const schema = typeof toolModule.schema === 'function' ? toolModule.schema(context) : toolModule.schema;
|
|
36
|
+
if (schema) {
|
|
37
|
+
tools.push(schema);
|
|
38
|
+
enabledToolNames.push(toolModule.name); // 记录启用的工具
|
|
39
|
+
}
|
|
40
|
+
handlers[toolModule.name] = async (params = {}) => toolModule.handler(params, context);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
TOOL_MODULES.forEach(registerTool);
|
|
44
|
+
|
|
45
|
+
const mcpManager = await createMcpManager(workspaceRoot, enabledMcps, {
|
|
46
|
+
mcpToolTimeout: settings.mcpToolTimeout
|
|
47
|
+
});
|
|
48
|
+
let mcpConfigPath = null;
|
|
49
|
+
const mcpToolNames = new Set(); // 记录所有 MCP 工具名称
|
|
50
|
+
const enabledMcpNames = []; // 记录启用的 MCP 服务器名称
|
|
51
|
+
if (mcpManager) {
|
|
52
|
+
mcpManager.getTools().forEach((mcpTool) => {
|
|
53
|
+
tools.push(mcpTool.schema);
|
|
54
|
+
handlers[mcpTool.name] = mcpTool.handler;
|
|
55
|
+
if (mcpTool.isMcpTool) {
|
|
56
|
+
mcpToolNames.add(mcpTool.name);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
mcpConfigPath = mcpManager.getConfigPath();
|
|
60
|
+
enabledMcpNames.push(...mcpManager.getEnabledServerNames()); // 获取启用的 MCP 名称
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const dispose = async () => {
|
|
64
|
+
if (mcpManager && typeof mcpManager.dispose === 'function') {
|
|
65
|
+
await mcpManager.dispose();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return { tools, handlers, dispose, mcpConfigPath, mcpToolNames, enabledToolNames, enabledMcpNames };
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
module.exports = {
|
|
73
|
+
createToolRuntime
|
|
74
|
+
};
|