chore: 清理 src 下 113 项未使用导入和死代码

删除未使用的文件(BuiltinStatusLine.tsx、4 个重复的 .ts stub)、
移除约 55 个文件中未使用的 React 导入、
清理约 50 处未使用的导入/变量/参数。
净减少 ~296 行代码,precheck 4077 测试全部通过。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-05-05 20:05:15 +08:00
parent 87b96199f9
commit fcbc882232
113 changed files with 63 additions and 359 deletions

View File

@@ -32,7 +32,7 @@ import { toolInfoFromToolUse } from './bridge.js'
export function createAcpCanUseTool(
conn: AgentSideConnection,
sessionId: string,
getCurrentMode: () => string,
_getCurrentMode: () => string,
clientCapabilities?: ClientCapabilities,
cwd?: string,
onModeChange?: (modeId: string) => void,

View File

@@ -121,7 +121,6 @@ import {
getAfkModeHeaderLatched,
getCacheEditingHeaderLatched,
getFastModeHeaderLatched,
getLastApiCompletionTimestamp,
getPromptCache1hAllowlist,
getPromptCache1hEligible,
getSessionId,
@@ -253,7 +252,6 @@ import {
type NonNullableUsage,
} from './logging.js'
import {
CACHE_TTL_1HOUR_MS,
checkResponseForCacheBreak,
recordPromptState,
} from './promptCacheBreakDetection.js'

View File

@@ -6,7 +6,7 @@ import type {
StreamEvent,
SystemAPIErrorMessage,
} from '../../../types/message.js'
import { getEmptyToolPermissionContext, type Tools } from '../../../Tool.js'
import { type Tools } from '../../../Tool.js'
import { toolToAPISchema } from '../../../utils/api.js'
import { logForDebugging } from '../../../utils/debug.js'
import {

View File

@@ -2,7 +2,6 @@ import OpenAI from 'openai'
import { openaiAdapter } from 'src/services/providerUsage/adapters/openai.js'
import { updateProviderBuckets } from 'src/services/providerUsage/store.js'
import { getProxyFetchOptions } from 'src/utils/proxy.js'
import { isEnvTruthy } from 'src/utils/envUtils.js'
/**
* Environment variables:

View File

@@ -9,8 +9,6 @@ import type {
} from '../../../types/message.js'
import type { AgentId } from '../../../types/ids.js'
import type { Tools } from '../../../Tool.js'
import type { Stream } from 'openai/streaming.mjs'
import type { ChatCompletionCreateParamsStreaming } from 'openai/resources/chat/completions/completions.mjs'
import { getOpenAIClient } from './client.js'
import {
anthropicMessagesToOpenAI,

View File

@@ -98,7 +98,7 @@ export function getToolResultsToDelete(state: CachedMCState): string[] {
* Returns null if toolIds is empty.
*/
export function createCacheEditsBlock(
state: CachedMCState,
_state: CachedMCState,
toolIds: string[],
): CacheEditsBlock | null {
if (toolIds.length === 0) return null

View File

@@ -82,7 +82,7 @@ function estimateMessageTokens(message: Message): number {
*/
export function snipCompactIfNeeded(
messages: Message[],
options?: { force?: boolean },
_options?: { force?: boolean },
): {
messages: Message[]
executed: boolean

View File

@@ -18,9 +18,6 @@ import { logError } from '../utils/log.js'
// Re-export FinalizeSource so useVoice can import from either module
export type { FinalizeSource } from './voiceStreamSTT.js'
// Maximum time to wait for the generator to finish after end-of-stream signal.
const FINALIZE_SAFETY_TIMEOUT_MS = 5_000
// ─── AsyncIterable audio queue ─────────────────────────────────────────
// A push-based queue that implements AsyncIterable<Uint8Array>.

View File

@@ -38,7 +38,6 @@ import { REPL_TOOL_NAME } from '@claude-code-best/builtin-tools/tools/REPLTool/c
import type {
AssistantMessage,
Message,
SystemLocalCommandMessage,
SystemMessage,
} from '../../types/message.js'
import { createAbortController } from '../../utils/abortController.js'

View File

@@ -60,7 +60,7 @@ function sanitizeObject(obj: Record<string, unknown>): Record<string, unknown> {
return result
}
export function sanitizeToolInput(toolName: string, input: unknown): unknown {
export function sanitizeToolInput(_toolName: string, input: unknown): unknown {
if (typeof input !== 'object' || input === null) return input
const obj = { ...(input as Record<string, unknown>) }

View File

@@ -23,12 +23,10 @@ import { CHANNEL_TAG } from '../../constants/xml.js'
import { getSubscriptionType } from '../../utils/auth.js'
import { lazySchema } from '../../utils/lazySchema.js'
import { parsePluginIdentifier } from '../../utils/plugins/pluginIdentifier.js'
import { getSettingsForSource } from '../../utils/settings/settings.js'
import { escapeXmlAttr } from '../../utils/xml.js'
import {
type ChannelAllowlistEntry,
getChannelAllowlist,
isChannelsEnabled,
} from './channelAllowlist.js'
export const ChannelMessageNotificationSchema = lazySchema(() =>

View File

@@ -117,13 +117,7 @@ import { getLoggingSafeMcpBaseUrl } from './utils.js'
// Package imports — delegate to mcp-client package utilities where applicable
import {
createMcpClient as createMcpClientFromPackage,
captureStderr,
isMcpSessionExpiredError as isMcpSessionExpiredErrorFromPackage,
installConnectionMonitor,
createCleanup as createCleanupFromPackage,
buildConnectedServer,
DEFAULT_CONNECTION_TIMEOUT_MS,
MAX_MCP_DESCRIPTION_LENGTH as PKG_MAX_MCP_DESCRIPTION_LENGTH,
} from '@claude-code-best/mcp-client'
import { recursivelySanitizeUnicode } from '@claude-code-best/mcp-client'

View File

@@ -1,4 +1,3 @@
import React from 'react';
import { MCPServerApprovalDialog } from '../components/MCPServerApprovalDialog.js';
import { MCPServerMultiselectDialog } from '../components/MCPServerMultiselectDialog.js';
import type { Root } from '@anthropic/ink';

View File

@@ -1,4 +1,3 @@
import React from 'react';
import { getIsInteractive } from '../../bootstrap/state.js';
import { ManagedSettingsSecurityDialog } from '../../components/ManagedSettingsSecurityDialog/ManagedSettingsSecurityDialog.js';
import {

View File

@@ -3,7 +3,6 @@ import { dirname, join } from 'node:path'
import { createHash, randomUUID } from 'node:crypto'
import type {
SkillLearningProjectContext as BaseSkillLearningProjectContext,
SkillLearningScope,
SkillObservation as BaseSkillObservation,
SkillObservationEvent,
SkillObservationOutcome,

View File

@@ -65,7 +65,7 @@ export function pruneEmittedTurns(): void {
// Prune over-sized Sets first. FIFO by insertion order — NOT by turn
// number magnitude. Non-monotonic turn ordering (e.g. replayed transcripts
// or nested tool chains) should not cause us to evict the wrong entries.
for (const [sessionId, turns] of emittedTurns) {
for (const [_sessionId, turns] of emittedTurns) {
if (turns.size > EMITTED_TURNS_SET_MAX) {
const iter = turns.values()
const toDrop = turns.size - EMITTED_TURNS_SET_KEEP

View File

@@ -270,7 +270,6 @@ function cosineSimilarity(
const DISPLAY_MIN_SCORE = Number(
process.env.SKILL_SEARCH_DISPLAY_MIN_SCORE ?? '0.10',
)
const NAME_MATCH_BONUS = 0.4
const NAME_MATCH_MIN_LENGTH = 4
const CJK_MIN_BIGRAM_MATCHES = 2

View File

@@ -307,7 +307,7 @@ export async function collectSkillDiscoveryPrefetch(
export async function getTurnZeroSkillDiscovery(
input: string,
messages: Message[],
_messages: Message[],
context: ToolUseContext,
): Promise<Attachment | null> {
if (!isSkillSearchEnabled()) return null

View File

@@ -45,7 +45,7 @@ export async function* runPostToolUseHooks<Input extends AnyObject, Output>(
toolResponse: Output,
requestId: string | undefined,
mcpServerType: McpServerType,
mcpServerBaseUrl: string | undefined,
_mcpServerBaseUrl: string | undefined,
): AsyncGenerator<PostToolUseHooksResult<Output>> {
const postToolStartTime = Date.now()
try {
@@ -204,7 +204,7 @@ export async function* runPostToolUseFailureHooks<Input extends AnyObject>(
isInterrupt: boolean | undefined,
requestId: string | undefined,
mcpServerType: McpServerType,
mcpServerBaseUrl: string | undefined,
_mcpServerBaseUrl: string | undefined,
): AsyncGenerator<
MessageUpdateLazy<AttachmentMessage | ProgressMessage<HookProgress>>
> {
@@ -448,7 +448,7 @@ export async function* runPreToolUseHooks(
messageId: string,
requestId: string | undefined,
mcpServerType: McpServerType,
mcpServerBaseUrl: string | undefined,
_mcpServerBaseUrl: string | undefined,
): AsyncGenerator<
| {
type: 'message'