refactor(react-native): collocate Metro, companion, and DevTools

Merged
TH
11h ago
+1119-831

Summary

Collocate Metro preparation and session bindings, companion lifecycle and worker, and React inspection/profiling in private @agent-device/react-native.

One "." export points to src/index.ts. Its explicit, typed interface exposes Metro operations, session lifecycle operations, and runReactDevtools; runtime implementations load lazily. Persistence helpers and internal modules stay private. Public CLI and SDK behavior is preserved.

flowchart LR
  Adapters[CLI / SDK adapters] --> Entry[react-native index.ts]
  Entry --> Metro[Metro preparation and bindings]
  Entry --> Companion[Companion lifecycle and worker]
  Entry --> DevTools[React inspection and profiling]
  DevTools --> Metro
  Metro --> Companion

82 files touched, mostly moves. Companion protocol/lifecycle code sits beside its worker; package-wide tests exercise the root interface, SDK session tests sit with the SDK, and shared fixtures live in test-kit. Remove the obsolete root overlay re-export; retain its canonical capture-kit implementation. Update ADR 0019 and path-keyed checks.

Validation

Tested commit: 143c6deee769c72ce19b818ece338006ef518c00.

  • 1,194 focused tests and 39 overlay/command tests pass.
  • pnpm check:affected --run: all runnable checks passed; 1,845 files / 15,564 tests passed, one skipped.
  • Bundled CLI text/JSON and installed-package companion checks pass.
  • Depgraph: all external package edges target src/index.ts; no root imports, value cycles, or zone cycles.
  • Independent review at b60d2b2: no actionable findings; follow-up changes only a doc comment.
  • CI integration and coverage pending on this head.