refactor: split lib/api.ts god module into domain files #1148

Closed
opened 2026-05-14 11:51:31 +00:00 by claude-desktop · 0 comments
Collaborator

As a developer, I want the API client split into focused domain modules, so that files are navigable and changes don't conflict across unrelated areas.

Context

apps/web/src/lib/api.ts is 2419 lines — the largest file in the codebase. It handles agents, tasks, flows, settings, auth, webhooks, and more in a single flat file.

Acceptance criteria

Refactor

  • Identify domain boundaries within api.ts (agents, tasks, flows, settings, auth, webhooks, stats, repos)
  • Extract each domain into apps/web/src/lib/api/ subdirectory (e.g. api/agents.ts, api/tasks.ts, api/flows.ts, etc.)
  • Re-export everything through apps/web/src/lib/api/index.ts so existing imports (import { ... } from "@/lib/api") continue to work unchanged
  • No import site changes required outside lib/api/
  • just qa passes (typecheck + lint)

Tests

  • Existing tests referencing API functions still pass

Out of scope

  • Changing API function signatures
  • Adding new API endpoints
  • Refactoring call sites to use per-domain imports
As a developer, I want the API client split into focused domain modules, so that files are navigable and changes don't conflict across unrelated areas. ## Context `apps/web/src/lib/api.ts` is **2419 lines** — the largest file in the codebase. It handles agents, tasks, flows, settings, auth, webhooks, and more in a single flat file. ## Acceptance criteria ### Refactor - [ ] Identify domain boundaries within `api.ts` (agents, tasks, flows, settings, auth, webhooks, stats, repos) - [ ] Extract each domain into `apps/web/src/lib/api/` subdirectory (e.g. `api/agents.ts`, `api/tasks.ts`, `api/flows.ts`, etc.) - [ ] Re-export everything through `apps/web/src/lib/api/index.ts` so existing imports (`import { ... } from "@/lib/api"`) continue to work unchanged - [ ] No import site changes required outside `lib/api/` - [ ] `just qa` passes (typecheck + lint) ### Tests - [ ] Existing tests referencing API functions still pass ## Out of scope - Changing API function signatures - Adding new API endpoints - Refactoring call sites to use per-domain imports
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/agent-hooks#1148
No description provided.