From de66de5b5c545427e572787e07ac0dd18a96bcaa Mon Sep 17 00:00:00 2001 From: wujunchen Date: Sat, 16 May 2026 00:15:10 +0800 Subject: [PATCH] refactor: remove dead code and over-broad exports - Delete unused CacheFile interface (src/types.ts) - Demote internal-only symbols from export to module scope: PROMPT_VERSION, DEFAULT_CLI_TIMEOUT_MS, MIN_STREAMING_TIMEOUT_MS, MIN_CLI_TIMEOUT_MS (settings.ts), CliFailureReason (cli.ts), GenerationErrorContext (error-ui.ts), AnthropicMessagesBody/ OpenAiChatBody/OpenAiResponsesBody/GeminiBody (provider-bodies.ts), BackendTestDeps (backend-test.ts) Verified: tsc, esbuild prod build, biome, all 28 test files pass. Change-Id: I0fc597ee51ec67d509a7f33db39fabcbdb301797 --- src/backend-test.ts | 2 +- src/cli.ts | 7 +------ src/error-ui.ts | 2 +- src/provider-bodies.ts | 8 ++++---- src/settings.ts | 8 ++++---- src/types.ts | 5 ----- 6 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/backend-test.ts b/src/backend-test.ts index c6b69d7..01c3388 100644 --- a/src/backend-test.ts +++ b/src/backend-test.ts @@ -14,7 +14,7 @@ const CLI_TEST_TIMEOUT_MS = 60000; type SpawnImpl = Parameters[5]; -export interface BackendTestDeps { +interface BackendTestDeps { requestUrlImpl?: RequestUrlFunction; spawnImpl?: SpawnImpl; } diff --git a/src/cli.ts b/src/cli.ts index ea16381..e276974 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -52,12 +52,7 @@ export function resolveCliPath(name: string, override: string): string { return name; } -export type CliFailureReason = - | 'wall-timeout' - | 'exit-nonzero' - | 'streams-unavailable' - | 'spawn-failure' - | 'startup-error'; +type CliFailureReason = 'wall-timeout' | 'exit-nonzero' | 'streams-unavailable' | 'spawn-failure' | 'startup-error'; export interface CliErrorDetails { reason: CliFailureReason; diff --git a/src/error-ui.ts b/src/error-ui.ts index 12979d6..c61074c 100644 --- a/src/error-ui.ts +++ b/src/error-ui.ts @@ -6,7 +6,7 @@ import { translate } from './i18n'; import type { ErrorKind, PluginSettings } from './types'; import { copyToClipboard } from './ui-helpers'; -export interface GenerationErrorContext { +interface GenerationErrorContext { app: App; settings: PluginSettings; /** Open the plugin settings tab (best-effort; falls back to no-op if unavailable). */ diff --git a/src/provider-bodies.ts b/src/provider-bodies.ts index 0da052f..040809b 100644 --- a/src/provider-bodies.ts +++ b/src/provider-bodies.ts @@ -12,7 +12,7 @@ import type { PluginSettings } from './types'; /* ---------- Body type interfaces ---------- */ -export interface AnthropicMessagesBody { +interface AnthropicMessagesBody { model: string; max_tokens: number; system: string; @@ -22,7 +22,7 @@ export interface AnthropicMessagesBody { stream?: boolean; } -export interface OpenAiChatBody { +interface OpenAiChatBody { model: string; messages: Array<{ role: string; content: string }>; response_format?: unknown; @@ -30,7 +30,7 @@ export interface OpenAiChatBody { [tokenField: string]: unknown; } -export interface OpenAiResponsesBody { +interface OpenAiResponsesBody { model: string; instructions: string; input: string; @@ -46,7 +46,7 @@ interface GeminiGenerationConfig { responseJsonSchema?: unknown; } -export interface GeminiBody { +interface GeminiBody { systemInstruction: { parts: Array<{ text: string }> }; contents: Array<{ role: string; parts: Array<{ text: string }> }>; generationConfig: GeminiGenerationConfig; diff --git a/src/settings.ts b/src/settings.ts index ae6a192..2b886d3 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -8,12 +8,12 @@ import type { ApiFormat, ApiProviderPreset, CacheEntry, PluginSettings } from '. export { API_PROVIDER_PRESETS } from './provider-presets'; export const MAX_DOC_CHARS = 100000; -export const PROMPT_VERSION = 2; +const PROMPT_VERSION = 2; export const CACHE_SCHEMA_VERSION = 2; export const DEFAULT_MAX_CACHE_ENTRIES = 100; -export const DEFAULT_CLI_TIMEOUT_MS = 300000; -export const MIN_STREAMING_TIMEOUT_MS = 1000; -export const MIN_CLI_TIMEOUT_MS = 1000; +const DEFAULT_CLI_TIMEOUT_MS = 300000; +const MIN_STREAMING_TIMEOUT_MS = 1000; +const MIN_CLI_TIMEOUT_MS = 1000; export const PROMPT_LANGUAGES = { zh: '中文', en: 'English', diff --git a/src/types.ts b/src/types.ts index c14f29a..929a8a3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -37,11 +37,6 @@ export interface CacheEntry { updatedAt?: string; } -export interface CacheFile { - version: number; - entries: Record; -} - /* ---------- Settings types ---------- */ export interface PluginSettings {