Initial commit: omoa toggle tool for OpenCode
This commit is contained in:
commit
858cb2ef5d
53
README.md
Normal file
53
README.md
Normal file
@ -0,0 +1,53 @@
|
||||
# OpenCode omoa Toggle
|
||||
|
||||
Toggle the [oh-my-openagent](https://github.com/code-yeongyu/oh-my-openagent) plugin for OpenCode.
|
||||
|
||||
## Purpose
|
||||
|
||||
oh-my-openagent adds multi-model orchestration, LSP tools, and other advanced features to OpenCode. However, it can interfere with normal operation. This tool provides a simple way to enable/disable it.
|
||||
|
||||
## Files
|
||||
|
||||
- `omoa.sh` — Shell script for direct use
|
||||
- `omoa.mjs` — OpenCode skill for integration with OpenCode sessions and Telegram bot
|
||||
|
||||
## Usage
|
||||
|
||||
### Shell Script
|
||||
|
||||
```bash
|
||||
./omoa.sh # Show status
|
||||
./omoa.sh on # Enable oh-my-openagent
|
||||
./omoa.sh off # Disable oh-my-openagent
|
||||
```
|
||||
|
||||
### OpenCode Skill
|
||||
|
||||
When registered in `opencode.json`, use `/commands` → `omoa_toggle` in OpenCode or Telegram.
|
||||
|
||||
## Installation
|
||||
|
||||
1. Copy `omoa.sh` and `omoa.mjs` to `/home/kenny/.config/opencode/skills/`
|
||||
2. Add to `opencode.json` under "skills":
|
||||
```json
|
||||
"omoa": {
|
||||
"description": "Toggle oh-my-openagent plugin on/off",
|
||||
"path": "/home/kenny/.config/opencode/skills/omoa.mjs"
|
||||
}
|
||||
```
|
||||
3. Restart OpenCode server
|
||||
|
||||
## Known Issues
|
||||
|
||||
- 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
|
||||
- Needs overhaul to handle edge cases better
|
||||
|
||||
## Author
|
||||
|
||||
Kenny Hibbhome
|
||||
|
||||
## Created
|
||||
|
||||
2026-05-03
|
||||
61
omoa.mjs
Normal file
61
omoa.mjs
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* omoa.mjs — OpenCode skill to toggle oh-my-openagent plugin
|
||||
*
|
||||
* PURPOSE:
|
||||
* Provides a skill interface for toggling the oh-my-openagent plugin
|
||||
* on/off from within OpenCode sessions or via the Telegram bot.
|
||||
*
|
||||
* USAGE:
|
||||
* In OpenCode or Telegram, use /commands → omoa_toggle
|
||||
* Actions: on, off, status
|
||||
*
|
||||
* UPSTREAM REPO:
|
||||
* https://git.hibbhome.com/Hibbhome/opencode-omoa-toggle
|
||||
*
|
||||
* SEE ALSO:
|
||||
* /home/kenny/.config/opencode/skills/omoa.sh — Shell script version
|
||||
*
|
||||
* AUTHOR: Kenny Hibbhome
|
||||
* CREATED: 2026-05-03
|
||||
*/
|
||||
|
||||
import { tool } from "@opencode-ai/plugin/tool";
|
||||
import { execSync } from "node:child_process";
|
||||
|
||||
export const OmoaPlugin = async (_ctx) => {
|
||||
return {
|
||||
tool: {
|
||||
omoa_toggle: tool({
|
||||
description: "Toggle oh-my-openagent plugin on or off",
|
||||
args: {
|
||||
action: tool.schema.enum(["on", "off", "status"]).describe("Action: on, off, or status"),
|
||||
},
|
||||
async execute(args) {
|
||||
const config = "/home/kenny/.config/opencode/opencode.json";
|
||||
const marker = "oh-my-openagent_enabled";
|
||||
|
||||
if (args.action === "status") {
|
||||
const check = execSync(`grep -c "${marker}" ${config} 2>/dev/null || echo 0`).toString().trim();
|
||||
return check === "0" ? "oh-my-openagent is DISABLED" : "oh-my-openagent is ENABLED";
|
||||
}
|
||||
|
||||
if (args.action === "off") {
|
||||
const backup = execSync(`ls -t ${config}.oh-my-openagent_enabled*.bak 2>/dev/null | head -1`).toString().trim();
|
||||
if (backup) {
|
||||
execSync(`cp "${backup}" ${config}`);
|
||||
return "oh-my-openagent DISABLED";
|
||||
}
|
||||
return "No backup found";
|
||||
}
|
||||
|
||||
if (args.action === "on") {
|
||||
execSync(`cd /home/kenny/.config/opencode && npx oh-my-openagent@latest install --no-tui --skip-auth --claude=no --gemini=no --copilot=no 2>&1`);
|
||||
return "oh-my-openagent ENABLED";
|
||||
}
|
||||
|
||||
return "Invalid action";
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
};
|
||||
116
omoa.sh
Executable file
116
omoa.sh
Executable file
@ -0,0 +1,116 @@
|
||||
#!/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
|
||||
Loading…
x
Reference in New Issue
Block a user