Skip to content

cleanup opportunities complexity hotspots

drferdi edited this page Sep 23, 2026 · 2 revisions

Complexity hotspots

File size is the clearest signal of where complexity has pooled. The sizes below were measured against the standalone capsule and exclude generated output.

File Size Lines (approx) Note
desktop/renderer/renderer.ts ~98.6 KB ~3400 Monolithic renderer; prime split candidate
lib/llm/prompt-builder.ts ~21.9 KB Prompt assembly and system-prompt text
desktop/main.ts ~18.8 KB Window sizing, env loading, IPC wiring, shell state
desktop/ipc/core.ts ~16.8 KB Command router and payload validation
types/index.ts ~16.4 KB Contract barrel (Zod schemas and inferred types)
lib/optimizer/engine.ts ~15.6 KB Optimizer orchestration

The renderer is roughly four times the next-largest file. It handles command parsing, transcript rendering, the streaming "scramble then decode" effect, and the Coding Brief clarification round in one module. A focused split would separate command parsing, rendering, and streaming into their own modules, leaving desktop/renderer/renderer.ts as the wiring layer. The comment density suggests it grew feature by feature rather than by design.

The other entries are less urgent. types/index.ts is a contract barrel, so its size reflects the number of schemas rather than tangled logic. desktop/main.ts and desktop/ipc/core.ts mix several concerns and could be split along their existing seams (env loading, window sizing, command routing), but neither is a correctness risk today.

Line counts are given only where measured; the table leaves them blank otherwise.

Clone this wiki locally