Skip to content

feat(bridge): Phase 3 — E2E actions: commit/branch/push + error recovery + undo #4

Closed

Description

@gHashTag

TASK: Phase 3 — E2E Actions: commit / branch / push / undo

Phase 2 Status: COMPLETE

  • ✅ gitbutler-analyzer.ts — 25/25 tests, 0 null fields
  • ✅ 3/3 mandatory scenarios pass (unstaged, staged-only, clean)
  • ✅ Edge cases: snapshot-only + no-data graceful fallback
  • ✅ CLI status = ground truth for file paths + staging
  • ✅ gitbutler_analyze_ui returns structured JSON + markdown + screenshot

Vision is accurate. Now we execute.

PHI LOOP: edit spec → seal hash → gen → test → verdict → experience → skill commit → git commit


Mission

All 10 bridge tools must produce real side effects in the GitButler repo.
Each action is followed by a verification step (read-back from GB or git log).


Action 1: gitbutler_commit_visible

Flow

analyze_ui → get unstaged files → stage all → create_commit → verify in git log

E2E test

# Setup: have 2+ modified files uncommitted
curl -X POST http://127.0.0.1:9200/mcp/tools/call \
  -H 'Content-Type: application/json' \
  -d '{"name":"gitbutler_commit_visible","arguments":{"message":"test: e2e via trios bridge phase3"}}'

# Verify:
git log --oneline -1
# Must show: "test: e2e via trios bridge phase3"

Error cases to handle

Situation Expected response
Nothing to commit {"ok": false, "reason": "Nothing to commit. Workspace is clean."}
GB not running {"ok": false, "reason": "GitButler is not running. Start the app first."}
but mcp timeout retry once, then {"ok": false, "reason": "GitButler MCP timeout. Try again."}

Action 2: gitbutler_create_branch

curl -X POST http://127.0.0.1:9200/mcp/tools/call \
  -H 'Content-Type: application/json' \
  -d '{"name":"gitbutler_create_branch","arguments":{"name":"agent-test-phase3"}}'

# Verify: branch appears in GitButler UI virtual branches list
# Verify via: `but branch list` or gitbutler_workspace_status tool

Action 3: gitbutler_push_stack

curl -X POST http://127.0.0.1:9200/mcp/tools/call \
  -H 'Content-Type: application/json' \
  -d '{"name":"gitbutler_push_stack","arguments":{}}'

# Verify: remote branch updated (git ls-remote origin)

Fallback if no remote configured: return {"ok": false, "reason": "No remote configured. Add a remote first."}


Action 4: Undo (gitbutler_absorb + new gitbutler_undo_last_commit)

Add new tool gitbutler_undo_last_commit:

// Calls: but mcp undo / amend
// Returns: {ok: true, restoredFiles: string[], previousSha: string}

E2E test:

# After committing → undo
curl -X POST http://127.0.0.1:9200/mcp/tools/call \
  -H 'Content-Type: application/json' \
  -d '{"name":"gitbutler_undo_last_commit","arguments":{}}'

# Verify: git log shows previous commit, files back to unstaged

Full Chain E2E Test (the real demo prep)

# 1. Analyze
curl -s -X POST .../tools/call -d '{"name":"gitbutler_analyze_ui"}'
# 2. Create branch
curl -s -X POST .../tools/call -d '{"name":"gitbutler_create_branch","arguments":{"name":"demo-from-agent"}}'
# 3. Commit visible changes
curl -s -X POST .../tools/call -d '{"name":"gitbutler_commit_visible","arguments":{"message":"feat: demo commit from trios bridge"}}'
# 4. Push
curl -s -X POST .../tools/call -d '{"name":"gitbutler_push_stack","arguments":{}}'

# ALL 4 steps must succeed in sequence. Any failure: log + return structured error.

Tests Required

// src/__tests__/actions.test.ts
describe('gitbutler_commit_visible', () => {
  it('commits staged changes and returns SHA', async () => { ... })
  it('returns clean message when nothing to commit', async () => { ... })
})
describe('gitbutler_create_branch', () => {
  it('creates virtual branch and returns name', async () => { ... })
  it('handles duplicate branch name gracefully', async () => { ... })
})
describe('gitbutler_undo_last_commit', () => {
  it('restores files to unstaged after undo', async () => { ... })
})

Experience Log

echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] PHASE3: e2e actions complete | commit+branch+push+undo | chain test: 4/4 steps | error recovery: structured JSON on all failures" \
  >> experience/trios/phase3_e2e_actions.trinity

Laws

Law Rule
L1 Closes #4 in every PR
L3 ASCII-only, English identifiers
L4 Tests for every action tool
L7 NO .sh files

Success Criteria

  • gitbutler_commit_visible creates real commit (verified by git log)
  • gitbutler_create_branch creates virtual branch visible in GB UI
  • gitbutler_push_stack pushes to remote without raw errors
  • gitbutler_undo_last_commit restores files to unstaged
  • Full chain (analyze → branch → commit → push) succeeds 4/4
  • All error states return structured JSON (no 500, no raw stack trace)
  • bun test green (including new actions.test.ts)
  • experience/trios/phase3_e2e_actions.trinity committed

Commit template

git commit -m "feat(bridge): Phase 3 e2e actions commit/branch/push/undo

- feat: gitbutler_commit_visible — real commits via but mcp
- feat: gitbutler_create_branch — virtual branch creation
- feat: gitbutler_push_stack — stack push with fallback
- feat: gitbutler_undo_last_commit — new tool
- test: actions.test.ts, full chain test 4/4
- fix: all error states return structured JSON
- experience: phase3_e2e_actions.trinity sealed
Closes #4"

Agent returns:

✅ TASK phase3-e2e-actions COMPLETED | SHA: xxxxxxxxx | chain: 4/4 | errors: structured

φ² + 1/φ² = 3 | TRINITY | GO.

Activity

  1. gHashTag commented on Apr 18, 2026

    @gHashTag
    CollaboratorAuthor

    Superseded by Issue #18 (RUST ONLY architecture)

    trios-mcp-bridge (TypeScript, port 9200) was the WRONG PATH.

    Correct architecture:

    • trios-server = Rust workspace (Cargo.toml)
    • port 9005 = trios-server (Rust, Axum)
    • 7 MCP tools in crates/trios-server/src/tools.rs

    See Issue #18 for architecture confirmation.

  2. added a commit that references this issue on Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions