Skip to content

Conversation

@D36u99er
Copy link

@D36u99er D36u99er commented Jan 7, 2026

Summary

This PR adds support for OpenCode (https://github.com/anomalyco/opencode) as a new agent flavor, enabling mobile control of OpenCode AI terminals through the Happy app.

Key Changes

  • New happy opencode subcommand - Start OpenCode sessions with mobile control
  • HTTP/SSE API Client - Clean integration using OpenCode's native REST API (port 4096), unlike Claude/Codex PTY spawning
  • Real-time event streaming - SSE-based message synchronization for tool calls, reasoning, and todos
  • Permission system integration - Forward permission requests to mobile app with full reply options
  • Model/Provider selection - Support --model and --provider flags for model configuration

Files Added

src/opencode/
├── index.ts              # Module exports
├── types.ts              # TypeScript type definitions for OpenCode API
├── openCodeClient.ts     # HTTP/SSE client for OpenCode server
├── runOpenCode.ts        # Main entry point (similar to runClaude.ts)
├── messageMapper.ts      # Message format conversion (Happy <-> OpenCode)
└── utils/
    └── permissionHandler.ts  # Permission request handling

Usage

# Start with default settings
happy opencode

# Start with all permissions bypassed
happy opencode --yolo

# Use specific model
happy opencode -m gpt-4o -p openrouter

# Show help
happy opencode --help

Why OpenCode?

OpenCode provides:

  • Native HTTP API (cleaner than PTY-based integration)
  • Best-in-class context management
  • Support for multiple AI providers (OpenRouter, Anthropic, OpenAI, etc.)
  • Active development (52k+ stars)

Related

Testing

  • TypeScript compilation passes
  • Build succeeds
  • OpenCode API connectivity verified locally

- Add new 'happy opencode' subcommand for OpenCode AI terminal control
- Implement OpenCodeClient with HTTP/SSE API support (port 4096)
- Add message format conversion between Happy and OpenCode
- Implement permission handling with mobile app integration
- Support model/provider selection and permission modes (--yolo, --accept-edits)

OpenCode provides a native HTTP API unlike Claude/Codex PTY spawning,
enabling cleaner integration with real-time SSE event streaming.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants