> For the complete documentation index, see [llms.txt](https://www.opencodebook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opencodebook.xyz/en/chapter_15_oh-my-opencode_deep_dive/15.1_project_overview_and_architecture.md). Agents can also search and read this documentation through its [MCP server](https://www.opencodebook.xyz/~gitbook/mcp).

# 15.1 Project Overview and Architecture

> **Model**: claude-opus-4-6 (anthropic/claude-opus-4-6) **Generation Date**: 2026-02-17

***

In the preceding chapters, we thoroughly dissected OpenCode's core architecture -- from Session, Tool, Agent, and Provider to the Plugin, Skill, Bus, and other subsystems. Readers now understand the internal workings of OpenCode as an AI programming assistant. But OpenCode's true power lies not just in itself, but in its **extensibility** -- the Plugin system allows third-party developers to inject entirely new tools, hooks, agents, and even complete workflows without modifying the OpenCode source code.

This chapter provides an in-depth analysis of **oh-my-opencode**, a "full-featured enhancement plugin" built on the OpenCode Plugin system. It is currently the most complex and feature-rich third-party Plugin in the OpenCode ecosystem, fully demonstrating the Plugin system's capability boundaries.

## 15.1.1 oh-my-opencode's Positioning: A "Batteries-Included" Enhancement Plugin

oh-my-opencode's official definition is:

> "The Best AI Agent Harness -- Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools"

**"Batteries-Included"** is a classic metaphor in software engineering, originating from the Python community. It means that after installation, all features work out of the box with no additional configuration needed. oh-my-opencode's design philosophy follows this exact principle -- users only need to run `npm install oh-my-opencode` to get a complete AI Agent enhancement experience.

### Core Philosophy

oh-my-opencode's core philosophy can be summarized across three dimensions:

1. **Agent Personification**: It does not merely configure a set of tools, but defines a complete AI Agent role system. The main Agent is named "Sisyphus", after the Greek mythological figure who eternally pushes a boulder uphill -- an LLM Agent spends every day "pushing boulders", handling one task after another, fundamentally no different from human daily work. This naming not only gives the Agent a personality, but also expresses an engineering philosophy.
2. **Multi-Agent Orchestration**: A single Agent has inherent limitations when facing complex tasks -- limited context window, narrow domain expertise, and a tendency toward tunnel vision. oh-my-opencode addresses this by defining multiple specialized Agents (Oracle as a technical advisor, Librarian as a documentation researcher, Explore as a codebase expert, etc.), allowing the main Agent to "delegate" subtasks to specialists, much like an architect managing a team of professionals.
3. **Defensive Programming**: AI Agent behavior is not always reliable. oh-my-opencode implements comprehensive "guardrails" through 53 hooks -- context window monitoring, automatic recovery from edit errors, babysitting of unstable Agents, Todo task continuation enforcement, and more. These mechanisms ensure that a single point of failure does not cause the entire workflow to collapse.

### Relationship with OpenCode

The relationship between oh-my-opencode and OpenCode is analogous to the relationship between **oh-my-zsh and Zsh** -- OpenCode provides the core runtime (Shell), while oh-my-opencode provides enhanced configuration and plugins (themes, plugins, aliases). This is also the origin of the project's name.

From a technical perspective, oh-my-opencode is a standard OpenCode Plugin. It exports an async function conforming to the `Plugin` type, which is loaded through OpenCode's Plugin loading mechanism:

```typescript
// oh-my-opencode/src/index.ts
import type { Plugin } from "@opencode-ai/plugin"

const OhMyOpenCodePlugin: Plugin = async (ctx) => {
  // Initialization logic...
  return {
    // Plugin interface implementation
  }
}

export default OhMyOpenCodePlugin
```

However, oh-my-opencode's complexity far exceeds that of a typical Plugin. Its codebase spans tens of thousands of lines and includes 11 Agent definitions, 15 custom tools, 53 hooks, 20 Feature modules, 3 embedded MCP services, and a complete configuration system. In essence, it is a "framework-level" Plugin.

## 15.1.2 Core Features Overview

oh-my-opencode's features can be organized into the following major categories:

### Multi-Agent Orchestration System

| Agent Name        | Role                                 | Typical Use Cases                                                 |
| ----------------- | ------------------------------------ | ----------------------------------------------------------------- |
| Sisyphus          | Main Agent / Orchestrator            | Receives user requests, classifies intent, delegates subtasks     |
| Oracle            | Senior Technical Advisor (read-only) | Architecture design, complex debugging, code review               |
| Explore           | Codebase Search Expert               | Rapid code pattern search, project structure comprehension        |
| Librarian         | External Resource Researcher         | Finding official documentation, OSS implementations, API examples |
| Prometheus        | Task Planner                         | Decomposing complex requirements into executable step plans       |
| Metis             | Pre-planning Analyst                 | Analyzing implicit intent and ambiguities in requirements         |
| Momus             | Plan Review Expert                   | Reviewing completeness and verifiability of work plans            |
| Hephaestus        | Autonomous Craftsman Executor        | Deep autonomous problem solving, goal-oriented                    |
| Atlas             | Project Navigator                    | Project structure comprehension and navigation                    |
| Sisyphus Junior   | Lightweight Task Execution           | Simple modifications, quick fixes, and other low-complexity tasks |
| Multimodal Looker | Multimodal Analysis                  | Analysis of images, PDFs, and other non-text files                |

### Custom Tool System

oh-my-opencode registers 15 custom tools, covering everything from code search to background task management:

| Tool               | Function                                                     |
| ------------------ | ------------------------------------------------------------ |
| `ast-grep`         | AST (Abstract Syntax Tree) level code search and replace     |
| `background-task`  | Background task output retrieval and cancellation management |
| `call-omo-agent`   | Direct invocation of oh-my-opencode internal Agents          |
| `delegate-task`    | Delegate subtasks to designated Agents                       |
| `glob`             | Enhanced file pattern matching                               |
| `grep`             | Enhanced content search                                      |
| `hashline-edit`    | Precise file editing based on line number hashes             |
| `interactive-bash` | tmux interactive terminal sessions                           |
| `look-at`          | Multimodal file analysis (images, PDFs)                      |
| `lsp`              | Language Server Protocol integration tool                    |
| `session-manager`  | Session history querying and searching                       |
| `skill-mcp`        | Skill embedded MCP service invocation                        |
| `skill`            | Skill file loading                                           |
| `slashcommand`     | Slash command execution                                      |
| `task`             | Enhanced task delegation (with Category + Skill support)     |

### Hook System

oh-my-opencode defines **53 hooks**, categorized by function as follows:

* **Context Injection** (4): Inject AGENTS.md, README, rules files, and other context into Agent messages
* **Error Recovery** (4): Automatic recovery from edit errors, JSON parse errors, context window overflow, and session interruptions
* **Agent Management** (3): Remind Agents to correctly use delegation protocols, monitor unstable sub-Agents
* **Session Management** (4): Context window monitoring, preemptive compaction, Todo state preservation, session notifications
* **Output Control** (3): Tool output truncation, thinking block validation, thinking mode control
* **Task Management** (4): Todo task continuation enforcement, task reminders, task recovery, TodoWrite disabling
* **Automation** (4): Auto slash commands, Ralph Loop self-driving cycle, start-work initialization
* **Environment Adaptation** (2): Non-interactive environment adaptation, interactive Bash session management
* **Miscellaneous** (various): Keyword detection, comment checking, Hashline read enhancement, file write protection, etc.

### Feature Modules

oh-my-opencode has 20 Feature modules, each encapsulating an independent functional domain:

| Module                       | Function                                           |
| ---------------------------- | -------------------------------------------------- |
| `background-agent`           | Background Agent creation, management, and polling |
| `boulder-state`              | Persistent work state management                   |
| `builtin-commands`           | Built-in slash commands                            |
| `builtin-skills`             | Built-in Skills (git-master, frontend-ui-ux, etc.) |
| `claude-code-agent-loader`   | Claude Code Agent compatibility loader             |
| `claude-code-command-loader` | Claude Code Command compatibility loader           |
| `claude-code-mcp-loader`     | Claude Code MCP compatibility loader               |
| `claude-code-plugin-loader`  | Claude Code Plugin compatibility loader            |
| `claude-code-session-state`  | Claude Code Session state management               |
| `claude-tasks`               | Claude Tasks system integration                    |
| `context-injector`           | General-purpose context injector                   |
| `hook-message-injector`      | Hook message injector                              |
| `mcp-oauth`                  | MCP OAuth authentication                           |
| `opencode-skill-loader`      | OpenCode Skill loader                              |
| `run-continuation-state`     | Run continuation state management                  |
| `skill-mcp-manager`          | Skill embedded MCP lifecycle management            |
| `task-toast-manager`         | Task Toast notification management                 |
| `tmux-subagent`              | tmux sub-Agent visual management                   |
| `tool-metadata-store`        | Tool metadata storage                              |

### Embedded MCP Services

oh-my-opencode integrates 3 MCP services out of the box, requiring no separate user configuration:

* **Context7**: For querying official documentation and code examples of open-source libraries
* **Grep.app**: For searching real-world code patterns on GitHub
* **Web Search (Exa)**: For general web searching

## 15.1.3 Directory Structure

oh-my-opencode's source code is cleanly organized, with each top-level directory corresponding to a functional domain:

```
oh-my-opencode/
├── src/
│   ├── index.ts                  # Plugin entry: exports OhMyOpenCodePlugin
│   ├── create-hooks.ts           # Hook creation factory
│   ├── create-managers.ts        # Manager creation factory
│   ├── create-tools.ts           # Tool creation factory
│   ├── plugin-interface.ts       # Final Plugin interface assembly
│   ├── plugin-config.ts          # Configuration loading and merging
│   ├── plugin-state.ts           # Plugin-level global state
│   │
│   ├── agents/                   # Agent definitions (11 Agents)
│   │   ├── sisyphus.ts           #   Main Agent: Sisyphus
│   │   ├── oracle.ts             #   Technical Advisor: Oracle
│   │   ├── explore.ts            #   Code Search: Explore
│   │   ├── librarian.ts          #   Documentation Search: Librarian
│   │   ├── metis.ts              #   Pre-planning: Metis
│   │   ├── momus.ts              #   Plan Review: Momus
│   │   ├── hephaestus.ts         #   Autonomous Execution: Hephaestus
│   │   ├── multimodal-looker.ts  #   Multimodal Analysis
│   │   ├── atlas/                #   Project Navigation: Atlas
│   │   ├── prometheus/           #   Task Planning: Prometheus (multi-file)
│   │   ├── sisyphus-junior/      #   Lightweight Execution: Sisyphus Junior
│   │   ├── agent-builder.ts      #   Unified Agent build factory
│   │   ├── dynamic-agent-prompt-builder.ts  # Dynamic Prompt builder
│   │   ├── env-context.ts        #   Environment context injection
│   │   ├── builtin-agents.ts     #   Built-in Agent registry
│   │   └── types.ts              #   Agent type definitions
│   │
│   ├── tools/                    # Custom tools (15 tools)
│   │   ├── ast-grep/             #   AST search and replace
│   │   ├── background-task/      #   Background task management
│   │   ├── call-omo-agent/       #   Direct Agent invocation
│   │   ├── delegate-task/        #   Task delegation
│   │   ├── glob/                 #   File pattern matching
│   │   ├── grep/                 #   Content search
│   │   ├── hashline-edit/        #   Line number hash editing
│   │   ├── interactive-bash/     #   Interactive terminal
│   │   ├── look-at/              #   Multimodal analysis
│   │   ├── lsp/                  #   LSP integration
│   │   ├── session-manager/      #   Session management
│   │   ├── skill-mcp/            #   Skill MCP invocation
│   │   ├── skill/                #   Skill loading
│   │   ├── slashcommand/         #   Slash commands
│   │   ├── task/                 #   Enhanced task delegation
│   │   └── index.ts              #   Tool export registry
│   │
│   ├── hooks/                    # Hook implementations (53 hooks)
│   │   ├── context-window-monitor.ts    # Context window monitoring
│   │   ├── preemptive-compaction.ts     # Preemptive compaction
│   │   ├── edit-error-recovery/         # Edit error recovery
│   │   ├── ralph-loop/                  # Self-driving work loop
│   │   ├── todo-continuation-enforcer/  # Todo continuation enforcement
│   │   ├── unstable-agent-babysitter/   # Unstable Agent monitoring
│   │   ├── ... (53 total)
│   │   └── index.ts
│   │
│   ├── features/                 # Feature modules (20 modules)
│   │   ├── background-agent/     #   Background Agent system
│   │   ├── boulder-state/        #   Work state persistence
│   │   ├── builtin-commands/     #   Built-in commands
│   │   ├── builtin-skills/       #   Built-in Skills
│   │   ├── tmux-subagent/        #   tmux integration
│   │   ├── skill-mcp-manager/    #   Skill MCP management
│   │   ├── claude-tasks/         #   Claude Tasks
│   │   ├── ... (20 total)
│   │   └── AGENTS.md
│   │
│   ├── plugin/                   # Plugin interface implementation layer
│   │   ├── chat-params.ts        #   chat.params hook
│   │   ├── chat-message.ts       #   chat.message hook
│   │   ├── messages-transform.ts #   Message transformation
│   │   ├── event.ts              #   Event handling
│   │   ├── tool-execute-before.ts#   Pre-tool-execution interception
│   │   ├── tool-execute-after.ts #   Post-tool-execution processing
│   │   ├── session-agent-resolver.ts #  Session-Agent mapping
│   │   ├── available-categories.ts   #  Category definitions
│   │   ├── tool-registry.ts      #   Tool registry
│   │   └── hooks/                #   Hook creation submodule
│   │
│   ├── mcp/                      # Embedded MCP services
│   │   ├── context7.ts           #   Context7 integration
│   │   ├── grep-app.ts           #   Grep.app integration
│   │   ├── websearch.ts          #   Web Search integration
│   │   ├── index.ts              #   MCP registration
│   │   └── types.ts
│   │
│   ├── config/                   # Configuration system
│   │   ├── index.ts              #   Configuration type exports
│   │   ├── schema.ts             #   Zod Schema definitions
│   │   └── schema/               #   Modular Schemas
│   │       ├── oh-my-opencode-config.ts  # Main configuration Schema
│   │       ├── agent-overrides.ts        # Agent override configuration
│   │       ├── categories.ts             # Category configuration
│   │       ├── skills.ts                 # Skill configuration
│   │       ├── background-task.ts        # Background task configuration
│   │       ├── tmux.ts                   # tmux configuration
│   │       ├── ralph-loop.ts             # Ralph Loop configuration
│   │       ├── notification.ts           # Notification configuration
│   │       └── ...
│   │
│   ├── shared/                   # Shared utility library (100+ files)
│   │   ├── logger.ts             #   Logging system
│   │   ├── model-resolver.ts     #   Model resolution
│   │   ├── safe-create-hook.ts   #   Safe Hook creation
│   │   ├── session-utils.ts      #   Session utility functions
│   │   ├── tmux/                 #   tmux operation wrappers
│   │   └── ...
│   │
│   └── plugin-handlers/          # Plugin handlers
│
├── packages/                     # Sub-packages (platform-specific binaries, etc.)
├── bin/                          # CLI entry scripts
├── docs/                         # Documentation
├── script/                       # Build scripts
└── package.json                  # Package configuration
```

### Architectural Layers

The directory structure clearly reveals oh-my-opencode's four-layer architecture:

```
┌─────────────────────────────────────────────────────┐
│                 Plugin Interface Layer                │
│  plugin-interface.ts → plugin/*.ts                   │
│  (Maps internal capabilities to OpenCode Plugin API) │
├─────────────────────────────────────────────────────┤
│                   Capability Layer                    │
│  agents/  │  tools/  │  hooks/  │  features/  │ mcp/ │
│  (Agent)  │ (Tools)  │ (Hooks)  │ (Features)  │(MCP) │
├─────────────────────────────────────────────────────┤
│                Infrastructure Layer                   │
│  shared/  │  config/  │  plugin-state.ts              │
│  (Utils)  │ (Config)  │  (Global state)               │
├─────────────────────────────────────────────────────┤
│               OpenCode Plugin Runtime                 │
│  @opencode-ai/plugin type defs + OpenCode loader      │
└─────────────────────────────────────────────────────┘
```

**Layer 1: Plugin Interface Layer** -- `plugin-interface.ts` and the `plugin/` directory. This layer is responsible for "translating" oh-my-opencode's internal capabilities into Plugin interfaces that OpenCode can understand. It implements the OpenCode-defined hook interfaces such as `chat.params`, `chat.message`, `event`, `tool.execute.before`, and `tool.execute.after`.

**Layer 2: Capability Layer** -- `agents/`, `tools/`, `hooks/`, `features/`, `mcp/`. This is the core of oh-my-opencode, defining what it can do. Each directory is an independent functional domain, interacting with other domains through well-defined interfaces.

**Layer 3: Infrastructure Layer** -- `shared/`, `config/`, `plugin-state.ts`. Provides cross-module shared utility functions (logging, model resolution, Session utilities, etc.), the configuration loading/parsing system, and plugin-level global state.

**Layer 4: OpenCode Plugin Runtime** -- This is not oh-my-opencode's code, but the "foundation" it runs on. The `@opencode-ai/plugin` package defines the Plugin type contract, and OpenCode's Plugin loader is responsible for discovering and invoking plugins.

### Initialization Flow Overview

As a preview of subsequent sections, here is the complete initialization flow of oh-my-opencode:

```
OpenCode starts → Discovers oh-my-opencode Plugin → Calls Plugin function(ctx)
                                                    │
                     ┌──────────────────────────────┤
                     │                              │
           loadPluginConfig()            injectServerAuthIntoClient()
           (Load & merge config)         (Inject server auth)
                     │                              │
                     ├──── startTmuxCheck()  ────────┘
                     │     (tmux environment detection)
                     │
           createManagers()
           ├── TmuxSessionManager      (tmux session management)
           ├── BackgroundManager        (Background Agent management)
           ├── SkillMcpManager          (Skill MCP management)
           └── ConfigHandler            (Configuration handler)
                     │
           await createTools()
           ├── createSkillContext()      (Load Skills)
           ├── createAvailableCategories() (Create Categories)
           └── createToolRegistry()     (Register 15 tools)
                     │
           createHooks()
           ├── createCoreHooks()        (Core hooks)
           ├── createContinuationHooks()(Continuation hooks)
           └── createSkillHooks()       (Skill hooks)
                     │
           createPluginInterface()
           (Assemble the final Plugin object)
                     │
                     ▼
           return { tool, chat.params, chat.message, event, ... }
```

This flow embodies an important design principle: **staged initialization**. Configuration loading -> Manager creation -> Tool registration -> Hook creation -> Interface assembly -- each stage's output serves as input to the next, forming a clear dependency chain.

> **Extended Explanation: What is the "Batteries-Included" Design Philosophy?**
>
> "Batteries-Included" is a software design philosophy originally popularized by the Python community. It means that a software product should be immediately usable for its core functions right after installation, without requiring users to find and install additional dependencies or plugins.
>
> The opposite is the "Batteries-Not-Included" approach, with Vim/Neovim being a classic example -- they provide an extremely powerful core editor, but to achieve an IDE-level experience (syntax highlighting, code completion, file trees, etc.), users need to install and configure numerous plugins on their own.
>
> oh-my-opencode chose the "Batteries-Included" approach: after installation, it automatically includes multi-Agent orchestration, LSP tools, AST search, background tasks, tmux integration, and all other features, requiring no additional configuration from the user. This lowers the barrier to entry but also means a larger installation footprint and more runtime overhead.
>
> In practice, both approaches have their strengths:
>
> * **Batteries-Included** suits tools that need quick onboarding (e.g., Django, Create React App)
> * **Batteries-Not-Included** suits tools that need high customizability (e.g., Vim, Express.js)
>
> oh-my-opencode's elegance lies in accommodating both: it works out of the box by default, but through configuration options like `disabled_hooks`, `disabled_tools`, etc., users can precisely control which features are enabled.

## Section Summary

oh-my-opencode is a "framework-level" OpenCode Plugin. On top of the Plugin interface provided by OpenCode, it builds a complete multi-Agent orchestration system, including 11 role-based Agents, 15 custom tools, 53 behavioral hooks, 20 Feature modules, and 3 embedded MCP services.

Architecturally, it employs a four-layer design: Plugin Interface -> Capability Layer -> Infrastructure -> OpenCode Runtime. The initialization flow follows a "staged initialization" pattern, completing all setup through the chained calls of `createManagers()` -> `createTools()` -> `createHooks()` -> `createPluginInterface()`.

The following sections will dive deep into the specific implementation of each of these components.
