#!/bin/bash # ============================================================================= # omoa — Toggle oh-my-openagent plugin for OpenCode # ============================================================================= # # PURPOSE: # This script provides a simple way to enable or disable the oh-my-openagent # (omoa) plugin for OpenCode. oh-my-openagent is a third-party plugin that # adds multi-model orchestration, LSP tools, and other advanced features to # OpenCode. However, it can interfere with normal OpenCode operation, so it # needs to be toggled on/off as needed. # # CONTEXT: # - oh-my-openagent modifies the OpenCode config file (opencode.json) when # enabled, creating a backup first # - When disabled, the original config is restored from backup # - The OpenCode server and Telegram bot need to be restarted after toggling # # USAGE: # ./omoa.sh — Show current status # ./omoa.sh on — Enable oh-my-openagent # ./omoa.sh off — Disable oh-my-openagent (restore from backup) # ./omoa.sh status — Show current status (same as no args) # # TELEGRAM INTEGRATION: # This script is registered as an OpenCode skill in opencode.json under the # "skills" section. When the OpenCode Telegram bot is running, users can # invoke this via /commands → omoa_toggle in Telegram. # # UPSTREAM REPO: # https://git.hibbhome.com/Hibbhome/opencode-omoa-toggle # # KNOWN ISSUES (as of 2026-05-03): # - The omoa install command is fragile and may fail silently # - The --no-tui flag requires all options to be specified manually # - The script does not verify success before restarting services # - The enable/disable logic could be cleaner # - Needs overhaul to handle edge cases better # # AUTHOR: Kenny Hibbhome # CREATED: 2026-05-03 # ============================================================================= # --- Configuration --- # Path to the OpenCode configuration file CONFIG="/home/kenny/.config/opencode/opencode.json" # Marker string that indicates oh-my-openagent is enabled # oh-my-openagent adds this to the config when installed OMOA_MARKER="oh-my-openagent_enabled" # --- Functions --- # Show current status and usage show_status() { if grep -q "$OMOA_MARKER" "$CONFIG" 2>/dev/null; then echo "oh-my-openagent is currently ENABLED" echo "Run '$0 off' to disable" else echo "oh-my-openagent is currently DISABLED" echo "Run '$0 on' to enable" fi } # Disable oh-my-openagent by restoring from backup disable_omoa() { # Find the most recent backup file created by oh-my-openagent BACKUP=$(ls -t "$CONFIG".oh-my-openagent_enabled*.bak 2>/dev/null | head -1) if [ -n "$BACKUP" ]; then cp "$BACKUP" "$CONFIG" echo "oh-my-openagent DISABLED" echo "Restored from: $BACKUP" else echo "ERROR: No backup found. Cannot disable." echo "You may need to manually restore your opencode.json" return 1 fi } # Enable oh-my-openagent by running the installer enable_omoa() { # oh-my-openagent installer options: # --no-tui — Run non-interactively (required for scripts) # --skip-auth — Skip authentication setup (we handle auth separately) # --claude=no — Disable Claude provider (we use our own proxy) # --gemini=no — Disable Gemini provider # --copilot=no — Disable GitHub Copilot provider # # Note: These options are required because --no-tui mode demands all # options be specified. The values here match our current setup where # we use custom providers (Zen, Mimo, etc.) instead of the built-in ones. cd /home/kenny/.config/opencode && npx oh-my-openagent@latest install \ --no-tui \ --skip-auth \ --claude=no \ --gemini=no \ --copilot=no 2>&1 echo "oh-my-openagent ENABLED" } # --- Main Logic --- case "${1:-status}" in on|enable) enable_omoa ;; off|disable) disable_omoa ;; status|*) show_status ;; esac