@ww_nero/mini-cli 1.0.78 → 1.0.79
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/package.json +1 -1
- package/src/chat.js +6 -6
- package/src/tools/{replace.js → edit.js} +4 -4
- package/src/tools/index.js +2 -2
- package/src/utils/renderer.js +3 -3
package/package.json
CHANGED
package/src/chat.js
CHANGED
|
@@ -113,7 +113,7 @@ const formatWriteOutput = (result) => {
|
|
|
113
113
|
return lines.slice(0, 20).join('\n') + '\n...(更多内容)';
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
-
const
|
|
116
|
+
const formatEditOutput = (result) => {
|
|
117
117
|
if (!result || typeof result !== 'object' || !result.success) {
|
|
118
118
|
return null;
|
|
119
119
|
}
|
|
@@ -996,11 +996,11 @@ const startChatSession = async ({
|
|
|
996
996
|
if (writeOutput) {
|
|
997
997
|
console.log(writeOutput);
|
|
998
998
|
}
|
|
999
|
-
} else if (functionName === '
|
|
1000
|
-
// For
|
|
1001
|
-
const
|
|
1002
|
-
if (
|
|
1003
|
-
console.log(
|
|
999
|
+
} else if (functionName === 'edit') {
|
|
1000
|
+
// For edit, display diff-style output
|
|
1001
|
+
const editOutput = formatEditOutput(toolResult);
|
|
1002
|
+
if (editOutput) {
|
|
1003
|
+
console.log(editOutput);
|
|
1004
1004
|
}
|
|
1005
1005
|
} else if (functionName === 'todos') {
|
|
1006
1006
|
// For todos, display full formatted output without truncation
|
|
@@ -30,7 +30,7 @@ const computeDiffStats = (before = '', after = '') => {
|
|
|
30
30
|
}, { added: 0, removed: 0 });
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const editFile = async ({ filePath, search, replace } = {}, context = {}) => {
|
|
34
34
|
if (!filePath || typeof filePath !== 'string') {
|
|
35
35
|
return 'filePath 参数不能为空';
|
|
36
36
|
}
|
|
@@ -107,7 +107,7 @@ const replaceInFile = async ({ filePath, search, replace } = {}, context = {}) =
|
|
|
107
107
|
const schema = {
|
|
108
108
|
type: 'function',
|
|
109
109
|
function: {
|
|
110
|
-
name: '
|
|
110
|
+
name: 'edit',
|
|
111
111
|
description: '在文件中搜索并替换指定的代码片段(简单字符串匹配,非正则)',
|
|
112
112
|
parameters: {
|
|
113
113
|
type: 'object',
|
|
@@ -131,7 +131,7 @@ const schema = {
|
|
|
131
131
|
};
|
|
132
132
|
|
|
133
133
|
module.exports = {
|
|
134
|
-
name: '
|
|
134
|
+
name: 'edit',
|
|
135
135
|
schema,
|
|
136
|
-
handler:
|
|
136
|
+
handler: editFile
|
|
137
137
|
};
|
package/src/tools/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const bash = require('./bash');
|
|
2
2
|
const read = require('./read');
|
|
3
3
|
const write = require('./write');
|
|
4
|
-
const
|
|
4
|
+
const edit = require('./edit');
|
|
5
5
|
const todos = require('./todos');
|
|
6
6
|
const skills = require('./skills');
|
|
7
7
|
const { createMcpManager } = require('./mcp');
|
|
8
8
|
const { loadSettings } = require('../config');
|
|
9
9
|
|
|
10
|
-
const TOOL_MODULES = [bash, read, write,
|
|
10
|
+
const TOOL_MODULES = [bash, read, write, edit, todos, skills];
|
|
11
11
|
|
|
12
12
|
const createToolRuntime = async (workspaceRoot, options = {}) => {
|
|
13
13
|
const defaultToolNames = TOOL_MODULES.map((tool) => tool.name);
|
package/src/utils/renderer.js
CHANGED
|
@@ -25,7 +25,7 @@ const formatWriteHeader = (args = {}) => {
|
|
|
25
25
|
return ` (${filePath}, ${chalk.green(`+${lineCount}`)})`;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const formatEditHeader = (args = {}) => {
|
|
29
29
|
const filePath = args.filePath || '';
|
|
30
30
|
const searchLines = countLines(args.search);
|
|
31
31
|
const replaceLines = countLines(args.replace);
|
|
@@ -40,8 +40,8 @@ const formatHeader = (name, args, options = {}) => {
|
|
|
40
40
|
let specialHeader = '';
|
|
41
41
|
if (name === 'write') {
|
|
42
42
|
specialHeader = formatWriteHeader(args);
|
|
43
|
-
} else if (name === '
|
|
44
|
-
specialHeader =
|
|
43
|
+
} else if (name === 'edit') {
|
|
44
|
+
specialHeader = formatEditHeader(args);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const labelWithInfo = `${labelBase}${specialHeader}`;
|