mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-23 00:35:51 +00:00
chore: 清理 18 处未使用导入、变量和函数
移除未使用的导入(getSubscriptionType、isEnvDefinedFalsy、 getClaudeConfigHomeDir 等)、未使用的常量(ACCENT_COLOR、 NAME_MATCH_BONUS、CLIPBOARD_THRESHOLD)和死函数 (getOpus41Option、pasteViaClipboard), 为未使用参数添加 _ 前缀。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,6 @@ import { setEnvHookNotifier } from '../../utils/hooks/fileChangedWatcher.js';
|
|||||||
import { toIDEDisplayName } from '../../utils/ide.js';
|
import { toIDEDisplayName } from '../../utils/ide.js';
|
||||||
import { getMessagesAfterCompactBoundary } from '../../utils/messages.js';
|
import { getMessagesAfterCompactBoundary } from '../../utils/messages.js';
|
||||||
import { tokenCountFromLastAPIResponse } from '../../utils/tokens.js';
|
import { tokenCountFromLastAPIResponse } from '../../utils/tokens.js';
|
||||||
import { AutoUpdaterWrapper } from '../AutoUpdaterWrapper.js';
|
|
||||||
import { ConfigurableShortcutHint } from '../ConfigurableShortcutHint.js';
|
import { ConfigurableShortcutHint } from '../ConfigurableShortcutHint.js';
|
||||||
import { IdeStatusIndicator } from '../IdeStatusIndicator.js';
|
import { IdeStatusIndicator } from '../IdeStatusIndicator.js';
|
||||||
import { MemoryUsageIndicator } from '../MemoryUsageIndicator.js';
|
import { MemoryUsageIndicator } from '../MemoryUsageIndicator.js';
|
||||||
@@ -57,13 +56,13 @@ type Props = {
|
|||||||
|
|
||||||
export function Notifications({
|
export function Notifications({
|
||||||
apiKeyStatus,
|
apiKeyStatus,
|
||||||
autoUpdaterResult,
|
autoUpdaterResult: _autoUpdaterResult,
|
||||||
debug,
|
debug,
|
||||||
isAutoUpdating,
|
isAutoUpdating: _isAutoUpdating,
|
||||||
verbose,
|
verbose,
|
||||||
messages,
|
messages,
|
||||||
onAutoUpdaterResult,
|
onAutoUpdaterResult: _onAutoUpdaterResult,
|
||||||
onChangeIsUpdating,
|
onChangeIsUpdating: _onChangeIsUpdating,
|
||||||
ideSelection,
|
ideSelection,
|
||||||
mcpClients,
|
mcpClients,
|
||||||
isInputWrapped = false,
|
isInputWrapped = false,
|
||||||
@@ -102,9 +101,6 @@ export function Notifications({
|
|||||||
const shouldShowIdeSelection =
|
const shouldShowIdeSelection =
|
||||||
ideStatus === 'connected' && (ideSelection?.filePath || (ideSelection?.text && ideSelection.lineCount > 0));
|
ideStatus === 'connected' && (ideSelection?.filePath || (ideSelection?.text && ideSelection.lineCount > 0));
|
||||||
|
|
||||||
// Hide update installed message when showing IDE selection
|
|
||||||
const shouldShowAutoUpdater = !shouldShowIdeSelection || isAutoUpdating || autoUpdaterResult?.status !== 'success';
|
|
||||||
|
|
||||||
// Check if we're in overage mode for UI indicators
|
// Check if we're in overage mode for UI indicators
|
||||||
const isInOverageMode = claudeAiLimits.isUsingOverage;
|
const isInOverageMode = claudeAiLimits.isUsingOverage;
|
||||||
const subscriptionType = getSubscriptionType();
|
const subscriptionType = getSubscriptionType();
|
||||||
@@ -157,12 +153,6 @@ export function Notifications({
|
|||||||
verbose={verbose}
|
verbose={verbose}
|
||||||
tokenUsage={tokenUsage}
|
tokenUsage={tokenUsage}
|
||||||
mainLoopModel={mainLoopModel}
|
mainLoopModel={mainLoopModel}
|
||||||
shouldShowAutoUpdater={shouldShowAutoUpdater}
|
|
||||||
autoUpdaterResult={autoUpdaterResult}
|
|
||||||
isAutoUpdating={isAutoUpdating}
|
|
||||||
isShowingCompactMessage={isShowingCompactMessage}
|
|
||||||
onAutoUpdaterResult={onAutoUpdaterResult}
|
|
||||||
onChangeIsUpdating={onChangeIsUpdating}
|
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</SentryErrorBoundary>
|
</SentryErrorBoundary>
|
||||||
@@ -180,12 +170,6 @@ function NotificationContent({
|
|||||||
verbose,
|
verbose,
|
||||||
tokenUsage,
|
tokenUsage,
|
||||||
mainLoopModel,
|
mainLoopModel,
|
||||||
shouldShowAutoUpdater,
|
|
||||||
autoUpdaterResult,
|
|
||||||
isAutoUpdating,
|
|
||||||
isShowingCompactMessage,
|
|
||||||
onAutoUpdaterResult,
|
|
||||||
onChangeIsUpdating,
|
|
||||||
}: {
|
}: {
|
||||||
ideSelection: IDESelection | undefined;
|
ideSelection: IDESelection | undefined;
|
||||||
mcpClients?: MCPServerConnection[];
|
mcpClients?: MCPServerConnection[];
|
||||||
@@ -200,12 +184,6 @@ function NotificationContent({
|
|||||||
verbose: boolean;
|
verbose: boolean;
|
||||||
tokenUsage: number;
|
tokenUsage: number;
|
||||||
mainLoopModel: string;
|
mainLoopModel: string;
|
||||||
shouldShowAutoUpdater: boolean;
|
|
||||||
autoUpdaterResult: AutoUpdaterResult | null;
|
|
||||||
isAutoUpdating: boolean;
|
|
||||||
isShowingCompactMessage: boolean;
|
|
||||||
onAutoUpdaterResult: (result: AutoUpdaterResult) => void;
|
|
||||||
onChangeIsUpdating: (isUpdating: boolean) => void;
|
|
||||||
}): ReactNode {
|
}): ReactNode {
|
||||||
// Poll apiKeyHelper inflight state to show slow-helper notice.
|
// Poll apiKeyHelper inflight state to show slow-helper notice.
|
||||||
// Gated on configuration — most users never set apiKeyHelper, so the
|
// Gated on configuration — most users never set apiKeyHelper, so the
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ import type {
|
|||||||
} from '@anthropic-ai/sdk/resources/messages.mjs'
|
} from '@anthropic-ai/sdk/resources/messages.mjs'
|
||||||
import { maybeResizeAndDownsampleImageBlock } from './imageResizer.js'
|
import { maybeResizeAndDownsampleImageBlock } from './imageResizer.js'
|
||||||
import type { PastedContent } from './config.js'
|
import type { PastedContent } from './config.js'
|
||||||
|
import { getSettings_DEPRECATED } from './settings/settings.js'
|
||||||
import {
|
import {
|
||||||
getDefaultSonnetModel,
|
getDefaultSonnetModel,
|
||||||
getDefaultHaikuModel,
|
getDefaultHaikuModel,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import type { CoordinateMode, CuSubGates } from '@ant/computer-use-mcp/types'
|
import type { CoordinateMode, CuSubGates } from '@ant/computer-use-mcp/types'
|
||||||
|
|
||||||
import { getDynamicConfig_CACHED_MAY_BE_STALE } from '../../services/analytics/growthbook.js'
|
import { getDynamicConfig_CACHED_MAY_BE_STALE } from '../../services/analytics/growthbook.js'
|
||||||
import { getSubscriptionType } from '../auth.js'
|
|
||||||
import { isEnvTruthy } from '../envUtils.js'
|
import { isEnvTruthy } from '../envUtils.js'
|
||||||
|
|
||||||
type ChicagoConfig = CuSubGates & {
|
type ChicagoConfig = CuSubGates & {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ const INDICATOR_HEIGHT = 28
|
|||||||
const FADE_AFTER_MS = 2000
|
const FADE_AFTER_MS = 2000
|
||||||
const BG_COLOR = '30, 30, 30' // dark background
|
const BG_COLOR = '30, 30, 30' // dark background
|
||||||
const TEXT_COLOR = '220, 220, 220' // light text
|
const TEXT_COLOR = '220, 220, 220' // light text
|
||||||
const ACCENT_COLOR = '80, 200, 80' // green accent for active
|
|
||||||
|
|
||||||
let indicatorProc: ReturnType<typeof Bun.spawn> | null = null
|
let indicatorProc: ReturnType<typeof Bun.spawn> | null = null
|
||||||
let stopFile: string | null = null
|
let stopFile: string | null = null
|
||||||
|
|||||||
@@ -12,9 +12,6 @@
|
|||||||
|
|
||||||
import { validateHwnd, runPs, VK_MAP, MODIFIER_KEYS } from './shared.js'
|
import { validateHwnd, runPs, VK_MAP, MODIFIER_KEYS } from './shared.js'
|
||||||
|
|
||||||
/** Character count above which we switch to clipboard paste */
|
|
||||||
const CLIPBOARD_THRESHOLD = 32
|
|
||||||
|
|
||||||
/** Cache findEditChild results — window structure doesn't change while bound */
|
/** Cache findEditChild results — window structure doesn't change while bound */
|
||||||
const editChildCache = new Map<string, string | null>()
|
const editChildCache = new Map<string, string | null>()
|
||||||
|
|
||||||
@@ -275,46 +272,6 @@ function buildWmCharLines(hwnd: string, text: string): string[] {
|
|||||||
return lines
|
return lines
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Paste text via clipboard into the target window.
|
|
||||||
* Uses Clipboard.SetText() + SendMessageW(Ctrl+V).
|
|
||||||
* NO global APIs (SendInput/keybd_event/SendKeys) — only window-targeted messages.
|
|
||||||
*/
|
|
||||||
function pasteViaClipboard(hwnd: string, text: string): boolean {
|
|
||||||
// Escape single quotes for PowerShell string literal
|
|
||||||
const escaped = text.replace(/'/g, "''")
|
|
||||||
const hwndExpr = `[IntPtr]::new([long]${hwnd})`
|
|
||||||
const script = `${WINMSG_TYPE}
|
|
||||||
Add-Type -AssemblyName System.Windows.Forms
|
|
||||||
|
|
||||||
# Save current clipboard
|
|
||||||
$saved = $null
|
|
||||||
try { $saved = [System.Windows.Forms.Clipboard]::GetText() } catch {}
|
|
||||||
|
|
||||||
# Set our text
|
|
||||||
[System.Windows.Forms.Clipboard]::SetText('${escaped}')
|
|
||||||
|
|
||||||
# Ctrl+V via PostMessage to the target window (NOT global keybd_event)
|
|
||||||
# Must use PostMessage + correct lParam (scan code) for Windows Terminal / ConPTY
|
|
||||||
[WinMsg]::PostMessage(${hwndExpr}, [WinMsg]::WM_KEYDOWN, [IntPtr]0x11, [WinMsg]::KeyDownLParam(0x11)) # Ctrl down
|
|
||||||
[WinMsg]::PostMessage(${hwndExpr}, [WinMsg]::WM_KEYDOWN, [IntPtr]0x56, [WinMsg]::KeyDownLParam(0x56)) # V down
|
|
||||||
[WinMsg]::PostMessage(${hwndExpr}, [WinMsg]::WM_KEYUP, [IntPtr]0x56, [WinMsg]::KeyUpLParam(0x56)) # V up
|
|
||||||
[WinMsg]::PostMessage(${hwndExpr}, [WinMsg]::WM_KEYUP, [IntPtr]0x11, [WinMsg]::KeyUpLParam(0x11)) # Ctrl up
|
|
||||||
|
|
||||||
# Brief wait for paste to complete
|
|
||||||
Start-Sleep -Milliseconds 50
|
|
||||||
|
|
||||||
# Restore clipboard
|
|
||||||
if ($saved -ne $null -and $saved -ne '') {
|
|
||||||
try { [System.Windows.Forms.Clipboard]::SetText($saved) } catch {}
|
|
||||||
} else {
|
|
||||||
try { [System.Windows.Forms.Clipboard]::Clear() } catch {}
|
|
||||||
}
|
|
||||||
Write-Output 'OK'
|
|
||||||
`
|
|
||||||
return runPs(script) === 'OK'
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send text to a window via WM_CHAR per Unicode codepoint.
|
* Send text to a window via WM_CHAR per Unicode codepoint.
|
||||||
* Always uses the WM_CHAR path — reliable across all window types including
|
* Always uses the WM_CHAR path — reliable across all window types including
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export class LanBeacon extends EventEmitter {
|
|||||||
// Non-fatal — multicast may not be supported on this network
|
// Non-fatal — multicast may not be supported on this network
|
||||||
})
|
})
|
||||||
|
|
||||||
this.socket.on('message', (buf, rinfo) => {
|
this.socket.on('message', (buf, _rinfo) => {
|
||||||
try {
|
try {
|
||||||
const msg = JSON.parse(buf.toString()) as LanAnnounce
|
const msg = JSON.parse(buf.toString()) as LanAnnounce
|
||||||
if (msg.proto !== 'claude-pipe-v1') return
|
if (msg.proto !== 'claude-pipe-v1') return
|
||||||
|
|||||||
@@ -1431,7 +1431,7 @@ export function updateMessageLookupsIncremental(
|
|||||||
const msg = messages[i]!
|
const msg = messages[i]!
|
||||||
if (msg.type === 'assistant') {
|
if (msg.type === 'assistant') {
|
||||||
const aMsg = msg as AssistantMessage
|
const aMsg = msg as AssistantMessage
|
||||||
const id = aMsg.message.id!
|
const _id = aMsg.message.id!
|
||||||
if (Array.isArray(aMsg.message.content)) {
|
if (Array.isArray(aMsg.message.content)) {
|
||||||
const newToolUseIDs: string[] = []
|
const newToolUseIDs: string[] = []
|
||||||
for (const content of aMsg.message.content) {
|
for (const content of aMsg.message.content) {
|
||||||
|
|||||||
@@ -158,15 +158,6 @@ function getCustomOpusOption(): ModelOption | undefined {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOpus41Option(): ModelOption {
|
|
||||||
return {
|
|
||||||
value: 'opus',
|
|
||||||
label: 'Opus 4.1',
|
|
||||||
description: `Opus 4.1 · Legacy`,
|
|
||||||
descriptionForModel: 'Opus 4.1 - legacy version',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getOpus47Option(fastMode = false): ModelOption {
|
function getOpus47Option(fastMode = false): ModelOption {
|
||||||
const is3P = getAPIProvider() !== 'firstParty'
|
const is3P = getAPIProvider() !== 'firstParty'
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { feature } from 'bun:bundle'
|
|
||||||
import z from 'zod/v4'
|
import z from 'zod/v4'
|
||||||
import { PAUSE_ICON } from '../../constants/figures.js'
|
import { PAUSE_ICON } from '../../constants/figures.js'
|
||||||
// Types extracted to src/types/permissions.ts to break import cycles
|
// Types extracted to src/types/permissions.ts to break import cycles
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { feature } from 'bun:bundle'
|
import { feature } from 'bun:bundle'
|
||||||
import { useEffect, useRef } from 'react'
|
import { useEffect, useRef } from 'react'
|
||||||
import { useNotifications } from 'src/context/notifications.js'
|
|
||||||
import { toError } from '../../utils/errors.js'
|
import { toError } from '../../utils/errors.js'
|
||||||
import { logError } from '../../utils/log.js'
|
import { logError } from '../../utils/log.js'
|
||||||
import { getIsRemoteMode } from '../../bootstrap/state.js'
|
import { getIsRemoteMode } from '../../bootstrap/state.js'
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import type { ToolPermissionContext } from '../../Tool.js'
|
import type { ToolPermissionContext } from '../../Tool.js'
|
||||||
import { logForDebugging } from '../debug.js'
|
|
||||||
import type { PermissionMode } from './PermissionMode.js'
|
import type { PermissionMode } from './PermissionMode.js'
|
||||||
import { transitionPermissionMode } from './permissionSetup.js'
|
import { transitionPermissionMode } from './permissionSetup.js'
|
||||||
|
|
||||||
|
|||||||
@@ -874,7 +874,7 @@ export async function initializeToolPermissionContext({
|
|||||||
disallowedToolsCli,
|
disallowedToolsCli,
|
||||||
baseToolsCli,
|
baseToolsCli,
|
||||||
permissionMode,
|
permissionMode,
|
||||||
allowDangerouslySkipPermissions,
|
allowDangerouslySkipPermissions: _allowDangerouslySkipPermissions,
|
||||||
addDirs,
|
addDirs,
|
||||||
}: {
|
}: {
|
||||||
allowedToolsCli: string[]
|
allowedToolsCli: string[]
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
import { readFile, writeFile, unlink, mkdir } from 'fs/promises'
|
import { readFile, writeFile, unlink, mkdir } from 'fs/promises'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { createHash } from 'crypto'
|
import { createHash } from 'crypto'
|
||||||
import { getClaudeConfigHomeDir } from './envUtils.js'
|
|
||||||
import { isPipeAlive, getPipesDir } from './pipeTransport.js'
|
import { isPipeAlive, getPipesDir } from './pipeTransport.js'
|
||||||
import type { TcpEndpoint } from './pipeTransport.js'
|
import type { TcpEndpoint } from './pipeTransport.js'
|
||||||
import type { LanAnnounce } from './lanBeacon.js'
|
import type { LanAnnounce } from './lanBeacon.js'
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ export function editFileInEditor(filePath: string): EditorResult {
|
|||||||
*/
|
*/
|
||||||
function recollapsePastedContent(
|
function recollapsePastedContent(
|
||||||
editedPrompt: string,
|
editedPrompt: string,
|
||||||
originalPrompt: string,
|
_originalPrompt: string,
|
||||||
pastedContents: Record<number, PastedContent>,
|
pastedContents: Record<number, PastedContent>,
|
||||||
): string {
|
): string {
|
||||||
let collapsed = editedPrompt
|
let collapsed = editedPrompt
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import type { ToolUseBlock } from '@anthropic-ai/sdk/resources/index.mjs'
|
import type { ToolUseBlock } from '@anthropic-ai/sdk/resources/index.mjs'
|
||||||
import last from 'lodash-es/last.js'
|
|
||||||
import {
|
import {
|
||||||
getSessionId,
|
getSessionId,
|
||||||
isSessionPersistenceDisabled,
|
isSessionPersistenceDisabled,
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export function initSentry(): void {
|
|||||||
'CancelError',
|
'CancelError',
|
||||||
],
|
],
|
||||||
|
|
||||||
beforeSendTransaction(event) {
|
beforeSendTransaction(_event) {
|
||||||
// Don't send performance transactions for now — errors only
|
// Don't send performance transactions for now — errors only
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,10 +3,7 @@ import { z } from 'zod/v4'
|
|||||||
import { SandboxSettingsSchema } from '../../entrypoints/sandboxTypes.js'
|
import { SandboxSettingsSchema } from '../../entrypoints/sandboxTypes.js'
|
||||||
import { isEnvTruthy } from '../envUtils.js'
|
import { isEnvTruthy } from '../envUtils.js'
|
||||||
import { lazySchema } from '../lazySchema.js'
|
import { lazySchema } from '../lazySchema.js'
|
||||||
import {
|
import { PERMISSION_MODES } from '../permissions/PermissionMode.js'
|
||||||
EXTERNAL_PERMISSION_MODES,
|
|
||||||
PERMISSION_MODES,
|
|
||||||
} from '../permissions/PermissionMode.js'
|
|
||||||
import { MarketplaceSourceSchema } from '../plugins/schemas.js'
|
import { MarketplaceSourceSchema } from '../plugins/schemas.js'
|
||||||
import { CLAUDE_CODE_SETTINGS_SCHEMA_URL } from './constants.js'
|
import { CLAUDE_CODE_SETTINGS_SCHEMA_URL } from './constants.js'
|
||||||
import { PermissionRuleSchema } from './permissionValidation.js'
|
import { PermissionRuleSchema } from './permissionValidation.js'
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export function applyCoordinatorToolFilter(tools: Tools): Tools {
|
|||||||
export function mergeAndFilterTools(
|
export function mergeAndFilterTools(
|
||||||
initialTools: Tools,
|
initialTools: Tools,
|
||||||
assembled: Tools,
|
assembled: Tools,
|
||||||
mode: ToolPermissionContext['mode'],
|
_mode: ToolPermissionContext['mode'],
|
||||||
): Tools {
|
): Tools {
|
||||||
// Merge initialTools on top - they take precedence in deduplication.
|
// Merge initialTools on top - they take precedence in deduplication.
|
||||||
// initialTools may include built-in tools (from getTools() in REPL.tsx) which
|
// initialTools may include built-in tools (from getTools() in REPL.tsx) which
|
||||||
|
|||||||
Reference in New Issue
Block a user