refactor: decompose the three largest TypeScript god files into single-responsibility modules
Merged
WI
4mo ago+1840+1840+0123456789012345678901234567890123456789-1099-1099-0123456789012345678901234567890123456789
Summary
Continues the god-file decomposition pattern (prior e7fd375 did the CLI) on the three largest TypeScript files — the system's most central client/orchestration surfaces. Each change is a behavior-preserving pure move behind an unchanged public API.
| File | Before → After | New modules |
|---|---|---|
sdk/messaging/relaycast.ts | 1654 → 1126 | relaycast-translate.ts, relaycast-placement.ts, relaycast-client.ts |
harness-driver/client.ts | 1199 → 931 | spawn-request.ts, broker-process.ts |
cloud/workflows.ts | 1129 → 893 | workflow-paths.ts |
The common thread: separate pure logic (wire↔domain translation, spawn-request shaping, workflow-path parsing) from the stateful/IO code (messaging client, broker-process client, cloud S3/API orchestrator). Public surfaces are preserved via re-exports, so consumers and tests are unaffected.
Per-file detail
relaycast.ts→relaycast-translate.ts(pure wire↔domain translation + record readers),relaycast-placement.ts(RelayPlacementError, placement payload helpers),relaycast-client.ts(structural relaycast adapter types, options,createRelaycastClient). Re-exportsRelayPlacementErrorandRelaycastMessagingOptions. A follow-up commit also unexports the translate readers that don't cross a module boundary (review feedback).harness-driver/client.ts→spawn-request.ts(/api/spawnbody builders + patch applier),broker-process.ts(managed broker child-process lifecycle: API-URL wait, stdio drain, recent-output buffering, startup-error formatting, shutdown).BrokerExitInfomoved and re-exported so the package barrel is unchanged.cloud/workflows.ts→workflow-paths.ts(YAML path parser + TS literal scanner +parseWorkflowPaths/inferWorkflowFileType/shouldSyncCodeByDefault). Validation (which shells out), the runtimePATH_NAME_REguard, GitHub-remote helpers, and all execution/API/S3 code stay behind; the three parser entry points are re-exported so the barrel and tests still import from./workflows.js.
Verification (every step)
- Build:
npm run build:coregreen, 0 TS errors. - Tests: full
vitest run— 959 passed / 5 skipped, identical to baseline throughout. - Live smoke tests: exercised the moved code through the built packages (SDK public surface +
agents.list; harness-driverisProcessRunning/buffer-cap/spawn-body builders; cloud YAML+TS path parsing + re-export identity). - Independent autoreview on each diff (finder + verifier agents): all returned APPROVE / empty bug list — verbatim-move integrity, import hygiene, public-surface preservation, and no-import-cycle confirmed.
Notes
- One reviewer flag was deliberately not acted on: merging the
translate.tsrecord readers withnormalize.ts's. They have genuine semantic divergence (normalize.readStringcoerces numbers→strings;readRecordclones) — consolidating would be a silent behavior change, not a refactor. - No
CHANGELOG.mdentry: these are internal module reorganizations with no user-visible effect.
🤖 Generated with Claude Code
Generated by Claude Code