[PR #11347] Add comprehensive architecture documentation for opencode #13747

Open
opened 2026-02-16 18:18:35 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11347

State: open
Merged: No


What does this PR do?

This PR adds a detailed architecture deep dive document (OPENCODE_ARCHITECTURE_DEEP_DIVE.md) that explains how the opencode system processes user requests from CLI input through LLM response and tool execution.

The document covers:

  • High-level flow diagram showing the complete request journey across 6 layers
  • Layer-by-layer breakdown with code examples:
    • CLI Layer (argument parsing, session management)
    • HTTP Server (Hono routes, request validation)
    • Session Prompt (processing loop orchestration)
    • Session Processor (LLM streaming, tool execution)
    • LLM Layer (provider abstraction, Vercel AI SDK integration)
    • Tool Execution (permission gates, bash tool example)
  • Event Bus architecture for real-time component communication
  • Bootstrap & Instance context initialization pattern
  • Data storage structure and persistence
  • Complete request flow walkthrough with numbered steps
  • Key patterns for extending the system

This documentation serves as a reference for developers who need to understand the codebase architecture, debug issues, or build new features. The code examples are extracted from actual implementation files and show real patterns used throughout the system.

How did you verify your code works?

This is documentation only - no code changes to verify. The document accurately reflects the existing architecture by:

  1. Following the actual file structure and module organization
  2. Including real code snippets from implementation files (run.ts, prompt.ts, processor.ts, llm.ts, etc.)
  3. Showing actual patterns like the Instance provider pattern, event bus subscription model, and tool execution flow
  4. Documenting real data structures (Zod schemas, message types, tool context)
  5. Reflecting actual event types and permission checking mechanisms

The diagrams and flow descriptions match the control flow visible in the codebase.

https://claude.ai/code/session_019cxVEEhEeqo5cLvoDakgrg

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11347 **State:** open **Merged:** No --- ### What does this PR do? This PR adds a detailed architecture deep dive document (`OPENCODE_ARCHITECTURE_DEEP_DIVE.md`) that explains how the opencode system processes user requests from CLI input through LLM response and tool execution. The document covers: - **High-level flow diagram** showing the complete request journey across 6 layers - **Layer-by-layer breakdown** with code examples: - CLI Layer (argument parsing, session management) - HTTP Server (Hono routes, request validation) - Session Prompt (processing loop orchestration) - Session Processor (LLM streaming, tool execution) - LLM Layer (provider abstraction, Vercel AI SDK integration) - Tool Execution (permission gates, bash tool example) - **Event Bus architecture** for real-time component communication - **Bootstrap & Instance context** initialization pattern - **Data storage** structure and persistence - **Complete request flow walkthrough** with numbered steps - **Key patterns** for extending the system This documentation serves as a reference for developers who need to understand the codebase architecture, debug issues, or build new features. The code examples are extracted from actual implementation files and show real patterns used throughout the system. ### How did you verify your code works? This is documentation only - no code changes to verify. The document accurately reflects the existing architecture by: 1. Following the actual file structure and module organization 2. Including real code snippets from implementation files (run.ts, prompt.ts, processor.ts, llm.ts, etc.) 3. Showing actual patterns like the Instance provider pattern, event bus subscription model, and tool execution flow 4. Documenting real data structures (Zod schemas, message types, tool context) 5. Reflecting actual event types and permission checking mechanisms The diagrams and flow descriptions match the control flow visible in the codebase. https://claude.ai/code/session_019cxVEEhEeqo5cLvoDakgrg
yindo added the pull-request label 2026-02-16 18:18:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13747