refactor: committer role — let agent run git, use discriminated union meta #17

Closed
opened 2026-05-06 10:03:29 +00:00 by xiaoju · 0 comments
Owner

What

Refactor @uncaged/workflow-role-committer to remove hardcoded git commands and let the agent handle git operations, with structured error feedback.

Why

The current committer hardcodes git checkout -b / add -A / commit -m / push, which:

  1. Bypasses the agent's ability to understand and react to git output
  2. Loses valuable error context when commits fail (hook failures, merge conflicts, push rejected)
  3. Cannot feed failure info back to other roles (e.g. coder) for retry

Changes

1. CommitterMeta → discriminated union

type CommitterMeta =
  | {
      status: "committed";
      branch: string;
      commitSha: string;
    }
  | {
      status: "failed";
      error: string;
      logRef: string | null;
    };

2. Remove hardcoded git commands

  • Delete git-exec.ts entirely
  • Remove @uncaged/workflow-util-agent dependency (no longer needed for spawnCli)
  • Committer becomes a pure agent role: prompt the agent to create branch, commit, push, then extract structured result from agent output

3. Agent prompt

The agent (Cursor/Hermes) receives:

  • The code changes context
  • Instructions to create a branch, commit with conventional message, and push
  • Instructions to report back: success (branch + sha) or failure (error summary + where to find full logs)

4. Moderator routing

With the new meta shape, moderator can route:

  • meta.status === "committed" → done
  • meta.status === "failed" → back to coder with meta.error as context

5. Update tests

  • Remove git-exec tests
  • Update committer tests for new meta shape
  • Test both success and failure extraction paths

Ref

Discussion in refactoring session — committer's core value is understanding git results, not running git commands.

## What Refactor `@uncaged/workflow-role-committer` to remove hardcoded git commands and let the agent handle git operations, with structured error feedback. ## Why The current committer hardcodes `git checkout -b / add -A / commit -m / push`, which: 1. Bypasses the agent's ability to understand and react to git output 2. Loses valuable error context when commits fail (hook failures, merge conflicts, push rejected) 3. Cannot feed failure info back to other roles (e.g. coder) for retry ## Changes ### 1. CommitterMeta → discriminated union ```typescript type CommitterMeta = | { status: "committed"; branch: string; commitSha: string; } | { status: "failed"; error: string; logRef: string | null; }; ``` ### 2. Remove hardcoded git commands - Delete `git-exec.ts` entirely - Remove `@uncaged/workflow-util-agent` dependency (no longer needed for spawnCli) - Committer becomes a pure agent role: prompt the agent to create branch, commit, push, then extract structured result from agent output ### 3. Agent prompt The agent (Cursor/Hermes) receives: - The code changes context - Instructions to create a branch, commit with conventional message, and push - Instructions to report back: success (branch + sha) or failure (error summary + where to find full logs) ### 4. Moderator routing With the new meta shape, moderator can route: - `meta.status === "committed"` → done - `meta.status === "failed"` → back to coder with `meta.error` as context ### 5. Update tests - Remove git-exec tests - Update committer tests for new meta shape - Test both success and failure extraction paths ## Ref Discussion in refactoring session — committer's core value is understanding git results, not running git commands.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#17