@ww_nero/mini-cli 1.0.72 → 1.0.73

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/chat.js +13 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ww_nero/mini-cli",
3
- "version": "1.0.72",
3
+ "version": "1.0.73",
4
4
  "description": "极简的 AI 命令行助手",
5
5
  "bin": {
6
6
  "mini": "bin/mini.js"
package/src/chat.js CHANGED
@@ -103,14 +103,20 @@ const formatReplaceOutput = (result) => {
103
103
  const lines = [];
104
104
 
105
105
  const searchLines = searchContent.split('\n');
106
- searchLines.forEach((line) => {
107
- lines.push(chalk.red(`-${line}`));
108
- });
109
-
110
106
  const replaceLines = replaceContent.split('\n');
111
- replaceLines.forEach((line) => {
112
- lines.push(chalk.green(`+${line}`));
113
- });
107
+ const maxLinesPerSide = 20;
108
+ const appendLimitedLines = (list, prefix, colorizer) => {
109
+ const limit = Math.min(list.length, maxLinesPerSide);
110
+ for (let i = 0; i < limit; i += 1) {
111
+ lines.push(colorizer(`${prefix}${list[i]}`));
112
+ }
113
+ if (list.length > maxLinesPerSide) {
114
+ lines.push(colorizer(`${prefix} ...(更多代码)`));
115
+ }
116
+ };
117
+
118
+ appendLimitedLines(searchLines, '-', chalk.red);
119
+ appendLimitedLines(replaceLines, '+', chalk.green);
114
120
 
115
121
  return lines.join('\n');
116
122
  };