claude-code-best/.hermes/plans/as-any-cleanup-task.md

8.2 KiB

Plan Only: Anthropic-Core as any Type Safety Improvement

IMPORTANT

  • DO NOT execute any code changes. Produce a detailed plan ONLY.
  • Output your plan to docs/plans/as-any-cleanup.md in the repo.
  • For each of the 94 as any, classify as: (FIXABLE with concrete type fix), (JUSTIFIED — explain why), or (NEEDS_UPSTREAM — requires CCB upstream context)

Goal

Eliminate all fixable as any casts in Anthropic-original decompiled code, improving type safety and reducing technical debt. These are all decompilation artifacts — the original Anthropic TypeScript had proper types that were lost in decompilation.

Scope

94 as any across ~60 files. EXCLUDED areas: API providers (openai/grok/gemini — JSON parsing), community commands (acp/autofix-pr/share/issue), generated types, test files, .d.ts stubs.

Full List of as any by File

src/main.tsx

  1. L408: (global as any).require('inspector')

src/hooks/

  1. useIdeSelection.ts L113: SelectionChangedSchema() as any
  2. useVirtualScroll.ts L186: comment only (not actual as any)
  3. toolPermission/PermissionContext.ts L228: suggestions as any
  4. useIdeLogging.ts L30: LogEventSchema() as any
  5. usePromptsFromClaudeInChrome.tsx L51: ClaudeInChromePromptNotificationSchema() as any

src/components/

  1. FeedbackSurvey/useFrustrationDetection.ts L15: (m as any).isApiErrorMessage
  2. FeedbackSurvey/useFrustrationDetection.ts L28: isPolicyAllowed('product_feedback' as any)
  3. ultraplan/UltraplanChoiceDialog.tsx L97: (key as any).wheelDown
  4. ultraplan/UltraplanChoiceDialog.tsx L98: (key as any).wheelDown
  5. ultraplan/UltraplanChoiceDialog.tsx L100: (key as any).wheelUp
  6. ultraplan/UltraplanChoiceDialog.tsx L101: (key as any).wheelUp
  7. PromptInput/PromptInput.tsx L1802: mode: previousModeBeforeAuto as any
  8. PromptInput/PromptInput.tsx L1808: mode: previousModeBeforeAuto as any
  9. messages/AttachmentMessage.tsx L146: attachment as any
  10. messages/UserTextMessage.tsx L106: UserGitHubWebhookMessage as any
  11. messages/UserTextMessage.tsx L160: UserForkBoilerplateMessage as any
  12. messages/UserTextMessage.tsx L173: UserCrossSessionMessage as any
  13. ConsoleOAuthFlow.tsx L275: { modelType: 'anthropic' } as any
  14. ConsoleOAuthFlow.tsx L680: modelType: 'anthropic' as any
  15. ConsoleOAuthFlow.tsx L682: } as any
  16. ConsoleOAuthFlow.tsx L900: modelType: 'openai' as any
  17. ConsoleOAuthFlow.tsx L902: } as any
  18. ConsoleOAuthFlow.tsx L1133: modelType: 'gemini' as any
  19. ConsoleOAuthFlow.tsx L1135: } as any
  20. permissions/PermissionRequest.tsx L106: (MonitorPermissionRequest ?? FallbackPermissionRequest) as any

src/utils/

  1. sideQuery.ts L224: client.chat.completions.create(requestParams as any, ...)
  2. execFileNoThrowPortable.ts L75: (execaSync as any)(command, ...)
  3. ultraplan/ccrSession.ts L104: (m as any).message.content
  4. ultraplan/ccrSession.ts L112: (m as any).message.content
  5. transcriptSearch.ts L100: (p as any[])
  6. filePersistence/outputsScanner.ts L72: }) as any[]
  7. filePersistence/outputsScanner.ts L116: (turnStartTime as any as number)
  8. performanceShim.ts L140: markResourceTiming: (() => {}) as any
  9. performanceShim.ts L146: (original as any).onresourcetimingbufferfull
  10. performanceShim.ts L162: (globalThis as any).__performanceShimInstalled
  11. performanceShim.ts L163: (globalThis as any).__performanceShimInstalled = true
  12. settings/validateEditTool.ts L39: (afterValidation as any).error
  13. log.ts L233: (await readdir(...)) as any
  14. hooks/execAgentHook.ts L214: (message as any).attachment.type
  15. hooks/execAgentHook.ts L216: (message as any).attachment.data
  16. computerUse/escHotkey.ts L29: (cu as any).hotkey?.registerEscape
  17. computerUse/escHotkey.ts L44: (requireComputerUseSwift() as any).hotkey?.unregister()
  18. computerUse/escHotkey.ts L54: (requireComputerUseSwift() as any).hotkey?.notifyExpectedEscape()
  19. computerUse/hostAdapter.ts L83: (cu as any).tcc
  20. computerUse/executorCrossPlatform.ts L494: (this as any).mouseDown()
  21. computerUse/executorCrossPlatform.ts L499: (this as any).mouseUp()
  22. computerUse/executorCrossPlatform.ts L556: windowManagement.manageWindow(action as any, opts)
  23. computerUse/win32/bridgeClient.ts L136: (writable as any).flush
  24. computerUse/win32/bridgeClient.ts L137: (writable as any).flush()
  25. computerUse/drainRunLoop.ts L21: (cu as any)?._drainMainRunLoop?.()
  26. computerUse/common.ts L57: : 'none') as any
  27. computerUse/common.ts L62: : 'darwin') as any
  28. messageQueueManager.ts L371: (cmd as any).origin?.kind === 'channel'
  29. plugins/marketplaceManager.ts L191: } as any
  30. forkedAgent.ts L565: (message as any).event?.type === 'message_delta'
  31. forkedAgent.ts L566: (message as any).event.usage
  32. forkedAgent.ts L568: (message as any).event.usage
  33. deepLink/protocolHandler.ts L97: (waitForUrlEvent as any)(5000)
  34. sliceAnsi.ts L80: (token as any).value
  35. plans.ts L370: (snapshotFiles as any[])
  36. plans.ts L377: (snapshotFiles as any[])
  37. textHighlighting.ts L131: (token as any).value.length
  38. textHighlighting.ts L138: (token as any).value.length
  39. sideQuestion.ts L139: (toolUse as any).name
  40. sideQuestion.ts L151: formatAPIError(apiErr.error as any)
  41. messages.ts L3894: attachment as any
  42. searchExtraTools.ts L507: (msg as any).compactMetadata?.preCompactDiscoveredTools
  43. effort.ts L81: get3PModelCapabilityOverride(_model, 'xhigh_effort' as any)
  44. sessionRestore.ts L81: (msg.message!.content as any[])
  45. worktree.ts L1296: (result as any).baseBranch
  46. permissions/permissions.ts L416: suggestions as any
  47. permissions/permissions.ts L427: decision.updatedPermissions as any
  48. permissions/permissions.ts L432: decision.updatedPermissions as any
  49. auth.ts L120: (settings as any).modelType === 'openai'
  50. auth.ts L121: (settings as any).modelType === 'gemini'
  51. swarm/inProcessRunner.ts L1452: (m.message?.content ?? []) as any[]

src/constants/

  1. promptEngineeringAudit.runner.ts L15: (globalThis as any).MACRO = {
  2. promptEngineeringAudit.runner.ts L217: ] as any
  3. outputStyles.ts L188: (style as any).source === 'plugin'
  4. outputStyles.ts L189: (style as any).forceForPlugin === true

src/services/

  1. vcr.ts L272: .filter(Boolean) as any
  2. tokenEstimation.ts L482: block.content as any
  3. skillSearch/prefetch.ts L244: } as any
  4. skillSearch/prefetch.ts L309: } as any
  5. notifier.ts L139: plist.parse(defaultsOutput.stdout) as any

src/tasks/

  1. LocalShellTask/killShellTasks.ts L18: (task as any).status !== 'running'

src/buddy/

  1. companionReact.ts L76: (m as any).message?.content
  2. companionReact.ts L92: (m as any).message?.content

src/entrypoints/

  1. mcp.ts L147: (validationResult as any).message
  2. cli.tsx L13: (globalThis as any).MACRO = {
  3. cli.tsx L149: ChannelPermissionRequestNotificationSchema() as any

packages/builtin-tools/src/tools/

  1. FileReadTool/FileReadTool.ts L913,917,984,1000,1177 (5 total): (extractResult as any), (sharp as any)
  2. AgentTool/runAgent.ts L789-808 (5 total): (message as any).event, (message as any).ttftMs, etc.

Categories for Analysis

For each occurrence, classify and recommend:

A. Zod schemas (2,5,6,92): SomeSchema() as any — schema type inference lost B. Message/attachment access (7,29-31,40-41,56-58,67-68,70,77,88-89): accessing sub-properties not in SDKMessage type C. globalThis/global MACRO (1,13-14,36-37,78,91): dev-mode constants injected at build time D. ComputerUse dynamic modules (42-53): optional native module feature detection E. ConsoleOAuthFlow config (19-25): settings update type mismatches F. Theme/permission/config (4,72-74,75-76,80-81): style/permission type extensions G. CLI key handlers (9-12): non-standard KeyboardEvent properties H. Performance polyfill (34-37): Bun lacks browser performance API I. Dynamic function calls (27-28,59): execaSync, openai client calls, dynamic imports J. Misc runtime access (3,8,15-18,26,32-33,38-39,54-55,60-66,69,71,79,82-87,90,93-94)

Verification

After plan is complete, verify by running:

export PATH="$HOME/.bun/bin:$PATH"
bun run typecheck  # should still have 20 errors (community code, unchanged)