# shitianfang/jev-use architecture

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

- Interactive diagram: https://gitdiagram.com/shitianfang/jev-use
- Repository: https://github.com/shitianfang/jev-use

## Overview

jev-use lets an agent delegate fast, typed decisions to Jev while retaining text generation and uncertain decisions. The main flow is: an agent supplies state and typed questions, jev-use screens them, selects a configured backend, and returns verdicts with confidence and escalation details. It also exposes an action gate, MCP tools, CLI setup and diagnostics, and routing guidance. The graph follows documented flows and source-index references; unsampled relationships are omitted where they cannot be verified.

Main entry points: [`src/backends/index.ts`](https://github.com/shitianfang/jev-use/blob/main/src/backends/index.ts) (Backend selection), [`src/judge.ts`](https://github.com/shitianfang/jev-use/blob/main/src/judge.ts) (Judge and gate), [`src/backends/typesafe.ts`](https://github.com/shitianfang/jev-use/blob/main/src/backends/typesafe.ts) (TypeSafe adapter), [`src/backends/openrouter.ts`](https://github.com/shitianfang/jev-use/blob/main/src/backends/openrouter.ts) (OpenRouter adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Judgment workflow"]
  node_protocol["Question protocol<br/>[protocol.ts]"]
  node_dispatch["Question screening<br/>[dispatch.ts]"]
  node_client["Jev client<br/>[jev.ts]"]
  node_engine["Judge and gate<br/>[judge.ts]"]
  node_redaction["Secret redaction<br/>[redact.ts]"]
end

subgraph group_backends["Backend adapters"]
  node_backend_types["Backend contract<br/>[types.ts]"]
  node_resolver["Backend selection<br/>[index.ts]"]
  node_http["HTTP transport<br/>[http.ts]"]
  node_native["Native wire format<br/>[native.ts]"]
  node_typesafe["TypeSafe adapter<br/>[typesafe.ts]"]
  node_openrouter["OpenRouter adapter<br/>[openrouter.ts]"]
  node_vercel["Vercel adapter<br/>[vercel.ts]"]
  node_mock["Mock adapter<br/>[mock.ts]"]
  node_unconfigured["Unconfigured adapter<br/>[unconfigured.ts]"]
end

subgraph group_interfaces["Agent interfaces"]
  node_mcp["MCP tools<br/>[server.ts]"]
  node_cli["CLI commands<br/>[cli.ts]"]
  node_pi["pi integration<br/>[jev-use.ts]"]
end

subgraph group_setup["Setup and routing"]
  node_installer["Harness installer<br/>[install.ts]"]
  node_skill["Routing skill<br/>[SKILL.md]"]
end

node_agent(("Agent / caller"))
node_providers(("Jev providers"))

node_agent -->|"asks judgments"| node_client
node_client -->|"resolves backend"| node_resolver
node_client -->|"runs judgments"| node_engine
node_engine -->|"screens questions"| node_dispatch
node_engine -->|"calls backend"| node_backend_types
node_engine -->|"builds verdicts"| node_protocol
node_engine -->|"redacts actions"| node_redaction
node_resolver -->|"selects adapter"| node_typesafe
node_resolver -->|"selects adapter"| node_openrouter
node_resolver -->|"selects adapter"| node_vercel
node_resolver -->|"selects adapter"| node_mock
node_resolver -->|"selects fallback"| node_unconfigured
node_typesafe -->|"encodes requests"| node_native
node_typesafe -->|"posts requests"| node_http
node_openrouter -->|"encodes requests"| node_native
node_openrouter -->|"posts requests"| node_http
node_vercel -->|"posts requests"| node_http
node_mock -->|"uses question shapes"| node_protocol
node_typesafe -.->|"judges remotely"| node_providers
node_openrouter -->|"judges remotely"| node_providers
node_vercel -->|"judges remotely"| node_providers
node_agent -->|"uses MCP tools"| node_mcp
node_mcp -->|"calls judge and gate"| node_engine
node_agent -->|"runs commands"| node_cli
node_cli -->|"runs install"| node_installer
node_cli -->|"serves tools"| node_mcp
node_agent -->|"follows routing rules"| node_skill
node_skill -.->|"routes decision steps"| node_dispatch
node_agent -->|"uses extension"| node_pi

click node_protocol "https://github.com/shitianfang/jev-use/blob/main/src/protocol.ts"
click node_dispatch "https://github.com/shitianfang/jev-use/blob/main/src/dispatch.ts"
click node_client "https://github.com/shitianfang/jev-use/blob/main/src/jev.ts"
click node_engine "https://github.com/shitianfang/jev-use/blob/main/src/judge.ts"
click node_redaction "https://github.com/shitianfang/jev-use/blob/main/src/redact.ts"
click node_backend_types "https://github.com/shitianfang/jev-use/blob/main/src/backends/types.ts"
click node_resolver "https://github.com/shitianfang/jev-use/blob/main/src/backends/index.ts"
click node_http "https://github.com/shitianfang/jev-use/blob/main/src/backends/http.ts"
click node_native "https://github.com/shitianfang/jev-use/blob/main/src/backends/native.ts"
click node_typesafe "https://github.com/shitianfang/jev-use/blob/main/src/backends/typesafe.ts"
click node_openrouter "https://github.com/shitianfang/jev-use/blob/main/src/backends/openrouter.ts"
click node_vercel "https://github.com/shitianfang/jev-use/blob/main/src/backends/vercel.ts"
click node_mock "https://github.com/shitianfang/jev-use/blob/main/src/backends/mock.ts"
click node_unconfigured "https://github.com/shitianfang/jev-use/blob/main/src/backends/unconfigured.ts"
click node_mcp "https://github.com/shitianfang/jev-use/blob/main/src/server.ts"
click node_cli "https://github.com/shitianfang/jev-use/blob/main/src/cli.ts"
click node_installer "https://github.com/shitianfang/jev-use/blob/main/src/install.ts"
click node_skill "https://github.com/shitianfang/jev-use/blob/main/skills/jev-use/SKILL.md"
click node_pi "https://github.com/shitianfang/jev-use/blob/main/harness/pi/jev-use.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_protocol,node_dispatch,node_client,node_engine,node_redaction toneBlue
class node_backend_types,node_resolver,node_http,node_native,node_typesafe,node_openrouter,node_vercel,node_mock,node_unconfigured toneAmber
class node_mcp,node_cli,node_pi toneMint
class node_installer,node_skill toneRose
class node_agent,node_providers toneIndigo
```

## Components

### Judgment workflow

- [Question protocol](https://github.com/shitianfang/jev-use/blob/main/src/protocol.ts): `src/protocol.ts`
- [Question screening](https://github.com/shitianfang/jev-use/blob/main/src/dispatch.ts): `src/dispatch.ts`
- [Jev client](https://github.com/shitianfang/jev-use/blob/main/src/jev.ts): `src/jev.ts`
- [Judge and gate](https://github.com/shitianfang/jev-use/blob/main/src/judge.ts): `src/judge.ts`
- [Secret redaction](https://github.com/shitianfang/jev-use/blob/main/src/redact.ts): `src/redact.ts`

### Backend adapters

- [Backend contract](https://github.com/shitianfang/jev-use/blob/main/src/backends/types.ts): `src/backends/types.ts`
- [Backend selection](https://github.com/shitianfang/jev-use/blob/main/src/backends/index.ts): `src/backends/index.ts`
- [HTTP transport](https://github.com/shitianfang/jev-use/blob/main/src/backends/http.ts): `src/backends/http.ts`
- [Native wire format](https://github.com/shitianfang/jev-use/blob/main/src/backends/native.ts): `src/backends/native.ts`
- [TypeSafe adapter](https://github.com/shitianfang/jev-use/blob/main/src/backends/typesafe.ts): `src/backends/typesafe.ts`
- [OpenRouter adapter](https://github.com/shitianfang/jev-use/blob/main/src/backends/openrouter.ts): `src/backends/openrouter.ts`
- [Vercel adapter](https://github.com/shitianfang/jev-use/blob/main/src/backends/vercel.ts): `src/backends/vercel.ts`
- [Mock adapter](https://github.com/shitianfang/jev-use/blob/main/src/backends/mock.ts): `src/backends/mock.ts`
- [Unconfigured adapter](https://github.com/shitianfang/jev-use/blob/main/src/backends/unconfigured.ts): `src/backends/unconfigured.ts`

### Agent interfaces

- [MCP tools](https://github.com/shitianfang/jev-use/blob/main/src/server.ts): `src/server.ts`
- [CLI commands](https://github.com/shitianfang/jev-use/blob/main/src/cli.ts): `src/cli.ts`
- [pi integration](https://github.com/shitianfang/jev-use/blob/main/harness/pi/jev-use.ts): `harness/pi/jev-use.ts`

### Setup and routing

- [Harness installer](https://github.com/shitianfang/jev-use/blob/main/src/install.ts): `src/install.ts`
- [Routing skill](https://github.com/shitianfang/jev-use/blob/main/skills/jev-use/SKILL.md): `skills/jev-use/SKILL.md`

### Other components

- **Agent / caller**
- **Jev providers**

## Connections

- Agent / caller → Jev client: asks judgments (evidence: `README.md`)
- Jev client → Backend selection: resolves backend (evidence: `src/jev.ts`)
- Jev client → Judge and gate: runs judgments (evidence: `src/jev.ts`)
- Judge and gate → Question screening: screens questions (evidence: `src/judge.ts`)
- Judge and gate → Backend contract: calls backend (evidence: `src/judge.ts`)
- Judge and gate → Question protocol: builds verdicts (evidence: `src/judge.ts`)
- Judge and gate → Secret redaction: redacts actions (evidence: `src/judge.ts`)
- Backend selection → TypeSafe adapter: selects adapter (evidence: `src/backends/index.ts`)
- Backend selection → OpenRouter adapter: selects adapter (evidence: `src/backends/index.ts`)
- Backend selection → Vercel adapter: selects adapter (evidence: `src/backends/index.ts`)
- Backend selection → Mock adapter: selects adapter (evidence: `src/backends/index.ts`)
- Backend selection → Unconfigured adapter: selects fallback (evidence: `src/backends/index.ts`)
- TypeSafe adapter → Native wire format: encodes requests (evidence: `src/backends/typesafe.ts`)
- TypeSafe adapter → HTTP transport: posts requests (evidence: `src/backends/typesafe.ts`)
- OpenRouter adapter → Native wire format: encodes requests (evidence: `src/backends/openrouter.ts`)
- OpenRouter adapter → HTTP transport: posts requests (evidence: `src/backends/openrouter.ts`)
- Vercel adapter → HTTP transport: posts requests (evidence: `src/backends/vercel.ts`)
- Mock adapter → Question protocol: uses question shapes (evidence: `src/backends/mock.ts`)
- TypeSafe adapter → Jev providers: judges remotely
- OpenRouter adapter → Jev providers: judges remotely (evidence: `src/backends/openrouter.ts`)
- Vercel adapter → Jev providers: judges remotely (evidence: `src/backends/vercel.ts`)
- Agent / caller → MCP tools: uses MCP tools (evidence: `README.md`)
- MCP tools → Judge and gate: calls judge and gate (evidence: `src/server.ts`)
- Agent / caller → CLI commands: runs commands (evidence: `README.md`)
- CLI commands → Harness installer: runs install (evidence: `src/cli.ts`)
- CLI commands → MCP tools: serves tools (evidence: `src/cli.ts`)
- Agent / caller → Routing skill: follows routing rules (evidence: `README.md`)
- Routing skill → Question screening: routes decision steps
- Agent / caller → pi integration: uses extension (evidence: `README.md`)
