refactor(mcp): split screen.ts by domain (1834 → 692 lines)#26
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
screen.tshad accumulated tools from many unrelated domains (text, device, background, effects, layout-prediction, render, description) and grown to 1834 lines — 4× the next-largest file inpackages/mcp/src/tools/.Splits into 6 per-domain files, all under 350 lines:
screen.tsscreen-text.tsscreen-effects.tsscreen-layout.tsscreen-device.tsscreen-background.tsAlso: moves
stripTagsFromHeadlinefrom screen.ts tohelpers.tsso multiple modules can share it without circular imports.Pure mechanical refactor — zero behavior change
pnpm buildsucceeds🤖 Generated with Claude Code