feat(agents): make OmO default agent via build name hack
- Set build agent's display name to 'OmO' (keeps builtIn: true priority) - Add OmO as subagent (actual execution target when selected) - Remove explicit tools list from OmO agent (inherit all) - Rename omo_agent.disable_build to omo_agent.disabled This hack works around OpenCode's agent selection by key name. TODO: Use config.default_agent when PR #5313 is released. 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
33
src/index.ts
33
src/index.ts
@@ -279,15 +279,32 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
||||
const userAgents = (pluginConfig.claude_code?.agents ?? true) ? loadUserAgents() : {};
|
||||
const projectAgents = (pluginConfig.claude_code?.agents ?? true) ? loadProjectAgents() : {};
|
||||
|
||||
const shouldHideBuild = pluginConfig.omo_agent?.disable_build !== false;
|
||||
const isOmoEnabled = pluginConfig.omo_agent?.disabled !== true;
|
||||
|
||||
config.agent = {
|
||||
...builtinAgents,
|
||||
...userAgents,
|
||||
...projectAgents,
|
||||
...config.agent,
|
||||
...(shouldHideBuild ? { build: { mode: "subagent" } } : {}),
|
||||
};
|
||||
if (isOmoEnabled && builtinAgents.OmO) {
|
||||
// TODO: When OpenCode releases `default_agent` config option (PR #5313),
|
||||
// remove this hack and use `config.default_agent = "OmO"` instead.
|
||||
// This hack works by:
|
||||
// 1. Setting build agent's display name to "OmO" (builtIn: true, appears first in TUI)
|
||||
// 2. Adding OmO as a subagent (actual execution target when "OmO" is selected)
|
||||
// Tracking: https://github.com/sst/opencode/pull/5313
|
||||
const { OmO: omoConfig, ...restAgents } = builtinAgents;
|
||||
config.agent = {
|
||||
...restAgents,
|
||||
...userAgents,
|
||||
...projectAgents,
|
||||
...config.agent,
|
||||
build: { ...omoConfig, name: "OmO" },
|
||||
OmO: { ...omoConfig, mode: "subagent" },
|
||||
};
|
||||
} else {
|
||||
config.agent = {
|
||||
...builtinAgents,
|
||||
...userAgents,
|
||||
...projectAgents,
|
||||
...config.agent,
|
||||
};
|
||||
}
|
||||
|
||||
config.tools = {
|
||||
...config.tools,
|
||||
|
||||
Reference in New Issue
Block a user