62 lines
2.0 KiB
JavaScript
62 lines
2.0 KiB
JavaScript
/**
|
|
* 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";
|
|
},
|
|
}),
|
|
},
|
|
};
|
|
};
|