OpenCode Initializer v3.2.0

Operating Model: Multi-Agent Framework v3.0 Wave: current_wave.md Checkpoint: session_checkpoint.json

AI-Native SDD Harness — one-command AI-enhanced development environment for WSL2, Linux, and macOS. 4 deployment profiles.
685-line orchestrator · 52 modules · 12 modes · 24 MCPs · 15 plugins · 13 LSPs · 23 providers · air-gap · governance · PII guard · audit trail · offline bundle

Tests ShellCheck Docs Documentation License: MIT GitHub stars GitVerse Mirror


Quick Start

curl -fsSL https://raw.githubusercontent.com/AlexanderNarbaev/opencode_initializer/main/setup.sh | bash -s -- --full

One command installs everything: 8 languages, 52 infrastructure modules, 24 MCP servers, 15 OpenCode plugins, 13 LSP servers, 23 AI providers, infrastructure as code (PostgreSQL + Qdrant + Redis + Prometheus + Grafana + Node Exporter + MemoryLayer), Cockpit TUI (7 tabs), Web GUI, Isolated Circuit Mode, hardware auto-detection, Lynis CIS scanner, auditd kernel rules, and SearXNG web search.

Full Documentation

macOS users: Requires bash>=4 and grep with -E support (GNU grep). Install via brew install bash grep. Associative arrays (declare -A) require bash>=4; macOS stock bash 3.2 needs brew install bash.

Feature Grid

Category Count Details
Languages 8 Java 25, Node.js 24, Python 3.14, Go 1.26, Rust 1.97.1, .NET 10, Kotlin, Zig
Modules 52 System, Docker, Chrome, ZSH, 7 languages, OpenCode, MCP/LSP, ChromaDB, LLM, RAG, SearXNG, providers, dotfiles, Devbox, Infra, Cockpit, Isolated Circuit, Services, Observability, GUI, Model Router, WAL, Best Practices, Upstream Sync, Linux Platform, Lynis, auditd, and more
MCP Servers 24 GitHub, GitLab, Filesystem, Playwright, Chrome DevTools, Postgres, SQLite, Memory, Excalidraw, Brave Search, Context7, Google Maps, and more
LSP Servers 13 gopls, rust-analyzer, tsserver, pyright, omnisharp, yaml, marksman, taplo, lua, zls, bash, dockerfile, css/html/json
Plugins 15 token-tracker, dcp, swarm, goal-mode, vibeguard, orchestrator, auto-fallback, notify, pty, snip, snippets, envsitter-guard, command-inject, ignore
AI Providers 22 DeepSeek, OpenCode, z.ai GLM-5.2, OpenRouter, OpenAI, Anthropic Claude 4, Google Gemini, xAI Grok 4, MiniMax, MiMo, Alibaba Qwen3, DeepInfra, Groq, Together, Fireworks, Perplexity, Mistral, Cohere, Cerebras + 3 local (Ollama, vLLM, SGLang)
Model Router 8 profiles coding, reasoning, fast, agentic, budget, vision, isolated, ru_cn
CLI Modes 11 full, reinit, new, health, update, upgrade, interactive, ci, fix-config, fix-zshrc, dry-run
Infrastructure 7 PostgreSQL, Qdrant, Redis, Prometheus, Grafana, Node Exporter, MemoryLayer
Observability Full stack Prometheus metrics, Grafana dashboards, OpenCode metrics exporter, Node Exporter system metrics
GUI Web Provider status, model manager, model router, MCP/LSP management, infra monitoring, Grafana iframe, backup, Isolated Circuit toggle
Package Managers 6 apt, dnf, pacman, apk, zypper, brew

v2.0.0 — Infrastructure as Code + Isolated Circuit + Observability

v3.0.0 — SDD-native AI Harness: Audit & Governance

Architecture

opencode_initializer/
├── setup.sh                  # Orchestrator (685 lines)
├── dev.sh                    # CLI: dev install|remove|update|health|metrics|observability|isolated|...
├── opencode.json             # Generated OpenCode multi-provider config (23 providers)
├── src/
│   ├── lib/                  # 42 modules (39 numbered + 3 helpers)
│   │   ├── helpers.sh        # _curl, _retry, _npm_install infrastructure
│   │   ├── 00-core.sh        # OS/PKG/ARCH detection, mirrors, progress, ISOLATED_CIRCUIT, port resolution
│   │   ├── 01-system.sh      # System packages (cross-distro: apt/dnf/pacman/apk/zypper/brew)
│   │   ├── ...               # 02-29: Languages, tools, infrastructure
│   │   ├── 30-infra.sh       # Infrastructure: PostgreSQL + Qdrant + Redis + Prometheus + Grafana + Node Exporter + MemoryLayer
│   │   ├── 31-cockpit.sh     # Cockpit TUI server management daemon (7-tab)
│   │   ├── 32-isolated.sh    # Isolated Circuit Mode — air-gapped LLM
│   │   ├── 33-services.sh    # Unified Service Layer — port resolution, service modes, deployment profiles
│   │   ├── 34-observability.sh  # Prometheus + Grafana observability stack + OTel
│   │   ├── 35-gui.sh         # Web GUI (Node.js, port 4200)
│   │   ├── 36-model-router.sh   # Model routing intelligence (8 task profiles, cost table)
│   │   ├── 37-wal.sh         # Write-Ahead Log — setup + agent session journal
│   │   ├── version-check.sh  # Version comparison (8+ tools)
│   │   └── pre-session-check.sh  # Pre-session provider/model validation
│   ├── cockpit/               # Go TUI source (BubbleTea framework)
│   ├── gui/                   # Web GUI (Node.js server + HTML dashboard)
│   ├── grafana/               # Grafana provisioning (datasources + dashboards)
│   ├── systemd/               # Systemd user units (opencode-metrics.service)
│   └── modes/                 # 5 mode scripts (+ 6 built-in)
├── scripts/                   # Utilities (provider-check, embed-proxy, ai-router, oc-*)
│   ├── oc-metrics.py          # OpenCode Prometheus metrics exporter (:9464)
│   ├── oc-sdk.py              # Python SDK
│   ├── embed-proxy.py         # Ollama → MemoryLayer embedding bridge
│   └── ai-router/             # Model routing intelligence
├── tests/                     # Unit (12), integration (5), E2E (4) — 398+ assertions
├── migrations/                # Timestamped, idempotent migrations
├── docs/                      # MkDocs Material documentation site (EN/RU)
├── .github/                   # CI workflows (test, shellcheck, build, security, docs)
└── CHANGELOG.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md, SECURITY.md, LICENSE

Modes

Mode Flag Description
Full --full (default) Complete bootstrap — all modules
Reinit --reinit Reinstall tools, preserve data
New Project --new <dir> Initialize new project only
CI/CD --ci Headless CI: OpenCode CLI + essential MCPs
Health --health Full diagnostics (65+ checks)
Update --update Update installed tools
Upgrade --upgrade Full system upgrade chain
Interactive --interactive Component-by-component selection
Fix Config --fix-config Regenerate opencode.json only
Fix ZSH --fix-zshrc Repair .zshrc
Dry Run --dry-run Preview mode, no changes

Installation

Full Install

curl -fsSL https://raw.githubusercontent.com/AlexanderNarbaev/opencode_initializer/main/setup.sh | bash -s -- --full

With API Keys

bash setup.sh --full \
  --deepseek-key "sk-..." \
  --zai-key "..." \
  --openrouter-key "sk-or-..." \
  --xai-key "xai-..." \
  --github-token "ghp_..." \
  --gitlab-token "glpat-..."

Deployment Profiles

# Corporate environment — point to existing infrastructure
DEPLOYMENT_PROFILE=corporate \
  POSTGRES_MODE=external POSTGRES_EXTERNAL_URL=pg.internal:5432 \
  GRAFANA_MODE=external EXTERNAL_GRAFANA_URL=https://grafana.company.com \
  PROMETHEUS_MODE=external EXTERNAL_PROMETHEUS_URL=https://prom.internal:9090 \
  OTEL_EXPORTER_ENABLED=true OTEL_EXPORTER_ENDPOINT=otel-collector:4317 \
  bash setup.sh --full

# Air-gapped — local LLMs only
bash setup.sh --full --isolated

Interactive

bash setup.sh --interactive     # Choose what to install
bash setup.sh --dry-run --full  # Preview without changes

Post-Install CLI

dev health              # Full diagnostics (65+ checks)
dev list                # List installed components
dev update              # Update everything + migrations
dev self-update         # Update the installer itself
dev version-check       # Compare installed vs latest versions
dev config              # Edit setup config file
dev provider-check      # Check AI provider connectivity
dev autoupdate          # Run topgrade full system update
dev remove java         # Remove a component
dev plugins list        # Show installed plugins

# Observability
dev observability status    # Prometheus + Grafana status
dev observability reload    # Regenerate prometheus.yml + restart
dev metrics start           # Start metrics exporter
dev metrics status          # View real-time metrics

# Infrastructure
dev infra up                # Start all Docker services
dev infra status            # Container health overview
dev infra down              # Stop all services

# Isolated Circuit (air-gapped LLM)
dev isolated on              # Enable local-only mode
dev isolated status          # Check current state

# Model Management
dev models coding            # Get model recommendation for coding
dev models install qwen3:32b # Download local model
dev models list-local        # List installed local models

# GUI & Cockpit
dev gui start                # Start Web GUI (http://localhost:4200)
cockpit                      # Launch TUI (or run 'dev install cockpit')

# Backup
dev backup create            # Backup all configs
dev backup list              # Show available backups
dev backup restore <file>    # Restore from backup

# Add components later
dev install llm              # Add GPU/LLM support
dev install docker           # Install Docker Engine

Observability Stack

Components

Component Port Description Auto-Start
Prometheus 9090 Metrics collection & storage systemd opencode-infra.service
Grafana 3001 Dashboards (infrastructure + agent performance) systemd opencode-infra.service
Node Exporter 9100 System metrics (CPU, RAM, disk, uptime) Docker unless-stopped
OpenCode Metrics 9464 Sessions, WAL, containers, models, config systemd opencode-metrics.service

Dashboards

Access

# Web GUI Metrics tab
http://localhost:4200  →  Metrics tab (Grafana iframe)

# Cockpit TUI
cockpit → Tab 8 (Grafana) → Press 'o' to open in browser

# Direct
http://localhost:3001  →  Grafana (admin/admin)
http://localhost:9090  →  Prometheus
http://localhost:9464/metrics  →  OpenCode metrics

Port Management

All service ports are configurable via environment variables or ~/.config/opencode-setup/setup.conf:

# Override default ports
POSTGRES_PORT=5433
GRAFANA_PORT=3002
METRICS_EXPORTER_PORT=9465

# Or use auto-detection (set to 0)
POSTGRES_PORT=0   # Finds first free port ≥ 5432

# Service modes
POSTGRES_MODE=external  POSTGRES_EXTERNAL_URL=pg.internal:5432
REDIS_MODE=disabled

Options

Flag Description
-k, --api-key <key> OpenCode Go API key
--deepseek-key <key> DeepSeek API key
--isolated Enable Isolated Circuit Mode (local LLM only)
--zai-key <key> z.ai GLM API key
--openrouter-key <key> OpenRouter API key
--alibaba-key <key> Alibaba Qwen API key
--deepinfra-key <key> DeepInfra API key
--with-observability Enable Prometheus + Grafana
--with-grafana Enable Grafana dashboards
--with-prometheus Enable Prometheus monitoring
--with-all-infra Enable all infrastructure services
--github-token <token> GitHub personal access token
--gitlab-token <token> GitLab personal access token
--google-maps-key <key> Google Maps API key
-s, --sudo-pass <pass> [DEPRECATED] Use SUDO_PASS env or interactive read -s
-p, --project-dir <dir> Project directory (default: ~/projects)
-n, --git-name <name> Git user name
-e, --git-email <email> Git user email

Resilience

Platform Support

Package Manager Distributions Arch
apt Ubuntu, Debian, Mint, Pop!_OS amd64, arm64
dnf Fedora, RHEL, CentOS Stream amd64, arm64
pacman Arch, Manjaro, EndeavourOS amd64
apk Alpine Linux amd64, arm64
zypper openSUSE amd64
brew macOS, Linuxbrew amd64, arm64

Security

Documentation

Community

License

MIT (c) 2025-2026 Alexander Narbaev