Consolidate omoa skills into single unified skill

This commit is contained in:
Twentyninehairs_bot 2026-05-03 22:05:15 -07:00
parent 8a1fcc67c8
commit 66e5330e96
Signed by: Twentyninehairs_bot
GPG Key ID: CC558AA42F05E387
3 changed files with 130 additions and 123 deletions

View File

@ -23,7 +23,7 @@ This approach:
- `omoa` — CLI command to toggle omoa on/off
- `opencode-start.sh` — Wrapper script that starts OpenCode with/without omoa
- `omoa-post-upgrade.sh` — Removes omoa plugin from `opencode.json` after upstream install
- `omoa-toggle.mjs` — OpenCode skill for Telegram bot integration
- `omoa.mjs` — Unified OpenCode skill for all omoa operations (toggle, status, post-upgrade)
- `git-ops.mjs` — OpenCode skill for git operations with Hibbhome Gitea server
- `opencode-setup.mjs` — OpenCode skill documenting the full system architecture
- `README.md` — This file
@ -51,9 +51,9 @@ This approach:
5. Add skill to `opencode.json`:
```json
"skills": {
"omoa-toggle": {
"description": "Toggle oh-my-openagent on/off",
"path": "/home/kenny/.config/opencode/skills/omoa-toggle.mjs"
"omoa": {
"description": "Manage oh-my-openagent (toggle, status, post-upgrade)",
"path": "/home/kenny/.config/opencode/skills/omoa.mjs"
}
}
```
@ -85,10 +85,12 @@ omoa-post-upgrade
### Telegram Bot
Use `/commands``omoa_toggle`:
- `on` — Enable omoa (creates state file, restarts server)
- `off` — Disable omoa (deletes state file, restarts server)
- `status` — Check if omoa is enabled
Use `/commands``omoa`:
- `omoa_status` — Check if omoa is enabled
- `omoa_enable` — Enable omoa
- `omoa_disable` — Disable omoa
- `omoa_toggle` — Toggle omoa on/off
- `omoa_post_upgrade` — Clean opencode.json after upstream install
### After Upstream Updates

View File

@ -1,86 +0,0 @@
/**
* omoa-toggle.mjs OpenCode skill to toggle oh-my-openagent on/off
*
* PURPOSE:
* Provides a single Telegram command to toggle oh-my-openagent on/off.
* Creates or deletes a state file, then restarts the OpenCode server.
*
* HOW IT WORKS:
* - State file: ~/.config/opencode/omoa-enabled
* - If state file exists omoa is enabled
* - If state file does not exist omoa is disabled
* - The opencode-start.sh script checks for this state file at startup
* - If present, it injects omoa via OPENCODE_CONFIG_CONTENT
* - If absent, it starts OpenCode vanilla (no omoa)
*
* USAGE:
* In Telegram: /commands omoa_toggle
* Actions:
* - on: Create state file, restart server (enables omoa)
* - off: Delete state file, restart server (disables omoa)
* - status: Check if state file exists
*
* UPSTREAM COMPATIBILITY:
* This approach does NOT modify opencode.json directly.
* The upstream install script can run safely use omoa-post-upgrade.sh
* to clean the plugin entry from opencode.json after running the installer.
*
* UPSTREAM REPO:
* https://git.hibbhome.com/Hibbhome/opencode-omoa-toggle
*
* CREATED: 2026-05-03
*/
import { tool } from "@opencode-ai/plugin/tool";
import { execSync } from "node:child_process";
import { existsSync, writeFileSync, unlinkSync } from "node:fs";
const STATE_FILE = "/home/kenny/.config/opencode/omoa-enabled";
export const OmoaTogglePlugin = async (_ctx) => {
return {
tool: {
omoa_toggle: tool({
description: "Toggle oh-my-openagent on or off",
args: {
action: tool.schema.enum(["on", "off", "status"]).describe("Action: on, off, or status"),
},
async execute(args) {
try {
if (args.action === "status") {
return existsSync(STATE_FILE)
? "oh-my-openagent is ENABLED (state file exists)"
: "oh-my-openagent is DISABLED (no state file)";
}
if (args.action === "on") {
// Create state file to enable omoa
writeFileSync(STATE_FILE, new Date().toISOString());
// Restart the OpenCode server
execSync("systemctl --user restart opencode-serve.service");
return "oh-my-openagent ENABLED. Server restarting...";
}
if (args.action === "off") {
// Delete state file to disable omoa
if (existsSync(STATE_FILE)) {
unlinkSync(STATE_FILE);
}
// Restart the OpenCode server
execSync("systemctl --user restart opencode-serve.service");
return "oh-my-openagent DISABLED. Server restarting...";
}
return "Invalid action. Use: on, off, or status";
} catch (err) {
return `Error: ${err.message}`;
}
},
}),
},
};
};

149
omoa.mjs
View File

@ -1,59 +1,150 @@
/**
* omoa.mjs OpenCode skill to toggle oh-my-openagent plugin
* omoa.mjs Unified OpenCode skill for oh-my-openagent management
*
* PURPOSE:
* Provides a skill interface for toggling the oh-my-openagent plugin
* on/off from within OpenCode sessions or via the Telegram bot.
* Single skill to manage oh-my-openagent from within OpenCode sessions.
* Combines toggle, status, and post-upgrade cleanup into one interface.
*
* STATE FILE:
* ~/.config/opencode/omoa-enabled
* - If this file exists, omoa is enabled
* - If this file does not exist, omoa is disabled
*
* HOW IT WORKS:
* - Toggle: Creates/deletes state file, restarts server
* - Status: Checks if state file exists
* - Post-upgrade: Removes omoa plugin from opencode.json after upstream install
* - The opencode-start.sh script checks for state file at startup
* - If present, injects omoa via OPENCODE_CONFIG_CONTENT
*
* USAGE:
* In OpenCode or Telegram, use /commands omoa_toggle
* Actions: on, off, status
* skill("omoa") Load this skill
* Then use the helper functions:
* - omoa_status: Check if omoa is enabled
* - omoa_enable: Enable omoa (create state file, restart server)
* - omoa_disable: Disable omoa (delete state file, restart server)
* - omoa_toggle: Toggle omoa on/off
* - omoa_post_upgrade: Clean opencode.json after upstream install
*
* CLI EQUIVALENT:
* omoa [on|off|status|toggle]
* omoa-post-upgrade
*
* 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";
import { existsSync, writeFileSync, unlinkSync, readFileSync, writeFileSync as writeSync } from "node:fs";
const STATE_FILE = "/home/kenny/.config/opencode/omoa-enabled";
const CONFIG_FILE = "/home/kenny/.config/opencode/opencode.json";
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"),
/**
* Check if omoa is enabled
*/
omoa_status: tool({
description: "Check if oh-my-openagent is enabled",
args: {},
async execute() {
const enabled = existsSync(STATE_FILE);
return enabled
? "oh-my-openagent is ENABLED (state file exists)"
: "oh-my-openagent is DISABLED (no state file)";
},
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";
/**
* Enable omoa
*/
omoa_enable: tool({
description: "Enable oh-my-openagent (create state file, restart server)",
args: {},
async execute() {
try {
writeFileSync(STATE_FILE, new Date().toISOString());
execSync("systemctl --user restart opencode-serve.service");
return "oh-my-openagent ENABLED. Server restarting...";
} catch (err) {
return `Error: ${err.message}`;
}
},
}),
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";
/**
* Disable omoa
*/
omoa_disable: tool({
description: "Disable oh-my-openagent (delete state file, restart server)",
args: {},
async execute() {
try {
if (existsSync(STATE_FILE)) {
unlinkSync(STATE_FILE);
}
return "No backup found";
execSync("systemctl --user restart opencode-serve.service");
return "oh-my-openagent DISABLED. Server restarting...";
} catch (err) {
return `Error: ${err.message}`;
}
},
}),
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";
/**
* Toggle omoa on/off
*/
omoa_toggle: tool({
description: "Toggle oh-my-openagent on/off",
args: {},
async execute() {
try {
if (existsSync(STATE_FILE)) {
unlinkSync(STATE_FILE);
execSync("systemctl --user restart opencode-serve.service");
return "oh-my-openagent DISABLED. Server restarting...";
} else {
writeFileSync(STATE_FILE, new Date().toISOString());
execSync("systemctl --user restart opencode-serve.service");
return "oh-my-openagent ENABLED. Server restarting...";
}
} catch (err) {
return `Error: ${err.message}`;
}
},
}),
return "Invalid action";
/**
* Post-upgrade cleanup
*/
omoa_post_upgrade: tool({
description: "Remove oh-my-openagent plugin from opencode.json after upstream install",
args: {},
async execute() {
try {
const config = JSON.parse(readFileSync(CONFIG_FILE, "utf-8"));
if (!config.plugin || !Array.isArray(config.plugin)) {
return "No plugin array in opencode.json — no changes needed";
}
const original = [...config.plugin];
config.plugin = config.plugin.filter(p => !p.includes("oh-my-openagent"));
if (original.length === config.plugin.length) {
return "oh-my-openagent not found in opencode.json — no changes needed";
}
writeSync(CONFIG_FILE, JSON.stringify(config, null, 2));
return `Removed oh-my-openagent from opencode.json (${original.length}${config.plugin.length} plugins)`;
} catch (err) {
return `Error: ${err.message}`;
}
},
}),
},