mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 13:55:50 +00:00
feat: 第一个可以用的 ink 组件抽象 (#158)
This commit is contained in:
@@ -8,8 +8,7 @@ import {
|
||||
CtrlOToExpand,
|
||||
SubAgentProvider,
|
||||
} from 'src/components/CtrlOToExpand.js'
|
||||
import { Byline } from 'src/components/design-system/Byline.js'
|
||||
import { KeyboardShortcutHint } from 'src/components/design-system/KeyboardShortcutHint.js'
|
||||
import { Byline, KeyboardShortcutHint } from '@anthropic/ink'
|
||||
import type { z } from 'zod/v4'
|
||||
import { AgentProgressLine } from '../../components/AgentProgressLine.js'
|
||||
import { FallbackToolUseErrorMessage } from '../../components/FallbackToolUseErrorMessage.js'
|
||||
@@ -18,7 +17,7 @@ import { Markdown } from '../../components/Markdown.js'
|
||||
import { Message as MessageComponent } from '../../components/Message.js'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { ToolUseLoader } from '../../components/ToolUseLoader.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import { getDumpPromptsPath } from '../../services/api/dumpPrompts.js'
|
||||
import { findToolByName, type Tools } from '../../Tool.js'
|
||||
import type { Message, ProgressMessage } from '../../types/message.js'
|
||||
|
||||
@@ -8,7 +8,7 @@ import { MessageResponse } from 'src/components/MessageResponse.js'
|
||||
import { BLACK_CIRCLE } from 'src/constants/figures.js'
|
||||
import { getModeColor } from 'src/utils/permissions/PermissionMode.js'
|
||||
import { z } from 'zod/v4'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import type { Tool } from '../../Tool.js'
|
||||
import { buildTool, type ToolDef } from '../../Tool.js'
|
||||
import { lazySchema } from '../../utils/lazySchema.js'
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import React from 'react'
|
||||
import { removeSandboxViolationTags } from 'src/utils/sandbox/sandbox-ui-utils.js'
|
||||
import { KeyboardShortcutHint } from '../../components/design-system/KeyboardShortcutHint.js'
|
||||
import { KeyboardShortcutHint } from '@anthropic/ink'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { OutputLine } from '../../components/shell/OutputLine.js'
|
||||
import { ShellTimeDisplay } from '../../components/shell/ShellTimeDisplay.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import type { Out as BashOut } from './BashTool.js'
|
||||
|
||||
type Props = {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs'
|
||||
import * as React from 'react'
|
||||
import { KeyboardShortcutHint } from '../../components/design-system/KeyboardShortcutHint.js'
|
||||
import { KeyboardShortcutHint } from '@anthropic/ink'
|
||||
import { FallbackToolUseErrorMessage } from '../../components/FallbackToolUseErrorMessage.js'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { ShellProgressMessage } from '../../components/shell/ShellProgressMessage.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import { useKeybinding } from '../../keybindings/useKeybinding.js'
|
||||
import { useShortcutDisplay } from '../../keybindings/useShortcutDisplay.js'
|
||||
import { useAppStateStore, useSetAppState } from '../../state/AppState.js'
|
||||
|
||||
@@ -2,7 +2,7 @@ import figures from 'figures'
|
||||
import React from 'react'
|
||||
import { Markdown } from '../../components/Markdown.js'
|
||||
import { BLACK_CIRCLE } from '../../constants/figures.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import { getDisplayPath } from '../../utils/file.js'
|
||||
import { formatFileSize } from '../../utils/format.js'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { Text } from '../../ink.js'
|
||||
import { Text } from '@anthropic/ink'
|
||||
import { jsonStringify } from '../../utils/slowOperations.js'
|
||||
import type { Input, Output } from './ConfigTool.js'
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as React from 'react'
|
||||
import { BLACK_CIRCLE } from 'src/constants/figures.js'
|
||||
import { getModeColor } from 'src/utils/permissions/PermissionMode.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import type { ToolProgressData } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import type { ThemeName } from '../../utils/theme.js'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as React from 'react'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import type { ToolProgressData } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import type { ThemeName } from '../../utils/theme.js'
|
||||
|
||||
@@ -4,7 +4,7 @@ import { MessageResponse } from 'src/components/MessageResponse.js'
|
||||
import { RejectedPlanMessage } from 'src/components/messages/UserToolResultMessage/RejectedPlanMessage.js'
|
||||
import { BLACK_CIRCLE } from 'src/constants/figures.js'
|
||||
import { getModeColor } from 'src/utils/permissions/PermissionMode.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import type { ToolProgressData } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import { getDisplayPath } from '../../utils/file.js'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as React from 'react'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import type { ToolProgressData } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import type { ThemeName } from '../../utils/theme.js'
|
||||
|
||||
@@ -7,8 +7,9 @@ import { MessageResponse } from 'src/components/MessageResponse.js'
|
||||
import { extractTag } from 'src/utils/messages.js'
|
||||
import { FallbackToolUseErrorMessage } from '../../components/FallbackToolUseErrorMessage.js'
|
||||
import { FileEditToolUpdatedMessage } from '../../components/FileEditToolUpdatedMessage.js'
|
||||
|
||||
import { Text } from '@anthropic/ink'
|
||||
import { FilePathLink } from '../../components/FilePathLink.js'
|
||||
import { Text } from '../../ink.js'
|
||||
import type { Tools } from '../../Tool.js'
|
||||
import type { Message, ProgressMessage } from '../../types/message.js'
|
||||
import { adjustHunkLineNumbers, CONTEXT_LINES } from '../../utils/diff.js'
|
||||
|
||||
@@ -2,9 +2,10 @@ import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs
|
||||
import * as React from 'react'
|
||||
import { extractTag } from 'src/utils/messages.js'
|
||||
import { FallbackToolUseErrorMessage } from '../../components/FallbackToolUseErrorMessage.js'
|
||||
import { FilePathLink } from '../../components/FilePathLink.js'
|
||||
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { Text } from '../../ink.js'
|
||||
import { Text } from '@anthropic/ink'
|
||||
import { FilePathLink } from '../../components/FilePathLink.js'
|
||||
import { FILE_NOT_FOUND_CWD_NOTE, getDisplayPath } from '../../utils/file.js'
|
||||
import { formatFileSize } from '../../utils/format.js'
|
||||
import { getPlansDirectory } from '../../utils/plans.js'
|
||||
|
||||
@@ -9,10 +9,11 @@ import { CtrlOToExpand } from '../../components/CtrlOToExpand.js'
|
||||
import { FallbackToolUseErrorMessage } from '../../components/FallbackToolUseErrorMessage.js'
|
||||
import { FileEditToolUpdatedMessage } from '../../components/FileEditToolUpdatedMessage.js'
|
||||
import { FileEditToolUseRejectedMessage } from '../../components/FileEditToolUseRejectedMessage.js'
|
||||
import { FilePathLink } from '../../components/FilePathLink.js'
|
||||
|
||||
import { HighlightedCode } from '../../components/HighlightedCode.js'
|
||||
import { useTerminalSize } from '../../hooks/useTerminalSize.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import { FilePathLink } from '../../components/FilePathLink.js'
|
||||
import type { ToolProgressData } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import { getCwd } from '../../utils/cwd.js'
|
||||
|
||||
@@ -4,7 +4,7 @@ import { MessageResponse } from 'src/components/MessageResponse.js'
|
||||
import { extractTag } from 'src/utils/messages.js'
|
||||
import { FallbackToolUseErrorMessage } from '../../components/FallbackToolUseErrorMessage.js'
|
||||
import { TOOL_SUMMARY_MAX_LENGTH } from '../../constants/toolLimits.js'
|
||||
import { Text } from '../../ink.js'
|
||||
import { Text } from '@anthropic/ink'
|
||||
import { FILE_NOT_FOUND_CWD_NOTE, getDisplayPath } from '../../utils/file.js'
|
||||
import { truncate } from '../../utils/format.js'
|
||||
import { GrepTool } from '../GrepTool/GrepTool.js'
|
||||
|
||||
@@ -4,7 +4,7 @@ import { CtrlOToExpand } from '../../components/CtrlOToExpand.js'
|
||||
import { FallbackToolUseErrorMessage } from '../../components/FallbackToolUseErrorMessage.js'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { TOOL_SUMMARY_MAX_LENGTH } from '../../constants/toolLimits.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import type { ToolProgressData } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import { FILE_NOT_FOUND_CWD_NOTE, getDisplayPath } from '../../utils/file.js'
|
||||
|
||||
@@ -3,7 +3,7 @@ import React from 'react'
|
||||
import { CtrlOToExpand } from '../../components/CtrlOToExpand.js'
|
||||
import { FallbackToolUseErrorMessage } from '../../components/FallbackToolUseErrorMessage.js'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import { getDisplayPath } from '../../utils/file.js'
|
||||
import { extractTag } from '../../utils/messages.js'
|
||||
import type { Input, Output } from './LSPTool.js'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as React from 'react'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { OutputLine } from '../../components/shell/OutputLine.js'
|
||||
import { Text } from '../../ink.js'
|
||||
import { Text } from '@anthropic/ink'
|
||||
import type { ToolProgressData } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import { jsonStringify } from '../../utils/slowOperations.js'
|
||||
|
||||
@@ -2,19 +2,19 @@ import { feature } from 'bun:bundle'
|
||||
import figures from 'figures'
|
||||
import * as React from 'react'
|
||||
import type { z } from 'zod/v4'
|
||||
import { ProgressBar } from '../../components/design-system/ProgressBar.js'
|
||||
import { ProgressBar } from '@anthropic/ink'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import {
|
||||
linkifyUrlsInText,
|
||||
OutputLine,
|
||||
} from '../../components/shell/OutputLine.js'
|
||||
import { stringWidth } from '../../ink/stringWidth.js'
|
||||
import { Ansi, Box, Text } from '../../ink.js'
|
||||
import { Ansi, Box, Text, stringWidth } from '@anthropic/ink'
|
||||
import { createHyperlink } from '../../utils/hyperlink.js'
|
||||
import type { ToolProgressData } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import type { MCPProgress } from '../../types/tools.js'
|
||||
import { formatNumber } from '../../utils/format.js'
|
||||
import { createHyperlink } from '../../utils/hyperlink.js'
|
||||
|
||||
import {
|
||||
getContentSizeEstimate,
|
||||
type MCPToolResult,
|
||||
|
||||
@@ -5,11 +5,12 @@ import { extractTag } from 'src/utils/messages.js'
|
||||
import type { ThemeName } from 'src/utils/theme.js'
|
||||
import type { z } from 'zod/v4'
|
||||
import { FallbackToolUseErrorMessage } from '../../components/FallbackToolUseErrorMessage.js'
|
||||
import { FilePathLink } from '../../components/FilePathLink.js'
|
||||
|
||||
import { HighlightedCode } from '../../components/HighlightedCode.js'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { NotebookEditToolUseRejectedMessage } from '../../components/NotebookEditToolUseRejectedMessage.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import { FilePathLink } from '../../components/FilePathLink.js'
|
||||
import type { Tools } from '../../Tool.js'
|
||||
import { getDisplayPath } from '../../utils/file.js'
|
||||
import type { inputSchema, Output } from './NotebookEditTool.js'
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs'
|
||||
import * as React from 'react'
|
||||
import { KeyboardShortcutHint } from '../../components/design-system/KeyboardShortcutHint.js'
|
||||
import { KeyboardShortcutHint } from '@anthropic/ink'
|
||||
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 { Box, Text } from '@anthropic/ink'
|
||||
import type { Tool } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import type { PowerShellProgress } from '../../types/tools.js'
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as React from 'react'
|
||||
import type { z } from 'zod/v4'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { OutputLine } from '../../components/shell/OutputLine.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import type { ToolProgressData } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import { jsonStringify } from '../../utils/slowOperations.js'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { Text } from '../../ink.js'
|
||||
import { Text } from '@anthropic/ink'
|
||||
import { countCharInString } from '../../utils/stringUtils.js'
|
||||
import type { Input, Output } from './RemoteTriggerTool.js'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { Text } from '../../ink.js'
|
||||
import { Text } from '@anthropic/ink'
|
||||
import { truncate } from '../../utils/format.js'
|
||||
import type { CreateOutput } from './CronCreateTool.js'
|
||||
import type { DeleteOutput } from './CronDeleteTool.js'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { Text } from '../../ink.js'
|
||||
import { Text } from '@anthropic/ink'
|
||||
import { jsonParse } from '../../utils/slowOperations.js'
|
||||
import type { Input, SendMessageToolOutput } from './SendMessageTool.js'
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import { FallbackToolUseErrorMessage } from 'src/components/FallbackToolUseError
|
||||
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 { Byline } from '@anthropic/ink'
|
||||
import { Message as MessageComponent } from '../../components/Message.js'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import type { Tools } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import { buildSubagentLookups, EMPTY_LOOKUPS } from '../../utils/messages.js'
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
getSlashCommandToolSkills,
|
||||
} from 'src/commands.js'
|
||||
import { COMMAND_NAME_TAG } from '../../constants/xml.js'
|
||||
import { stringWidth } from '../../ink/stringWidth.js'
|
||||
import { stringWidth } from '@anthropic/ink'
|
||||
import {
|
||||
type AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
|
||||
logEvent,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { z } from 'zod/v4'
|
||||
import { FallbackToolUseErrorMessage } from '../../components/FallbackToolUseErrorMessage.js'
|
||||
import { FallbackToolUseRejectedMessage } from '../../components/FallbackToolUseRejectedMessage.js'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import { useShortcutDisplay } from '../../keybindings/useShortcutDisplay.js'
|
||||
import type { TaskType } from '../../Task.js'
|
||||
import type { Tool } from '../../Tool.js'
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React from 'react'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { stringWidth } from '../../ink/stringWidth.js'
|
||||
import { Text } from '../../ink.js'
|
||||
import { Text, stringWidth } from '@anthropic/ink'
|
||||
import { truncateToWidthNoEllipsis } from '../../utils/format.js'
|
||||
import type { Output } from './TaskStopTool.js'
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { TOOL_SUMMARY_MAX_LENGTH } from '../../constants/toolLimits.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import type { ToolProgressData } from '../../Tool.js'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import { formatFileSize, truncate } from '../../utils/format.js'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react'
|
||||
import { MessageResponse } from '../../components/MessageResponse.js'
|
||||
import { TOOL_SUMMARY_MAX_LENGTH } from '../../constants/toolLimits.js'
|
||||
import { Box, Text } from '../../ink.js'
|
||||
import { Box, Text } from '@anthropic/ink'
|
||||
import type { ProgressMessage } from '../../types/message.js'
|
||||
import { truncate } from '../../utils/format.js'
|
||||
import type {
|
||||
|
||||
Reference in New Issue
Block a user