Skip to content

Comments

feat: implement autoCommit engine behavior for task completion#198

Merged
subsy merged 3 commits intomainfrom
feat/auto-commit-engine
Jan 22, 2026
Merged

feat: implement autoCommit engine behavior for task completion#198
subsy merged 3 commits intomainfrom
feat/auto-commit-engine

Conversation

@subsy
Copy link
Owner

@subsy subsy commented Jan 22, 2026

Summary

  • Wires the existing autoCommit config option into the execution engine so it actually stages and commits all changes after successful task completion
  • Adds autoCommit to the RalphConfig runtime interface and buildConfig() return
  • Creates src/engine/auto-commit.ts utility module with hasUncommittedChanges() and performAutoCommit() functions
  • Adds task:auto-committed engine event type for consumers (TUI, remote server) to react to
  • Integrates auto-commit into the engine loop: runs after tracker.completeTask() (so .beads/ changes are included) but before saveIterationLog() (so iteration logs are not committed)
  • Auto-commit failures are silently caught and never halt the engine

Test plan

  • bun run typecheck — no type errors
  • bun run build — builds successfully
  • bun test src/engine/auto-commit.test.ts — 10/10 tests pass
  • Manual: Set autoCommit = true in config, run a task, verify commit is created after completion

Summary by CodeRabbit

  • New Features

    • Added an optional autoCommit setting to optionally stage and commit changes automatically after successful task completion; emits an event when a task is auto‑committed.
  • Documentation

    • Expanded configuration docs with detailed behaviour, caveats and how templates interact with auto‑commit.
  • Tests

    • New test coverage validating auto‑commit behaviour across common repository scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
ralph-tui Ignored Ignored Preview Jan 22, 2026 10:22pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

Warning

Rate limit exceeded

@subsy has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 33 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

Walkthrough

Adds an auto-commit configuration option and implements automatic Git commits after successful tasks: new auto-commit utility with tests, engine integration emitting a task:auto-committed event, template conditionalisations, and documentation updates.

Changes

Cohort / File(s) Summary
Configuration
src/config/types.ts, src/config/index.ts
Added autoCommit?: boolean to RalphConfig and surfaced storedConfig.autoCommit ?? false in buildConfig.
Auto-commit Utility
src/engine/auto-commit.ts
New module: hasUncommittedChanges() and performAutoCommit() returning AutoCommitResult (committed, commitMessage, commitSha, skipReason, error). Uses runProcess to run Git commands.
Auto-commit Tests
src/engine/auto-commit.test.ts
New tests exercising clean/dirty repos, commit creation, skip behaviour, multiple file types, SHA verification, Git failure handling, and working-tree cleanliness.
Engine Integration & Types
src/engine/index.ts, src/engine/types.ts
Integrated auto-commit into ExecutionEngine flow; added TaskAutoCommittedEvent and 'task:auto-committed' event type; emits event on successful auto-commit and logs/suppresses failures.
Templates
src/plugins/trackers/builtin/*/template.hbs, src/templates/builtin.ts
Replaced static commit instructions with conditional messaging driven by config.autoCommit across multiple tracker templates.
Documentation
website/content/docs/configuration/*.mdx
Expanded autoCommit docs to describe staging/committing behaviour, timing, and caveats with agent templates/CLAUDE.md.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I hopped through changes, swift and bright,

Auto-commit ready, keeping work tight,
When tasks finish clean, I stamp with glee,
A tiny SHA, a tidy tree,
Hooray for commits — from me, the rabbit, tee-hee!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: implementing the autoCommit engine behavior for task completion, which is the core objective across all modified files.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

❌ Patch coverage is 49.54128% with 55 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.87%. Comparing base (4a36a29) to head (9a87c14).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/engine/index.ts 11.62% 38 Missing ⚠️
src/engine/auto-commit.ts 73.84% 17 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
src/config/index.ts 52.09% <100.00%> (+0.07%) ⬆️
src/config/types.ts 100.00% <ø> (ø)
src/engine/types.ts 100.00% <ø> (ø)
src/templates/builtin.ts 100.00% <ø> (ø)
src/engine/auto-commit.ts 73.84% <73.84%> (ø)
src/engine/index.ts 49.01% <11.62%> (-1.08%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 initGitRepo to 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');
 }

AI Agent added 3 commits January 22, 2026 22:19
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
@subsy subsy force-pushed the feat/auto-commit-engine branch from e58c3b4 to 9a87c14 Compare January 22, 2026 22:21
@subsy subsy merged commit 40ba620 into main Jan 22, 2026
9 checks passed
@subsy subsy deleted the feat/auto-commit-engine branch January 22, 2026 22:23
sakaman pushed a commit to sakaman/ralph-tui that referenced this pull request Feb 15, 2026
feat: implement autoCommit engine behavior for task completion
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.

1 participant