Using OpenCode Directly ​

Product Overview ​

OpenCode is the agent framework that powers Witty CLI. All backend interaction of Witty is built on opencode serve: session operations use the HTTP API, streaming events use SSE, permission and question replies use the API, and agent / MCP / session metadata also comes from OpenCode.

For regular users, Witty CLI already wraps the terminal entry, so OpenCode is not exposed directly. This manual targets advanced users who want to bypass Witty CLI and use OpenCode directly, or to understand its underlying implementation. It describes how to use OpenCode on openEuler and the structure of its managed configuration.

Version note: this section is based on the OpenCode version currently installed on openEuler 24.03 LTS (1.17.x). OpenCode releases on its upstream schedule; refer to opencode.ai/docs for commands and configuration.

What OpenCode Provides ​

OpenCode is an agent framework for terminals and servers, organized around the following core capabilities:

CapabilityDescription
AgentAgent definitions with role prompts, permissions, and default mode (primary / subagent / all)
SkillScenario capability packages loaded on demand by agents, such as diagnosis, drawing, and reports
MCPModel Context Protocol services connecting external data and tools, such as the openEuler portal
PermissionAuthorization policies for tools, files, and shell operations (allow / ask / deny)
SessionSession management and context restoration
Serveropencode serve provides headless HTTP + SSE services for clients such as Witty

Relationship Between Witty and OpenCode ​

  • Witty CLI provides Shell direct input and REPL entries for terminal users;
  • Witty does not implement agent logic; it reuses the OpenCode Agent / Skill / MCP / Permission capabilities;
  • after installing Witty, witty-agent-loader aggregates the OpenCode configuration in /etc/opencode/opencode.json, registering the built-in Agent, Skills, and MCP.

When using OpenCode directly, these capabilities remain available. The difference is that you start opencode or opencode serve yourself and manage them through the OpenCode configuration system.