You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 1. Copy the template
cp -r agents/_template agents/opencode
# 2. Edit the config# agents/opencode/agent.json — name, MCP paths, cleanup paths# agents/opencode/driver.ts — isInstalled, install, authenticate, uninstall# 3. Add MCP configs# agents/opencode/mcp/global.json# 4. Add scaffold files# agents/opencode/scaffold/ — rules, skills, project MCP, etc.# 5. Done. Run ./setup.sh — OpenCode appears in the menu automatically.
agent.json Reference
{
"name": "OpenCode", // Display name"id": "opencode", // Must match folder name"description": "Terminal AI", // Shown in menus"icon": "🖥️", // Menu icon"requires": ["homebrew", "node"],
"installMethod": "custom", // "custom" | "brew-cask" | "brew" | "npm-global""command": "opencode", // CLI command to check installation"mcp": {
"global.json": { // File under mcp/ → destination path"path": "~/.opencode/mcp.json"
}
},
"cleanup": {
"paths": ["~/.opencode"], // Removed by nuke (user-level)"sudoPaths": [] // Removed by nuke (with sudo)
}
}
driver.ts Reference
importtype{AgentDriver,Context}from"../../src/core/types.js";exportconstdriver: AgentDriver={asyncisInstalled(){/* return true if installed */},asyncinstall(ctx){/* install the agent */},asyncauthenticate(ctx){/* prompt user to log in */},asyncuninstall(ctx){/* remove the agent */},};exportdefaultdriver;
Adding a Plugin
Plugins are optional add-ons that inject files into projects during ai-init.
# 1. Copy the template
cp -r plugins/_template plugins/git-hooks
# 2. Edit plugins/git-hooks/plugin.json
{
"name": "Git Hooks",
"id": "git-hooks",
"description": "Husky + commitlint pre-commit hooks",
"icon": "🪝",
"compatibleAgents": [] // empty = compatible with all agents
}
# 3. Add files under plugins/git-hooks/files/# These are copied to the project root preserving directory structure.# Supports {{PROJECT_DIR}} and {{PROJECT_NAME}} tokens.# 4. Done. Plugin appears in ai-init menu automatically.
{ "name": "OpenCode", // Display name "id": "opencode", // Must match folder name "description": "Terminal AI", // Shown in menus "icon": "🖥️", // Menu icon "requires": ["homebrew", "node"], "installMethod": "custom", // "custom" | "brew-cask" | "brew" | "npm-global" "command": "opencode", // CLI command to check installation "mcp": { "global.json": { // File under mcp/ → destination path "path": "~/.opencode/mcp.json" } }, "cleanup": { "paths": ["~/.opencode"], // Removed by nuke (user-level) "sudoPaths": [] // Removed by nuke (with sudo) } }