style: 完成所有文件的lint

This commit is contained in:
claude-code-best
2026-05-01 21:39:30 +08:00
parent d136872cc9
commit 6182015005
1333 changed files with 68255 additions and 77882 deletions

View File

@@ -267,7 +267,9 @@ export const NotebookEditTool = buildTool({
}
} else {
// First try to find the cell by its actual ID
const cellIndex = notebook.cells.findIndex((cell: NotebookCell) => cell.id === cell_id)
const cellIndex = notebook.cells.findIndex(
(cell: NotebookCell) => cell.id === cell_id,
)
if (cellIndex === -1) {
// If not found, try to parse as a numeric index (cell-N format)
@@ -352,7 +354,9 @@ export const NotebookEditTool = buildTool({
cellIndex = 0 // Default to inserting at the beginning if no cell_id is provided
} else {
// First try to find the cell by its actual ID
cellIndex = notebook.cells.findIndex((cell: NotebookCell) => cell.id === cell_id)
cellIndex = notebook.cells.findIndex(
(cell: NotebookCell) => cell.id === cell_id,
)
// If not found, try to parse as a numeric index (cell-N format)
if (cellIndex === -1) {
@@ -377,7 +381,7 @@ export const NotebookEditTool = buildTool({
}
const language = notebook.metadata.language_info?.name ?? 'python'
let new_cell_id = undefined
let new_cell_id
if (
notebook.nbformat > 4 ||
(notebook.nbformat === 4 && notebook.nbformat_minor >= 5)

View File

@@ -1,57 +1,49 @@
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs'
import * as React from 'react'
import type { Message, ProgressMessage } from 'src/types/message.js'
import { extractTag } from 'src/utils/messages.js'
import type { ThemeName } from 'src/utils/theme.js'
import type { z } from 'zod/v4'
import { FallbackToolUseErrorMessage } from 'src/components/FallbackToolUseErrorMessage.js'
import type { ToolResultBlockParam } from '@anthropic-ai/sdk/resources/index.mjs';
import * as React from 'react';
import type { Message, ProgressMessage } from 'src/types/message.js';
import { extractTag } from 'src/utils/messages.js';
import type { ThemeName } from 'src/utils/theme.js';
import type { z } from 'zod/v4';
import { FallbackToolUseErrorMessage } from 'src/components/FallbackToolUseErrorMessage.js';
import { HighlightedCode } from 'src/components/HighlightedCode.js'
import { MessageResponse } from 'src/components/MessageResponse.js'
import { NotebookEditToolUseRejectedMessage } from 'src/components/NotebookEditToolUseRejectedMessage.js'
import { Box, Text } from '@anthropic/ink'
import { FilePathLink } from 'src/components/FilePathLink.js'
import type { Tools } from 'src/Tool.js'
import { getDisplayPath } from 'src/utils/file.js'
import type { inputSchema, Output } from './NotebookEditTool.js'
import { HighlightedCode } from 'src/components/HighlightedCode.js';
import { MessageResponse } from 'src/components/MessageResponse.js';
import { NotebookEditToolUseRejectedMessage } from 'src/components/NotebookEditToolUseRejectedMessage.js';
import { Box, Text } from '@anthropic/ink';
import { FilePathLink } from 'src/components/FilePathLink.js';
import type { Tools } from 'src/Tool.js';
import { getDisplayPath } from 'src/utils/file.js';
import type { inputSchema, Output } from './NotebookEditTool.js';
export function getToolUseSummary(
input: Partial<z.infer<ReturnType<typeof inputSchema>>> | undefined,
): string | null {
export function getToolUseSummary(input: Partial<z.infer<ReturnType<typeof inputSchema>>> | undefined): string | null {
if (!input?.notebook_path) {
return null
return null;
}
return getDisplayPath(input.notebook_path)
return getDisplayPath(input.notebook_path);
}
export function renderToolUseMessage(
{
notebook_path,
cell_id,
new_source,
cell_type,
edit_mode,
}: Partial<z.infer<ReturnType<typeof inputSchema>>>,
{ notebook_path, cell_id, new_source, cell_type, edit_mode }: Partial<z.infer<ReturnType<typeof inputSchema>>>,
{ verbose }: { verbose: boolean },
): React.ReactNode {
if (!notebook_path || !new_source || !cell_type) {
return null
return null;
}
const displayPath = verbose ? notebook_path : getDisplayPath(notebook_path)
const displayPath = verbose ? notebook_path : getDisplayPath(notebook_path);
if (verbose) {
return (
<>
<FilePathLink filePath={notebook_path}>{displayPath}</FilePathLink>
{`@${cell_id}, content: ${new_source.slice(0, 30)}…, cell_type: ${cell_type}, edit_mode: ${edit_mode ?? 'replace'}`}
</>
)
);
}
return (
<>
<FilePathLink filePath={notebook_path}>{displayPath}</FilePathLink>
{`@${cell_id}`}
</>
)
);
}
export function renderToolUseRejectedMessage(
@@ -59,12 +51,12 @@ export function renderToolUseRejectedMessage(
{
verbose,
}: {
columns?: number
messages?: Message[]
progressMessagesForMessage?: ProgressMessage[]
theme?: ThemeName
tools?: Tools
verbose: boolean
columns?: number;
messages?: Message[];
progressMessagesForMessage?: ProgressMessage[];
theme?: ThemeName;
tools?: Tools;
verbose: boolean;
},
): React.ReactNode {
return (
@@ -76,38 +68,30 @@ export function renderToolUseRejectedMessage(
edit_mode={input.edit_mode}
verbose={verbose}
/>
)
);
}
export function renderToolUseErrorMessage(
result: ToolResultBlockParam['content'],
{ verbose }: { verbose: boolean },
): React.ReactNode {
if (
!verbose &&
typeof result === 'string' &&
extractTag(result, 'tool_use_error')
) {
if (!verbose && typeof result === 'string' && extractTag(result, 'tool_use_error')) {
return (
<MessageResponse>
<Text color="error">Error editing notebook</Text>
</MessageResponse>
)
);
}
return <FallbackToolUseErrorMessage result={result} verbose={verbose} />
return <FallbackToolUseErrorMessage result={result} verbose={verbose} />;
}
export function renderToolResultMessage({
cell_id,
new_source,
error,
}: Output): React.ReactNode {
export function renderToolResultMessage({ cell_id, new_source, error }: Output): React.ReactNode {
if (error) {
return (
<MessageResponse>
<Text color="error">{error}</Text>
</MessageResponse>
)
);
}
return (
@@ -121,5 +105,5 @@ export function renderToolResultMessage({
</Box>
</Box>
</MessageResponse>
)
);
}

View File

@@ -1,3 +1,3 @@
// Auto-generated type stub — replace with real implementation
export type Message = any;
export type ProgressMessage<T = any> = any;
export type Message = any
export type ProgressMessage<T = any> = any

View File

@@ -1,3 +1,3 @@
// Auto-generated type stub — replace with real implementation
export type fileHistoryEnabled = any;
export type fileHistoryTrackEdit = any;
export type fileHistoryEnabled = any
export type fileHistoryTrackEdit = any

View File

@@ -1,2 +1,2 @@
// Auto-generated type stub — replace with real implementation
export type extractTag = any;
export type extractTag = any

View File

@@ -1,2 +1,2 @@
// Auto-generated type stub — replace with real implementation
export type ThemeName = any;
export type ThemeName = any