Skip to content

refactor(mcp): split screen.ts by domain (1834 → 692 lines)#26

Merged
andresdefi merged 1 commit into
mainfrom
refactor/split-screen-ts
May 23, 2026
Merged

refactor(mcp): split screen.ts by domain (1834 → 692 lines)#26
andresdefi merged 1 commit into
mainfrom
refactor/split-screen-ts

Conversation

@andresdefi
Copy link
Copy Markdown
Owner

Summary

screen.ts had accumulated tools from many unrelated domains (text, device, background, effects, layout-prediction, render, description) and grown to 1834 lines — 4× the next-largest file in packages/mcp/src/tools/.

Splits into 6 per-domain files, all under 350 lines:

File Lines Tools
screen.ts 692 (was 1834) core: patch_screen, batch_patch_screens, get_screen, render_preview, render_preview_grid, describe_screen, describe_project, inspect_fonts + helpers
screen-text.ts 329 set_headline, set_subtitle, set_font, set_text_position, set_text_layer, set_text_gradient, set_text_shadow
screen-effects.ts 254 set_spotlight, set_loupe, set_border_simulation, set_device_shadow
screen-layout.ts 253 auto_fit_headline, check_text_overlap, predict_locale_overflow
screen-device.ts 173 set_composition, set_device_frame, move_device_frame
screen-background.ts 169 set_background

Also: moves stripTagsFromHeadline from screen.ts to helpers.ts so multiple modules can share it without circular imports.

Pure mechanical refactor — zero behavior change

  • 71 tools registered (same as before)
  • 535/535 tests pass
  • typecheck clean across all packages
  • pnpm build succeeds

🤖 Generated with Claude Code

screen.ts had accumulated tools from many domains (text, device,
background, effects, layout-prediction, render, description) and grown
to 1834 lines — 4x the next-largest file. Splits into:

  screen.ts            (692 lines) — patch_screen, batch_patch_screens,
                                     get_screen, render_preview,
                                     render_preview_grid, describe_screen,
                                     describe_project, inspect_fonts +
                                     formatScreenDescription, pickFields
  screen-text.ts       (329 lines) — set_headline, set_subtitle, set_font,
                                     set_text_position, set_text_layer,
                                     set_text_gradient, set_text_shadow,
                                     setText helper
  screen-effects.ts    (254 lines) — set_spotlight, set_loupe,
                                     set_border_simulation, set_device_shadow
  screen-layout.ts     (253 lines) — auto_fit_headline, check_text_overlap,
                                     predict_locale_overflow
  screen-device.ts     (173 lines) — set_composition, set_device_frame,
                                     move_device_frame
  screen-background.ts (169 lines) — set_background

Also: moves `stripTagsFromHeadline` from screen.ts to helpers.ts so
screen-layout.ts and screen.ts can share it without circular imports.

Pure mechanical refactor. Zero behavior change:
  - 71 tools registered (same as before)
  - 535/535 tests pass
  - typecheck clean across all packages

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@andresdefi andresdefi merged commit cadb000 into main May 23, 2026
4 checks passed
@andresdefi andresdefi deleted the refactor/split-screen-ts branch May 23, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant