← 返回
未分类

OpenCode Game Builder

Spawn OpenCode as an ACP (Agent Client Protocol) subagent for complex coding tasks. Use when building games, web apps, multi-file projects, or when the user...
jadegaul
未分类 clawhub v1.0.0 100000 Key: 无需
★ 0
Stars
📥 346
下载
💾 0
安装

概述

OpenCode

Overview

OpenCode is an open-source AI coding agent that integrates with OpenClaw via ACP (Agent Client Protocol). It provides specialized coding capabilities including game development, multi-file projects, complex refactoring, and production-ready code generation.

Status: ✅ Fully tested - Built 12 production-ready games including Pac-Man, Space Invaders, Tetris, Q*bert, and more.

When to Use This Skill

Use OpenCode when:

  1. Building games (HTML5 Canvas games work excellently)
  2. Creating multi-file projects from scratch
  3. Performing complex code refactoring across multiple files
  4. Building production-ready applications with proper structure
  5. Tasks requiring dedicated coding agent focus
  6. The user explicitly asks to use OpenCode

Quick Start

Spawn OpenCode as ACP Subagent

// One-shot task (recommended for most builds)
sessions_spawn({
  runtime: "acp",
  agentId: "opencode",
  task: "Create a complete [game/app] in HTML/CSS/JavaScript...",
  mode: "run",
  cwd: "/path/to/project"
})

// Parallel builds (run multiple simultaneously)
sessions_spawn({...}) // Game 1
sessions_spawn({...}) // Game 2  
sessions_spawn({...}) // Game 3

Parallel Builds

OpenCode supports parallel execution - spawn multiple subagents simultaneously:

// Launch 3 games at once
const game1 = sessions_spawn({... Asteroids ...})
const game2 = sessions_spawn({... Doodle Jump ...})
const game3 = sessions_spawn({... Flappy Bird ...})

// All build concurrently, limited by slowest

Performance: 3 parallel games completed in ~1m 20s (same as single game)

Performance Expectations

Based on 12-game test suite:

ComplexityExamplesBuild TimeLines
-----------------------------------------
SimplePong, Flappy Bird30-60s300-600
MediumSnake, 2048, Breakout1m - 1m 30s500-800
ComplexPac-Man, Q*bert, Tetris1m 30s - 2m+1000-1300

Proven Game Templates

The following game types have been fully tested and verified:

GameKey FeaturesTest Result
---------------------------------
TetrisGhost piece, hold, preview, levels✅ Complete
Pac-Man4 AI ghosts, maze, power pellets✅ Complete
Space InvadersEnemy formation, bunkers, UFO✅ Complete
SnakeGrid movement, progressive speed✅ Complete
PongAI opponent, physics✅ Complete
BreakoutMulti-level, power-ups✅ Complete
2048Merge algorithm, undo, swipe✅ Complete
MinesweeperFlood-fill, 3 difficulties✅ Complete
Q*bertIsometric, pyramid, enemies✅ Complete (fixed spawn)
AsteroidsVector physics, screen wrap✅ Complete
Flappy BirdGravity, pipes, medals✅ Complete
Doodle JumpBouncing, power-ups, black holes✅ Complete (fixed spawn)

Commands Reference

Core Commands

CommandDescription
----------------------
opencodeStart interactive TUI
opencode run Run non-interactive mode
opencode acpStart ACP server (for OpenClaw integration)
opencode serveStart headless server
opencode webStart web interface

Utility Commands

CommandDescription
----------------------
opencode providersManage AI providers
opencode modelsList available models
opencode statsShow token usage
opencode upgradeUpdate to latest version
opencode sessionManage sessions

Built-in Agents

  • build - Full-access agent for development work (default)
  • plan - Read-only agent for analysis and exploration
  • @general - Subagent for complex searches

Configuration

ACP Integration

OpenCode is configured in OpenClaw. The ACP command is:

opencode acp

This starts JSON-RPC over stdio for ACP-compatible communication.

Providers

OpenCode supports multiple AI providers:

  • OpenCode Zen (recommended)
  • Claude (Anthropic)
  • OpenAI
  • Google Gemini
  • Local models

Set API keys via opencode providers or environment variables.

Usage Patterns

Pattern 1: One-shot Build

sessions_spawn({
  runtime: "acp",
  agentId: "opencode",
  task: "Create a complete Snake game in HTML/CSS/JavaScript...",
  mode: "run",
  cwd: "/Users/jadegaul/.openclaw/workspace/codeprojects"
})

Pattern 2: Parallel Builds

// Build 3 games simultaneously
const builds = [
  sessions_spawn({ task: "Asteroids...", ... }),
  sessions_spawn({ task: "Doodle Jump...", ... }),
  sessions_spawn({ task: "Flappy Bird...", ... })
]

Pattern 3: Bug Fixes

// Fix existing code
sessions_spawn({
  runtime: "acp",
  agentId: "opencode",
  task: "Fix the bug in /path/to/file.html where...",
  mode: "run"
})

Pattern 4: Check Status

subagents({ action: "list" })

Pattern 5: Steer Running Subagent

subagents({
  action: "steer",
  target: "<runId>",
  message: "Continue with the implementation"
})

File Operations

OpenCode has full file system access:

  • Read/write files
  • Execute shell commands
  • Navigate directories
  • Git operations

Capabilities

  • 100% open source (unlike Claude Code)
  • Provider-agnostic - use any model
  • LSP support - code intelligence
  • Client/server architecture - run remotely
  • Undo/redo - /undo and /redo commands
  • Session sharing - /share creates shareable links

Best Practices

  1. Be specific in task descriptions - include file paths, required features
  2. Use mode: "run" for one-shot builds (faster)
  3. Use mode: "session" for multi-step work
  4. Test immediately - some games need spawn fixes
  5. Parallel builds work great for 3+ independent tasks

Common Issues & Solutions

Issue: Game spawns in wrong position

Fix: Spawn OpenCode to add starting platform/position

Issue: Character dies immediately

Fix: Add spawn delay or ensure safe starting position

Issue: Controls not working

Fix: Check that touch + keyboard controls both specified

References

See references/opencode-docs.md for complete ACP documentation.

Test Results Summary

Total Games Built: 12

Total Build Time: ~15 minutes

Total Lines of Code: ~8,000+

Success Rate: 100% (with minor spawn fixes)

Average Build Times:

  • Simple games: ~50s
  • Medium games: ~1m 15s
  • Complex games: ~1m 40s

OpenCode via ACP is production-ready for game development and coding tasks.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 15:22 安全 安全

安全检测

暂无安全检测报告