@ww_nero/mini-cli 1.0.90 → 1.0.91

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 CHANGED
File without changes
package/bin/mini.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ww_nero/mini-cli",
3
- "version": "1.0.90",
3
+ "version": "1.0.91",
4
4
  "description": "极简的 AI 命令行助手",
5
5
  "bin": {
6
6
  "mini": "bin/mini.js"
package/src/chat.js CHANGED
@@ -151,42 +151,31 @@ const enforceToolOutputLimit = (text, tokenLimit) => {
151
151
  const content = typeof text === 'string' ? text : stringifyToolResult(text);
152
152
  const safeContent = typeof content === 'string' ? content : '';
153
153
  try {
154
- const tokens = encode(safeContent);
155
- const tokenCount = tokens.length;
156
- if (tokenCount > tokenLimit) {
157
- return {
158
- content: '输出内容太长,请优化工具调用方式。',
159
- truncated: true,
160
- originalTokenCount: tokenCount,
161
- limit: tokenLimit
162
- };
154
+ if (encode(safeContent).length > tokenLimit) {
155
+ return '输出内容太长,请优化工具调用方式。';
163
156
  }
164
- return {
165
- content: safeContent,
166
- truncated: false,
167
- tokenCount
168
- };
157
+ return safeContent;
169
158
  } catch (_) {
170
159
  // 忽略分词异常,保持原始输出
171
- return {
172
- content: safeContent,
173
- truncated: false,
174
- tokenCount: null
175
- };
160
+ return safeContent;
176
161
  }
177
162
  };
178
163
 
179
- const truncateForDisplay = (text, maxLength = 100) => {
180
- if (!text || typeof text !== 'string') {
164
+ const formatToolResultForDisplay = (text, maxLength = 100) => {
165
+ if (typeof text !== 'string') {
181
166
  return '';
182
167
  }
183
- const normalized = text.replace(/\s+/g, ' ').trim();
184
- if (normalized.length <= maxLength) {
185
- return normalized;
168
+ const normalized = text.replace(/\r\n/g, '\n').replace(/\r/g, '\n').trim();
169
+ if (!normalized) {
170
+ return '';
186
171
  }
187
- return normalized.substring(0, maxLength) + '...';
172
+ return normalized.length > maxLength ? 'Done' : normalized;
188
173
  };
189
174
 
175
+ const indentToolResult = (text = '') => splitDisplayLines(text)
176
+ .map((line) => ` ${line}`)
177
+ .join('\n');
178
+
190
179
  const supportsCursorControl = () => Boolean(process.stdout && process.stdout.isTTY);
191
180
 
192
181
  let loadingCursorActive = false;
@@ -870,7 +859,6 @@ const startChatSession = async ({
870
859
  };
871
860
 
872
861
  while (true) {
873
- process.stdout.write('\n');
874
862
  showLoadingPrompt();
875
863
  const streamState = {
876
864
  thinkState: createThinkParserState(),
@@ -878,13 +866,12 @@ const startChatSession = async ({
878
866
  reasoningFromThink: ''
879
867
  };
880
868
  let reasoningFromModel = '';
881
- let printedNewline = false;
869
+ let outputStarted = false;
882
870
 
883
871
  const ensureNewline = () => {
884
- if (!printedNewline) {
872
+ if (!outputStarted) {
885
873
  clearLoadingPrompt();
886
- process.stdout.write('\n');
887
- printedNewline = true;
874
+ outputStarted = true;
888
875
  }
889
876
  };
890
877
 
@@ -962,6 +949,7 @@ const startChatSession = async ({
962
949
  ? parsedArgs
963
950
  : { raw: typeof rawArgs === 'string' ? rawArgs : '' };
964
951
 
952
+ ensureNewline();
965
953
  renderToolCall({ functionName, args: displayArgs }, mcpToolNames);
966
954
 
967
955
  let toolResult;
@@ -981,8 +969,8 @@ const startChatSession = async ({
981
969
  }
982
970
  }
983
971
 
984
- const resultInfo = enforceToolOutputLimit(stringifyToolResult(toolResult), toolOutputTokenLimit);
985
- const toolContent = resultInfo.content;
972
+ const rawToolContent = stringifyToolResult(toolResult);
973
+ const toolContent = enforceToolOutputLimit(rawToolContent, toolOutputTokenLimit);
986
974
 
987
975
  // Display tool output
988
976
  if (functionName === 'write') {
@@ -997,24 +985,15 @@ const startChatSession = async ({
997
985
  if (editOutput) {
998
986
  console.log(editOutput);
999
987
  }
1000
- } else if (functionName === 'skills') {
1001
- const preview = truncateForDisplay(toolContent, 200);
1002
- if (preview) {
1003
- console.log(chalk.gray(` ${preview}`));
1004
- }
1005
988
  } else {
1006
- // For other tools, show preview in gray
1007
- const preview = truncateForDisplay(toolContent, 100);
1008
- if (preview) {
1009
- console.log(chalk.gray(` ${preview}`));
1010
- }
1011
-
1012
- // If truncated, show warning
1013
- if (resultInfo.truncated) {
1014
- console.log(chalk.yellow(` ⚠ 输出已截断 (${resultInfo.originalTokenCount} tokens > ${resultInfo.limit} limit)`));
989
+ const displayResult = formatToolResultForDisplay(rawToolContent, 100);
990
+ if (displayResult) {
991
+ console.log(chalk.gray(indentToolResult(displayResult)));
1015
992
  }
1016
993
  }
1017
994
 
995
+ process.stdout.write('\n');
996
+
1018
997
  messages.push({
1019
998
  role: 'tool',
1020
999
  tool_call_id: toolCall.id,
package/src/config.js CHANGED
File without changes
package/src/index.js CHANGED
File without changes
package/src/llm.js CHANGED
File without changes
File without changes
package/src/request.js CHANGED
File without changes
package/src/tools/bash.js CHANGED
File without changes
package/src/tools/edit.js CHANGED
File without changes
File without changes
package/src/tools/mcp.js CHANGED
File without changes
package/src/tools/read.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
package/src/utils/git.js CHANGED
File without changes
File without changes
File without changes
package/src/utils/menu.js CHANGED
File without changes
File without changes
@@ -1,7 +1,7 @@
1
1
  const chalk = require('chalk');
2
2
  const { Marked } = require('marked');
3
3
  const { markedTerminal } = require('marked-terminal');
4
- const { splitThinkContent, summarizeReasoning } = require('./think');
4
+ const { splitThinkContent } = require('./think');
5
5
 
6
6
  const ANSI_PATTERN = /\u001B\[[0-9;]*m/g;
7
7
 
@@ -70,10 +70,14 @@ const mergeReasoningContent = (...segments) => {
70
70
  return normalized.join('\n');
71
71
  };
72
72
 
73
- const printReasoningSummary = (text, ensureNewline) => {
74
- if (!text) return;
73
+ const printReasoningContent = (text, ensureNewline) => {
74
+ const normalized = typeof text === 'string'
75
+ ? text.replace(/\r\n/g, '\n').replace(/\r/g, '\n').trim()
76
+ : '';
77
+
78
+ if (!normalized) return;
75
79
  ensureNewline();
76
- console.log(chalk.gray(`思考:${summarizeReasoning(text)}`));
80
+ console.log(chalk.gray(`思考:\n${normalized}`));
77
81
  };
78
82
 
79
83
  const printAssistantContent = (text, ensureNewline) => {
@@ -89,7 +93,7 @@ const printAssistantContent = (text, ensureNewline) => {
89
93
  };
90
94
 
91
95
  const renderAssistantOutput = (reasoning, content, ensureNewline) => {
92
- printReasoningSummary(reasoning, ensureNewline);
96
+ printReasoningContent(reasoning, ensureNewline);
93
97
  printAssistantContent(content, ensureNewline);
94
98
  };
95
99
 
@@ -126,7 +130,7 @@ const printUsageTokens = (usage) => {
126
130
 
127
131
  module.exports = {
128
132
  mergeReasoningContent,
129
- printReasoningSummary,
133
+ printReasoningContent,
130
134
  printAssistantContent,
131
135
  renderAssistantOutput,
132
136
  sanitizeContentWithThink,
File without changes
File without changes
File without changes
@@ -194,21 +194,10 @@ const splitThinkContent = (text = '') => {
194
194
  return { content, reasoning };
195
195
  };
196
196
 
197
- const summarizeReasoning = (text = '', maxLength = 100) => {
198
- if (!text) return '';
199
- const normalized = text.replace(/\s+/g, ' ').trim();
200
- if (!normalized) return '';
201
- if (normalized.length > maxLength) {
202
- return normalized.substring(0, maxLength) + '...';
203
- }
204
- return normalized;
205
- };
206
-
207
197
  module.exports = {
208
198
  THINK_TAGS,
209
199
  createThinkParserState,
210
200
  processThinkChunk,
211
201
  flushThinkState,
212
- splitThinkContent,
213
- summarizeReasoning
202
+ splitThinkContent
214
203
  };