# woozheng/aicp_cli architecture

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

- Interactive diagram: https://gitdiagram.com/woozheng/aicp_cli
- Repository: https://github.com/woozheng/aicp_cli

## Overview

AICP_CLI is a stateless, protocol-driven agent CLI: a user submits a request, the CLI selects local, remote, or Studio mode, and the selected engine returns a response. In local mode, the AICP runtime coordinates LLM requests and generated-code execution; in remote modes, the CLI posts to a configured endpoint. The README describes broad computer, file, and network tasks, while the excerpts show the sandbox and execution machinery but not every capability implementation. Relationships are limited to those shown in excerpts, the source index, or README.

Main entry points: [`runtime/_aicp_llm.py`](https://github.com/woozheng/aicp_cli/blob/main/runtime/_aicp_llm.py) (AICP runtime), [`aicp.py`](https://github.com/woozheng/aicp_cli/blob/main/aicp.py) (Chat CLI), [`runtime/_llm.py`](https://github.com/woozheng/aicp_cli/blob/main/runtime/_llm.py) (LLM client), [`core/__init__.py`](https://github.com/woozheng/aicp_cli/blob/main/core/__init__.py) (Envelop and agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and modes"]
  node_application["Application<br/>[aicp.py]"]
  node_chat_cli["Chat CLI<br/>[aicp.py]"]
  node_local_engine["Local engine<br/>[aicp.py]"]
  node_remote_engine["Remote engine<br/>[aicp.py]"]
end

subgraph group_runtime["Agent runtime"]
  node_aicp_runtime["AICP runtime<br/>[_aicp_llm.py]"]
  node_envelop_agent["Envelop and agent<br/>[__init__.py]"]
  node_prompt_builder["Prompt builder<br/>[_aicp_llm.py]"]
end

subgraph group_execution["Code execution"]
  node_code_executor["Code executor<br/>[_aicp_llm.py]"]
end

subgraph group_providers["Model and endpoints"]
  node_config["Configuration<br/>[_config.py]"]
  node_llm_client["LLM client<br/>[_llm.py]"]
end

node_user(("User"))
node_local_computer["Local computer"]
node_model_provider["Model API"]
node_remote_endpoint["Remote endpoint"]

node_user -->|"enters request"| node_chat_cli
node_application -->|"loads configuration"| node_config
node_application -->|"starts CLI"| node_chat_cli
node_chat_cli -->|"sends request"| node_local_engine
node_chat_cli -->|"sends request"| node_remote_engine
node_local_engine -->|"calls runtime"| node_aicp_runtime
node_remote_engine -->|"posts request"| node_remote_endpoint
node_aicp_runtime -->|"builds prompt"| node_prompt_builder
node_aicp_runtime -->|"requests completion"| node_llm_client
node_aicp_runtime -->|"executes code"| node_code_executor
node_aicp_runtime -->|"uses protocol types"| node_envelop_agent
node_code_executor -->|"runs local operations"| node_local_computer
node_llm_client -->|"calls model API"| node_model_provider

click node_application "https://github.com/woozheng/aicp_cli/blob/main/aicp.py"
click node_chat_cli "https://github.com/woozheng/aicp_cli/blob/main/aicp.py"
click node_local_engine "https://github.com/woozheng/aicp_cli/blob/main/aicp.py"
click node_remote_engine "https://github.com/woozheng/aicp_cli/blob/main/aicp.py"
click node_config "https://github.com/woozheng/aicp_cli/blob/main/runtime/_config.py"
click node_aicp_runtime "https://github.com/woozheng/aicp_cli/blob/main/runtime/_aicp_llm.py"
click node_envelop_agent "https://github.com/woozheng/aicp_cli/blob/main/core/__init__.py"
click node_prompt_builder "https://github.com/woozheng/aicp_cli/blob/main/runtime/_aicp_llm.py"
click node_code_executor "https://github.com/woozheng/aicp_cli/blob/main/runtime/_aicp_llm.py"
click node_llm_client "https://github.com/woozheng/aicp_cli/blob/main/runtime/_llm.py"

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_application,node_chat_cli,node_local_engine,node_remote_engine,node_user toneBlue
class node_aicp_runtime,node_envelop_agent,node_prompt_builder toneAmber
class node_code_executor,node_model_provider toneMint
class node_config,node_llm_client toneRose
class node_local_computer,node_remote_endpoint toneIndigo
```

## Components

### CLI and modes

- [Application](https://github.com/woozheng/aicp_cli/blob/main/aicp.py): `aicp.py`
- [Chat CLI](https://github.com/woozheng/aicp_cli/blob/main/aicp.py): `aicp.py`
- [Local engine](https://github.com/woozheng/aicp_cli/blob/main/aicp.py): `aicp.py`
- [Remote engine](https://github.com/woozheng/aicp_cli/blob/main/aicp.py): `aicp.py`

### Agent runtime

- [AICP runtime](https://github.com/woozheng/aicp_cli/blob/main/runtime/_aicp_llm.py): `runtime/_aicp_llm.py`
- [Envelop and agent](https://github.com/woozheng/aicp_cli/blob/main/core/__init__.py): `core/__init__.py`
- [Prompt builder](https://github.com/woozheng/aicp_cli/blob/main/runtime/_aicp_llm.py): `runtime/_aicp_llm.py`

### Code execution

- [Code executor](https://github.com/woozheng/aicp_cli/blob/main/runtime/_aicp_llm.py): `runtime/_aicp_llm.py`

### Model and endpoints

- [Configuration](https://github.com/woozheng/aicp_cli/blob/main/runtime/_config.py): `runtime/_config.py`
- [LLM client](https://github.com/woozheng/aicp_cli/blob/main/runtime/_llm.py): `runtime/_llm.py`

### Other components

- **User**
- **Local computer**
- **Model API**
- **Remote endpoint**

## Connections

- User → Chat CLI: enters request (evidence: `README.md`)
- Application → Configuration: loads configuration (evidence: `aicp.py`)
- Application → Chat CLI: starts CLI (evidence: `aicp.py`)
- Chat CLI → Local engine: sends request (evidence: `aicp.py`)
- Chat CLI → Remote engine: sends request (evidence: `aicp.py`)
- Local engine → AICP runtime: calls runtime (evidence: `aicp.py`)
- Remote engine → Remote endpoint: posts request (evidence: `aicp.py`)
- AICP runtime → Prompt builder: builds prompt (evidence: `runtime/_aicp_llm.py`)
- AICP runtime → LLM client: requests completion (evidence: `runtime/_aicp_llm.py`)
- AICP runtime → Code executor: executes code (evidence: `runtime/_aicp_llm.py`)
- AICP runtime → Envelop and agent: uses protocol types (evidence: `runtime/_aicp_llm.py`)
- Code executor → Local computer: runs local operations (evidence: `runtime/_aicp_llm.py`)
- LLM client → Model API: calls model API (evidence: `runtime/_llm.py`)
