opencode-cloud Rust CLI
This is the source of truth for all CLI commands.
The Rust CLI (occ) contains the complete implementation of all opencode-cloud commands. The Node CLI (packages/cli-node) is a transparent passthrough wrapper that spawns this binary.
Architecture
opencode-cloud uses a dual-CLI strategy:
- Rust CLI (this package) - Complete implementation, all logic lives here
- Node CLI (
packages/cli-node) - Wrapper that spawns Rust binary withstdio: 'inherit'
This architecture provides:
- Single source of truth - All command logic in one place (Rust)
- No duplication - Node wrapper has zero command logic
- Automatic sync - New Rust commands instantly work via Node
- Full TTY support - Colors, interactive prompts, progress bars all work
- Cross-platform - Users choose their preferred installation method
Building
Development Build
# Build Rust CLI only
# Run directly
# Or via cargo
Release Build
Full Project Build
# Build all packages (core + CLIs)
Project Structure
packages/cli-rust/
├── src/
│ ├── bin/
│ │ ├── occ.rs # Binary entry point (occ)
│ │ └── opencode-cloud.rs # Binary entry point (opencode-cloud)
│ ├── commands/
│ │ ├── mod.rs # Command registry
│ │ ├── start.rs # occ start
│ │ ├── stop.rs # occ stop
│ │ ├── status.rs # occ status
│ │ ├── config/ # occ config subcommands
│ │ ├── user/ # occ user subcommands
│ │ ├── mount/ # occ mount subcommands
│ │ └── ... # Other commands
│ ├── output/
│ │ ├── spinner.rs # Progress spinners
│ │ ├── colors.rs # Terminal color utilities
│ │ ├── errors.rs # Error formatting
│ │ └── urls.rs # URL formatting helpers
│ ├── wizard/
│ │ ├── mod.rs # Interactive setup wizard
│ │ ├── auth.rs # Auth prompts
│ │ └── network.rs # Network prompts
│ └── lib.rs # Shared CLI implementation
├── Cargo.toml
└── README.md # This file
Adding Commands
To add a new command (e.g., occ shell):
1. Create the command module
2. Implement the command
use Result;
use Args;
use DockerClient;
pub async
3. Register in commands/mod.rs
pub use ;
4. Add to CLI enum in src/lib.rs
5. Add command handler in src/lib.rs
In the match cli.command block:
Some =>
6. Test
# Build
# Test Rust CLI
# Node CLI automatically works too
That's all! No changes needed in packages/cli-node - it automatically delegates to the new Rust command.
Testing
# Run all tests
# Run specific test
# With verbose output
Installation
From Source (Development)
From crates.io (Users)
Via npm (Users)
# or
The npm package includes this Rust CLI and compiles it during installation.
Code Style
See CLAUDE.md for detailed code style guidelines.
Quick reference:
- Prefer
?for error propagation overunwrap() - Use
let...elsefor early returns - Prefix
Optiontypes withmaybe_ - Document public APIs with
///comments - Run
cargo fmtandcargo clippybefore committing
Contributing
See CONTRIBUTING.md for full contribution guidelines.