Split server/internal/dev/routes.go by domain#85
Merged
Conversation
routes.go had grown to 6297 lines mixing agents, workspaces, conversations, feishu, gateway, models, secrets, runtimes, agent-runs, workspace-members, me, and dev-only handlers in one file, making it hard to review or navigate. Pure mechanical code motion, zero behavior change: every top-level func/type/var/const (including its swaggo annotation block) was moved verbatim to a new file grouped by its @tags domain (or closest natural grouping for untagged helpers), with router wiring / shared RBAC and JSON helpers kept in routes.go / routes_helpers.go. capability_routes.go is left untouched — it is already a single coherent domain file. New files: routes_agents.go, routes_conversations.go, routes_dev.go, routes_feishu.go, routes_gateway.go, routes_helpers.go, routes_me.go, routes_models.go, routes_runs.go, routes_runtimes.go, routes_secrets.go, routes_workspace_members.go, routes_workspaces.go. routes_test.go was left as a single file (not split) to avoid risking the test suite for a secondary, lower-priority part of this refactor. Verified via an AST-level diff that all 202 top-level declarations were moved byte-for-byte identical (including doc comments), and that `make openapi` produces an empty diff against docs/openapi/openapi.yaml. Co-Authored-By: Claude Sonnet 5 <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
server/internal/dev/routes.gohad grown to 6297 lines, mixing agents,workspaces, conversations, feishu, gateway, models, secrets, runtimes,
agent-runs, workspace-members, me, and dev-only handlers in one file —
too large to review or navigate comfortably.
This is a pure mechanical split, zero behavior change:
func/type/var/const(including its swaggoannotation block, directly above the
func, per AGENTS.md) was movedverbatim to a new file, grouped by its
@Tagsvalue (or theclosest natural grouping for untagged helpers/types).
RegisterRoutes,RegisterRoutesWithStore, allRouterOption/With*functions) and shared cross-domain helpers(RBAC gates, JSON decode/write, pagination) stay in
routes.go/routes_helpers.go.capability_routes.go(1600 lines) is untouched — it's already asingle coherent domain file, per the task's own carve-out.
routes_test.go(4183 lines) was not split, to avoid risking thetest suite for a lower-priority part of this refactor. Flagging this
explicitly as a known follow-up.
dev(renaming it is a separate, bigger concern, outof scope here).
New files:
routes_agents.go,routes_conversations.go,routes_dev.go,routes_feishu.go,routes_gateway.go,routes_helpers.go,routes_me.go,routes_models.go,routes_runs.go,routes_runtimes.go,routes_secrets.go,routes_workspace_members.go,routes_workspaces.go.routes.goitself shrinks from 6297 to 716 lines (interfaces,
RouterOptions,RegisterRoutesWithStoremounting).Nothing outside
server/internal/dev/was touched.Verification
An AST-level script confirmed all 202 top-level declarations in the
original
routes.goexist in the new files with byte-for-byteidentical text (including doc/swaggo comments) — zero lost, zero
duplicated, zero altered.
go build ./...succeedsgo test ./server/internal/dev/...— 192 pass / 0 fail / 55skip, identical to a baseline run on
origin/mainbefore thischange
make openapiproduces an empty diff againstdocs/openapi/openapi.yaml(still 129 paths) — the strongestproof no swaggo annotation was lost/mangled and no route
signature changed
make check(full CI-parity gate: go test, sqlc drift check,migration check,
pnpm typecheck, ESLint design-system guard,CWD-pollution guard) passes
the ~150-line delta is exactly the per-file
package/importboilerplate across 14 files, confirmed via the AST diff above)
🤖 Generated with Claude Code