# aryankori/bridge architecture

> Architecture diagram of the GitHub repository aryankori/bridge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aryankori/bridge
- Repository: https://github.com/aryankori/bridge

## Overview

Bridge is an interoperability and orchestration layer for heterogeneous coding agents, with a separate `bridge resolve` workflow for arbitrating committed worktree divergence. The principal workflow routes work to an available agent, transfers work context, and communicates through agent adapters and transport. The graph also preserves the documented authority-resolution stages. README claims about protocol support are broader than the sampled implementation; unsampled internal wiring is shown only where documented, and uncertain links are omitted.

Main entry points: [`src/transport/stdio-json.ts`](https://github.com/aryankori/bridge/blob/main/src/transport/stdio-json.ts) (Stdio transport), [`src/core/index.ts`](https://github.com/aryankori/bridge/blob/main/src/core/index.ts) (Core API), [`src/adapters/index.ts`](https://github.com/aryankori/bridge/blob/main/src/adapters/index.ts) (Adapter exports), [`src/effective-directive/cli.ts`](https://github.com/aryankori/bridge/blob/main/src/effective-directive/cli.ts) (Resolve command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Agent orchestration"]
  node_core["Core API<br/>[index.ts]"]
  node_registry["Agent registry<br/>[registry.ts]"]
  node_router["Capability router<br/>[router.ts]"]
  node_events["Event bus<br/>[events.ts]"]
  node_transfer["Work transfer<br/>[work-transfer.ts]"]
end

subgraph group_integrations["Agent integrations"]
  node_adapter_api["Adapter API<br/>[types.ts]"]
  node_adapters["Adapter exports<br/>[index.ts]"]
  node_claude["Claude Code<br/>[index.ts]"]
  node_opencode["OpenCode<br/>[index.ts]"]
  node_codex["Codex<br/>[index.ts]"]
  node_gemini["Gemini CLI<br/>[index.ts]"]
end

subgraph group_communications["Communication"]
  node_transport["Stdio transport<br/>[stdio-json.ts]"]
  node_jsonrpc["JSON-RPC<br/>[jsonrpc.ts]"]
end

subgraph group_resolution["Authority resolution"]
  node_cli["Bridge CLI<br/>[bridge.ts]"]
  node_directive_cli["Resolve command<br/>[cli.ts]"]
  node_git["Git evidence<br/>[git.ts]"]
  node_codeowners["CODEOWNERS rules<br/>[codeowners.ts]"]
  node_precedence["Rule precedence<br/>[precedence.ts]"]
  node_evaluator["Directive evaluation<br/>[evaluator.ts]"]
  node_arbitration["Conflict arbitration<br/>[arbitration.ts]"]
end

node_engineer(("Engineer"))
node_agent_fleet(("Agent processes"))
node_result["Resolution status"]

node_engineer -->|"submits work"| node_core
node_core -->|"uses registry"| node_registry
node_core -->|"routes work"| node_router
node_router -->|"lists agents"| node_registry
node_core -->|"creates transfers"| node_transfer
node_core -->|"emits events"| node_events
node_adapters -->|"exports"| node_claude
node_adapters -->|"exports"| node_opencode
node_adapters -->|"exports"| node_codex
node_adapters -->|"exports"| node_gemini
node_claude -->|"uses"| node_transport
node_opencode -->|"uses"| node_transport
node_codex -->|"uses"| node_transport
node_gemini -->|"uses"| node_transport
node_transport -->|"exchanges streams"| node_agent_fleet
node_jsonrpc -->|"encodes messages"| node_transport
node_engineer -->|"requests resolution"| node_cli
node_cli -->|"dispatches resolve"| node_directive_cli
node_directive_cli -->|"inspects commits"| node_git
node_directive_cli -->|"reads ownership rules"| node_codeowners
node_directive_cli -->|"requests decision"| node_arbitration
node_arbitration -->|"evaluates authority"| node_evaluator
node_evaluator -->|"applies precedence"| node_precedence
node_arbitration -->|"returns status"| node_result

click node_cli "https://github.com/aryankori/bridge/blob/main/src/bin/bridge.ts"
click node_core "https://github.com/aryankori/bridge/blob/main/src/core/index.ts"
click node_registry "https://github.com/aryankori/bridge/blob/main/src/core/registry.ts"
click node_router "https://github.com/aryankori/bridge/blob/main/src/core/router.ts"
click node_events "https://github.com/aryankori/bridge/blob/main/src/core/events.ts"
click node_transfer "https://github.com/aryankori/bridge/blob/main/src/core/work-transfer.ts"
click node_adapter_api "https://github.com/aryankori/bridge/blob/main/src/core/types.ts"
click node_adapters "https://github.com/aryankori/bridge/blob/main/src/adapters/index.ts"
click node_claude "https://github.com/aryankori/bridge/blob/main/src/adapters/claude-code/index.ts"
click node_opencode "https://github.com/aryankori/bridge/blob/main/src/adapters/opencode/index.ts"
click node_codex "https://github.com/aryankori/bridge/blob/main/src/adapters/codex/index.ts"
click node_gemini "https://github.com/aryankori/bridge/blob/main/src/adapters/gemini-cli/index.ts"
click node_transport "https://github.com/aryankori/bridge/blob/main/src/transport/stdio-json.ts"
click node_jsonrpc "https://github.com/aryankori/bridge/blob/main/src/transport/jsonrpc.ts"
click node_directive_cli "https://github.com/aryankori/bridge/blob/main/src/effective-directive/cli.ts"
click node_git "https://github.com/aryankori/bridge/blob/main/src/effective-directive/git.ts"
click node_codeowners "https://github.com/aryankori/bridge/blob/main/src/effective-directive/codeowners.ts"
click node_precedence "https://github.com/aryankori/bridge/blob/main/src/effective-directive/precedence.ts"
click node_evaluator "https://github.com/aryankori/bridge/blob/main/src/effective-directive/evaluator.ts"
click node_arbitration "https://github.com/aryankori/bridge/blob/main/src/effective-directive/arbitration.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_core,node_registry,node_router,node_events,node_transfer toneBlue
class node_adapter_api,node_adapters,node_claude,node_opencode,node_codex,node_gemini toneAmber
class node_transport,node_jsonrpc toneMint
class node_cli,node_directive_cli,node_git,node_codeowners,node_precedence,node_evaluator,node_arbitration toneRose
class node_engineer,node_agent_fleet,node_result toneIndigo
```

## Components

### Agent orchestration

- [Core API](https://github.com/aryankori/bridge/blob/main/src/core/index.ts): `src/core/index.ts`
- [Agent registry](https://github.com/aryankori/bridge/blob/main/src/core/registry.ts): `src/core/registry.ts`
- [Capability router](https://github.com/aryankori/bridge/blob/main/src/core/router.ts): `src/core/router.ts`
- [Event bus](https://github.com/aryankori/bridge/blob/main/src/core/events.ts): `src/core/events.ts`
- [Work transfer](https://github.com/aryankori/bridge/blob/main/src/core/work-transfer.ts): `src/core/work-transfer.ts`

### Agent integrations

- [Adapter API](https://github.com/aryankori/bridge/blob/main/src/core/types.ts): `src/core/types.ts`
- [Adapter exports](https://github.com/aryankori/bridge/blob/main/src/adapters/index.ts): `src/adapters/index.ts`
- [Claude Code](https://github.com/aryankori/bridge/blob/main/src/adapters/claude-code/index.ts): `src/adapters/claude-code/index.ts`
- [OpenCode](https://github.com/aryankori/bridge/blob/main/src/adapters/opencode/index.ts): `src/adapters/opencode/index.ts`
- [Codex](https://github.com/aryankori/bridge/blob/main/src/adapters/codex/index.ts): `src/adapters/codex/index.ts`
- [Gemini CLI](https://github.com/aryankori/bridge/blob/main/src/adapters/gemini-cli/index.ts): `src/adapters/gemini-cli/index.ts`

### Communication

- [Stdio transport](https://github.com/aryankori/bridge/blob/main/src/transport/stdio-json.ts): `src/transport/stdio-json.ts`
- [JSON-RPC](https://github.com/aryankori/bridge/blob/main/src/transport/jsonrpc.ts): `src/transport/jsonrpc.ts`

### Authority resolution

- [Bridge CLI](https://github.com/aryankori/bridge/blob/main/src/bin/bridge.ts): `src/bin/bridge.ts`
- [Resolve command](https://github.com/aryankori/bridge/blob/main/src/effective-directive/cli.ts): `src/effective-directive/cli.ts`
- [Git evidence](https://github.com/aryankori/bridge/blob/main/src/effective-directive/git.ts): `src/effective-directive/git.ts`
- [CODEOWNERS rules](https://github.com/aryankori/bridge/blob/main/src/effective-directive/codeowners.ts): `src/effective-directive/codeowners.ts`
- [Rule precedence](https://github.com/aryankori/bridge/blob/main/src/effective-directive/precedence.ts): `src/effective-directive/precedence.ts`
- [Directive evaluation](https://github.com/aryankori/bridge/blob/main/src/effective-directive/evaluator.ts): `src/effective-directive/evaluator.ts`
- [Conflict arbitration](https://github.com/aryankori/bridge/blob/main/src/effective-directive/arbitration.ts): `src/effective-directive/arbitration.ts`

### Other components

- **Engineer**
- **Agent processes**
- **Resolution status**

## Connections

- Engineer → Core API: submits work
- Core API → Agent registry: uses registry
- Core API → Capability router: routes work
- Capability router → Agent registry: lists agents
- Core API → Work transfer: creates transfers
- Core API → Event bus: emits events
- Adapter exports → Claude Code: exports
- Adapter exports → OpenCode: exports
- Adapter exports → Codex: exports
- Adapter exports → Gemini CLI: exports
- Claude Code → Stdio transport: uses
- OpenCode → Stdio transport: uses
- Codex → Stdio transport: uses
- Gemini CLI → Stdio transport: uses
- Stdio transport → Agent processes: exchanges streams
- JSON-RPC → Stdio transport: encodes messages
- Engineer → Bridge CLI: requests resolution
- Bridge CLI → Resolve command: dispatches resolve
- Resolve command → Git evidence: inspects commits
- Resolve command → CODEOWNERS rules: reads ownership rules
- Resolve command → Conflict arbitration: requests decision
- Conflict arbitration → Directive evaluation: evaluates authority
- Directive evaluation → Rule precedence: applies precedence
- Conflict arbitration → Resolution status: returns status
