import hud
from hud.agents import create_agent
from hud.tools.coding import EditTool, ShellTool
from hud.tools.filesystem import ReadTool, GrepTool, GlobTool, ListTool
# Create environment with all OpenCode tools
env = hud.Environment("my-opencode")
base = "./workspace"
# Coding tools
env.add_tool(ShellTool())
env.add_tool(EditTool())
# Filesystem exploration tools
env.add_tool(ReadTool(base_path=base))
env.add_tool(GrepTool(base_path=base))
env.add_tool(GlobTool(base_path=base))
env.add_tool(ListTool(base_path=base))
# Define scenario for evaluation
@env.scenario("coding_task")
async def coding_task(task: str):
yield f"""You are a skilled software developer. Complete the following task:
{task}
Available tools:
- `shell` - Run bash commands
- `str_replace_based_edit_tool` - Edit files using str_replace
- `read` - Read file contents with line numbers
- `grep` - Search file contents with regex
- `glob` - Find files by pattern
- `list` - List directory contents
Explore the codebase first using read/grep/glob/list, then make changes."""
yield 1.0
# Run with any model
agent = create_agent("gpt-4o")
async with hud.eval(env("coding_task", task="Fix the bug in main.py"), name="opencode-local") as ctx:
await agent.run(ctx, max_steps=30)