Repository navigation
Closed
Description
TASK: Phase 2 — Vision + Context
Status from Phase 0+1
- ✅
but mcprunning — 66 tools loaded - ✅ GitButler MCP server running
- ❌
tools/list→ 500 error — SDK issue@hono/mcp@^0.2.3 - ✅
trios-mcp-bridgescaffolded atpackages/browseros-agent/apps/trios-mcp-bridge/
Mission
Fix the SDK issue and implement vision pipeline:
screenshot → LLM → structured GitButler state JSON
PHI LOOP: edit spec → seal hash → gen → test → verdict → experience → skill commit → git commit
Step 1: Fix @hono/mcp SDK 500 error
Diagnose and fix tools/list returning 500.
# Check current version
cat packages/browseros-agent/apps/trios-mcp-bridge/package.json | grep hono
# Option A: pin to working version
npm install @hono/mcp@0.1.x
# Option B: switch to official MCP SDK
npm install @modelcontextprotocol/sdk
# Verify fix
curl http://localhost:9005/mcp/tools/list
# Expected: JSON array of tool namesDeliverable: tools/list returns 200 + JSON list. Log fix to .trinity.
Step 2: take_gitbutler_screenshot tool
Calls BrowserOS CDP to capture GitButler app window:
// tools/take_gitbutler_screenshot.ts
export async function takeGitButlerScreenshot(): Promise<{
base64: string; // PNG base64
timestamp: string; // ISO
window: string; // 'gitbutler' | 'unknown'
}>Logic:
- Find GitButler window via CDP tab list (match title
GitButler) - Capture screenshot via
Page.captureScreenshot - Return base64 PNG
Fallback: if CDP fails → try screencapture -x (macOS) as secondary, log warning.
Step 3: analyze_gitbutler_ui tool (vision core)
Sends screenshot to LLM, returns structured state:
// tools/analyze_gitbutler_ui.ts
export interface GitButlerUIState {
activeBranch: string; // e.g. "feature-xyz"
changedFiles: FileChange[]; // [{path, status: 'modified'|'added'|'deleted', staged: boolean}]
stacks: Stack[]; // [{name, commits: number}]
hasUncommitted: boolean;
rawSummary: string; // LLM free-form summary
}
export async function analyzeGitButlerUI(
base64png: string
): Promise<GitButlerUIState>LLM prompt (system):
You are analyzing a GitButler UI screenshot.
Return ONLY valid JSON matching the GitButlerUIState schema.
Extract: active virtual branch name, list of changed files with their staged status, stack names.
If you cannot determine a field, use null.
Step 4: commit_visible_changes tool (high-level)
Chains screenshot → analyze → stage → commit:
// tools/commit_visible_changes.ts
export async function commitVisibleChanges(params: {
message: string;
stageAll?: boolean; // default: true (stage all unstaged)
}): Promise<{ sha: string; branch: string; filesCommitted: string[] }>Flow:
takeGitButlerScreenshot()analyzeGitButlerUI(screenshot)→ get changed files- Call
but mcptoolstage_changeswith file list - Call
but mcptoolcreate_commitwith message - Return commit SHA + summary
Step 5: Tests
// tests/vision.test.ts
describe('analyze_gitbutler_ui', () => {
it('parses staged files from screenshot', async () => {
const fixture = readFileSync('tests/fixtures/gb_screenshot.png', 'base64');
const state = await analyzeGitButlerUI(fixture);
expect(state.changedFiles.length).toBeGreaterThan(0);
expect(state.activeBranch).toBeTruthy();
});
});Add fixture: save a real GitButler screenshot to tests/fixtures/gb_screenshot.png.
Experience log
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] PHASE2: vision pipeline complete | tools: take_screenshot + analyze_ui + commit_visible | SDK fix: @hono/mcp patched" \
>> experience/trios/phase2_vision_context.trinityLaws
| Law | Rule |
|---|---|
| L1 | Closes #2 in every PR |
| L3 | ASCII-only, English identifiers |
| L4 | Tests for every tool |
| L7 | NO .sh files |
Success Criteria
-
tools/listreturns 200 (SDK fixed) -
take_gitbutler_screenshotreturns base64 PNG via MCP POST -
analyze_gitbutler_uireturnsGitButlerUIStateJSON from real screenshot -
commit_visible_changes("msg")stages + commits — returns SHA - All tests pass (
bun testornpx vitest) -
experience/trios/phase2_vision_context.trinitycommitted
Commit template
git commit -m "feat(bridge): Phase 2 vision pipeline (screenshot → LLM → GB state)
- fix: @hono/mcp SDK 500 on tools/list
- feat: take_gitbutler_screenshot via CDP
- feat: analyze_gitbutler_ui → GitButlerUIState JSON
- feat: commit_visible_changes high-level tool
- tests: fixture-based vision tests
- experience: phase2_vision_context.trinity sealed
Closes #2"
Agent returns:
✅ TASK phase2-vision-context COMPLETED | SHA: xxxxxxxxx
φ² + 1/φ² = 3 | TRINITY | GO.
Metadata
Metadata
Assignees
Labels
No labels
Activity
fix(coq): L-COQ47 sweep-1 — queen verdict: restate lucas_phi_2 to anc…
fix(coq): L-COQ47 sweep-1 — close 8/11 Admitted in ExactIdentities.v (#…
feat(phd-dashboard): Coq Admitted ledger + Rehearsal #2 progress bar …
feat(matrix): L-MR-MATRIX-PRIORITY — 50-cell priority subset + local …
feat(assertions): Lane Q — lever_stack.json · L-DPC25 Wave-28 (#836)