Skip to content

Extract findnext package from main#477

Merged
hollesse merged 4 commits intomainfrom
claude/plan-package-structure-0KGaB
Feb 16, 2026
Merged

Extract findnext package from main#477
hollesse merged 4 commits intomainfrom
claude/plan-package-structure-0KGaB

Conversation

@hollesse
Copy link
Member

Summary

This PR extracts the "find next typist" algorithm into its own dedicated package as the first step of a larger refactoring to improve code organization and separation of concerns in mob.sh.

Changes Made

  • New package findnext/: Created a new package containing the algorithm for determining who should type next based on commit history

    • findnext/findnext.go: Contains FindNextTypist() function (exported) and helper functions (unexported)
    • findnext/findnext_test.go: Moved all 12 existing tests with updated imports
  • Updated mob.go:

    • Added import for the new findnext package
    • Updated call sites to use findnext.FindNextTypist() instead of the local findNextTypist() function
  • Removed from main package:

    • find_next.go (moved to findnext/findnext.go)
    • find_next_test.go (moved to findnext/findnext_test.go)
  • Added documentation: Comprehensive refactoring plan in plan/packagestruktur.md outlining the vision for the entire codebase restructuring, including dependency hierarchy and future extraction steps

Implementation Details

  • The algorithm itself is unchanged; this is purely a structural refactoring
  • Function signature changed from findNextTypist() to FindNextTypist() to follow Go naming conventions for exported functions
  • Helper functions (reverse, lookahead, contains, min, prepend) remain unexported within the package
  • All existing tests pass without modification to test logic (only import paths updated)
  • This extraction establishes the pattern for future package extractions (e.g., coauthor/, git/, branch/, etc.)

https://claude.ai/code/session_01Hpdc7emSdo5SfustrYFjjr

Analyze current code structure and propose a step-by-step plan to
extract well-defined packages from the monolithic main package.
First step: extract findnext/ package (pure algorithm, zero dependencies).

https://claude.ai/code/session_01Hpdc7emSdo5SfustrYFjjr
Detail where shared functions (startCommand, runCommand, git wrappers,
injectCommandWithMessage, etc.) will live. Introduce git.Context struct
concept to encapsulate global state (workingDir, GitPassthroughStderrStdout).

https://claude.ai/code/session_01Hpdc7emSdo5SfustrYFjjr
Move FindNextTypist algorithm and its helpers into a dedicated package.
This is a pure algorithm with zero external dependencies, making it
the ideal first extraction in the package restructuring.

- findNextTypist() -> findnext.FindNextTypist() (exported)
- Helper functions (reverse, lookahead, contains, min, prepend) stay unexported
- Tests moved to findnext/findnext_test.go using test.Equals

https://claude.ai/code/session_01Hpdc7emSdo5SfustrYFjjr
@hollesse hollesse merged commit f7bae34 into main Feb 16, 2026
12 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