mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 06:15:51 +00:00
更新大量 tsx 原始文件; 已经迁移 login panel; 部分 (#121)
* style(B1-1): 格式化 ink/buddy/cli/context/screens/tasks/services/keybindings/state (43 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 修复了 Box.tsx 和 ScrollBox.tsx 中无效的 global.d.ts import。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-2): 格式化 commands (79 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-3): 格式化 components/messages,permissions,mcp,sandbox,shell (104 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-4): 格式化 components/PromptInput,FeedbackSurvey,tasks,agents,skills,design-system,wizard (73 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-5): 格式化 components其余 + hooks + tools (232 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-6): 格式化 main/entrypoints/utils/moreright (21 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: 更新 README,新增 Run.ps1/TODO.md,删除 V6.md - README.md: 大幅重写,更详细版本历史和配置示例 - Run.ps1: 新增 Windows 启动脚本 - TODO.md: 新增包完成清单 - V6.md: 删除(架构重构规划已不适用) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: 修复以前的问题 * fix: 修复 login 面板的问题 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,130 +1,181 @@
|
||||
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs';
|
||||
import * as React from 'react';
|
||||
import { KeyboardShortcutHint } from '../../components/design-system/KeyboardShortcutHint.js';
|
||||
import { FallbackToolUseErrorMessage } from '../../components/FallbackToolUseErrorMessage.js';
|
||||
import { MessageResponse } from '../../components/MessageResponse.js';
|
||||
import { OutputLine } from '../../components/shell/OutputLine.js';
|
||||
import { ShellProgressMessage } from '../../components/shell/ShellProgressMessage.js';
|
||||
import { ShellTimeDisplay } from '../../components/shell/ShellTimeDisplay.js';
|
||||
import { Box, Text } from '../../ink.js';
|
||||
import type { Tool } from '../../Tool.js';
|
||||
import type { ProgressMessage } from '../../types/message.js';
|
||||
import type { PowerShellProgress } from '../../types/tools.js';
|
||||
import type { ThemeName } from '../../utils/theme.js';
|
||||
import type { Out, PowerShellToolInput } from './PowerShellTool.js';
|
||||
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs'
|
||||
import * as React from 'react'
|
||||
import { KeyboardShortcutHint } from '../../components/design-system/KeyboardShortcutHint.js'
|
||||
import { FallbackToolUseErrorMessage } from '../../components/FallbackToolUseErrorMessage.js'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { OutputLine } from '../../components/shell/OutputLine.js'
|
||||
import { ShellProgressMessage } from '../../components/shell/ShellProgressMessage.js'
|
||||
import { ShellTimeDisplay } from '../../components/shell/ShellTimeDisplay.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import type { Tool } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import type { PowerShellProgress } from '../../types/tools.js'
|
||||
import type { ThemeName } from '../../utils/theme.js'
|
||||
import type { Out, PowerShellToolInput } from './PowerShellTool.js'
|
||||
|
||||
// Constants for command display
|
||||
const MAX_COMMAND_DISPLAY_LINES = 2;
|
||||
const MAX_COMMAND_DISPLAY_CHARS = 160;
|
||||
export function renderToolUseMessage(input: Partial<PowerShellToolInput>, {
|
||||
verbose,
|
||||
theme: _theme
|
||||
}: {
|
||||
verbose: boolean;
|
||||
theme: ThemeName;
|
||||
}): React.ReactNode {
|
||||
const {
|
||||
command
|
||||
} = input;
|
||||
const MAX_COMMAND_DISPLAY_LINES = 2
|
||||
const MAX_COMMAND_DISPLAY_CHARS = 160
|
||||
|
||||
export function renderToolUseMessage(
|
||||
input: Partial<PowerShellToolInput>,
|
||||
{ verbose, theme: _theme }: { verbose: boolean; theme: ThemeName },
|
||||
): React.ReactNode {
|
||||
const { command } = input
|
||||
if (!command) {
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
const displayCommand = command;
|
||||
|
||||
const displayCommand = command
|
||||
|
||||
if (!verbose) {
|
||||
const lines = displayCommand.split('\n');
|
||||
const needsLineTruncation = lines.length > MAX_COMMAND_DISPLAY_LINES;
|
||||
const needsCharTruncation = displayCommand.length > MAX_COMMAND_DISPLAY_CHARS;
|
||||
const lines = displayCommand.split('\n')
|
||||
const needsLineTruncation = lines.length > MAX_COMMAND_DISPLAY_LINES
|
||||
const needsCharTruncation =
|
||||
displayCommand.length > MAX_COMMAND_DISPLAY_CHARS
|
||||
|
||||
if (needsLineTruncation || needsCharTruncation) {
|
||||
let truncated = displayCommand;
|
||||
let truncated = displayCommand
|
||||
|
||||
if (needsLineTruncation) {
|
||||
truncated = lines.slice(0, MAX_COMMAND_DISPLAY_LINES).join('\n');
|
||||
truncated = lines.slice(0, MAX_COMMAND_DISPLAY_LINES).join('\n')
|
||||
}
|
||||
|
||||
if (truncated.length > MAX_COMMAND_DISPLAY_CHARS) {
|
||||
truncated = truncated.slice(0, MAX_COMMAND_DISPLAY_CHARS);
|
||||
truncated = truncated.slice(0, MAX_COMMAND_DISPLAY_CHARS)
|
||||
}
|
||||
return <Text>{truncated.trim()}…</Text>;
|
||||
|
||||
return <Text>{truncated.trim()}…</Text>
|
||||
}
|
||||
}
|
||||
return displayCommand;
|
||||
|
||||
return displayCommand
|
||||
}
|
||||
export function renderToolUseProgressMessage(progressMessagesForMessage: ProgressMessage<PowerShellProgress>[], {
|
||||
verbose,
|
||||
tools: _tools,
|
||||
terminalSize: _terminalSize,
|
||||
inProgressToolCallCount: _inProgressToolCallCount
|
||||
}: {
|
||||
tools: Tool[];
|
||||
verbose: boolean;
|
||||
terminalSize?: {
|
||||
columns: number;
|
||||
rows: number;
|
||||
};
|
||||
inProgressToolCallCount?: number;
|
||||
}): React.ReactNode {
|
||||
const lastProgress = progressMessagesForMessage.at(-1);
|
||||
|
||||
export function renderToolUseProgressMessage(
|
||||
progressMessagesForMessage: ProgressMessage<PowerShellProgress>[],
|
||||
{
|
||||
verbose,
|
||||
tools: _tools,
|
||||
terminalSize: _terminalSize,
|
||||
inProgressToolCallCount: _inProgressToolCallCount,
|
||||
}: {
|
||||
tools: Tool[]
|
||||
verbose: boolean
|
||||
terminalSize?: { columns: number; rows: number }
|
||||
inProgressToolCallCount?: number
|
||||
},
|
||||
): React.ReactNode {
|
||||
const lastProgress = progressMessagesForMessage.at(-1)
|
||||
|
||||
if (!lastProgress || !lastProgress.data) {
|
||||
return <MessageResponse height={1}>
|
||||
return (
|
||||
<MessageResponse height={1}>
|
||||
<Text dimColor>Running…</Text>
|
||||
</MessageResponse>;
|
||||
</MessageResponse>
|
||||
)
|
||||
}
|
||||
const data = lastProgress.data;
|
||||
return <ShellProgressMessage fullOutput={data.fullOutput} output={data.output} elapsedTimeSeconds={data.elapsedTimeSeconds} totalLines={data.totalLines} totalBytes={data.totalBytes} timeoutMs={data.timeoutMs} taskId={data.taskId} verbose={verbose} />;
|
||||
|
||||
const data = lastProgress.data
|
||||
|
||||
return (
|
||||
<ShellProgressMessage
|
||||
fullOutput={data.fullOutput}
|
||||
output={data.output}
|
||||
elapsedTimeSeconds={data.elapsedTimeSeconds}
|
||||
totalLines={data.totalLines}
|
||||
totalBytes={data.totalBytes}
|
||||
timeoutMs={data.timeoutMs}
|
||||
taskId={data.taskId}
|
||||
verbose={verbose}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export function renderToolUseQueuedMessage(): React.ReactNode {
|
||||
return <MessageResponse height={1}>
|
||||
return (
|
||||
<MessageResponse height={1}>
|
||||
<Text dimColor>Waiting…</Text>
|
||||
</MessageResponse>;
|
||||
</MessageResponse>
|
||||
)
|
||||
}
|
||||
export function renderToolResultMessage(content: Out, progressMessagesForMessage: ProgressMessage<PowerShellProgress>[], {
|
||||
verbose,
|
||||
theme: _theme,
|
||||
tools: _tools,
|
||||
style: _style
|
||||
}: {
|
||||
verbose: boolean;
|
||||
theme: ThemeName;
|
||||
tools: Tool[];
|
||||
style?: 'condensed';
|
||||
}): React.ReactNode {
|
||||
const lastProgress = progressMessagesForMessage.at(-1);
|
||||
const timeoutMs = lastProgress?.data?.timeoutMs;
|
||||
|
||||
export function renderToolResultMessage(
|
||||
content: Out,
|
||||
progressMessagesForMessage: ProgressMessage<PowerShellProgress>[],
|
||||
{
|
||||
verbose,
|
||||
theme: _theme,
|
||||
tools: _tools,
|
||||
style: _style,
|
||||
}: {
|
||||
verbose: boolean
|
||||
theme: ThemeName
|
||||
tools: Tool[]
|
||||
style?: 'condensed'
|
||||
},
|
||||
): React.ReactNode {
|
||||
const lastProgress = progressMessagesForMessage.at(-1)
|
||||
const timeoutMs = lastProgress?.data?.timeoutMs
|
||||
const {
|
||||
stdout,
|
||||
stderr,
|
||||
interrupted,
|
||||
returnCodeInterpretation,
|
||||
isImage,
|
||||
backgroundTaskId
|
||||
} = content;
|
||||
backgroundTaskId,
|
||||
} = content
|
||||
|
||||
if (isImage) {
|
||||
return <MessageResponse height={1}>
|
||||
return (
|
||||
<MessageResponse height={1}>
|
||||
<Text dimColor>[Image data detected and sent to Claude]</Text>
|
||||
</MessageResponse>;
|
||||
</MessageResponse>
|
||||
)
|
||||
}
|
||||
return <Box flexDirection="column">
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
{stdout !== '' ? <OutputLine content={stdout} verbose={verbose} /> : null}
|
||||
{stderr.trim() !== '' ? <OutputLine content={stderr} verbose={verbose} isError /> : null}
|
||||
{stdout === '' && stderr.trim() === '' ? <MessageResponse height={1}>
|
||||
{stderr.trim() !== '' ? (
|
||||
<OutputLine content={stderr} verbose={verbose} isError />
|
||||
) : null}
|
||||
{stdout === '' && stderr.trim() === '' ? (
|
||||
<MessageResponse height={1}>
|
||||
<Text dimColor>
|
||||
{backgroundTaskId ? <>
|
||||
{backgroundTaskId ? (
|
||||
<>
|
||||
Running in the background{' '}
|
||||
<KeyboardShortcutHint shortcut="↓" action="manage" parens />
|
||||
</> : interrupted ? 'Interrupted' : returnCodeInterpretation || '(No output)'}
|
||||
</>
|
||||
) : interrupted ? (
|
||||
'Interrupted'
|
||||
) : (
|
||||
returnCodeInterpretation || '(No output)'
|
||||
)}
|
||||
</Text>
|
||||
</MessageResponse> : null}
|
||||
{timeoutMs ? <MessageResponse>
|
||||
</MessageResponse>
|
||||
) : null}
|
||||
{timeoutMs ? (
|
||||
<MessageResponse>
|
||||
<ShellTimeDisplay timeoutMs={timeoutMs} />
|
||||
</MessageResponse> : null}
|
||||
</Box>;
|
||||
</MessageResponse>
|
||||
) : null}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
export function renderToolUseErrorMessage(result: ToolResultBlockParam['content'], {
|
||||
verbose,
|
||||
progressMessagesForMessage: _progressMessagesForMessage,
|
||||
tools: _tools
|
||||
}: {
|
||||
verbose: boolean;
|
||||
progressMessagesForMessage: ProgressMessage<PowerShellProgress>[];
|
||||
tools: Tool[];
|
||||
}): React.ReactNode {
|
||||
return <FallbackToolUseErrorMessage result={result} verbose={verbose} />;
|
||||
|
||||
export function renderToolUseErrorMessage(
|
||||
result: ToolResultBlockParam['content'],
|
||||
{
|
||||
verbose,
|
||||
progressMessagesForMessage: _progressMessagesForMessage,
|
||||
tools: _tools,
|
||||
}: {
|
||||
verbose: boolean
|
||||
progressMessagesForMessage: ProgressMessage<PowerShellProgress>[]
|
||||
tools: Tool[]
|
||||
},
|
||||
): React.ReactNode {
|
||||
return <FallbackToolUseErrorMessage result={result} verbose={verbose} />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user