mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-21 15:55:50 +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,227 +1,203 @@
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs';
|
||||
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 { getDisplayPath } from '../../utils/file.js';
|
||||
import { extractTag } from '../../utils/messages.js';
|
||||
import type { Input, Output } from './LSPTool.js';
|
||||
import { getSymbolAtPosition } from './symbolContext.js';
|
||||
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs'
|
||||
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 { getDisplayPath } from '../../utils/file.js'
|
||||
import { extractTag } from '../../utils/messages.js'
|
||||
import type { Input, Output } from './LSPTool.js'
|
||||
import { getSymbolAtPosition } from './symbolContext.js'
|
||||
|
||||
// Lookup map for operation-specific labels
|
||||
const OPERATION_LABELS: Record<Input['operation'], {
|
||||
singular: string;
|
||||
plural: string;
|
||||
special?: string;
|
||||
}> = {
|
||||
goToDefinition: {
|
||||
singular: 'definition',
|
||||
plural: 'definitions'
|
||||
},
|
||||
findReferences: {
|
||||
singular: 'reference',
|
||||
plural: 'references'
|
||||
},
|
||||
documentSymbol: {
|
||||
singular: 'symbol',
|
||||
plural: 'symbols'
|
||||
},
|
||||
workspaceSymbol: {
|
||||
singular: 'symbol',
|
||||
plural: 'symbols'
|
||||
},
|
||||
hover: {
|
||||
singular: 'hover info',
|
||||
plural: 'hover info',
|
||||
special: 'available'
|
||||
},
|
||||
goToImplementation: {
|
||||
singular: 'implementation',
|
||||
plural: 'implementations'
|
||||
},
|
||||
prepareCallHierarchy: {
|
||||
singular: 'call item',
|
||||
plural: 'call items'
|
||||
},
|
||||
incomingCalls: {
|
||||
singular: 'caller',
|
||||
plural: 'callers'
|
||||
},
|
||||
outgoingCalls: {
|
||||
singular: 'callee',
|
||||
plural: 'callees'
|
||||
}
|
||||
};
|
||||
const OPERATION_LABELS: Record<
|
||||
Input['operation'],
|
||||
{ singular: string; plural: string; special?: string }
|
||||
> = {
|
||||
goToDefinition: { singular: 'definition', plural: 'definitions' },
|
||||
findReferences: { singular: 'reference', plural: 'references' },
|
||||
documentSymbol: { singular: 'symbol', plural: 'symbols' },
|
||||
workspaceSymbol: { singular: 'symbol', plural: 'symbols' },
|
||||
hover: { singular: 'hover info', plural: 'hover info', special: 'available' },
|
||||
goToImplementation: { singular: 'implementation', plural: 'implementations' },
|
||||
prepareCallHierarchy: { singular: 'call item', plural: 'call items' },
|
||||
incomingCalls: { singular: 'caller', plural: 'callers' },
|
||||
outgoingCalls: { singular: 'callee', plural: 'callees' },
|
||||
}
|
||||
|
||||
/**
|
||||
* Reusable component for LSP result summaries with collapsed/expanded views
|
||||
*/
|
||||
function LSPResultSummary(t0) {
|
||||
const $ = _c(24);
|
||||
const {
|
||||
operation,
|
||||
resultCount,
|
||||
fileCount,
|
||||
content,
|
||||
verbose
|
||||
} = t0;
|
||||
let t1;
|
||||
if ($[0] !== operation) {
|
||||
t1 = OPERATION_LABELS[operation] || {
|
||||
singular: "result",
|
||||
plural: "results"
|
||||
};
|
||||
$[0] = operation;
|
||||
$[1] = t1;
|
||||
} else {
|
||||
t1 = $[1];
|
||||
}
|
||||
const labelConfig = t1;
|
||||
const countLabel = resultCount === 1 ? labelConfig.singular : labelConfig.plural;
|
||||
let t2;
|
||||
if ($[2] !== countLabel || $[3] !== labelConfig.special || $[4] !== operation || $[5] !== resultCount) {
|
||||
t2 = operation === "hover" && resultCount > 0 && labelConfig.special ? <Text>Hover info {labelConfig.special}</Text> : <Text>Found <Text bold={true}>{resultCount} </Text>{countLabel}</Text>;
|
||||
$[2] = countLabel;
|
||||
$[3] = labelConfig.special;
|
||||
$[4] = operation;
|
||||
$[5] = resultCount;
|
||||
$[6] = t2;
|
||||
} else {
|
||||
t2 = $[6];
|
||||
}
|
||||
const primaryText = t2;
|
||||
let t3;
|
||||
if ($[7] !== fileCount) {
|
||||
t3 = fileCount > 1 ? <Text>{" "}across <Text bold={true}>{fileCount} </Text>files</Text> : null;
|
||||
$[7] = fileCount;
|
||||
$[8] = t3;
|
||||
} else {
|
||||
t3 = $[8];
|
||||
}
|
||||
const secondaryText = t3;
|
||||
if (verbose) {
|
||||
let t4;
|
||||
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t4 = <Text dimColor={true}> ⎿ </Text>;
|
||||
$[9] = t4;
|
||||
} else {
|
||||
t4 = $[9];
|
||||
}
|
||||
let t5;
|
||||
if ($[10] !== primaryText || $[11] !== secondaryText) {
|
||||
t5 = <Box flexDirection="row"><Text>{t4}{primaryText}{secondaryText}</Text></Box>;
|
||||
$[10] = primaryText;
|
||||
$[11] = secondaryText;
|
||||
$[12] = t5;
|
||||
} else {
|
||||
t5 = $[12];
|
||||
}
|
||||
let t6;
|
||||
if ($[13] !== content) {
|
||||
t6 = <Box marginLeft={5}><Text>{content}</Text></Box>;
|
||||
$[13] = content;
|
||||
$[14] = t6;
|
||||
} else {
|
||||
t6 = $[14];
|
||||
}
|
||||
let t7;
|
||||
if ($[15] !== t5 || $[16] !== t6) {
|
||||
t7 = <Box flexDirection="column">{t5}{t6}</Box>;
|
||||
$[15] = t5;
|
||||
$[16] = t6;
|
||||
$[17] = t7;
|
||||
} else {
|
||||
t7 = $[17];
|
||||
}
|
||||
return t7;
|
||||
}
|
||||
let t4;
|
||||
if ($[18] !== resultCount) {
|
||||
t4 = resultCount > 0 && <CtrlOToExpand />;
|
||||
$[18] = resultCount;
|
||||
$[19] = t4;
|
||||
} else {
|
||||
t4 = $[19];
|
||||
}
|
||||
let t5;
|
||||
if ($[20] !== primaryText || $[21] !== secondaryText || $[22] !== t4) {
|
||||
t5 = <MessageResponse height={1}><Text>{primaryText}{secondaryText} {t4}</Text></MessageResponse>;
|
||||
$[20] = primaryText;
|
||||
$[21] = secondaryText;
|
||||
$[22] = t4;
|
||||
$[23] = t5;
|
||||
} else {
|
||||
t5 = $[23];
|
||||
}
|
||||
return t5;
|
||||
}
|
||||
export function userFacingName(): string {
|
||||
return 'LSP';
|
||||
}
|
||||
export function renderToolUseMessage(input: Partial<Input>, {
|
||||
verbose
|
||||
function LSPResultSummary({
|
||||
operation,
|
||||
resultCount,
|
||||
fileCount,
|
||||
content,
|
||||
verbose,
|
||||
}: {
|
||||
verbose: boolean;
|
||||
operation: Input['operation']
|
||||
resultCount: number
|
||||
fileCount: number
|
||||
content: string
|
||||
verbose: boolean
|
||||
}): React.ReactNode {
|
||||
if (!input.operation) {
|
||||
return null;
|
||||
// Get label configuration for this operation
|
||||
const labelConfig = OPERATION_LABELS[operation] || {
|
||||
singular: 'result',
|
||||
plural: 'results',
|
||||
}
|
||||
const parts: string[] = [];
|
||||
const countLabel =
|
||||
resultCount === 1 ? labelConfig.singular : labelConfig.plural
|
||||
|
||||
const primaryText =
|
||||
operation === 'hover' && resultCount > 0 && labelConfig.special ? (
|
||||
<Text>Hover info {labelConfig.special}</Text>
|
||||
) : (
|
||||
<Text>
|
||||
Found <Text bold>{resultCount} </Text>
|
||||
{countLabel}
|
||||
</Text>
|
||||
)
|
||||
|
||||
const secondaryText =
|
||||
fileCount > 1 ? (
|
||||
<Text>
|
||||
{' '}
|
||||
across <Text bold>{fileCount} </Text>
|
||||
files
|
||||
</Text>
|
||||
) : null
|
||||
|
||||
if (verbose) {
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Box flexDirection="row">
|
||||
<Text>
|
||||
<Text dimColor> ⎿ </Text>
|
||||
{primaryText}
|
||||
{secondaryText}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box marginLeft={5}>
|
||||
<Text>{content}</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<MessageResponse height={1}>
|
||||
<Text>
|
||||
{primaryText}
|
||||
{secondaryText} {resultCount > 0 && <CtrlOToExpand />}
|
||||
</Text>
|
||||
</MessageResponse>
|
||||
)
|
||||
}
|
||||
|
||||
export function userFacingName(): string {
|
||||
return 'LSP'
|
||||
}
|
||||
|
||||
export function renderToolUseMessage(
|
||||
input: Partial<Input>,
|
||||
{ verbose }: { verbose: boolean },
|
||||
): React.ReactNode {
|
||||
if (!input.operation) {
|
||||
return null
|
||||
}
|
||||
|
||||
const parts: string[] = []
|
||||
|
||||
// For position-based operations (goToDefinition, findReferences, hover, goToImplementation),
|
||||
// show the symbol at the position for better context
|
||||
if ((input.operation === 'goToDefinition' || input.operation === 'findReferences' || input.operation === 'hover' || input.operation === 'goToImplementation') && input.filePath && input.line !== undefined && input.character !== undefined) {
|
||||
if (
|
||||
(input.operation === 'goToDefinition' ||
|
||||
input.operation === 'findReferences' ||
|
||||
input.operation === 'hover' ||
|
||||
input.operation === 'goToImplementation') &&
|
||||
input.filePath &&
|
||||
input.line !== undefined &&
|
||||
input.character !== undefined
|
||||
) {
|
||||
// Convert from 1-based (user input) to 0-based (internal file reading)
|
||||
const symbol = getSymbolAtPosition(input.filePath, input.line - 1, input.character - 1);
|
||||
const displayPath = verbose ? input.filePath : getDisplayPath(input.filePath);
|
||||
const symbol = getSymbolAtPosition(
|
||||
input.filePath,
|
||||
input.line - 1,
|
||||
input.character - 1,
|
||||
)
|
||||
const displayPath = verbose
|
||||
? input.filePath
|
||||
: getDisplayPath(input.filePath)
|
||||
|
||||
if (symbol) {
|
||||
parts.push(`operation: "${input.operation}"`);
|
||||
parts.push(`symbol: "${symbol}"`);
|
||||
parts.push(`in: "${displayPath}"`);
|
||||
parts.push(`operation: "${input.operation}"`)
|
||||
parts.push(`symbol: "${symbol}"`)
|
||||
parts.push(`in: "${displayPath}"`)
|
||||
} else {
|
||||
parts.push(`operation: "${input.operation}"`);
|
||||
parts.push(`file: "${displayPath}"`);
|
||||
parts.push(`position: ${input.line}:${input.character}`);
|
||||
parts.push(`operation: "${input.operation}"`)
|
||||
parts.push(`file: "${displayPath}"`)
|
||||
parts.push(`position: ${input.line}:${input.character}`)
|
||||
}
|
||||
return parts.join(', ');
|
||||
|
||||
return parts.join(', ')
|
||||
}
|
||||
|
||||
// For other operations (documentSymbol, workspaceSymbol),
|
||||
// show operation and file without position details
|
||||
parts.push(`operation: "${input.operation}"`);
|
||||
parts.push(`operation: "${input.operation}"`)
|
||||
|
||||
if (input.filePath) {
|
||||
const displayPath = verbose ? input.filePath : getDisplayPath(input.filePath);
|
||||
parts.push(`file: "${displayPath}"`);
|
||||
const displayPath = verbose
|
||||
? input.filePath
|
||||
: getDisplayPath(input.filePath)
|
||||
parts.push(`file: "${displayPath}"`)
|
||||
}
|
||||
return parts.join(', ');
|
||||
|
||||
return parts.join(', ')
|
||||
}
|
||||
export function renderToolUseErrorMessage(result: ToolResultBlockParam['content'], {
|
||||
verbose
|
||||
}: {
|
||||
verbose: boolean;
|
||||
}): React.ReactNode {
|
||||
if (!verbose && typeof result === 'string' && extractTag(result, 'tool_use_error')) {
|
||||
return <MessageResponse>
|
||||
|
||||
export function renderToolUseErrorMessage(
|
||||
result: ToolResultBlockParam['content'],
|
||||
{ verbose }: { verbose: boolean },
|
||||
): React.ReactNode {
|
||||
if (
|
||||
!verbose &&
|
||||
typeof result === 'string' &&
|
||||
extractTag(result, 'tool_use_error')
|
||||
) {
|
||||
return (
|
||||
<MessageResponse>
|
||||
<Text color="error">LSP operation failed</Text>
|
||||
</MessageResponse>;
|
||||
</MessageResponse>
|
||||
)
|
||||
}
|
||||
return <FallbackToolUseErrorMessage result={result} verbose={verbose} />;
|
||||
return <FallbackToolUseErrorMessage result={result} verbose={verbose} />
|
||||
}
|
||||
export function renderToolResultMessage(output: Output, _progressMessages: unknown[], {
|
||||
verbose
|
||||
}: {
|
||||
verbose: boolean;
|
||||
}): React.ReactNode {
|
||||
|
||||
export function renderToolResultMessage(
|
||||
output: Output,
|
||||
_progressMessages: unknown[],
|
||||
{ verbose }: { verbose: boolean },
|
||||
): React.ReactNode {
|
||||
// Use collapsed/expanded view if we have count information
|
||||
if (output.resultCount !== undefined && output.fileCount !== undefined) {
|
||||
return <LSPResultSummary operation={output.operation} resultCount={output.resultCount} fileCount={output.fileCount} content={output.result} verbose={verbose} />;
|
||||
return (
|
||||
<LSPResultSummary
|
||||
operation={output.operation}
|
||||
resultCount={output.resultCount}
|
||||
fileCount={output.fileCount}
|
||||
content={output.result}
|
||||
verbose={verbose}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
// Fallback for error cases where counts aren't available
|
||||
// (e.g., LSP server initialization failures, request errors)
|
||||
return <MessageResponse>
|
||||
return (
|
||||
<MessageResponse>
|
||||
<Text>{output.result}</Text>
|
||||
</MessageResponse>;
|
||||
</MessageResponse>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user