@ww_nero/mini-cli 1.0.104 → 1.0.106

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ww_nero/mini-cli",
3
- "version": "1.0.104",
3
+ "version": "1.0.106",
4
4
  "description": "极简的 AI 命令行助手",
5
5
  "bin": {
6
6
  "mini": "bin/mini.js"
package/src/config.js CHANGED
@@ -12,7 +12,6 @@ const FILE_NAMES = {
12
12
  const DEFAULT_TOOL_RESPONSE_MAX_TOKENS = 65536;
13
13
  const DEFAULT_COMPACT_TOKEN_THRESHOLD = 65536;
14
14
  const DEFAULT_MCP_TOOL_TIMEOUT_MS = 10 * 60 * 1000;
15
- const DEFAULT_OUTPUT_MAX_LENGTH = 12000;
16
15
  const DEFAULT_EXECUTION_TIMEOUT = 300000;
17
16
  const DEFAULT_SERVICE_BOOT_WINDOW = 5000;
18
17
  const DEFAULT_LARGE_FILE_LINE_THRESHOLD = 2000;
@@ -56,7 +55,6 @@ const DEFAULT_SETTINGS = {
56
55
  maxToolTokens: DEFAULT_TOOL_RESPONSE_MAX_TOKENS,
57
56
  compactTokenThreshold: DEFAULT_COMPACT_TOKEN_THRESHOLD,
58
57
  mcpToolTimeout: DEFAULT_MCP_TOOL_TIMEOUT_MS,
59
- outputMaxLength: DEFAULT_OUTPUT_MAX_LENGTH,
60
58
  executionTimeout: DEFAULT_EXECUTION_TIMEOUT,
61
59
  serviceBootWindow: DEFAULT_SERVICE_BOOT_WINDOW,
62
60
  largeFileLineThreshold: DEFAULT_LARGE_FILE_LINE_THRESHOLD
@@ -301,10 +299,6 @@ const loadSettings = ({ defaultTools = [] } = {}) => {
301
299
  parsed.mcpToolTimeout,
302
300
  DEFAULT_MCP_TOOL_TIMEOUT_MS
303
301
  ),
304
- outputMaxLength: normalizePositiveInteger(
305
- parsed.outputMaxLength,
306
- DEFAULT_OUTPUT_MAX_LENGTH
307
- ),
308
302
  executionTimeout: normalizePositiveInteger(
309
303
  parsed.executionTimeout,
310
304
  DEFAULT_EXECUTION_TIMEOUT
package/src/tools/bash.js CHANGED
@@ -8,7 +8,6 @@ const executeCommand = async ({ command, workingDirectory = '.', isService = fal
8
8
 
9
9
  const normalizedCommand = command.replace(/\bpython3\b/g, 'python');
10
10
 
11
- const outputMaxLength = context.outputMaxLength || 12000;
12
11
  const executionTimeout = context.executionTimeout || 300000;
13
12
  const serviceBootWindow = context.serviceBootWindow || 5000;
14
13
 
@@ -37,16 +36,10 @@ const executeCommand = async ({ command, workingDirectory = '.', isService = fal
37
36
 
38
37
  child.stdout.on('data', (data) => {
39
38
  stdout += data.toString();
40
- if (stdout.length > outputMaxLength) {
41
- stdout = stdout.slice(0, outputMaxLength);
42
- }
43
39
  });
44
40
 
45
41
  child.stderr.on('data', (data) => {
46
42
  stderr += data.toString();
47
- if (stderr.length > outputMaxLength) {
48
- stderr = stderr.slice(0, outputMaxLength);
49
- }
50
43
  });
51
44
 
52
45
  const handleProcessError = (error) => {
@@ -16,7 +16,6 @@ const createToolRuntime = async (workspaceRoot, options = {}) => {
16
16
 
17
17
  const context = {
18
18
  workspaceRoot,
19
- outputMaxLength: settings.outputMaxLength,
20
19
  executionTimeout: settings.executionTimeout,
21
20
  serviceBootWindow: settings.serviceBootWindow,
22
21
  largeFileLineThreshold: settings.largeFileLineThreshold,
@@ -1,6 +1,7 @@
1
1
  const chalk = require('chalk');
2
2
  const { Marked } = require('marked');
3
3
  const { markedTerminal } = require('marked-terminal');
4
+ const { encode } = require('gpt-tokenizer');
4
5
  const { splitThinkContent } = require('./think');
5
6
 
6
7
  const ANSI_PATTERN = /\u001B\[[0-9;]*m/g;
@@ -79,7 +80,16 @@ const printReasoningContent = (text, ensureNewline) => {
79
80
 
80
81
  if (!normalized) return;
81
82
  ensureNewline();
82
- console.log(chalk.gray(normalized));
83
+
84
+ let tokenCount = 0;
85
+ try {
86
+ tokenCount = encode(normalized).length;
87
+ } catch (_) {
88
+ // 忽略分词异常
89
+ }
90
+
91
+ const formattedTokens = `${(tokenCount / 1024).toFixed(1)}k`;
92
+ console.log(chalk.gray(`思考Tokens: ${formattedTokens}`));
83
93
  };
84
94
 
85
95
  const printAssistantContent = (text, ensureNewline) => {