Load agents from OpenCode config files instead of VS Code settings - #7
Merged
Merged
Conversation
…ttings The agent registry now reads agent definitions from the workspace's opencode.json/opencode.jsonc and .opencode/agents/ markdown files, matching the same config sources the OpenCode CLI itself uses. This removes the need for the duplicate opencode-devcontainer.agents and opencode-devcontainer.defaultAgent VS Code settings. https://claude.ai/code/session_01BCbPTVpavaPCg2iYsCizE6
Users can now set opencode-devcontainer.opencodeConfigPath in VS Code settings to point to their opencode.json (supports ~ expansion and direct file paths). When empty, the extension searches the workspace root then ~/.config/opencode/ — matching OpenCode's own search order. The AgentRegistry also reloads when this setting changes. https://claude.ai/code/session_01BCbPTVpavaPCg2iYsCizE6
Add documentation for: chat participant (@OpenCode) with all slash commands, subagent activity tree view, agent configuration from opencode.json (search order, config format, markdown agents, built-in agents, auto-reload), opencodeConfigPath setting, chat display settings, and development scripts. https://claude.ai/code/session_01BCbPTVpavaPCg2iYsCizE6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors agent configuration to read directly from OpenCode configuration files (
opencode.json/opencode.jsonc) instead of VS Code settings. The extension now searches for config in the same locations as the OpenCode CLI: explicit path → workspace root →~/.config/opencode/. It also discovers markdown-based agents from.opencode/agents/directories and provides built-in fallback agents (build, plan).Key Changes
New
opencodeConfigReadermodule — Implements config file discovery and parsing:resolveConfigSearchPaths()— Builds ordered search paths with~expansionreadOpenCodeConfig()— Reads and parsesopencode.json/opencode.jsoncwith JSONC comment strippingreadMarkdownAgents()— Discovers markdown-based agents from.opencode/agents/loadAgentsFromOpenCodeConfig()— Orchestrates loading from all sources with proper precedenceUpdated
AgentRegistry— Now loads agents from OpenCode config files:opencodeConfigPathVS Code setting (new), workspace root, or global~/.config/opencode/opencode.json/opencode.jsoncfiles and auto-reloadsAgent configuration enhancements:
modefield toAgentConfigto distinguish primary agents from subagentsprovider/modelformat (e.g.,anthropic/claude-sonnet-4-20250514)Updated chat participant —
/agentscommand now groups agents by primary vs. subagent and shows they're loaded from config filesDocumentation — Expanded README with agent configuration guide, search order, config file format examples, and markdown agent discovery
Settings changes:
opencode-devcontainer.opencodeConfigPathsetting for explicit config pathopencode-devcontainer.agentsandopencode-devcontainer.defaultAgentsettings (now read from config files)Implementation Details
//) and block comments (/* */) before JSON parsing/default toprovider: "unknown".md) as ID and first non-empty line as descriptionhttps://claude.ai/code/session_01BCbPTVpavaPCg2iYsCizE6