Skip to content

Instantly share code, notes, and snippets.

@dewdad
Last active May 6, 2026 17:24
Show Gist options
  • Select an option

  • Save dewdad/d60ef27605f6e7c8dfa590366e5d12b2 to your computer and use it in GitHub Desktop.

Select an option

Save dewdad/d60ef27605f6e7c8dfa590366e5d12b2 to your computer and use it in GitHub Desktop.
oh-my-openagent efficiency optimizer — disable telemetry, reduce noise, keep diagnostics

oh-my-openagent Efficiency Optimizer

Applies best-practice configuration to an existing oh-my-openagent installation:

  • Disables PostHog telemetry (no network calls home)
  • Disables noisy hooks (update checker, startup toast, agent-usage reminders)
  • Preserves all logging and error recovery for troubleshooting
  • Updates runtime cache to latest version
  • Runs doctor health check

One-liner Install

Bash (Mac / Linux)

curl -fsSL https://gist.githubusercontent.com/dewdad/d60ef27605f6e7c8dfa590366e5d12b2/raw/optimize-omo.sh | bash

or with wget:

wget -qO- https://gist.githubusercontent.com/dewdad/d60ef27605f6e7c8dfa590366e5d12b2/raw/optimize-omo.sh | bash

PowerShell (Windows)

irm https://gist.githubusercontent.com/dewdad/d60ef27605f6e7c8dfa590366e5d12b2/raw/optimize-omo.ps1 | iex

What it does

Step Action
1 Sets OMO_SEND_ANONYMOUS_TELEMETRY=0 and OMO_DISABLE_POSTHOG=1 persistently
2 Adds disabled_hooks to oh-my-opencode.json (idempotent, won't duplicate)
3 Cleans stale .tmp files
4 Updates runtime cache to latest version via bun or npm
5 Runs oh-my-openagent doctor health check

Hooks disabled

Hook Why
auto-update-checker Periodic npm registry calls during sessions — adds latency
startup-toast Startup banner noise
agent-usage-reminder "Use explore/librarian instead" reminders in tool output

What's preserved

  • Internal log() diagnostics (viewable via opencode --debug)
  • Session recovery
  • All error recovery hooks (edit, JSON, delegate-task-retry, etc.)
  • Background notification
  • All agent orchestration functionality

Options

PowerShell

# Dry run (no changes written)
& ./optimize-omo.ps1 -DryRun

# Skip updating the runtime cache
& ./optimize-omo.ps1 -SkipUpdate

Bash

The bash script auto-detects:

  • Shell type (zsh, bash, fish) for correct profile file
  • Platform (macOS vs Linux) for sed compatibility
  • JSON tool (jq preferred, falls back to python3)

Prerequisites

  • opencode must be installed and initialized (run opencode once first)
  • npm or bun for cache updates
  • Bash script: jq or python3 for JSON manipulation
  • PowerShell script: PowerShell 5.1+ (built into Windows)

Idempotent

Safe to run multiple times. Existing hooks won't be duplicated, env vars are checked before writing.

<#
.SYNOPSIS
Optimize oh-my-openagent for efficiency — disable telemetry, reduce noise, keep diagnostics.
.DESCRIPTION
Applies best-practice configuration to an existing oh-my-openagent/oh-my-opencode installation:
- Disables PostHog telemetry (environment variables)
- Disables non-essential hooks (auto-update-checker, startup-toast, agent-usage-reminder)
- Updates runtime cache to latest version
- Cleans stale tmp files
- Runs doctor health check
.NOTES
One-liner: irm https://gist.githubusercontent.com/RAW_URL | iex
#>
param(
[switch]$SkipUpdate,
[switch]$DryRun
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
# --- Helpers ---
function Write-Step($msg) { Write-Host " [*] $msg" -ForegroundColor Cyan }
function Write-Ok($msg) { Write-Host " [+] $msg" -ForegroundColor Green }
function Write-Warn($msg) { Write-Host " [!] $msg" -ForegroundColor Yellow }
function Write-Err($msg) { Write-Host " [-] $msg" -ForegroundColor Red }
Write-Host ""
Write-Host " oh-my-openagent efficiency optimizer" -ForegroundColor Magenta
Write-Host " =====================================" -ForegroundColor DarkGray
Write-Host ""
# --- Locate config ---
$configDir = Join-Path $env:USERPROFILE ".config" "opencode"
$configFile = Join-Path $configDir "oh-my-opencode.json"
$cacheDir = Join-Path $env:USERPROFILE ".cache" "opencode"
if (-not (Test-Path $configDir)) {
Write-Err "OpenCode config directory not found: $configDir"
Write-Err "Is opencode installed? Run 'opencode' first to initialize."
exit 1
}
# --- 1. Environment variables (persistent user-level) ---
Write-Step "Setting telemetry opt-out environment variables..."
$envVars = @{
"OMO_SEND_ANONYMOUS_TELEMETRY" = "0"
"OMO_DISABLE_POSTHOG" = "1"
}
foreach ($kv in $envVars.GetEnumerator()) {
$current = [Environment]::GetEnvironmentVariable($kv.Key, "User")
if ($current -eq $kv.Value) {
Write-Ok "$($kv.Key) already set to $($kv.Value)"
} else {
if (-not $DryRun) {
[Environment]::SetEnvironmentVariable($kv.Key, $kv.Value, "User")
# Also set for current process
[Environment]::SetEnvironmentVariable($kv.Key, $kv.Value, "Process")
}
Write-Ok "$($kv.Key) = $($kv.Value) (persistent)"
}
}
# --- 2. Config file: add disabled_hooks ---
Write-Step "Configuring oh-my-opencode.json..."
$hooksToDisable = @("auto-update-checker", "startup-toast", "agent-usage-reminder")
if (Test-Path $configFile) {
$json = Get-Content $configFile -Raw | ConvertFrom-Json
# Ensure disabled_hooks exists
if (-not ($json.PSObject.Properties.Name -contains "disabled_hooks")) {
$json | Add-Member -NotePropertyName "disabled_hooks" -NotePropertyValue @()
}
# Merge hooks (don't duplicate)
$existing = @($json.disabled_hooks)
$added = @()
foreach ($hook in $hooksToDisable) {
if ($hook -notin $existing) {
$existing += $hook
$added += $hook
}
}
$json.disabled_hooks = $existing
if ($added.Count -gt 0) {
if (-not $DryRun) {
$json | ConvertTo-Json -Depth 10 | Set-Content $configFile -Encoding UTF8
}
Write-Ok "Added disabled_hooks: $($added -join ', ')"
} else {
Write-Ok "All hooks already disabled"
}
} else {
# Create minimal config
$newConfig = @{
'$schema' = "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json"
disabled_hooks = $hooksToDisable
agents = @{}
categories = @{}
}
if (-not $DryRun) {
$newConfig | ConvertTo-Json -Depth 10 | Set-Content $configFile -Encoding UTF8
}
Write-Ok "Created $configFile with disabled hooks"
}
# --- 3. Clean stale tmp files ---
Write-Step "Cleaning stale files..."
$tmpFiles = @(
(Join-Path $configDir "oh-my-openagent.json.tmp"),
(Join-Path $configDir "oh-my-opencode.json.tmp")
)
foreach ($f in $tmpFiles) {
if (Test-Path $f) {
if (-not $DryRun) { Remove-Item $f -Force }
Write-Ok "Removed $((Split-Path $f -Leaf))"
}
}
# --- 4. Update runtime cache ---
if (-not $SkipUpdate) {
Write-Step "Updating oh-my-opencode in runtime cache..."
if (Test-Path $cacheDir) {
if (-not $DryRun) {
$bunPath = Get-Command bun -ErrorAction SilentlyContinue
$npmPath = Get-Command npm -ErrorAction SilentlyContinue
if ($bunPath) {
Push-Location $cacheDir
& bun add oh-my-opencode@latest 2>&1 | Out-Null
Pop-Location
Write-Ok "Updated via bun"
} elseif ($npmPath) {
Push-Location $cacheDir
& npm install oh-my-opencode@latest 2>&1 | Out-Null
Pop-Location
Write-Ok "Updated via npm"
} else {
Write-Warn "Neither bun nor npm found — skipping cache update"
}
}
} else {
Write-Warn "Cache directory not found: $cacheDir (will update on next opencode launch)"
}
} else {
Write-Step "Skipping update (--SkipUpdate)"
}
# --- 5. Doctor check ---
Write-Step "Running health check..."
if (-not $DryRun) {
$npxPath = Get-Command npx -ErrorAction SilentlyContinue
if ($npxPath) {
Push-Location $configDir
& npx oh-my-openagent@latest doctor 2>&1 | ForEach-Object { Write-Host " $_" }
Pop-Location
} else {
Write-Warn "npx not found — skipping doctor"
}
}
# --- Summary ---
Write-Host ""
Write-Host " Done! Changes take effect on next opencode launch." -ForegroundColor Green
if ($DryRun) {
Write-Warn "DRY RUN — no changes were written"
}
Write-Host ""
#!/usr/bin/env bash
# optimize-omo.sh — Optimize oh-my-openagent for efficiency
# Disables telemetry, reduces noise, keeps diagnostics.
#
# One-liner install:
# curl -fsSL https://gist.githubusercontent.com/RAW_URL | bash
# wget -qO- https://gist.githubusercontent.com/RAW_URL | bash
set -euo pipefail
# --- Helpers ---
step() { printf ' \033[36m[*]\033[0m %s\n' "$1"; }
ok() { printf ' \033[32m[+]\033[0m %s\n' "$1"; }
warn() { printf ' \033[33m[!]\033[0m %s\n' "$1"; }
err() { printf ' \033[31m[-]\033[0m %s\n' "$1"; }
echo ""
printf ' \033[35moh-my-openagent efficiency optimizer\033[0m\n'
printf ' \033[90m=====================================\033[0m\n'
echo ""
# --- Detect OS ---
OS="$(uname -s)"
case "$OS" in
Darwin) PLATFORM="macos" ;;
Linux) PLATFORM="linux" ;;
*) err "Unsupported OS: $OS"; exit 1 ;;
esac
# --- Locate config ---
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/opencode"
CONFIG_FILE="$CONFIG_DIR/oh-my-opencode.json"
CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/opencode"
if [ ! -d "$CONFIG_DIR" ]; then
err "OpenCode config directory not found: $CONFIG_DIR"
err "Is opencode installed? Run 'opencode' first to initialize."
exit 1
fi
# --- 1. Environment variables ---
step "Setting telemetry opt-out environment variables..."
# Determine shell profile
SHELL_NAME="$(basename "${SHELL:-/bin/bash}")"
case "$SHELL_NAME" in
zsh) PROFILE="$HOME/.zshrc" ;;
bash)
if [ "$PLATFORM" = "macos" ]; then
PROFILE="$HOME/.bash_profile"
else
PROFILE="$HOME/.bashrc"
fi
;;
fish) PROFILE="$HOME/.config/fish/config.fish" ;;
*) PROFILE="$HOME/.profile" ;;
esac
set_env_var() {
local key="$1" val="$2"
# Set for current session
export "$key=$val"
# Check if already in profile
if [ -f "$PROFILE" ] && grep -q "^export ${key}=" "$PROFILE" 2>/dev/null; then
# Update existing
if [ "$PLATFORM" = "macos" ]; then
sed -i '' "s|^export ${key}=.*|export ${key}=\"${val}\"|" "$PROFILE"
else
sed -i "s|^export ${key}=.*|export ${key}=\"${val}\"|" "$PROFILE"
fi
ok "$key already in $PROFILE (updated)"
elif [ -f "$PROFILE" ] && [ "$SHELL_NAME" = "fish" ] && grep -q "^set -gx ${key}" "$PROFILE" 2>/dev/null; then
if [ "$PLATFORM" = "macos" ]; then
sed -i '' "s|^set -gx ${key}.*|set -gx ${key} \"${val}\"|" "$PROFILE"
else
sed -i "s|^set -gx ${key}.*|set -gx ${key} \"${val}\"|" "$PROFILE"
fi
ok "$key already in $PROFILE (updated)"
else
# Append
if [ "$SHELL_NAME" = "fish" ]; then
echo "set -gx ${key} \"${val}\"" >> "$PROFILE"
else
echo "export ${key}=\"${val}\"" >> "$PROFILE"
fi
ok "$key = $val (added to $PROFILE)"
fi
}
set_env_var "OMO_SEND_ANONYMOUS_TELEMETRY" "0"
set_env_var "OMO_DISABLE_POSTHOG" "1"
# --- 2. Config file: add disabled_hooks ---
step "Configuring oh-my-opencode.json..."
# We need jq or python3 for JSON manipulation
if command -v jq &>/dev/null; then
JSON_TOOL="jq"
elif command -v python3 &>/dev/null; then
JSON_TOOL="python3"
else
err "Neither jq nor python3 found. Install one to continue."
exit 1
fi
HOOKS_TO_DISABLE='["auto-update-checker","startup-toast","agent-usage-reminder"]'
if [ -f "$CONFIG_FILE" ]; then
if [ "$JSON_TOOL" = "jq" ]; then
# Merge disabled_hooks without duplicates
UPDATED=$(jq --argjson hooks "$HOOKS_TO_DISABLE" '
.disabled_hooks = ((.disabled_hooks // []) + $hooks | unique)
' "$CONFIG_FILE")
echo "$UPDATED" > "$CONFIG_FILE"
else
python3 -c "
import json, sys
hooks_to_add = $HOOKS_TO_DISABLE
with open('$CONFIG_FILE', 'r') as f:
config = json.load(f)
existing = config.get('disabled_hooks', [])
merged = list(dict.fromkeys(existing + hooks_to_add)) # unique, order preserved
config['disabled_hooks'] = merged
with open('$CONFIG_FILE', 'w') as f:
json.dump(config, f, indent=2)
f.write('\n')
"
fi
ok "disabled_hooks configured in $CONFIG_FILE"
else
# Create minimal config
if [ "$JSON_TOOL" = "jq" ]; then
jq -n --argjson hooks "$HOOKS_TO_DISABLE" '{
"$schema": "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json",
"disabled_hooks": $hooks,
"agents": {},
"categories": {}
}' > "$CONFIG_FILE"
else
python3 -c "
import json
config = {
'\$schema': 'https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json',
'disabled_hooks': $HOOKS_TO_DISABLE,
'agents': {},
'categories': {}
}
with open('$CONFIG_FILE', 'w') as f:
json.dump(config, f, indent=2)
f.write('\n')
"
fi
ok "Created $CONFIG_FILE with disabled hooks"
fi
# --- 3. Clean stale tmp files ---
step "Cleaning stale files..."
for tmp in "$CONFIG_DIR/oh-my-openagent.json.tmp" "$CONFIG_DIR/oh-my-opencode.json.tmp"; do
if [ -f "$tmp" ]; then
rm -f "$tmp"
ok "Removed $(basename "$tmp")"
fi
done
# --- 4. Update runtime cache ---
step "Updating oh-my-opencode in runtime cache..."
if [ -d "$CACHE_DIR" ]; then
if command -v bun &>/dev/null; then
(cd "$CACHE_DIR" && bun add oh-my-opencode@latest 2>/dev/null) && ok "Updated via bun" || warn "bun update failed (non-critical)"
elif command -v npm &>/dev/null; then
(cd "$CACHE_DIR" && npm install oh-my-opencode@latest 2>/dev/null) && ok "Updated via npm" || warn "npm update failed (non-critical)"
else
warn "Neither bun nor npm found — will update on next opencode launch"
fi
else
warn "Cache directory not found: $CACHE_DIR (will update on next opencode launch)"
fi
# --- 5. Doctor check ---
step "Running health check..."
if command -v npx &>/dev/null; then
(cd "$CONFIG_DIR" && npx oh-my-openagent@latest doctor 2>&1) | while IFS= read -r line; do
echo " $line"
done
else
warn "npx not found — skipping doctor"
fi
# --- Summary ---
echo ""
printf ' \033[32mDone! Changes take effect on next opencode launch.\033[0m\n'
printf ' \033[90mReload your shell or run: source %s\033[0m\n' "$PROFILE"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment