#!/bin/bash # ============================================================================= # omoa-post-upgrade.sh — Clean oh-my-openagent plugin from opencode.json # ============================================================================= # # PURPOSE: # After running the upstream oh-my-openagent install script, this script # removes the plugin entry from opencode.json. This keeps the config clean # so that omoa can be injected at runtime via OPENCODE_CONFIG_CONTENT. # # WHY THIS EXISTS: # The upstream install script adds "oh-my-openagent@latest" to the plugin # array in opencode.json. This conflicts with our runtime injection approach # because: # - If the plugin is in both opencode.json AND OPENCODE_CONFIG_CONTENT, # it may be loaded twice # - Our toggle approach uses OPENCODE_CONFIG_CONTENT to inject the plugin # only when needed, so the config file should stay clean # # USAGE: # ./omoa-post-upgrade.sh — Remove omoa plugin from opencode.json # # WHEN TO RUN: # After running: npx oh-my-openagent@latest install # This script is idempotent — safe to run multiple times # # UPSTREAM REPO: # https://git.hibbhome.com/Hibbhome/opencode-omoa-toggle # # CREATED: 2026-05-03 # ============================================================================= CONFIG_FILE="$HOME/.config/opencode/opencode.json" # Use python3 to remove oh-my-openagent from the plugin array python3 -c " import json with open('$CONFIG_FILE', 'r') as f: config = json.load(f) # Remove oh-my-openagent from plugin array if present if 'plugin' in config: original = config['plugin'][:] config['plugin'] = [p for p in config['plugin'] if 'oh-my-openagent' not in p] if original != config['plugin']: with open('$CONFIG_FILE', 'w') as f: json.dump(config, f, indent=2) print('Removed oh-my-openagent from opencode.json') else: print('oh-my-openagent not found in opencode.json — no changes needed') else: print('No plugin array in opencode.json — no changes needed') "