chore: 清理 src 下 33 项死代码和类型断言

删除未使用的文件/目录(mcp/adapter、cli/update.ts 等)、
未使用的重导出文件(design-system/color.ts 等 12 个)、
7 个零引用的导出函数、修复 5 处 as any 为精确类型。
净减少 ~1194 行代码,precheck 4077 测试全部通过。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-05-05 16:07:30 +08:00
parent cf2bf29dcd
commit d0915fc880
39 changed files with 12 additions and 1206 deletions

View File

@@ -1,24 +0,0 @@
// Host analytics adapter — bridges logEvent to mcp-client's AnalyticsSink interface
import type { AnalyticsSink } from '@claude-code-best/mcp-client'
import {
type AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
logEvent,
} from '../../analytics/index.js'
/**
* Creates an AnalyticsSink implementation that delegates to the host's logEvent.
*/
export function createMcpAnalytics(): AnalyticsSink {
return {
trackEvent(event: string, metadata: Record<string, unknown>) {
logEvent(
event,
metadata as Record<
string,
AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
>,
)
},
}
}

View File

@@ -1,28 +0,0 @@
// Host auth provider adapter — bridges OAuth token management to mcp-client's AuthProvider interface
import type { AuthProvider } from '@claude-code-best/mcp-client'
import {
getClaudeAIOAuthTokens,
checkAndRefreshOAuthTokenIfNeeded,
handleOAuth401Error,
} from '../../../utils/auth.js'
/**
* Creates an AuthProvider implementation using the host's OAuth token management.
*/
export function createMcpAuth(): AuthProvider {
return {
async getTokens() {
const tokens = getClaudeAIOAuthTokens()
if (!tokens) return null
return { accessToken: tokens.accessToken }
},
async refreshTokens() {
await checkAndRefreshOAuthTokenIfNeeded()
},
async handleOAuthError(error: unknown) {
const currentToken = getClaudeAIOAuthTokens()?.accessToken ?? ''
await handleOAuth401Error(currentToken)
},
}
}

View File

@@ -1,15 +0,0 @@
// Host feature gate adapter — bridges feature() to mcp-client's FeatureGate interface
import type { FeatureGate } from '@claude-code-best/mcp-client'
import { feature } from 'bun:bundle'
/**
* Creates a FeatureGate implementation using the host's feature flag system.
*/
export function createMcpFeatureGate(): FeatureGate {
return {
isEnabled(flag: string) {
return feature(flag)
},
}
}

View File

@@ -1,15 +0,0 @@
// Host HTTP config adapter — bridges getUserAgent/getSessionId to mcp-client's HttpConfig interface
import type { HttpConfig } from '@claude-code-best/mcp-client'
import { getMCPUserAgent } from '../../../utils/http.js'
import { getSessionId } from '../../../bootstrap/state.js'
/**
* Creates an HttpConfig implementation using the host's user agent and session ID.
*/
export function createMcpHttpConfig(): HttpConfig {
return {
getUserAgent: () => getMCPUserAgent(),
getSessionId: () => getSessionId(),
}
}

View File

@@ -1,20 +0,0 @@
// Host image processor adapter — bridges maybeResizeAndDownsampleImageBuffer to mcp-client's ImageProcessor interface
import type { ImageProcessor } from '@claude-code-best/mcp-client'
import { maybeResizeAndDownsampleImageBuffer } from '../../../utils/imageResizer.js'
/**
* Creates an ImageProcessor implementation using the host's image resizing.
*/
export function createMcpImageProcessor(): ImageProcessor {
return {
async resizeAndDownsample(buffer: Buffer) {
const result = await maybeResizeAndDownsampleImageBuffer(
buffer,
buffer.length,
'png',
)
return result.buffer
},
}
}

View File

@@ -1,32 +0,0 @@
// Host dependency injection — assembles McpClientDependencies from host infrastructure
// This is the single entry point for creating the dependencies object used by createMcpManager()
import type { McpClientDependencies } from '@claude-code-best/mcp-client'
import { createMcpLogger } from './logger.js'
import { createMcpHttpConfig } from './httpConfig.js'
import { createMcpProxyConfig } from './proxy.js'
import { createMcpAnalytics } from './analytics.js'
import { createMcpSubprocessEnv } from './subprocessEnv.js'
import { createMcpStorage } from './storage.js'
import { createMcpImageProcessor } from './imageProcessor.js'
import { createMcpAuth } from './auth.js'
/**
* Creates the full set of MCP client dependencies using host infrastructure.
* All adapters are lazy — they only call into host modules when invoked.
*
* Note: featureGate is omitted because Bun's feature() requires string-literal
* arguments at compile time and cannot accept runtime variables. The interface
* field is optional and the mcp-client package does not use it currently.
*/
export function createMcpDependencies(): McpClientDependencies {
return {
logger: createMcpLogger(),
httpConfig: createMcpHttpConfig(),
proxy: createMcpProxyConfig(),
analytics: createMcpAnalytics(),
subprocessEnv: createMcpSubprocessEnv(),
storage: createMcpStorage(),
imageProcessor: createMcpImageProcessor(),
auth: createMcpAuth(),
}
}

View File

@@ -1,38 +0,0 @@
// Host logger adapter — bridges logMCPDebug/logMCPError to mcp-client's Logger interface
import type { Logger } from '@claude-code-best/mcp-client'
import { logMCPDebug, logMCPError } from '../../../utils/log.js'
/**
* Creates a Logger implementation that delegates to the host's MCP logging system.
*/
export function createMcpLogger(): Logger {
return {
debug(message: string, ...args: unknown[]) {
// Extract server name from bracketed prefix if present: [serverName] message
const match = message.match(/^\[([^\]]+)\]\s*(.*)/)
if (match) {
logMCPDebug(match[1], match[2])
}
// Silently ignore messages without server name prefix
},
info(message: string, ...args: unknown[]) {
const match = message.match(/^\[([^\]]+)\]\s*(.*)/)
if (match) {
logMCPDebug(match[1], match[2])
}
},
warn(message: string, ...args: unknown[]) {
const match = message.match(/^\[([^\]]+)\]\s*(.*)/)
if (match) {
logMCPError(match[1], message)
}
},
error(message: string, ...args: unknown[]) {
const match = message.match(/^\[([^\]]+)\]\s*(.*)/)
if (match) {
logMCPError(match[1], args[0] ?? message)
}
},
}
}

View File

@@ -1,30 +0,0 @@
// Host proxy config adapter — bridges proxy/MTLS to mcp-client's ProxyConfig interface
import type { ProxyConfig } from '@claude-code-best/mcp-client'
import {
getProxyFetchOptions,
getWebSocketProxyAgent,
getWebSocketProxyUrl,
} from '../../../utils/proxy.js'
import { getWebSocketTLSOptions } from '../../../utils/mtls.js'
/**
* Creates a ProxyConfig implementation using the host's proxy and TLS settings.
*/
export function createMcpProxyConfig(): ProxyConfig {
return {
getFetchOptions() {
return getProxyFetchOptions() as Record<string, unknown>
},
getWebSocketAgent(url: string) {
return getWebSocketProxyAgent(url)
},
getWebSocketUrl(url: string) {
return getWebSocketProxyUrl(url)
},
getTLSOptions() {
const opts = getWebSocketTLSOptions()
return opts as Record<string, unknown> | undefined
},
}
}

View File

@@ -1,27 +0,0 @@
// Host content storage adapter — bridges persistBinaryContent to mcp-client's ContentStorage interface
import type { ContentStorage } from '@claude-code-best/mcp-client'
import { persistBinaryContent } from '../../../utils/mcpOutputStorage.js'
import {
persistToolResult,
isPersistError,
} from '../../../utils/toolResultStorage.js'
/**
* Creates a ContentStorage implementation using the host's binary persistence.
*/
export function createMcpStorage(): ContentStorage {
return {
async persistBinaryContent(data: Buffer, ext: string) {
const result = await persistBinaryContent(
data,
ext,
`mcp-adapter-${Date.now()}`,
)
if ('error' in result) {
throw new Error(result.error)
}
return result.filepath
},
}
}

View File

@@ -1,15 +0,0 @@
// Host subprocess environment adapter
import type { SubprocessEnvProvider } from '@claude-code-best/mcp-client'
import { subprocessEnv } from '../../../utils/subprocessEnv.js'
/**
* Creates a SubprocessEnvProvider using the host's subprocess environment logic.
*/
export function createMcpSubprocessEnv(): SubprocessEnvProvider {
return {
getEnv(additional?: Record<string, string>) {
return { ...subprocessEnv(), ...additional } as Record<string, string>
},
}
}