Add commit split for staged multi-commit plans
Merged
RA
3mo ago+2128+2128+0123456789012345678901234567890123456789-48-48-01234567890123456789
Motivation
No motivation was provided.
What's New
Git Pathspecs
listStagedPathsreads staged paths withgit diff --staged --name-only -z.performCommittakes optional pathspecs so one staged set can become several commits.- Commits run as
git -C <worktree-root>so those root-relative paths work when cwd is a subdirectory.
Split Plan
- The model returns JSON commit groups. The parser rejects empty messages, empty file lists, duplicates, and unknown paths.
- Leftover staged paths are appended as
Commit remaining staged changes.
CLI
commit splitproposes a plan, then apply, apply and push, edit, move, reorder, regenerate, or cancel.- Apply walks the plan and commits each group with pathspecs.
Split Plan Flow
flowchart TB
A["commit split"] --> B["Staged diff and paths"]
B --> C["generateSplitPlan"]
C --> D{"Action"}
D -->|edit move reorder| D
D -->|regenerate| C
D -->|apply| E["performCommit per group"]
D -->|apply and push| E
E --> F["push publish or force-with-lease"]
D -->|cancel| G["exit"]
Changed Files
| File | Change Type | Summary |
|---|---|---|
src/infra/git/repo.ts | Modified | Pathspecs, listStagedPaths, git -C root |
src/domain/split/plan.ts | Added | Parse and validate plan JSON |
src/cli/split.ts | Added | Interactive apply loop |
src/domain/commit/prompts.ts | Modified | getSplitPrompt |
src/domain/llm/router.ts | Modified | generateSplitPlan |
src/cli/parser.ts | Modified | split command |
src/domain/alias/alias.ts | Modified | Alias target split |
index.ts | Modified | Dispatch split |
README.md | Modified | Document commit split |
| tests listed above | Added/Modified | Plan, router, CLI apply/cancel, git pathspec |
Testing & Feedback
Try commit split on a mixed staged set, including from a subdirectory. Confirm apply leaves the right files in each commit, leftover paths get the remaining-changes commit, and cancel writes nothing.
If you find any bugs or have recommendations for improvements, please open an issue and assign it to me.
[!NOTE]
Cursor Bugbot is generating a summary for commit 59297560a9bcda3fff193548e45801ffd3ce8357. Configure here.