opencode-python is a local CLI coding assistant implemented in Python.
The MVP uses a Planner -> Executor (ReAct-style) -> Reviewer flow orchestrated by LangGraph, backed by lightweight code retrieval, local tool execution, and SQLite session storage.
This repository currently implements the MVP runtime described in:
docs/plans/2026-03-11-opencode-python-prd.mddocs/plans/2026-03-11-opencode-python-architecture.mddocs/plans/2026-03-11-opencode-python-task-breakdown.md
- Python 3.12+
- An OpenAI-compatible API key if you want to run against a real model provider
python -m pip install -e ".[dev]"Settings are loaded with this precedence:
- Environment variables
~/.opencode/config.toml- CLI overrides
Copy .env.example and set at least OPENCODE_API_KEY when using a real provider.
Supported environment variables:
OPENCODE_API_KEYOPENCODE_BASE_URLOPENCODE_MODELOPENCODE_TIMEOUT_SECONDSOPENCODE_PERMISSION_MODEOPENCODE_DATA_DIR
Example ~/.opencode/config.toml:
[app]
data_dir = "C:/Users/you/.opencode"
[provider]
model = "gpt-4o-mini"
api_key = "sk-..."
base_url = "https://api.openai.com/v1"
timeout_seconds = 60
[security]
mode = "ask"Show help:
opencode --helpRun a one-shot task:
opencode run "inspect the repository and summarize the entry points"Run a chat-style task with explicit workspace and model overrides:
opencode chat "find the retrieval flow" --workspace-root . --model gpt-4o-miniInspect stored sessions:
opencode session list
opencode session show <session-id>
opencode session resume <session-id>allow: execute supported tools without promptingask: require confirmation for risky operationsdeny: block risky operations
Current tool set:
shellfs_readfs_writesearch
Run the test suite:
python -m pytest -vRun a focused CLI test:
python -m pytest tests/cli/test_chat_command.py -vRun the lightweight end-to-end CLI test:
python -m pytest tests/e2e/test_run_command_e2e.py -v- The MVP targets local single-user CLI usage only.
- Retrieval is lightweight keyword/BM25-style retrieval with reranking; it does not include symbol graphs.
- Provider support is currently OpenAI-compatible only.
- The CLI is command-oriented, not a full-screen TUI.