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

@@ -41,7 +41,11 @@ import { type Tools, type ToolUseContext, toolMatchesName } from './Tool.js'
import type { AgentDefinition } from '@claude-code-best/builtin-tools/tools/AgentTool/loadAgentsDir.js'
import { SYNTHETIC_OUTPUT_TOOL_NAME } from '@claude-code-best/builtin-tools/tools/SyntheticOutputTool/SyntheticOutputTool.js'
import type { APIError } from '@anthropic-ai/sdk'
import type { CompactMetadata, Message, SystemCompactBoundaryMessage } from './types/message.js'
import type {
CompactMetadata,
Message,
SystemCompactBoundaryMessage,
} from './types/message.js'
import type { OrphanedPermission } from './types/textInputTypes.js'
import { createAbortController } from './utils/abortController.js'
import type { AttributionState } from './utils/commitAttribution.js'
@@ -86,7 +90,9 @@ import {
// Lazy: MessageSelector.tsx pulls React/ink; only needed for message filtering at query time
/* eslint-disable @typescript-eslint/no-require-imports */
const messageSelector = (): typeof import('src/components/MessageSelector.js') | null => {
const messageSelector = ():
| typeof import('src/components/MessageSelector.js')
| null => {
try {
return require('src/components/MessageSelector.js')
} catch {
@@ -649,20 +655,19 @@ export class QueryEngine {
if (fileHistoryEnabled() && persistSession) {
const _sel = messageSelector()
const _filter = _sel?.selectableUserMessagesFilter ?? ((_msg: unknown) => true)
messagesFromUserInput
.filter(_filter)
.forEach(message => {
void fileHistoryMakeSnapshot(
(updater: (prev: FileHistoryState) => FileHistoryState) => {
setAppState(prev => ({
...prev,
fileHistory: updater(prev.fileHistory),
}))
},
message.uuid,
)
})
const _filter =
_sel?.selectableUserMessagesFilter ?? ((_msg: unknown) => true)
messagesFromUserInput.filter(_filter).forEach(message => {
void fileHistoryMakeSnapshot(
(updater: (prev: FileHistoryState) => FileHistoryState) => {
setAppState(prev => ({
...prev,
fileHistory: updater(prev.fileHistory),
}))
},
message.uuid,
)
})
}
// Track current message usage (reset on each message_start)
@@ -715,7 +720,8 @@ export class QueryEngine {
message.subtype === 'compact_boundary'
) {
const compactMsg = message as SystemCompactBoundaryMessage
const tailUuid = compactMsg.compactMetadata?.preservedSegment?.tailUuid
const tailUuid =
compactMsg.compactMetadata?.preservedSegment?.tailUuid
if (tailUuid) {
const tailIdx = this.mutableMessages.findLastIndex(
m => m.uuid === tailUuid,
@@ -775,7 +781,10 @@ export class QueryEngine {
// streamed responses, this is null at content_block_stop time;
// the real value arrives via message_delta (handled below).
const msg = message as Message
const stopReason = msg.message?.stop_reason as string | null | undefined
const stopReason = msg.message?.stop_reason as
| string
| null
| undefined
if (stopReason != null) {
lastStopReason = stopReason
}
@@ -805,11 +814,15 @@ export class QueryEngine {
break
}
case 'stream_event': {
const event = (message as unknown as { event: Record<string, unknown> }).event
const event = (
message as unknown as { event: Record<string, unknown> }
).event
if (event.type === 'message_start') {
// Reset current message usage for new message
currentMessageUsage = EMPTY_USAGE
const eventMessage = event.message as { usage: BetaMessageDeltaUsage }
const eventMessage = event.message as {
usage: BetaMessageDeltaUsage
}
currentMessageUsage = updateUsage(
currentMessageUsage,
eventMessage.usage,
@@ -858,7 +871,15 @@ export class QueryEngine {
void recordTranscript(messages)
}
const attachment = msg.attachment as { type: string; data?: unknown; turnCount?: number; maxTurns?: number; prompt?: string; source_uuid?: string; [key: string]: unknown }
const attachment = msg.attachment as {
type: string
data?: unknown
turnCount?: number
maxTurns?: number
prompt?: string
source_uuid?: string
[key: string]: unknown
}
// Extract structured output from StructuredOutput tool calls
if (attachment.type === 'structured_output') {
@@ -899,10 +920,7 @@ export class QueryEngine {
return
}
// Yield queued_command attachments as SDK user message replays
else if (
replayUserMessages &&
attachment.type === 'queued_command'
) {
else if (replayUserMessages && attachment.type === 'queued_command') {
yield {
type: 'user',
message: {
@@ -930,10 +948,7 @@ export class QueryEngine {
// never shrinks (memory leak in long SDK sessions). The subtype
// check lives inside the injected callback so feature-gated strings
// stay out of this file (excluded-strings check).
const snipResult = this.config.snipReplay?.(
msg,
this.mutableMessages,
)
const snipResult = this.config.snipReplay?.(msg, this.mutableMessages)
if (snipResult !== undefined) {
if (snipResult.executed) {
this.mutableMessages.length = 0
@@ -943,10 +958,7 @@ export class QueryEngine {
}
this.mutableMessages.push(msg)
// Yield compact boundary messages to SDK
if (
msg.subtype === 'compact_boundary' &&
msg.compactMetadata
) {
if (msg.subtype === 'compact_boundary' && msg.compactMetadata) {
const compactMsg = msg as SystemCompactBoundaryMessage
// Release pre-compaction messages for GC. The boundary was just
// pushed so it's the last element. query.ts already uses
@@ -966,11 +978,18 @@ export class QueryEngine {
subtype: 'compact_boundary' as const,
session_id: getSessionId(),
uuid: msg.uuid,
compact_metadata: toSDKCompactMetadata(compactMsg.compactMetadata),
compact_metadata: toSDKCompactMetadata(
compactMsg.compactMetadata,
),
}
}
if (msg.subtype === 'api_error') {
const apiErrorMsg = msg as Message & { retryAttempt: number; maxRetries: number; retryInMs: number; error: APIError }
const apiErrorMsg = msg as Message & {
retryAttempt: number
maxRetries: number
retryInMs: number
error: APIError
}
yield {
type: 'system',
subtype: 'api_retry' as const,
@@ -987,7 +1006,10 @@ export class QueryEngine {
break
}
case 'tool_use_summary': {
const msg = message as Message & { summary: unknown; precedingToolUseIds: unknown }
const msg = message as Message & {
summary: unknown
precedingToolUseIds: unknown
}
// Yield tool use summary messages to SDK
yield {
type: 'tool_use_summary' as const,
@@ -1096,7 +1118,10 @@ export class QueryEngine {
const edeResultType = result?.type ?? 'undefined'
const edeLastContentType =
result?.type === 'assistant'
? (last(result.message!.content as import('@anthropic-ai/sdk/resources/beta/messages/messages.js').BetaContentBlock[])?.type ?? 'none')
? (last(
result.message!
.content as import('@anthropic-ai/sdk/resources/beta/messages/messages.js').BetaContentBlock[],
)?.type ?? 'none')
: 'n/a'
// Flush buffered transcript writes before yielding result.
@@ -1154,7 +1179,10 @@ export class QueryEngine {
let isApiError = false
if (result.type === 'assistant') {
const lastContent = last(result.message!.content as import('@anthropic-ai/sdk/resources/beta/messages/messages.js').BetaContentBlock[])
const lastContent = last(
result.message!
.content as import('@anthropic-ai/sdk/resources/beta/messages/messages.js').BetaContentBlock[],
)
if (
lastContent?.type === 'text' &&
!SYNTHETIC_MESSAGES.has(lastContent.text)