Task summary
When commit-echo is run in a freshly initialized git repository (no commits yet), checkGitRepo() passes (it only validates git rev-parse --git-dir), but the suggest flow eventually fails with a cryptic error. Add a check for zero commits early in the flow and show a clear, actionable message.
Why this is a good first issue
Single-file change that follows the existing error-handling pattern used in suggestCommand(). Teaches how git operations are wrapped, how error messages are surfaced to users, and the importance of validating preconditions before doing work.
Suggested files or areas
src/git/diff.ts — Add a hasCommits() function (e.g., git rev-list --count HEAD) or modify checkGitRepo() to also verify the repo has at least one commit
src/commands/suggest.ts — Call hasCommits() early in the suggest flow and show a friendly message if the repo has no commits
Acceptance criteria
Extra context
checkGitRepo() in src/git/diff.ts runs git rev-parse --git-dir — add a helper that checks git rev-list --count HEAD (or git log --oneline -1) and returns a boolean
- See the existing error handling in
suggestCommand() for patterns (e.g., the loadOrPromptConfig catch block using outro(pc.red(...)))
- The check should go right after
checkGitRepo() succeeds, before loading config or calling getStagedDiff()
Task summary
When
commit-echois run in a freshly initialized git repository (no commits yet),checkGitRepo()passes (it only validatesgit rev-parse --git-dir), but the suggest flow eventually fails with a cryptic error. Add a check for zero commits early in the flow and show a clear, actionable message.Why this is a good first issue
Single-file change that follows the existing error-handling pattern used in
suggestCommand(). Teaches how git operations are wrapped, how error messages are surfaced to users, and the importance of validating preconditions before doing work.Suggested files or areas
src/git/diff.ts— Add ahasCommits()function (e.g.,git rev-list --count HEAD) or modifycheckGitRepo()to also verify the repo has at least one commitsrc/commands/suggest.ts— CallhasCommits()early in the suggest flow and show a friendly message if the repo has no commitsAcceptance criteria
commit-echoin a repo with zero commits shows a clear message like "This repository has no commits yet. commit-echo needs at least one commit to analyze your style."npm run buildpasses with no errorsExtra context
checkGitRepo()insrc/git/diff.tsrunsgit rev-parse --git-dir— add a helper that checksgit rev-list --count HEAD(orgit log --oneline -1) and returns a booleansuggestCommand()for patterns (e.g., theloadOrPromptConfigcatch block usingoutro(pc.red(...)))checkGitRepo()succeeds, before loading config or callinggetStagedDiff()