Skip to content

Conversation

@aryasaatvik
Copy link
Contributor

Summary

  • Extract routes from server.ts (~2900 → 576 lines) into 14 router files
  • Improves maintainability and type inference performance
  • Pure refactor - all 92 API endpoints preserved

Changes

New routers: session, pty, provider, mcp, file, config, tool, permission, auth, worktree, agent, lsp, formatter, command

Expanded tui.ts to include all /tui/* routes.

Test plan

  • TypeScript compiles
  • All operationIds preserved in OpenAPI spec
  • SDK regenerated successfully

Break up server.ts (~2900 lines) into 14 separate router files for better
maintainability and faster type inference:

- session.ts: Session CRUD, messages, diff, todo, summarize
- pty.ts: PTY management with WebSocket support
- provider.ts: Provider listing and OAuth flows
- mcp.ts: MCP server management and resources
- file.ts: File operations and search (find routes)
- config.ts: Configuration get/update
- tool.ts: Tool listing
- permission.ts: Permission requests
- auth.ts: Auth credentials
- worktree.ts: Worktree operations
- agent.ts: Agent listing
- lsp.ts: LSP status
- formatter.ts: Formatter status
- command.ts: Command listing

Expanded tui.ts to include all /tui/* routes with control routes nested.

This is a pure refactor - all 92 API endpoints preserved with identical
behavior. SDK regenerated with only ordering changes.
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

aryasaatvik added a commit to aryasaatvik/opencode that referenced this pull request Jan 12, 2026
Refactors the monolithic server.ts file into domain-specific router modules for better organization and maintainability.

## Changes

- Extract authentication routes to `auth.ts`
- Extract session management routes to `session.ts`
- Extract agent routes to `agent.ts`
- Extract file operation routes to `file.ts`
- Extract PTY/terminal routes to `pty.ts`
- Extract MCP routes to `mcp.ts`
- Extract LSP routes to `lsp.ts`
- Extract provider routes to `provider.ts`
- Extract config routes to `config.ts`
- Extract command routes to `command.ts`
- Extract permission routes to `permission.ts`
- Extract worktree routes to `worktree.ts`
- Extract formatter routes to `formatter.ts`
- Extract tool routes to `tool.ts`

Patchwork-Source: routers
Patchwork-PR: anomalyco#7947
Patchwork-Squashed: $(date -u +%Y-%m-%dT%H:%M:%SZ)
aryasaatvik added a commit to aryasaatvik/opencode that referenced this pull request Jan 12, 2026
Refactors the monolithic server.ts file into domain-specific router modules for better organization and maintainability.

- Extract authentication routes to `auth.ts`
- Extract session management routes to `session.ts`
- Extract agent routes to `agent.ts`
- Extract file operation routes to `file.ts`
- Extract PTY/terminal routes to `pty.ts`
- Extract MCP routes to `mcp.ts`
- Extract LSP routes to `lsp.ts`
- Extract provider routes to `provider.ts`
- Extract config routes to `config.ts`
- Extract command routes to `command.ts`
- Extract permission routes to `permission.ts`
- Extract worktree routes to `worktree.ts`
- Extract formatter routes to `formatter.ts`
- Extract tool routes to `tool.ts`

Patchwork-Source: routers
Patchwork-PR: anomalyco#7947
Patchwork-Squashed: $(date -u +%Y-%m-%dT%H:%M:%SZ)
aryasaatvik added a commit to aryasaatvik/opencode that referenced this pull request Jan 12, 2026
Refactors the monolithic server.ts file into domain-specific router modules for better organization and maintainability.

- Extract authentication routes to `auth.ts`
- Extract session management routes to `session.ts`
- Extract agent routes to `agent.ts`
- Extract file operation routes to `file.ts`
- Extract PTY/terminal routes to `pty.ts`
- Extract MCP routes to `mcp.ts`
- Extract LSP routes to `lsp.ts`
- Extract provider routes to `provider.ts`
- Extract config routes to `config.ts`
- Extract command routes to `command.ts`
- Extract permission routes to `permission.ts`
- Extract worktree routes to `worktree.ts`
- Extract formatter routes to `formatter.ts`
- Extract tool routes to `tool.ts`

Patchwork-Source: routers
Patchwork-PR: anomalyco#7947
Patchwork-Squashed: $(date -u +%Y-%m-%dT%H:%M:%SZ)
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