| 2029 |
workers/mcp/src/instance-tools.ts |
Every instance-scoped MCP tool (schema + handler) in one file (~dozens of tools). Split by tool group (knowledge, coding, triggers, board, settings, …). |
| 1470 |
workers/api/src/routes/coding.ts |
ALL coding routes — repos, sessions, deployments/builds, issues, overseer, engines, work-mode. Too many endpoints in one router; split by sub-domain. |
| 1317 |
workers/api/src/routes/instances.ts |
Instance CRUD + voice-settings + typed settings + language sync + more. Mixed concerns; extract voice-settings and settings routers. |
| 1290 |
workers/api/src/agent-do.ts |
The AgentDO Durable Object: chat loop, tool execution, storage wiring, repo ingest, alarm state machine. Classic god-object; split the ingest/alarm and chat loop out. |
| 1276 |
store/console/src/tabs/SettingsTab.tsx |
One giant Settings component (voice, translation, board maintenance, runner info, danger zone, …). Split into per-section subcomponents. |
| 1251 |
workers/api/src/agent-storage.ts |
Storage engine spanning collections, files, vectors, activity, summaries, memory — many domains in one class. Split per storage domain. |
| 1155 |
packages/browser-runner/src/runner.ts |
Runner entry: Playwright + tmux + relay transport + task dispatch. Mixes transport and task handlers; extract the task registry. |
| 1064 |
workers/mcp/src/index.ts |
MCP server bootstrap + account-tool registration + dispatch. Split registration from transport/dispatch. |
| 1064 |
packages/sdk/src/voice/use-voice.ts |
The voice hook — STT/TTS/VAD/modes/commands/timers/echo-guard all in one useVoice. Very high complexity; extract sub-hooks (e.g. useStt, useTurnTimers, useCommands). |
| 986 |
e2e/console.spec.ts |
Playwright e2e suite for the console (one big spec). Lower priority (tests), but could split by feature area for readability. |
| 788 |
workers/api/src/routes/instances-runtime.ts |
Runtime/relay node routes (register/resolve/status). Cohesive but long; candidate to split node-management vs runtime-call. |
| 763 |
agents/coder/web/src/CodingTab.tsx |
The Coder UI container: repos, sessions, terminal/co-pilot, header override, builds toggle, loop, engines. Many responsibilities in one component — prime split candidate (header, session view, landing view). |
| 748 |
workers/api/src/lib/storage-tools.ts |
executeStorageTool — one big switch over all storage + coding tools. Split handlers per group. |
| 725 |
packages/cli/src/commands/runner.ts |
CLI runner command (connect, relay, multiplex, reattach). Long single command; extract helpers. |
| 720 |
store/console/src/pages/InstanceDetail.tsx |
Instance detail page: chat thread + tab routing + voice + loop + gloss. Mixed concerns; extract the chat thread component. |
Audit of the largest TypeScript source files (excluding
node_modules,dist, and unit*.test.*). Purpose: identify refactor candidates — files that are too long and/or mix multiple responsibilities. No refactoring in this issue — just the list + rationale, to be split into follow-up tasks.Command used:
Top 15 by line count
workers/mcp/src/instance-tools.tsworkers/api/src/routes/coding.tsworkers/api/src/routes/instances.tsworkers/api/src/agent-do.tsAgentDODurable Object: chat loop, tool execution, storage wiring, repo ingest, alarm state machine. Classic god-object; split the ingest/alarm and chat loop out.store/console/src/tabs/SettingsTab.tsxworkers/api/src/agent-storage.tspackages/browser-runner/src/runner.tsworkers/mcp/src/index.tspackages/sdk/src/voice/use-voice.tsuseVoice. Very high complexity; extract sub-hooks (e.g. useStt, useTurnTimers, useCommands).e2e/console.spec.tsworkers/api/src/routes/instances-runtime.tsagents/coder/web/src/CodingTab.tsxworkers/api/src/lib/storage-tools.tsexecuteStorageTool— one big switch over all storage + coding tools. Split handlers per group.packages/cli/src/commands/runner.tsrunnercommand (connect, relay, multiplex, reattach). Long single command; extract helpers.store/console/src/pages/InstanceDetail.tsxSuggested next steps
agent-do.ts,agent-storage.ts,instance-tools.ts, anduse-voice.ts— highest complexity-per-file and most-touched.SettingsTab.tsx,CodingTab.tsx,InstanceDetail.tsxsplit into subcomponents (they already have natural section boundaries).