# can1357/oh-my-pi architecture

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

- Interactive diagram: https://gitdiagram.com/can1357/oh-my-pi
- Repository: https://github.com/can1357/oh-my-pi
- Video tour (about a minute): https://gitdiagram.com/can1357/oh-my-pi/video

## Overview

OMP is a coding agent with IDE-oriented tools, model/provider support, persistent sessions, and native Rust capabilities. The principal workflow is a user request handled by the agent, which uses tools to inspect or change a workspace and returns results; sessions preserve work across turns. The README also documents code execution, LSP, debugging, stream rules, and subagents. Several of those feature paths are represented by their existing enclosing source directories because their implementation files were not sampled; those relationships are documented rather than source-verified.

Main entry points: [`packages/agent/src/agent-loop.ts`](https://github.com/can1357/oh-my-pi/blob/main/packages/agent/src/agent-loop.ts) (Agent loop), [`packages/coding-agent/src/tools`](https://github.com/can1357/oh-my-pi/tree/main/packages/coding-agent/src/tools) (Agent tools), [`packages/ai/src/stream.ts`](https://github.com/can1357/oh-my-pi/blob/main/packages/ai/src/stream.ts) (Model streaming), [`packages/coding-agent/src`](https://github.com/can1357/oh-my-pi/tree/main/packages/coding-agent/src) (Coding agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["Agent runtime"]
  node_coding_agent["Coding agent"]
  node_agent_loop["Agent loop<br/>[agent-loop.ts]"]
  node_stream_rules["Stream rules"]
  node_subagents["Subagents"]
end

subgraph group_models["Models and auth"]
  node_ai_stream["Model streaming<br/>[stream.ts]"]
  node_auth["Credential storage<br/>[auth-storage.ts]"]
  node_catalog["Model catalog<br/>[model-manager.ts]"]
end

subgraph group_workspace["Workspace tools"]
  node_tools["Agent tools"]
  node_edit_engine["Edit engine<br/>[engine.rs]"]
  node_shell["Shell execution<br/>[shell.rs]"]
  node_minimizer["Output minimizer<br/>[engine.rs]"]
  node_execution["Code execution"]
end

subgraph group_state["Session state"]
  node_sessions[("Session storage<br/>[session-storage.ts]")]
  node_session_index["Session indexing"]
  node_compaction["Context compaction"]
end

subgraph group_native["IDE capabilities"]
  node_lsp["LSP operations"]
  node_debugger["Debugger operations"]
end

node_user(("User"))

node_user -->|"requests work"| node_coding_agent
node_coding_agent -.->|"runs turns"| node_agent_loop
node_agent_loop -.->|"requests models"| node_ai_stream
node_agent_loop -->|"invokes tools"| node_tools
node_tools -->|"applies edits"| node_edit_engine
node_tools -.->|"runs commands"| node_shell
node_shell -.->|"filters output"| node_minimizer
node_agent_loop -.->|"persists sessions"| node_sessions
node_sessions -->|"indexed by"| node_session_index
node_agent_loop -.->|"compacts context"| node_compaction
node_ai_stream -.->|"uses credentials"| node_auth
node_ai_stream -.->|"selects models"| node_catalog
node_agent_loop -->|"executes code"| node_execution
node_execution -->|"calls tools"| node_tools
node_tools -->|"uses IDE services"| node_lsp
node_tools -->|"controls debugger"| node_debugger
node_agent_loop -->|"applies rules"| node_stream_rules
node_agent_loop -->|"delegates tasks"| node_subagents

click node_coding_agent "https://github.com/can1357/oh-my-pi/tree/main/packages/coding-agent/src"
click node_agent_loop "https://github.com/can1357/oh-my-pi/blob/main/packages/agent/src/agent-loop.ts"
click node_tools "https://github.com/can1357/oh-my-pi/tree/main/packages/coding-agent/src/tools"
click node_edit_engine "https://github.com/can1357/oh-my-pi/blob/main/crates/pi-edit/src/engine.rs"
click node_shell "https://github.com/can1357/oh-my-pi/blob/main/crates/pi-shell/src/shell.rs"
click node_minimizer "https://github.com/can1357/oh-my-pi/blob/main/crates/pi-shell/src/minimizer/engine.rs"
click node_ai_stream "https://github.com/can1357/oh-my-pi/blob/main/packages/ai/src/stream.ts"
click node_auth "https://github.com/can1357/oh-my-pi/blob/main/packages/ai/src/auth-storage.ts"
click node_catalog "https://github.com/can1357/oh-my-pi/blob/main/packages/catalog/src/model-manager.ts"
click node_sessions "https://github.com/can1357/oh-my-pi/blob/main/packages/coding-agent/src/session/session-storage.ts"
click node_session_index "https://github.com/can1357/oh-my-pi/blob/main/packages/coding-agent/src/session/indexed-session-storage.ts"
click node_compaction "https://github.com/can1357/oh-my-pi/tree/main/packages/agent/src/compaction"
click node_execution "https://github.com/can1357/oh-my-pi/tree/main/packages/coding-agent/src"
click node_lsp "https://github.com/can1357/oh-my-pi/tree/main/crates/pi-natives/src"
click node_debugger "https://github.com/can1357/oh-my-pi/tree/main/crates/pi-natives/src"
click node_stream_rules "https://github.com/can1357/oh-my-pi/tree/main/packages/agent/src"
click node_subagents "https://github.com/can1357/oh-my-pi/tree/main/packages/coding-agent/src/task"

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_coding_agent,node_agent_loop,node_stream_rules,node_subagents,node_user toneBlue
class node_ai_stream,node_auth,node_catalog toneAmber
class node_tools,node_edit_engine,node_shell,node_minimizer,node_execution toneMint
class node_sessions,node_session_index,node_compaction toneRose
class node_lsp,node_debugger toneIndigo
```

## Components

### Agent runtime

- [Coding agent](https://github.com/can1357/oh-my-pi/tree/main/packages/coding-agent/src): `packages/coding-agent/src`
- [Agent loop](https://github.com/can1357/oh-my-pi/blob/main/packages/agent/src/agent-loop.ts): `packages/agent/src/agent-loop.ts`
- [Stream rules](https://github.com/can1357/oh-my-pi/tree/main/packages/agent/src): `packages/agent/src`
- [Subagents](https://github.com/can1357/oh-my-pi/tree/main/packages/coding-agent/src/task): `packages/coding-agent/src/task`

### Models and auth

- [Model streaming](https://github.com/can1357/oh-my-pi/blob/main/packages/ai/src/stream.ts): `packages/ai/src/stream.ts`
- [Credential storage](https://github.com/can1357/oh-my-pi/blob/main/packages/ai/src/auth-storage.ts): `packages/ai/src/auth-storage.ts`
- [Model catalog](https://github.com/can1357/oh-my-pi/blob/main/packages/catalog/src/model-manager.ts): `packages/catalog/src/model-manager.ts`

### Workspace tools

- [Agent tools](https://github.com/can1357/oh-my-pi/tree/main/packages/coding-agent/src/tools): `packages/coding-agent/src/tools`
- [Edit engine](https://github.com/can1357/oh-my-pi/blob/main/crates/pi-edit/src/engine.rs): `crates/pi-edit/src/engine.rs`
- [Shell execution](https://github.com/can1357/oh-my-pi/blob/main/crates/pi-shell/src/shell.rs): `crates/pi-shell/src/shell.rs`
- [Output minimizer](https://github.com/can1357/oh-my-pi/blob/main/crates/pi-shell/src/minimizer/engine.rs): `crates/pi-shell/src/minimizer/engine.rs`
- [Code execution](https://github.com/can1357/oh-my-pi/tree/main/packages/coding-agent/src): `packages/coding-agent/src`

### Session state

- [Session storage](https://github.com/can1357/oh-my-pi/blob/main/packages/coding-agent/src/session/session-storage.ts): `packages/coding-agent/src/session/session-storage.ts`
- [Session indexing](https://github.com/can1357/oh-my-pi/blob/main/packages/coding-agent/src/session/indexed-session-storage.ts): `packages/coding-agent/src/session/indexed-session-storage.ts`
- [Context compaction](https://github.com/can1357/oh-my-pi/tree/main/packages/agent/src/compaction): `packages/agent/src/compaction`

### IDE capabilities

- [LSP operations](https://github.com/can1357/oh-my-pi/tree/main/crates/pi-natives/src): `crates/pi-natives/src`
- [Debugger operations](https://github.com/can1357/oh-my-pi/tree/main/crates/pi-natives/src): `crates/pi-natives/src`

### Other components

- **User**

## Connections

- User → Coding agent: requests work
- Coding agent → Agent loop: runs turns
- Agent loop → Model streaming: requests models
- Agent loop → Agent tools: invokes tools
- Agent tools → Edit engine: applies edits
- Agent tools → Shell execution: runs commands
- Shell execution → Output minimizer: filters output
- Agent loop → Session storage: persists sessions
- Session storage → Session indexing: indexed by (evidence: `packages/coding-agent/src/session/indexed-session-storage.ts`)
- Agent loop → Context compaction: compacts context
- Model streaming → Credential storage: uses credentials
- Model streaming → Model catalog: selects models
- Agent loop → Code execution: executes code
- Code execution → Agent tools: calls tools
- Agent tools → LSP operations: uses IDE services
- Agent tools → Debugger operations: controls debugger
- Agent loop → Stream rules: applies rules
- Agent loop → Subagents: delegates tasks
