How midorin-linux/opencoder works
Project type and purpose
• This is a Rust-based command-line “coding agent” framework (“OpenCoder”) that speaks the OpenAI V1 chat API.
• It provides a CLI interface, parses commands, runs them through an application runner, dispatches to domain logic (chat sessions, messages, models), persists state, and calls out to an LLM service.
File structure
• Top-level: .env, Cargo.toml, README.md
• src/main.rs: entry point
• src/cli: handles user input, prompts, output
• src/app: core application runner and configuration
• src/commands: command parser, registry, and handler modules (exit, help, models, set, etc.)
• src/domain: business logic layer
• chat (conversation, message, session)
• model (provider, model_info)
• src/infrastructure: external integrations
• lm (client abstraction over HTTP calls to API_URL)
• storage (history_store, session_store)
• src/utils: logging helpers
README for additional insights
• Configured via .env: API_URL, API_KEY, RUST_LOG, TIMEOUT_SECS
• Described as an “OpenAI-API-compatible coding agent”
Detailed capturing of essential elements
• Don’t lump everything into “backend”; separate the command parsing, runners, domain services, and each store or client
• Trait definitions in domain (model/provider) and their concrete bindings in infrastructure
• Configuration as a shared module influencing App Runner and infra clients