@ww_nero/mini-cli 1.0.81 → 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.
@@ -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
+ };