og

module
v0.0.0-...-e1c7d53 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: GPL-3.0

README

og

A minimal, std-lib-first Go terminal agent harness. A REPL that runs an agentic loop against an OpenAI-compatible provider.

Install

Requires Go 1.24+.

go install github.com/okayest-dev/og/cmd/og@latest

Or build from source:

git clone https://github.com/okayest-dev/og && cd og
make build

Quick start

  1. Set your API key:
export OPENCODE_API_KEY="sk-..."
  1. Run:
og

You get an interactive og> prompt. Type naturally — the model can read, write, edit files, and run shell commands.

Usage

Interactive REPL
og

Starts an interactive session at the og> prompt. Each input runs a full agent loop — the model produces text and/or tool calls, the harness executes them, and results are fed back until the model stops calling tools.

Non-interactive mode
og -p "explain this project"

Runs a single prompt, prints the reply to stdout, and exits. Tool calls requiring confirmation are auto-denied in this mode.

Slash commands
Command Description
/help Show available commands
/quit, /exit Exit the REPL
/new Start a new session
/model List available models
/model <id> Switch to a different model

Ctrl+C cancels a running turn. Ctrl+C at the prompt exits.

Tools

The model has access to four tools:

Tool Description
read Read file contents or list directories. Supports offset/limit pagination. Rejects binary files.
write Create or overwrite files. Overwrites require confirmation. Auto-creates parent directories.
edit Surgical find-and-replace. Exact, whitespace-sensitive matching. One pair at a time.
bash Run shell commands via sh -c. Requires confirmation. 120s timeout (configurable).

Tools can be individually disabled in config.

Configuration

Config lives at ~/.config/og/config.toml (XDG-aware). The file is optional — everything has sensible defaults.

Precedence: defaults < config file < environment variables.

Config file
model = "big-pickle"
base_url = "https://opencode.ai/zen/v1"
api_key_env = "OPENCODE_API_KEY"
# wire = "openai"            # auto-detect from model prefix
# provider = "copilot"       # route through a wire plugin (e.g. copilot, bedrock)
# instruction_file = ""      # path to agent instruction file
# session_dir = ""           # defaults to ~/.config/og/sessions
bash_timeout = 120

[tools]
read = true
write = true
edit = true
bash = true

[plugins]
# dir = "~/.config/og/plugins"
# enable = ["my-plugin"]
# disable = ["broken-plugin"]
Environment variables
Variable Description
OG_MODEL Model ID
OG_BASE_URL Provider base URL
OG_API_KEY_ENV Name of env var holding the API key
OG_WIRE Wire protocol override
OG_PROVIDER Route through a wire plugin by name
OG_GATEWAY Gateway URL override
OG_INSTRUCTION_FILE Path to agent instruction file
OG_SESSION_DIR Session storage directory
OG_BASH_TIMEOUT Bash command timeout (seconds)
OG_PLUGIN_DIR Plugin discovery directory
OG_DEBUG Enable debug mode (true/1/yes)
Debug and verbose modes
og -v          # verbose: high-level flow to stderr
og -d          # debug: low-level detail (implies -v)
OG_DEBUG=1 og  # same as -d, via env var

Verbose shows config resolution, instruction assembly, turn lifecycle, and token usage. Debug adds HTTP requests, SSE chunks, and full config values.

Wire protocols

Og auto-detects the wire protocol from the model ID prefix:

Prefix Wire
claude-* Anthropic messages
gpt-* OpenAI Responses API
gemini-* Google generateContent
everything else OpenAI chat/completions

Override with wire = "openai" (or anthropic, responses, google) in config or OG_WIRE env var.

If a model doesn't support tool calling, the harness retries without tools — letting free/non-tool models still work.

Plugins

Og supports plugins via NDJSON-RPC 2.0 over stdio. Drop an executable into ~/.config/og/plugins/ and it's loaded automatically.

Plugin types
  • Tool plugins — add new tools to the harness
  • Wire plugins — add new provider backends (e.g. AWS Bedrock, GitHub Copilot)
Plugin layout

Plugins can be laid out in two ways:

Directory layout (recommended):

~/.config/og/plugins/
  copilot/
    manifest.toml
    config.toml     # optional, plugin-specific
    copilot         # binary

Flat layout (backward compatible):

~/.config/og/plugins/
  copilot           # binary
  copilot.toml      # manifest
Plugin manifest (optional)

A TOML file describing the plugin. In directory layout, place it inside the plugin directory as manifest.toml. In flat layout, place it next to the executable as <name>.toml:

name = "my-plugin"
version = "1.0.0"
capabilities = ["tools", "wires"]
Included plugins
  • bedrock — AWS Bedrock wire (SigV4 signing, ConverseStream API)
  • copilot — GitHub Copilot wire (OAuth token exchange, OpenAI-compatible API)
Copilot config (GHE support)

For GitHub Enterprise, create ~/.config/og/plugins/copilot/config.toml:

domain = "github.example.com"

The plugin will use https://api.github.example.com/copilot_internal/v2/token for token exchange and read the matching host key from ~/.config/github-copilot/hosts.json. Without this file, the plugin defaults to github.com.

Plugin enable/disable
[plugins]
dir = "~/.config/og/plugins"
enable = ["bedrock"]    # explicit allowlist (empty = all)
disable = ["broken"]    # denylist (takes precedence)

Max 16 plugins loaded concurrently. Plugins that crash or hang are automatically marked inactive.

Agent instructions

Og reads AGENTS.md from the working directory (if present) and sends it as the agent instruction on every turn. Set instruction_file in config or OG_INSTRUCTION_FILE env var to use a different file.

Session persistence

Sessions are saved as JSONL in ~/.config/og/sessions/. Each session carries a change ledger — a record of every file change made during that session, grouped into change batches with unified diffs. Use /new to start a fresh session.

License

GPL v3 — see LICENSE.

Directories

Path Synopsis
cmd
og command
internal
agent
Package agent runs the harness's agent loop: send the prompt, stream the reply, and when the model requests tool calls, execute them serially and feed results back until the model stops calling tools.
Package agent runs the harness's agent loop: send the prompt, stream the reply, and when the model requests tool calls, execute them serially and feed results back until the model stops calling tools.
config
Package config loads the harness's v1 configuration: a TOML file at the user config dir overlaid on pure defaults, with six env overrides on top and an API key that lives only in the environment.
Package config loads the harness's v1 configuration: a TOML file at the user config dir overlaid on pure defaults, with six env overrides on top and an API key that lives only in the environment.
e2e/fake
Package fake provides in-process, scripted fake providers for E2E testing.
Package fake provides in-process, scripted fake providers for E2E testing.
instruct
Package instruct assembles the agent instruction from three append-only sources in order: a built-in default prompt (always present), an optional config instruction file, and an optional AGENTS.md in the working directory.
Package instruct assembles the agent instruction from three append-only sources in order: a built-in default prompt (always present), an optional config instruction file, and an optional AGENTS.md in the working directory.
ledger
Package ledger implements the change ledger: an append-only JSONL record of file mutations captured during agent-loop cycles.
Package ledger implements the change ledger: an append-only JSONL record of file mutations captured during agent-loop cycles.
llm
Package llm is the seam between the agent loop and the provider: one small Client interface the loop depends on, a normalized event stream, and the error surface.
Package llm is the seam between the agent loop and the provider: one small Client interface the loop depends on, a normalized event stream, and the error surface.
llm/anthropic
Package anthropic implements the llm seam over the Anthropic Messages wire protocol (used by Zen and other Anthropic-compatible providers).
Package anthropic implements the llm seam over the Anthropic Messages wire protocol (used by Zen and other Anthropic-compatible providers).
llm/google
Package google implements the llm seam over the Google generateContent wire protocol (used by OpenCode Zen for gemini-* models and by direct Google API endpoints).
Package google implements the llm seam over the Google generateContent wire protocol (used by OpenCode Zen for gemini-* models and by direct Google API endpoints).
llm/openai
Package openai implements the llm seam over the OpenAI-compatible chat/completions wire protocol (used by OpenCode Zen and other OpenAI-compatible providers).
Package openai implements the llm seam over the OpenAI-compatible chat/completions wire protocol (used by OpenCode Zen and other OpenAI-compatible providers).
llm/responses
Package responses implements the llm seam over the OpenAI Responses-API wire protocol (used by OpenCode Zen for gpt-* models).
Package responses implements the llm seam over the OpenAI Responses-API wire protocol (used by OpenCode Zen for gpt-* models).
repl
Package repl implements the interactive REPL (Read-Eval-Print Loop) for og.
Package repl implements the interactive REPL (Read-Eval-Print Loop) for og.
session
Package session manages JSONL session transcripts.
Package session manages JSONL session transcripts.
tools
Package tools provides the tool registry, JSON Schema validation, and the disabled-tool error surface.
Package tools provides the tool registry, JSON Schema validation, and the disabled-tool error surface.
tools/bashtool
Package bashtool implements the bash tool: shell command execution with confirm gate, timeout, output truncation with spill files, and merged stdout+stderr.
Package bashtool implements the bash tool: shell command execution with confirm gate, timeout, output truncation with spill files, and merged stdout+stderr.
tools/edittool
Package edittool implements the edit tool: surgical single-pair text replacement with exact whitespace-sensitive matching, line-ending preservation, and BOM stripping.
Package edittool implements the edit tool: surgical single-pair text replacement with exact whitespace-sensitive matching, line-ending preservation, and BOM stripping.
tools/readtool
Package readtool implements the read tool: file content, directory listing, offset/limit, shared 2000-line/50KB truncation cap, and binary detection.
Package readtool implements the read tool: file content, directory listing, offset/limit, shared 2000-line/50KB truncation cap, and binary detection.
tools/writetool
Package writetool implements the write tool: whole-file writes with auto-mkdir for new files, a confirm gate for overwrites, and a 1MB cap.
Package writetool implements the write tool: whole-file writes with auto-mkdir for new files, a confirm gate for overwrites, and a 1MB cap.
plugins
bedrock command
Bedrock wire plugin for og.
Bedrock wire plugin for og.
copilot command
Copilot wire plugin for og.
Copilot wire plugin for og.
shared
Package shared provides protocol helpers for wire plugins.
Package shared provides protocol helpers for wire plugins.
prototype
ndjson-rpc/host command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL