mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-23 08:45:50 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -3,10 +3,7 @@ import type { ValidationResult } from 'src/Tool.js'
|
||||
import { buildTool, type ToolDef } from 'src/Tool.js'
|
||||
import { getCwd } from 'src/utils/cwd.js'
|
||||
import { isENOENT } from 'src/utils/errors.js'
|
||||
import {
|
||||
FILE_NOT_FOUND_CWD_NOTE,
|
||||
suggestPathUnderCwd,
|
||||
} from 'src/utils/file.js'
|
||||
import { FILE_NOT_FOUND_CWD_NOTE, suggestPathUnderCwd } from 'src/utils/file.js'
|
||||
import { getFsImplementation } from 'src/utils/fsOperations.js'
|
||||
import { glob } from 'src/utils/glob.js'
|
||||
import { lazySchema } from 'src/utils/lazySchema.js'
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs'
|
||||
import React from 'react'
|
||||
import { MessageResponse } from 'src/components/MessageResponse.js'
|
||||
import { extractTag } from 'src/utils/messages.js'
|
||||
import { FallbackToolUseErrorMessage } from 'src/components/FallbackToolUseErrorMessage.js'
|
||||
import { TOOL_SUMMARY_MAX_LENGTH } from 'src/constants/toolLimits.js'
|
||||
import { Text } from '@anthropic/ink'
|
||||
import { FILE_NOT_FOUND_CWD_NOTE, getDisplayPath } from 'src/utils/file.js'
|
||||
import { truncate } from 'src/utils/format.js'
|
||||
import { GrepTool } from '../GrepTool/GrepTool.js'
|
||||
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs';
|
||||
import React from 'react';
|
||||
import { MessageResponse } from 'src/components/MessageResponse.js';
|
||||
import { extractTag } from 'src/utils/messages.js';
|
||||
import { FallbackToolUseErrorMessage } from 'src/components/FallbackToolUseErrorMessage.js';
|
||||
import { TOOL_SUMMARY_MAX_LENGTH } from 'src/constants/toolLimits.js';
|
||||
import { Text } from '@anthropic/ink';
|
||||
import { FILE_NOT_FOUND_CWD_NOTE, getDisplayPath } from 'src/utils/file.js';
|
||||
import { truncate } from 'src/utils/format.js';
|
||||
import { GrepTool } from '../GrepTool/GrepTool.js';
|
||||
|
||||
export function userFacingName(): string {
|
||||
return 'Search'
|
||||
return 'Search';
|
||||
}
|
||||
|
||||
export function renderToolUseMessage(
|
||||
@@ -18,48 +18,42 @@ export function renderToolUseMessage(
|
||||
{ verbose }: { verbose: boolean },
|
||||
): React.ReactNode {
|
||||
if (!pattern) {
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
if (!path) {
|
||||
return `pattern: "${pattern}"`
|
||||
return `pattern: "${pattern}"`;
|
||||
}
|
||||
return `pattern: "${pattern}", path: "${verbose ? path : getDisplayPath(path)}"`
|
||||
return `pattern: "${pattern}", path: "${verbose ? path : getDisplayPath(path)}"`;
|
||||
}
|
||||
|
||||
export function renderToolUseErrorMessage(
|
||||
result: ToolResultBlockParam['content'],
|
||||
{ verbose }: { verbose: boolean },
|
||||
): React.ReactNode {
|
||||
if (
|
||||
!verbose &&
|
||||
typeof result === 'string' &&
|
||||
extractTag(result, 'tool_use_error')
|
||||
) {
|
||||
const errorMessage = extractTag(result, 'tool_use_error')
|
||||
if (!verbose && typeof result === 'string' && extractTag(result, 'tool_use_error')) {
|
||||
const errorMessage = extractTag(result, 'tool_use_error');
|
||||
if (errorMessage?.includes(FILE_NOT_FOUND_CWD_NOTE)) {
|
||||
return (
|
||||
<MessageResponse>
|
||||
<Text color="error">File not found</Text>
|
||||
</MessageResponse>
|
||||
)
|
||||
);
|
||||
}
|
||||
return (
|
||||
<MessageResponse>
|
||||
<Text color="error">Error searching files</Text>
|
||||
</MessageResponse>
|
||||
)
|
||||
);
|
||||
}
|
||||
return <FallbackToolUseErrorMessage result={result} verbose={verbose} />
|
||||
return <FallbackToolUseErrorMessage result={result} verbose={verbose} />;
|
||||
}
|
||||
|
||||
// Note: GlobTool reuses GrepTool's renderToolResultMessage
|
||||
export const renderToolResultMessage = GrepTool.renderToolResultMessage
|
||||
export const renderToolResultMessage = GrepTool.renderToolResultMessage;
|
||||
|
||||
export function getToolUseSummary(
|
||||
input: Partial<{ pattern: string; path: string }> | undefined,
|
||||
): string | null {
|
||||
export function getToolUseSummary(input: Partial<{ pattern: string; path: string }> | undefined): string | null {
|
||||
if (!input?.pattern) {
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
return truncate(input.pattern, TOOL_SUMMARY_MAX_LENGTH)
|
||||
return truncate(input.pattern, TOOL_SUMMARY_MAX_LENGTH);
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// Auto-generated type stub — replace with real implementation
|
||||
export type MessageResponse = any;
|
||||
export type MessageResponse = any
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// Auto-generated type stub — replace with real implementation
|
||||
export type extractTag = any;
|
||||
export type extractTag = any
|
||||
|
||||
Reference in New Issue
Block a user