Consolidate omoa skills into single unified skill
This commit is contained in:
parent
8a1fcc67c8
commit
66e5330e96
18
README.md
18
README.md
@ -23,7 +23,7 @@ This approach:
|
|||||||
- `omoa` — CLI command to toggle omoa on/off
|
- `omoa` — CLI command to toggle omoa on/off
|
||||||
- `opencode-start.sh` — Wrapper script that starts OpenCode with/without omoa
|
- `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-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
|
- `git-ops.mjs` — OpenCode skill for git operations with Hibbhome Gitea server
|
||||||
- `opencode-setup.mjs` — OpenCode skill documenting the full system architecture
|
- `opencode-setup.mjs` — OpenCode skill documenting the full system architecture
|
||||||
- `README.md` — This file
|
- `README.md` — This file
|
||||||
@ -51,9 +51,9 @@ This approach:
|
|||||||
5. Add skill to `opencode.json`:
|
5. Add skill to `opencode.json`:
|
||||||
```json
|
```json
|
||||||
"skills": {
|
"skills": {
|
||||||
"omoa-toggle": {
|
"omoa": {
|
||||||
"description": "Toggle oh-my-openagent on/off",
|
"description": "Manage oh-my-openagent (toggle, status, post-upgrade)",
|
||||||
"path": "/home/kenny/.config/opencode/skills/omoa-toggle.mjs"
|
"path": "/home/kenny/.config/opencode/skills/omoa.mjs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -85,10 +85,12 @@ omoa-post-upgrade
|
|||||||
|
|
||||||
### Telegram Bot
|
### Telegram Bot
|
||||||
|
|
||||||
Use `/commands` → `omoa_toggle`:
|
Use `/commands` → `omoa`:
|
||||||
- `on` — Enable omoa (creates state file, restarts server)
|
- `omoa_status` — Check if omoa is enabled
|
||||||
- `off` — Disable omoa (deletes state file, restarts server)
|
- `omoa_enable` — Enable omoa
|
||||||
- `status` — Check if omoa is enabled
|
- `omoa_disable` — Disable omoa
|
||||||
|
- `omoa_toggle` — Toggle omoa on/off
|
||||||
|
- `omoa_post_upgrade` — Clean opencode.json after upstream install
|
||||||
|
|
||||||
### After Upstream Updates
|
### After Upstream Updates
|
||||||
|
|
||||||
|
|||||||
@ -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}`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
153
omoa.mjs
153
omoa.mjs
@ -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:
|
* PURPOSE:
|
||||||
* Provides a skill interface for toggling the oh-my-openagent plugin
|
* Single skill to manage oh-my-openagent from within OpenCode sessions.
|
||||||
* on/off from within OpenCode sessions or via the Telegram bot.
|
* 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:
|
* USAGE:
|
||||||
* In OpenCode or Telegram, use /commands → omoa_toggle
|
* skill("omoa") — Load this skill
|
||||||
* Actions: on, off, status
|
* 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:
|
* UPSTREAM REPO:
|
||||||
* https://git.hibbhome.com/Hibbhome/opencode-omoa-toggle
|
* 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
|
* CREATED: 2026-05-03
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { tool } from "@opencode-ai/plugin/tool";
|
import { tool } from "@opencode-ai/plugin/tool";
|
||||||
import { execSync } from "node:child_process";
|
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) => {
|
export const OmoaPlugin = async (_ctx) => {
|
||||||
return {
|
return {
|
||||||
tool: {
|
tool: {
|
||||||
omoa_toggle: tool({
|
/**
|
||||||
description: "Toggle oh-my-openagent plugin on or off",
|
* Check if omoa is enabled
|
||||||
args: {
|
*/
|
||||||
action: tool.schema.enum(["on", "off", "status"]).describe("Action: on, off, or status"),
|
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();
|
* Enable omoa
|
||||||
return check === "0" ? "oh-my-openagent is DISABLED" : "oh-my-openagent is ENABLED";
|
*/
|
||||||
|
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}`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
execSync("systemctl --user restart opencode-serve.service");
|
||||||
|
return "oh-my-openagent DISABLED. Server restarting...";
|
||||||
|
} catch (err) {
|
||||||
|
return `Error: ${err.message}`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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}`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.action === "off") {
|
const original = [...config.plugin];
|
||||||
const backup = execSync(`ls -t ${config}.oh-my-openagent_enabled*.bak 2>/dev/null | head -1`).toString().trim();
|
config.plugin = config.plugin.filter(p => !p.includes("oh-my-openagent"));
|
||||||
if (backup) {
|
|
||||||
execSync(`cp "${backup}" ${config}`);
|
if (original.length === config.plugin.length) {
|
||||||
return "oh-my-openagent DISABLED";
|
return "oh-my-openagent not found in opencode.json — no changes needed";
|
||||||
}
|
|
||||||
return "No backup found";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.action === "on") {
|
writeSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
||||||
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 `Removed oh-my-openagent from opencode.json (${original.length} → ${config.plugin.length} plugins)`;
|
||||||
return "oh-my-openagent ENABLED";
|
} catch (err) {
|
||||||
|
return `Error: ${err.message}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Invalid action";
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user