# hallofcodes/acode-ai-agent-plugin architecture

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

- Interactive diagram: https://gitdiagram.com/hallofcodes/acode-ai-agent-plugin
- Repository: https://github.com/hallofcodes/acode-ai-agent-plugin

## Overview

Rutex is an Acode mobile-editor plugin that lets a user chat with an AI agent to inspect and modify the active project. The principal flow runs from the chat panel through agent orchestration and a configured model provider, then uses file tools to carry out requested operations; results and edit previews return to the panel. Chat and edit histories persist locally. The README also documents terminal integration, but no implementation path for it appears in the supplied tree. Provider dispatch details are unsampled, so that link is shown as unverified.

Main entry points: [`src/panel.ts`](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/panel.ts) (Chat panel), [`src/chats/providers`](https://github.com/hallofcodes/acode-ai-agent-plugin/tree/main/src/chats/providers) (Provider adapters), [`src/chats/tools/functions`](https://github.com/hallofcodes/acode-ai-agent-plugin/tree/main/src/chats/tools/functions) (File operation tools), [`src/chats/history/chatHistory.ts`](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/chats/history/chatHistory.ts) (Chat and edit history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Plugin interface"]
  node_plugin["Plugin lifecycle<br/>[main.ts]"]
  node_sidebar["Sidebar entry<br/>[sidebar.ts]"]
  node_panel["Chat panel<br/>[panel.ts]"]
  node_panel_render["Message rendering<br/>[markdown.ts]"]
  node_commands["Tool preview rendering<br/>[commandParser.ts]"]
  node_history_ui["History navigation"]
  node_settings_ui["Settings UI"]
  node_edit_dialog["Edit review dialog"]
end

subgraph group_agent["Agent and models"]
  node_orchestrator["Agent loop<br/>[handleAgents.ts]"]
  node_providers["Provider adapters"]
  node_models["Model catalogs"]
end

subgraph group_files["Project operations"]
  node_tool_specs["Tool definitions<br/>[ollama_tools.ts]"]
  node_file_tools["File operation tools"]
  node_workspace["Workspace context<br/>[workspace.ts]"]
end

subgraph group_state["Settings and history"]
  node_settings["AI settings<br/>[settings.ts]"]
  node_plugin_settings["Plugin credentials<br/>[pluginSettings.ts]"]
  node_chat_history[("Chat and edit history<br/>[chatHistory.ts]")]
end

node_user(("Acode user"))
node_acode{{"Acode APIs"}}
node_llm{{"AI provider services"}}
node_project[("Project filesystem")]

node_user -->|"opens"| node_sidebar
node_plugin -->|"registers"| node_sidebar
node_sidebar -->|"opens"| node_panel
node_panel -->|"submits tasks"| node_orchestrator
node_orchestrator -.->|"dispatches requests"| node_providers
node_providers -.->|"sends prompts"| node_llm
node_providers -.->|"uses model catalogs"| node_models
node_providers -.->|"offers tools"| node_tool_specs
node_orchestrator -.->|"executes tools"| node_file_tools
node_file_tools -->|"reads and writes"| node_project
node_panel -->|"gets active files"| node_workspace
node_panel -->|"loads and saves"| node_chat_history
node_file_tools -->|"records edits"| node_chat_history
node_chat_history -->|"supplies edit history"| node_commands
node_file_tools -->|"opens review"| node_edit_dialog
node_panel -->|"renders messages"| node_panel_render
node_panel -->|"shows history"| node_history_ui
node_panel -->|"shows settings"| node_settings_ui
node_settings_ui -->|"configures"| node_settings
node_settings -->|"loads credentials"| node_plugin_settings
node_plugin_settings -->|"registers plugin settings"| node_acode
node_plugin -->|"loads configuration"| node_settings
node_plugin -->|"clears on teardown"| node_chat_history

click node_plugin "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/main.ts"
click node_sidebar "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/sidebar.ts"
click node_panel "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/panel.ts"
click node_panel_render "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/panel/markdown.ts"
click node_commands "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/panel/commandParser.ts"
click node_history_ui "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/panel/historyContainer.ts"
click node_settings_ui "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/panel/settingsContainer.ts"
click node_orchestrator "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/chats/handleAgents.ts"
click node_providers "https://github.com/hallofcodes/acode-ai-agent-plugin/tree/main/src/chats/providers"
click node_models "https://github.com/hallofcodes/acode-ai-agent-plugin/tree/main/src/chats/models"
click node_tool_specs "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/chats/tools/ollama_tools.ts"
click node_file_tools "https://github.com/hallofcodes/acode-ai-agent-plugin/tree/main/src/chats/tools/functions"
click node_workspace "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/helpers/workspace.ts"
click node_edit_dialog "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/panel/renderEditedFilesDialog.ts"
click node_settings "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/chats/settings.ts"
click node_plugin_settings "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/helpers/pluginSettings.ts"
click node_chat_history "https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/chats/history/chatHistory.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_plugin,node_sidebar,node_panel,node_panel_render,node_commands,node_history_ui,node_settings_ui,node_edit_dialog,node_user toneBlue
class node_orchestrator,node_providers,node_models,node_project toneAmber
class node_tool_specs,node_file_tools,node_workspace,node_acode toneMint
class node_settings,node_plugin_settings,node_chat_history toneRose
class node_llm toneIndigo
```

## Components

### Plugin interface

- [Plugin lifecycle](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/main.ts): `src/main.ts`
- [Sidebar entry](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/sidebar.ts): `src/sidebar.ts`
- [Chat panel](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/panel.ts): `src/panel.ts`
- [Message rendering](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/panel/markdown.ts): `src/panel/markdown.ts`
- [Tool preview rendering](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/panel/commandParser.ts): `src/panel/commandParser.ts`
- [History navigation](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/panel/historyContainer.ts): `src/panel/historyContainer.ts`
- [Settings UI](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/panel/settingsContainer.ts): `src/panel/settingsContainer.ts`
- [Edit review dialog](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/panel/renderEditedFilesDialog.ts): `src/panel/renderEditedFilesDialog.ts`

### Agent and models

- [Agent loop](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/chats/handleAgents.ts): `src/chats/handleAgents.ts`
- [Provider adapters](https://github.com/hallofcodes/acode-ai-agent-plugin/tree/main/src/chats/providers): `src/chats/providers`
- [Model catalogs](https://github.com/hallofcodes/acode-ai-agent-plugin/tree/main/src/chats/models): `src/chats/models`

### Project operations

- [Tool definitions](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/chats/tools/ollama_tools.ts): `src/chats/tools/ollama_tools.ts`
- [File operation tools](https://github.com/hallofcodes/acode-ai-agent-plugin/tree/main/src/chats/tools/functions): `src/chats/tools/functions`
- [Workspace context](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/helpers/workspace.ts): `src/helpers/workspace.ts`

### Settings and history

- [AI settings](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/chats/settings.ts): `src/chats/settings.ts`
- [Plugin credentials](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/helpers/pluginSettings.ts): `src/helpers/pluginSettings.ts`
- [Chat and edit history](https://github.com/hallofcodes/acode-ai-agent-plugin/blob/main/src/chats/history/chatHistory.ts): `src/chats/history/chatHistory.ts`

### Other components

- **Acode user**
- **Acode APIs**
- **AI provider services**
- **Project filesystem**

## Connections

- Acode user → Sidebar entry: opens (evidence: `src/sidebar.ts`)
- Plugin lifecycle → Sidebar entry: registers (evidence: `src/main.ts`)
- Sidebar entry → Chat panel: opens (evidence: `src/sidebar.ts`)
- Chat panel → Agent loop: submits tasks (evidence: `src/panel.ts`)
- Agent loop → Provider adapters: dispatches requests
- Provider adapters → AI provider services: sends prompts
- Provider adapters → Model catalogs: uses model catalogs
- Provider adapters → Tool definitions: offers tools (evidence: `src/chats/providers/openrouter.ts`)
- Agent loop → File operation tools: executes tools
- File operation tools → Project filesystem: reads and writes (evidence: `src/chats/tools/functions/edit_file.ts`)
- Chat panel → Workspace context: gets active files (evidence: `src/panel.ts`)
- Chat panel → Chat and edit history: loads and saves (evidence: `src/panel.ts`)
- File operation tools → Chat and edit history: records edits (evidence: `src/chats/tools/functions/edit_file.ts`)
- Chat and edit history → Tool preview rendering: supplies edit history (evidence: `src/panel/commandParser.ts`)
- File operation tools → Edit review dialog: opens review (evidence: `src/chats/tools/functions/edit_file.ts`)
- Chat panel → Message rendering: renders messages (evidence: `src/panel.ts`)
- Chat panel → History navigation: shows history (evidence: `src/panel.ts`)
- Chat panel → Settings UI: shows settings (evidence: `src/panel.ts`)
- Settings UI → AI settings: configures (evidence: `src/panel/settingsContainer.ts`)
- AI settings → Plugin credentials: loads credentials (evidence: `src/helpers/pluginSettings.ts`)
- Plugin credentials → Acode APIs: registers plugin settings
- Plugin lifecycle → AI settings: loads configuration (evidence: `src/main.ts`)
- Plugin lifecycle → Chat and edit history: clears on teardown (evidence: `src/main.ts`)
