Skip to content

refactor: split 6 large files into focused sub-modules (wave 2)#385

Open
edobry wants to merge 2 commits intomainfrom
claude/large-file-wave2
Open

refactor: split 6 large files into focused sub-modules (wave 2)#385
edobry wants to merge 2 commits intomainfrom
claude/large-file-wave2

Conversation

@edobry
Copy link
Copy Markdown
Owner

@edobry edobry commented Apr 14, 2026

Summary

Continuation of the large file audit. Splits 6 files in the 636-763 line range into focused sub-modules, all under 400 lines.

File Before After Split into
adapters/shared/commands/ai.ts 763 18 completion, model-cache, provider command groups
domain/rules/rules-command-operations.ts 727 58 types, CRUD ops, config ops, migration ops
domain/tasks/taskCommands.ts 694 31 query commands, mutation commands, shared helpers
adapters/shared/commands/config.ts 677 30 helpers, list/show, get/set, validate/doctor
adapters/shared/commands/tasks/deps-rendering.ts 637 14 ASCII rendering, Graphviz rendering
adapters/cli/utilities/formatting-utilities.ts 636 23 config formatting split by concern

All original files become thin barrel re-exports. 20 new focused sub-modules created. No behavioral changes.

Files deliberately NOT split (and why):

  • session-workspace.ts (796) — MCP tools actively evolving
  • test-context.ts (759) — runtime AI context component, inherently verbose
  • session-parameters.ts (724) — pure param definitions, low complexity/line
  • remote.ts (711), github.ts (659) — already refactored, monolithic class structure
  • migrate-backend-command.ts (708) — single cohesive migration flow
  • Session operation files — DI threading actively being reworked

Result: 65 → 59 files over 400 lines.

Test plan

  • bun run typecheck — 0 errors
  • bun test — 1515 pass, 0 fail
  • bun run lint — 0 errors, 146 warnings (under 167 threshold)
  • All git hooks pass (gitleaks, format, lint, typecheck, tests)
  • No public API changes — all exports preserved via barrel re-exports

https://claude.ai/code/session_01MbaCeaVY3c1KPcofP4Cvd8

claude added 2 commits April 14, 2026 01:23
- rules-command-operations.ts: 727→58 (barrel; types, CRUD, config, migration ops)
- ai.ts: 763→18 (barrel; completion, model-cache, provider command groups)
- config.ts: 677→30 (barrel; helpers, list/show, get/set, validate/doctor)
- deps-rendering.ts: 637→14 (barrel; ASCII rendering vs Graphviz rendering)
- formatting-utilities.ts: 636→23 (barrel; config formatting split by concern)
- taskCommands.ts: 694→31 (barrel; query vs mutation command groups)

All exports preserved via re-export barrels. No behavioral changes.

https://claude.ai/code/session_01MbaCeaVY3c1KPcofP4Cvd8
Review fixes:
- Replace 8x hand-rolled error extraction with getErrorMessage()
- Rename 9x unused context params to _context
- Move configCommandParams to config/shared.ts (break cross-module coupling)
- Remove dead resolveRepoPath double-call and taskId alias in query-commands
- Remove voided dead params in deps-rendering-ascii
- Use TASK_STATUS constants in deps-rendering-graphviz
- Convert dynamic import("fs/promises") to static import
- Remove redundant destExists=false catch assignment

Flaky test fix:
- Add afterEach cleanup to rules.test.ts mock filesystem
- Use unique test directory paths to prevent cross-test interference

https://claude.ai/code/session_01MbaCeaVY3c1KPcofP4Cvd8
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