Skip to content

refactor(contracts): one file per domain behind the contracts index - #621

Merged
klNuno merged 10 commits into
mainfrom
refactor/split-contracts
Oct 19, 2026
Merged

klNuno merged 10 commits into
mainfrom
refactor/split-contracts

Conversation

@klNuno

@klNuno klNuno commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Note

Clanker Claude Opus 5.5 is responding on behalf of meetsu

Two changes to different parts of the protocol no longer edit the same contract file.

Depends on #614.

migrating an open branch

A branch cut before this PR edits the single packages/contracts/src/index.ts. After git merge origin/main stops on it, run:

bun scripts/migrate/split-contracts.ts

It splits the merge base and the branch versions with the codemod that made this split, replays each domain's change onto main's file with git merge-file, rewrites the imports of each file it touched and stages the result. A domain both sides changed on the same lines keeps conflict markers and is listed.

what changed

  • The 5,328-line index.ts is 32 domain files beside it (threads.ts, providers.ts, wire.ts), the largest 719 lines.
  • Each domain declares its methods and events in <Domain>RpcMethods and <Domain>RpcEvents; index.ts re-exports every file and composes RpcMethods and RpcEvents from them.
  • scripts/migrate/split-contracts.ts holds the codemod (--split), its anchor and namespace tables, and the migration; scripts/migrate/git.ts is shared with the catalogue migration.
  • The contract leaves the size-budget exemption; AGENTS.md, docs/development.md, docs/panel.md and the PR template name the domain files.

to question

Declarations go by anchors in the single file's order, so a type a branch adds lands beside its neighbours, and members by namespace (threads.*). Imports between domains are generated: types through import type, values from the file that declares them, with no runtime cycle.

verified

  • Exported surface: 735 of 735 names kept, 54 added (the domain maps); each type and value is mutually assignable and identical to its old self under tsc.
  • Runtime exports: 317 before and after, same keys, equal values.
  • --split replayed on the parent commit reproduces all 33 files byte for byte.
  • bun run check passes; bun run check:architecture reports no cycle and no exempt entry.
  • Migration on throwaway merges of feat(chat): show how long a mid-turn compaction has run #605 and feat(push): choose which notifications each device gets #598 with this branch: no conflict, every file equals a single-file 3-way merge then split, and contracts, core and UI type checks pass on both.
  • bun test scripts/migrate scripts/architecture: 30 pass.
  • not verified: core, UI and E2E suites, which this PR's CI runs.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: beboite/boite/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2a001067-434b-4462-8b1e-7b632c8bdbbc
📥 Commits

Reviewing files that changed from the base of the PR and between 38d5ca2 and 9fa2606.

📒 Files selected for processing: 44
  • .github/pull_request_template.md
  • AGENTS.md
  • docs/development.md
  • docs/panel.md
  • packages/contracts/src/accounts.ts
  • packages/contracts/src/agent-door.ts
  • packages/contracts/src/brain.ts
  • packages/contracts/src/coordination.ts
  • packages/contracts/src/core.ts
  • packages/contracts/src/delegation.ts
  • packages/contracts/src/files.ts
  • packages/contracts/src/git.ts
  • packages/contracts/src/group.ts
  • packages/contracts/src/hooks.ts
  • packages/contracts/src/ids.ts
  • packages/contracts/src/imports.ts
  • packages/contracts/src/index.ts
  • packages/contracts/src/keybindings.ts
  • packages/contracts/src/messages.ts
  • packages/contracts/src/pairing.ts
  • packages/contracts/src/panel.ts
  • packages/contracts/src/permissions.ts
  • packages/contracts/src/plugins.ts
  • packages/contracts/src/projects.ts
  • packages/contracts/src/providers.ts
  • packages/contracts/src/questions.ts
  • packages/contracts/src/scheduler.ts
  • packages/contracts/src/settings.ts
  • packages/contracts/src/speech.ts
  • packages/contracts/src/subscription-proxy.ts
  • packages/contracts/src/terminals.ts
  • packages/contracts/src/threads.ts
  • packages/contracts/src/todos.ts
  • packages/contracts/src/trace.ts
  • packages/contracts/src/turns.ts
  • packages/contracts/src/usage.ts
  • packages/contracts/src/wire.ts
  • scripts/architecture/size-budget.json
  • scripts/architecture/size.test.ts
  • scripts/architecture/size.ts
  • scripts/migrate/git.ts
  • scripts/migrate/split-catalogues.ts
  • scripts/migrate/split-contracts.test.ts
  • scripts/migrate/split-contracts.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added documentation Improvements or additions to documentation core packages/core and packages/contracts ci Workflows and CI scripts labels Oct 19, 2026
@klNuno
klNuno deleted the branch refactor/split-catalogues October 19, 2026 02:54
@klNuno klNuno closed this Oct 19, 2026
@klNuno klNuno reopened this Oct 19, 2026
@klNuno
klNuno changed the base branch from refactor/split-catalogues to main October 19, 2026 02:54
# Conflicts:
#	scripts/architecture/size-budget.json
#	scripts/architecture/size.test.ts
#	scripts/migrate/split-catalogues.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Workflows and CI scripts core packages/core and packages/contracts documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant