Skip to content

Commit 7a6676d

Browse files
itdoveclaude
andauthored
feat(agent): add OpenCode agent support (#403)
- Add OpenCodeAgent class with XDG-compliant config paths and session management - Register opencode/opencode-ai backends in agent factory - Add OpenCode skill directory mappings (global and project-level) - Update config model, TUI, CLI, docs, and tests for OpenCode support 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent bbd4f13 commit 7a6676d

11 files changed

Lines changed: 966 additions & 42 deletions

File tree

devflow/agent/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Aider (experimental)
1313
- Continue (experimental)
1414
- Crush (experimental)
15+
- OpenCode (experimental)
1516
1617
Note: Only Claude Code and Ollama have been fully tested. Other agents are experimental implementations
1718
that may have limitations in session management, conversation export, and message counting.
@@ -26,6 +27,7 @@
2627
from devflow.agent.aider_agent import AiderAgent
2728
from devflow.agent.continue_agent import ContinueAgent
2829
from devflow.agent.crush_agent import CrushAgent
30+
from devflow.agent.opencode_agent import OpenCodeAgent
2931
from devflow.agent.factory import create_agent_client
3032

3133
__all__ = [
@@ -38,5 +40,6 @@
3840
"AiderAgent",
3941
"ContinueAgent",
4042
"CrushAgent",
43+
"OpenCodeAgent",
4144
"create_agent_client",
4245
]

devflow/agent/factory.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
from devflow.agent.aider_agent import AiderAgent
1818
from devflow.agent.continue_agent import ContinueAgent
1919
from devflow.agent.crush_agent import CrushAgent
20+
from devflow.agent.opencode_agent import OpenCodeAgent
2021

2122

2223
def create_agent_client(backend: str = "claude", agent_home: Optional[Path] = None) -> AgentInterface:
2324
"""Create an agent client for the specified backend.
2425
2526
Args:
26-
backend: Agent backend to use ("claude", "ollama", "github-copilot", "cursor", "windsurf", "aider", "continue", "crush")
27+
backend: Agent backend to use ("claude", "ollama", "github-copilot", "cursor", "windsurf", "aider", "continue", "crush", "opencode")
2728
agent_home: Optional custom home directory for the agent
2829
2930
Returns:
@@ -73,13 +74,18 @@ def create_agent_client(backend: str = "claude", agent_home: Optional[Path] = No
7374
>>> agent.get_agent_name()
7475
'crush'
7576
77+
>>> # Create OpenCode agent
78+
>>> agent = create_agent_client("opencode")
79+
>>> agent.get_agent_name()
80+
'opencode'
81+
7682
>>> # Create with custom home directory
7783
>>> agent = create_agent_client("claude", Path("/custom/path"))
7884
7985
Note:
8086
Only Claude Code and Ollama have been fully tested. Other agents (GitHub Copilot,
81-
Cursor, Windsurf, Aider, Continue, Crush) are experimental and may have limitations in
82-
session management, conversation export, and message counting capabilities.
87+
Cursor, Windsurf, Aider, Continue, Crush, OpenCode) are experimental and may have
88+
limitations in session management, conversation export, and message counting capabilities.
8389
"""
8490
backend = backend.lower()
8591

@@ -97,10 +103,12 @@ def create_agent_client(backend: str = "claude", agent_home: Optional[Path] = No
97103
return AiderAgent(aider_dir=agent_home)
98104
elif backend == "continue":
99105
return ContinueAgent(continue_dir=agent_home)
100-
elif backend in ("crush", "opencode"):
106+
elif backend == "crush":
101107
return CrushAgent(crush_dir=agent_home)
108+
elif backend in ("opencode", "opencode-ai"):
109+
return OpenCodeAgent(opencode_dir=agent_home)
102110
else:
103111
raise ValueError(
104112
f"Unsupported agent backend: {backend}. "
105-
f"Supported backends: claude, ollama, github-copilot, cursor, windsurf, aider, continue, crush"
113+
f"Supported backends: claude, ollama, github-copilot, cursor, windsurf, aider, continue, crush, opencode"
106114
)

0 commit comments

Comments
 (0)