mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-20 07: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,127 +1,181 @@
|
||||
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs';
|
||||
import * as React from 'react';
|
||||
import { SubAgentProvider } from 'src/components/CtrlOToExpand.js';
|
||||
import { FallbackToolUseErrorMessage } from 'src/components/FallbackToolUseErrorMessage.js';
|
||||
import { FallbackToolUseRejectedMessage } from 'src/components/FallbackToolUseRejectedMessage.js';
|
||||
import type { z } from 'zod/v4';
|
||||
import type { Command } from '../../commands.js';
|
||||
import { Byline } from '../../components/design-system/Byline.js';
|
||||
import { Message as MessageComponent } from '../../components/Message.js';
|
||||
import { MessageResponse } from '../../components/MessageResponse.js';
|
||||
import { Box, Text } from '../../ink.js';
|
||||
import type { Tools } from '../../Tool.js';
|
||||
import type { ProgressMessage } from '../../types/message.js';
|
||||
import { buildSubagentLookups, EMPTY_LOOKUPS } from '../../utils/messages.js';
|
||||
import { plural } from '../../utils/stringUtils.js';
|
||||
import type { inputSchema, Output, Progress } from './SkillTool.js';
|
||||
type Input = z.infer<ReturnType<typeof inputSchema>>;
|
||||
const MAX_PROGRESS_MESSAGES_TO_SHOW = 3;
|
||||
const INITIALIZING_TEXT = 'Initializing…';
|
||||
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs'
|
||||
import * as React from 'react'
|
||||
import { SubAgentProvider } from 'src/components/CtrlOToExpand.js'
|
||||
import { FallbackToolUseErrorMessage } from 'src/components/FallbackToolUseErrorMessage.js'
|
||||
import { FallbackToolUseRejectedMessage } from 'src/components/FallbackToolUseRejectedMessage.js'
|
||||
import type { z } from 'zod/v4'
|
||||
import type { Command } from '../../commands.js'
|
||||
import { Byline } from '../../components/design-system/Byline.js'
|
||||
import { Message as MessageComponent } from '../../components/Message.js'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import type { Tools } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import { buildSubagentLookups, EMPTY_LOOKUPS } from '../../utils/messages.js'
|
||||
import { plural } from '../../utils/stringUtils.js'
|
||||
import type { inputSchema, Output, Progress } from './SkillTool.js'
|
||||
|
||||
type Input = z.infer<ReturnType<typeof inputSchema>>
|
||||
|
||||
const MAX_PROGRESS_MESSAGES_TO_SHOW = 3
|
||||
const INITIALIZING_TEXT = 'Initializing…'
|
||||
|
||||
export function renderToolResultMessage(output: Output): React.ReactNode {
|
||||
// Handle forked skill result
|
||||
if ('status' in output && output.status === 'forked') {
|
||||
return <MessageResponse height={1}>
|
||||
return (
|
||||
<MessageResponse height={1}>
|
||||
<Text>
|
||||
<Byline>{['Done']}</Byline>
|
||||
</Text>
|
||||
</MessageResponse>;
|
||||
</MessageResponse>
|
||||
)
|
||||
}
|
||||
const parts: string[] = ['Successfully loaded skill'];
|
||||
|
||||
const parts: string[] = ['Successfully loaded skill']
|
||||
|
||||
// Show tools count (only for inline skills)
|
||||
if ('allowedTools' in output && output.allowedTools && output.allowedTools.length > 0) {
|
||||
const count = output.allowedTools.length;
|
||||
parts.push(`${count} ${plural(count, 'tool')} allowed`);
|
||||
if (
|
||||
'allowedTools' in output &&
|
||||
output.allowedTools &&
|
||||
output.allowedTools.length > 0
|
||||
) {
|
||||
const count = output.allowedTools.length
|
||||
parts.push(`${count} ${plural(count, 'tool')} allowed`)
|
||||
}
|
||||
|
||||
// Show model if non-default (only for inline skills)
|
||||
if ('model' in output && output.model) {
|
||||
parts.push(output.model);
|
||||
parts.push(output.model)
|
||||
}
|
||||
return <MessageResponse height={1}>
|
||||
|
||||
return (
|
||||
<MessageResponse height={1}>
|
||||
<Text>
|
||||
<Byline>{parts}</Byline>
|
||||
</Text>
|
||||
</MessageResponse>;
|
||||
</MessageResponse>
|
||||
)
|
||||
}
|
||||
export function renderToolUseMessage({
|
||||
skill
|
||||
}: Partial<Input>, {
|
||||
commands
|
||||
}: {
|
||||
commands?: Command[];
|
||||
}): React.ReactNode {
|
||||
|
||||
export function renderToolUseMessage(
|
||||
{ skill }: Partial<Input>,
|
||||
{ commands }: { commands?: Command[] },
|
||||
): React.ReactNode {
|
||||
if (!skill) {
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
// Look up the command to check if it came from the legacy /commands folder
|
||||
const command = commands?.find(c => c.name === skill);
|
||||
const displayName = command?.loadedFrom === 'commands_DEPRECATED' ? `/${skill}` : skill;
|
||||
return displayName;
|
||||
const command = commands?.find(c => c.name === skill)
|
||||
const displayName =
|
||||
command?.loadedFrom === 'commands_DEPRECATED' ? `/${skill}` : skill
|
||||
return displayName
|
||||
}
|
||||
export function renderToolUseProgressMessage(progressMessages: ProgressMessage<Progress>[], {
|
||||
tools,
|
||||
verbose
|
||||
}: {
|
||||
tools: Tools;
|
||||
verbose: boolean;
|
||||
}): React.ReactNode {
|
||||
|
||||
export function renderToolUseProgressMessage(
|
||||
progressMessages: ProgressMessage<Progress>[],
|
||||
{
|
||||
tools,
|
||||
verbose,
|
||||
}: {
|
||||
tools: Tools
|
||||
verbose: boolean
|
||||
},
|
||||
): React.ReactNode {
|
||||
if (!progressMessages.length) {
|
||||
return <MessageResponse height={1}>
|
||||
return (
|
||||
<MessageResponse height={1}>
|
||||
<Text dimColor>{INITIALIZING_TEXT}</Text>
|
||||
</MessageResponse>;
|
||||
</MessageResponse>
|
||||
)
|
||||
}
|
||||
|
||||
// Take only the last few messages for display in non-verbose mode
|
||||
const displayedMessages = verbose ? progressMessages : progressMessages.slice(-MAX_PROGRESS_MESSAGES_TO_SHOW);
|
||||
const hiddenCount = progressMessages.length - displayedMessages.length;
|
||||
const {
|
||||
inProgressToolUseIDs
|
||||
} = buildSubagentLookups(progressMessages.map(pm => pm.data));
|
||||
return <MessageResponse>
|
||||
const displayedMessages = verbose
|
||||
? progressMessages
|
||||
: progressMessages.slice(-MAX_PROGRESS_MESSAGES_TO_SHOW)
|
||||
|
||||
const hiddenCount = progressMessages.length - displayedMessages.length
|
||||
const { inProgressToolUseIDs } = buildSubagentLookups(
|
||||
progressMessages.map(pm => pm.data),
|
||||
)
|
||||
|
||||
return (
|
||||
<MessageResponse>
|
||||
<Box flexDirection="column">
|
||||
<SubAgentProvider>
|
||||
{displayedMessages.map(progressMessage => <Box key={progressMessage.uuid} height={1} overflow="hidden">
|
||||
<MessageComponent message={progressMessage.data.message} lookups={EMPTY_LOOKUPS} addMargin={false} tools={tools} commands={[]} verbose={verbose} inProgressToolUseIDs={inProgressToolUseIDs} progressMessagesForMessage={[]} shouldAnimate={false} shouldShowDot={false} style="condensed" isTranscriptMode={false} isStatic={true} />
|
||||
</Box>)}
|
||||
{displayedMessages.map(progressMessage => (
|
||||
<Box key={progressMessage.uuid} height={1} overflow="hidden">
|
||||
<MessageComponent
|
||||
message={progressMessage.data.message}
|
||||
lookups={EMPTY_LOOKUPS}
|
||||
addMargin={false}
|
||||
tools={tools}
|
||||
commands={[]}
|
||||
verbose={verbose}
|
||||
inProgressToolUseIDs={inProgressToolUseIDs}
|
||||
progressMessagesForMessage={[]}
|
||||
shouldAnimate={false}
|
||||
shouldShowDot={false}
|
||||
style="condensed"
|
||||
isTranscriptMode={false}
|
||||
isStatic={true}
|
||||
/>
|
||||
</Box>
|
||||
))}
|
||||
</SubAgentProvider>
|
||||
{hiddenCount > 0 && <Text dimColor>
|
||||
{hiddenCount > 0 && (
|
||||
<Text dimColor>
|
||||
+{hiddenCount} more tool {plural(hiddenCount, 'use')}
|
||||
</Text>}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</MessageResponse>;
|
||||
</MessageResponse>
|
||||
)
|
||||
}
|
||||
export function renderToolUseRejectedMessage(_input: Input, {
|
||||
progressMessagesForMessage,
|
||||
tools,
|
||||
verbose
|
||||
}: {
|
||||
progressMessagesForMessage: ProgressMessage<Progress>[];
|
||||
tools: Tools;
|
||||
verbose: boolean;
|
||||
}): React.ReactNode {
|
||||
return <>
|
||||
|
||||
export function renderToolUseRejectedMessage(
|
||||
_input: Input,
|
||||
{
|
||||
progressMessagesForMessage,
|
||||
tools,
|
||||
verbose,
|
||||
}: {
|
||||
progressMessagesForMessage: ProgressMessage<Progress>[]
|
||||
tools: Tools
|
||||
verbose: boolean
|
||||
},
|
||||
): React.ReactNode {
|
||||
return (
|
||||
<>
|
||||
{renderToolUseProgressMessage(progressMessagesForMessage, {
|
||||
tools,
|
||||
verbose
|
||||
})}
|
||||
tools,
|
||||
verbose,
|
||||
})}
|
||||
<FallbackToolUseRejectedMessage />
|
||||
</>;
|
||||
</>
|
||||
)
|
||||
}
|
||||
export function renderToolUseErrorMessage(result: ToolResultBlockParam['content'], {
|
||||
progressMessagesForMessage,
|
||||
tools,
|
||||
verbose
|
||||
}: {
|
||||
progressMessagesForMessage: ProgressMessage<Progress>[];
|
||||
tools: Tools;
|
||||
verbose: boolean;
|
||||
}): React.ReactNode {
|
||||
return <>
|
||||
|
||||
export function renderToolUseErrorMessage(
|
||||
result: ToolResultBlockParam['content'],
|
||||
{
|
||||
progressMessagesForMessage,
|
||||
tools,
|
||||
verbose,
|
||||
}: {
|
||||
progressMessagesForMessage: ProgressMessage<Progress>[]
|
||||
tools: Tools
|
||||
verbose: boolean
|
||||
},
|
||||
): React.ReactNode {
|
||||
return (
|
||||
<>
|
||||
{renderToolUseProgressMessage(progressMessagesForMessage, {
|
||||
tools,
|
||||
verbose
|
||||
})}
|
||||
tools,
|
||||
verbose,
|
||||
})}
|
||||
<FallbackToolUseErrorMessage result={result} verbose={verbose} />
|
||||
</>;
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user