From 22acb0def102ce78df1e485a31b2d2244ba3085d Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Fri, 5 Dec 2025 02:32:33 +0900 Subject: [PATCH] feat(agents): add agent override configuration support - Add AgentName, AgentOverrideConfig, AgentOverrides types - Implement createBuiltinAgents with disabled_agents and overrides support - Support oh-my-opencode.json config for: - disabled_agents: disable specific built-in agents - agents: override model, temperature, tools, permission per agent - Tools and permission objects are shallow-merged with base config - Export types for external consumers - Update README with agent override documentation --- README.en.md | 36 +++++++++++++++++++++++++---- src/agents/index.ts | 3 +++ src/agents/types.ts | 12 ++++++++++ src/agents/utils.ts | 55 +++++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 14 ++++++++++-- 5 files changed, 114 insertions(+), 6 deletions(-) create mode 100644 src/agents/types.ts create mode 100644 src/agents/utils.ts diff --git a/README.en.md b/README.en.md index fcae1c6..012bf9b 100644 --- a/README.en.md +++ b/README.en.md @@ -5,6 +5,7 @@ English | [한국어](README.ko.md) - [Oh My OpenCode](#oh-my-opencode) - [Installation](#installation) - [Configuration](#configuration) + - [Disable specific MCPs](#disable-specific-mcps) - [TL;DR](#tldr) - [Why OpenCode \& Why Oh My OpenCode](#why-opencode--why-oh-my-opencode) - [Features](#features) @@ -58,6 +59,36 @@ If you want to disable specific built-in MCPs, you can use the `disabled_mcps` o } ``` +### Disable specific Agents + +If you want to disable specific built-in agents, you can use the `disabled_agents` option. +Available agents: `oracle`, `librarian`, `explore`, `frontend-ui-ux-engineer`, `document-writer` + +```json +{ + "disabled_agents": ["oracle", "librarian"] +} +``` + +### Override Agents + +You can override the configuration of built-in agents using the `agents` option. +Overridable properties: `model`, `temperature`, `tools`, `permission`, `color`, `disable`, `mode`. + +```json +{ + "agents": { + "oracle": { + "model": "anthropic/claude-3-7-sonnet-20250219", + "temperature": 0.5 + }, + "frontend-ui-ux-engineer": { + "tools": ["playwright_browser_take_screenshot"] + } + } +} +``` + ## TL;DR - **Model Setup Required** @@ -163,11 +194,8 @@ If this sounds arrogant and you have a superior solution, send a PR. You are wel As of now, I have no affiliation with any of the projects or models mentioned here. This plugin is purely based on personal experimentation and preference. +I constructed 99% of this project using OpenCode. I focused on functional verification. This documentation has been personally reviewed and comprehensively rewritten, so you can rely on it with confidence. ## Warnings - If you are on [1.0.132](https://github.com/sst/opencode/releases/tag/v1.0.132) or lower, OpenCode has a bug that might break config. - [The fix](https://github.com/sst/opencode/pull/5040) was merged after 1.0.132, so use a newer version. - -- I constructed 99% of this project using OpenCode. I focused on functional verification. This documentation has been personally reviewed and comprehensively rewritten, so you can rely on it with confidence. - - diff --git a/src/agents/index.ts b/src/agents/index.ts index c85c565..b4eaf5a 100644 --- a/src/agents/index.ts +++ b/src/agents/index.ts @@ -12,3 +12,6 @@ export const builtinAgents: Record = { "frontend-ui-ux-engineer": frontendUiUxEngineerAgent, "document-writer": documentWriterAgent, } + +export * from "./types" +export { createBuiltinAgents } from "./utils" diff --git a/src/agents/types.ts b/src/agents/types.ts new file mode 100644 index 0000000..7e338e8 --- /dev/null +++ b/src/agents/types.ts @@ -0,0 +1,12 @@ +import type { AgentConfig } from "@opencode-ai/sdk" + +export type AgentName = + | "oracle" + | "librarian" + | "explore" + | "frontend-ui-ux-engineer" + | "document-writer" + +export type AgentOverrideConfig = Partial + +export type AgentOverrides = Partial> diff --git a/src/agents/utils.ts b/src/agents/utils.ts new file mode 100644 index 0000000..f0d3519 --- /dev/null +++ b/src/agents/utils.ts @@ -0,0 +1,55 @@ +import type { AgentConfig } from "@opencode-ai/sdk" +import type { AgentName, AgentOverrideConfig, AgentOverrides } from "./types" +import { oracleAgent } from "./oracle" +import { librarianAgent } from "./librarian" +import { exploreAgent } from "./explore" +import { frontendUiUxEngineerAgent } from "./frontend-ui-ux-engineer" +import { documentWriterAgent } from "./document-writer" + +const allBuiltinAgents: Record = { + oracle: oracleAgent, + librarian: librarianAgent, + explore: exploreAgent, + "frontend-ui-ux-engineer": frontendUiUxEngineerAgent, + "document-writer": documentWriterAgent, +} + +function mergeAgentConfig( + base: AgentConfig, + override: AgentOverrideConfig +): AgentConfig { + return { + ...base, + ...override, + tools: override.tools !== undefined + ? { ...(base.tools ?? {}), ...override.tools } + : base.tools, + permission: override.permission !== undefined + ? { ...(base.permission ?? {}), ...override.permission } + : base.permission, + } +} + +export function createBuiltinAgents( + disabledAgents: AgentName[] = [], + agentOverrides: AgentOverrides = {} +): Record { + const result: Record = {} + + for (const [name, config] of Object.entries(allBuiltinAgents)) { + const agentName = name as AgentName + + if (disabledAgents.includes(agentName)) { + continue + } + + const override = agentOverrides[agentName] + if (override) { + result[name] = mergeAgentConfig(config, override) + } else { + result[name] = config + } + } + + return result +} diff --git a/src/index.ts b/src/index.ts index 8bca4c2..8d2ab58 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import type { Plugin } from "@opencode-ai/plugin" -import { builtinAgents } from "./agents" +import { createBuiltinAgents, type AgentName, type AgentOverrides } from "./agents" import { createTodoContinuationEnforcer, createContextWindowMonitorHook, createSessionRecoveryHook } from "./hooks" import { updateTerminalTitle } from "./features/terminal" import { builtinTools } from "./tools" @@ -9,6 +9,8 @@ import * as path from "path" interface OhMyOpenCodeConfig { disabled_mcps?: McpName[] + disabled_agents?: AgentName[] + agents?: AgentOverrides } function loadPluginConfig(directory: string): OhMyOpenCodeConfig { @@ -48,9 +50,14 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => { tool: builtinTools, config: async (config) => { + const agents = createBuiltinAgents( + pluginConfig.disabled_agents, + pluginConfig.agents + ) + config.agent = { ...config.agent, - ...builtinAgents, + ...agents, } config.tools = { ...config.tools, @@ -176,3 +183,6 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => { } export default OhMyOpenCodePlugin + +export type { AgentName, AgentOverrideConfig, AgentOverrides } from "./agents" +export type { McpName } from "./mcp"