What's the difference between CLI and desktop app?
does cli version and desktop app have any difference?
Perfect! Now I have a comprehensive understanding. Let me create a summary based on what I've found:
##Key Differences Between CLI and Desktop App
Yes, there are important differences. Here's a comprehensive breakdown:
###Architecture
CLI Version (packages/opencode):
- Type: Node.js/Bun CLI application
- Entry Point:
src/index.ts- usesyargsfor command-line argument parsing - Runtime: Runs directly in the terminal using Node.js/Bun runtime
- Available as: npm package (
opencode-ai) or standalone binary
Desktop App (packages/desktop):
- Type: Tauri v2 native desktop application
- Frontend: React-like UI built with Solid.js (in
src/) - Backend: Rust backend (in
src-tauri/) that manages the native window and system integration - Architecture:
- Uses Tauri to create a native shell around the web frontend
- Runs a sidecar server (the CLI itself)
- Communicates with the server via TCP/HTTP
###Core Functionality
The desktop app actually embeds and runs the CLI:
- The desktop app bundles the OpenCode CLI as a "sidecar" binary (
opencode-cli) - It starts the CLI as a background server when the app launches
- The frontend communicates with this server via HTTP/TCP
You can see this in src-tauri/src/lib.rs:
ServerStatemanages the running CLI processget_sidecar_path()locates the embeddedopencode-clibinaryensure_server_started()ensures the server is running
###CLI Features
The CLI (packages/opencode) has these commands:
- run, generate, serve, web, debug
- auth, upgrade, uninstall, models
- agent, skill, mcp, acp
- github, pr, session, import, export, stats
- And more...
###UI Differences
CLI:
- Terminal-based interface (TUI)
- Text-only interaction
- Platform-agnostic
Desktop:
- Native graphical interface using Tauri
- Can use system file dialogs
- Native notifications
- Built-in auto-update mechanism
- Platform-specific installation (DMG for macOS, MSI for Windows, AppImage/deb/rpm for Linux)
###Platform Integration
The desktop app has platform-specific capabilities defined via the Platform type in packages/app/src/context/platform.tsx:
- Native file/directory pickers (Tauri only)
- System notifications
- Auto-update checking
- Restart functionality
- Storage management with Tauri's plugin system
The CLI doesn't have these native capabilities - it's purely terminal-based.
###Additional Feature: CLI Installation
Interestingly, the desktop app can install the CLI to your system via the install_cli command in Rust (src-tauri/src/cli.rs), allowing you to use opencode command from the terminal even after closing the desktop app.
In summary: The desktop app is a GUI wrapper around the CLI with native system integration, while the CLI is the core engine that runs independently in the terminal.
END OF POST