Skip to content

Split server/internal/dev/routes.go by domain#85

Merged
MiniMax-AI-Dev merged 1 commit into
mainfrom
refactor/split-dev-routes
Jul 10, 2026
Merged

Split server/internal/dev/routes.go by domain#85
MiniMax-AI-Dev merged 1 commit into
mainfrom
refactor/split-dev-routes

Conversation

@RyanLee-Dev

Copy link
Copy Markdown
Collaborator

Summary

server/internal/dev/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 —
too large to review or navigate comfortably.

This is a pure mechanical split, zero behavior change:

  • Every top-level func/type/var/const (including its swaggo
    annotation block, directly above the func, per AGENTS.md) was moved
    verbatim to a new file, grouped by its @Tags value (or the
    closest natural grouping for untagged helpers/types).
  • Router wiring (RegisterRoutes, RegisterRoutesWithStore, all
    RouterOption / 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 a
    single coherent domain file, per the task's own carve-out.
  • routes_test.go (4183 lines) was not split, to avoid risking the
    test suite for a lower-priority part of this refactor. Flagging this
    explicitly as a known follow-up.
  • Package stays dev (renaming it is a separate, bigger concern, out
    of 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.go
itself shrinks from 6297 to 716 lines (interfaces, RouterOptions,
RegisterRoutesWithStore mounting).

Nothing outside server/internal/dev/ was touched.

Verification

An AST-level script confirmed all 202 top-level declarations in the
original routes.go exist in the new files with byte-for-byte
identical text (including doc/swaggo comments) — zero lost, zero
duplicated, zero altered.

  • go build ./... succeeds
  • go test ./server/internal/dev/... — 192 pass / 0 fail / 55
    skip, identical to a baseline run on origin/main before this
    change
  • make openapi produces an empty diff against
    docs/openapi/openapi.yaml (still 129 paths) — the strongest
    proof 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
  • Non-blank line count of the package is conserved (22882 → 23035;
    the ~150-line delta is exactly the per-file package/import
    boilerplate across 14 files, confirmed via the AST diff above)

🤖 Generated with Claude Code

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>
@MiniMax-AI-Dev MiniMax-AI-Dev merged commit 7fc6e0e into main Jul 10, 2026
6 checks passed
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.

2 participants