feat: implement autoCommit engine behavior for task completion#198
feat: implement autoCommit engine behavior for task completion#198
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughAdds an auto-commit configuration option and implements automatic Git commits after successful tasks: new auto-commit utility with tests, engine integration emitting a Changes
Sequence Diagram(s)sequenceDiagram
participant Engine as ExecutionEngine
participant AutoCommit as performAutoCommit()
participant Git as Git Repository
participant EventBus as Event Bus
Engine->>Engine: Task completes
Engine->>Engine: check config.autoCommit
alt autoCommit enabled
Engine->>AutoCommit: performAutoCommit(cwd, taskId, taskTitle)
AutoCommit->>Git: git status --porcelain
Git-->>AutoCommit: status output
alt changes detected
AutoCommit->>Git: git add -A
Git-->>AutoCommit: staged
AutoCommit->>Git: git commit -m "feat: <taskId> - <taskTitle>"
Git-->>AutoCommit: commit created
AutoCommit->>Git: git rev-parse --short HEAD
Git-->>AutoCommit: commitSha
AutoCommit-->>Engine: {committed: true, commitMessage, commitSha}
Engine->>EventBus: emit task:auto-committed
else no changes
AutoCommit-->>Engine: {committed: false, skipReason}
end
else autoCommit disabled
Engine->>EventBus: continue without auto-commit
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #198 +/- ##
==========================================
+ Coverage 44.86% 44.87% +0.01%
==========================================
Files 78 79 +1
Lines 22873 22988 +115
==========================================
+ Hits 10261 10316 +55
- Misses 12612 12672 +60
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/engine/auto-commit.ts`:
- Around line 27-50: The helper hasUncommittedChanges currently swallows git
failures by returning false; change it to throw an Error (include result.stderr
or a descriptive message) when runProcess('git', ['status', '--porcelain'], {
cwd }) returns !result.success, and keep returning the boolean only on success.
Then update performAutoCommit to call hasUncommittedChanges inside a try/catch,
and on catch return an AutoCommitResult with committed: false and the caught
error serialized into the error field so callers see the real git failure.
Ensure you reference runProcess, hasUncommittedChanges, performAutoCommit, and
the AutoCommitResult shape when making the changes.
In `@src/engine/index.ts`:
- Around line 1883-1903: handleAutoCommit currently swallows errors from
performAutoCommit; update the catch to surface failures by logging and/or
emitting an event: in the catch block capture the thrown error (e.g., err) and
call this.emit with a new event like type: 'task:auto-commit-failed' including
timestamp, task, iteration, and an error message/stack (and optionally include
the original result fields if present), and also log the error using the
engine's logger (or console.error) so auto-commit failures are visible; modify
handleAutoCommit and its catch to reference performAutoCommit, this.emit, and
the task/iteration symbols to locate the change.
🧹 Nitpick comments (1)
src/engine/auto-commit.test.ts (1)
15-23: Fail fast on git setup errors.If git commands fail, the tests become noisy to diagnose. Consider asserting success in
initGitRepoto surface the actual failing step.♻️ Proposed refactor
async function initGitRepo(dir: string): Promise<void> { - await runProcess('git', ['init'], { cwd: dir }); - await runProcess('git', ['config', 'user.email', '[email protected]'], { cwd: dir }); - await runProcess('git', ['config', 'user.name', 'Test'], { cwd: dir }); + const runGit = async (args: string[], label: string) => { + const result = await runProcess('git', args, { cwd: dir }); + if (!result.success) { + throw new Error(`${label} failed: ${result.stderr.trim() || 'unknown error'}`); + } + }; + await runGit(['init'], 'git init'); + await runGit(['config', 'user.email', '[email protected]'], 'git config user.email'); + await runGit(['config', 'user.name', 'Test'], 'git config user.name'); // Create initial commit so HEAD exists await writeFile(join(dir, '.gitkeep'), ''); - await runProcess('git', ['add', '-A'], { cwd: dir }); - await runProcess('git', ['commit', '-m', 'initial'], { cwd: dir }); + await runGit(['add', '-A'], 'git add'); + await runGit(['commit', '-m', 'initial'], 'git commit'); }
Wire the existing autoCommit config option into the engine so it stages and commits all changes after successful task completion. Adds auto-commit utility module, event type, and integration tests.
…ommits Templates now conditionally instruct the agent NOT to commit in both cases: when autoCommit=true (engine handles it) and autoCommit=false (user handles it manually). Previously, templates always told the agent to commit regardless of the setting.
…rors - hasUncommittedChanges now throws on git failure instead of returning false, so callers can distinguish "no changes" from "git broken" - performAutoCommit wraps hasUncommittedChanges in try/catch and returns the error in AutoCommitResult.error - handleAutoCommit emits task:auto-commit-failed event on errors (both from result.error and unexpected throws) - Adds TaskAutoCommitFailedEvent to engine event types
e58c3b4 to
9a87c14
Compare
feat: implement autoCommit engine behavior for task completion
Summary
autoCommitconfig option into the execution engine so it actually stages and commits all changes after successful task completionautoCommitto theRalphConfigruntime interface andbuildConfig()returnsrc/engine/auto-commit.tsutility module withhasUncommittedChanges()andperformAutoCommit()functionstask:auto-committedengine event type for consumers (TUI, remote server) to react totracker.completeTask()(so.beads/changes are included) but beforesaveIterationLog()(so iteration logs are not committed)Test plan
bun run typecheck— no type errorsbun run build— builds successfullybun test src/engine/auto-commit.test.ts— 10/10 tests passautoCommit = truein config, run a task, verify commit is created after completionSummary by CodeRabbit
New Features
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.