refactor(core): move truncation logic from scheduler to shell tool

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

- Extract truncateAndSaveToFile to utils/truncation.ts with tests

- Move truncation handling from CoreToolScheduler to ShellTool

- Remove outputFile field from ToolCallResponseInfo and display types

- Add line limit constraint alongside character threshold for truncation

This improves separation of concerns by handling output truncation at the tool level where the output is generated, rather than centrally in the scheduler.
This commit is contained in:
tanzhenxin 2026-03-15 13:37:12 +08:00
parent 6e0cf6541d
commit 04b94d5720
11 changed files with 465 additions and 345 deletions

View file

@ -6,7 +6,7 @@
import type React from 'react';
import { useMemo } from 'react';
import { Box, Text } from 'ink';
import { Box } from 'ink';
import type { IndividualToolCallDisplay } from '../../types.js';
import { ToolCallStatus } from '../../types.js';
import { ToolMessage } from './ToolMessage.js';
@ -136,13 +136,6 @@ export const ToolGroupMessage: React.FC<ToolGroupMessageProps> = ({
contentWidth={innerWidth}
/>
)}
{tool.outputFile && (
<Box marginX={1}>
<Text color={theme.text.primary}>
Output too long and was saved to: {tool.outputFile}
</Text>
</Box>
)}
</Box>
);
})}