Skip to content

refactor(#319): split state-utils.ts into focused modules - #330

Merged
admarble merged 1 commit into
mainfrom
feature/319-refactor-state-utils-split-943-line-file-into-focu
Feb 22, 2026
Merged

admarble merged 1 commit into
mainfrom
feature/319-refactor-state-utils-split-943-line-file-into-focu

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • Split 943-line state-utils.ts into focused, single-responsibility modules
  • Created 4 new modules with clear boundaries:
    • pr-status.ts (151 lines): PR merge detection and branch status
    • state-rebuild.ts (194 lines): State reconstruction from run logs
    • worktree-discovery.ts (320 lines): Worktree discovery for state bootstrapping
    • state-cleanup.ts (331 lines): Cleanup of stale entries and startup reconciliation
  • Converted state-utils.ts to a 53-line re-export barrel file for backward compatibility

Test Plan

  • All 31 existing state-utils.test.ts tests pass
  • All 6 state.test.ts tests pass
  • npm run build succeeds (TypeScript compilation)
  • npm run lint passes (no warnings)
  • All existing imports from state-utils continue to work unchanged

Pre-PR AC Verification

AC Source Description Status Evidence
AC-1 Original state-utils.ts reduced to < 300 lines ✅ Implemented 53 lines (re-export barrel)
AC-2 Original Each extracted module has a single responsibility ✅ Implemented Each module handles one concern
AC-3 Original All existing imports from state-utils continue to work ✅ Implemented Barrel re-exports all functions/types
AC-4 Original All existing tests pass without modification ✅ Implemented 31 tests pass unchanged
AC-5 Original No behavior changes — pure refactor ✅ Implemented Function bodies copied verbatim

Closes #319

🤖 Generated with Claude Code

Split the 943-line state-utils.ts into focused, single-responsibility modules:

- pr-status.ts (151 lines): PR merge detection and branch status
- state-rebuild.ts (194 lines): State reconstruction from run logs
- worktree-discovery.ts (320 lines): Worktree discovery for state bootstrapping
- state-cleanup.ts (331 lines): Cleanup of stale entries and startup reconciliation
- state-utils.ts (53 lines): Re-export barrel for backward compatibility

All existing imports continue to work through the barrel file.

Entire-Checkpoint: be89c6723d82
@admarble
admarble merged commit 2f4ac4a into main Feb 22, 2026
6 checks passed
@admarble
admarble deleted the feature/319-refactor-state-utils-split-943-line-file-into-focu branch February 22, 2026 21:20
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.

refactor(state-utils): split 943-line file into focused modules

1 participant