A minimal, public domain AI CLI agent compatible with OpenCode's JSON interface
This is the Rust implementation. See also the JavaScript/Bun implementation.
Work in Progress - The Rust implementation provides core functionality but is still under active development. For production use, consider the JavaScript/Bun version which has full feature parity with OpenCode.
- JSON Input/Output compatible with OpenCode format
- Plain text input support (auto-converted to JSON)
- Core CLI argument parsing
- Session and message ID generation
- Tool framework with 7 implemented tools:
bash- Execute shell commandsread- Read file contentswrite- Write filesedit- Edit files with string replacementlist- List directory contentsglob- File pattern matchinggrep- Text search with regex support
- LLM API integration (currently echoes input)
- WebSearch and CodeSearch tools
- Batch tool
- Task tool (subagent support)
- Todo tool
- WebFetch tool
- MCP (Model Context Protocol) support
- Session resume/continue functionality
- Authentication system
- Rust 1.70 or newer (includes Cargo, Rust's package manager)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.bashrc # Or restart your terminal (use ~/.zshrc for Zsh)
# Verify Rust is installed
rustc --version
cargo --versioncd rust
cargo build --release
# The binary will be at target/release/agent
./target/release/agent --helpcargo install link-assistant-agentPlain text input:
echo "hi" | ./target/release/agentJSON input:
echo '{"message":"hi"}' | ./target/release/agentDirect prompt:
./target/release/agent -p "hello world"Dry run mode (no API calls):
./target/release/agent --dry-run -p "test"agent [OPTIONS]
Options:
--model <MODEL> Model to use in format providerID/modelID
[default: opencode/minimax-m2.5-free]
--json-standard <JSON_STANDARD> JSON output format standard
[possible values: opencode, claude]
[default: opencode]
-p, --prompt <PROMPT> Direct prompt (bypasses stdin reading)
--system-message <SYSTEM_MESSAGE> System message override
--append-system-message <MSG> Append to system message
--verbose Enable verbose mode
--dry-run Dry run mode (simulate without API calls)
--compact-json Output compact JSON (single line)
--working-directory <PATH> Working directory
-h, --help Print help
-V, --version Print versioncargo buildcargo testRUST_LOG=debug cargo run -- -p "hello"rust/
├── src/
│ ├── main.rs # Entry point
│ ├── cli.rs # CLI argument parsing
│ ├── error.rs # Error handling
│ ├── id.rs # ID generation (session, message, part IDs)
│ ├── util/ # Utility modules
│ └── tool/ # Tool implementations
│ ├── mod.rs # Tool registry
│ ├── context.rs
│ ├── bash.rs
│ ├── read.rs
│ ├── write.rs
│ ├── edit.rs
│ ├── list.rs
│ ├── glob.rs
│ └── grep.rs
├── changelog.d/ # Changelog fragments
├── Cargo.toml # Package configuration
└── Cargo.lock # Dependency lock file
The Rust implementation outputs OpenCode-compatible JSON events:
{
"type": "step_start",
"timestamp": 1763618628840,
"sessionID": "ses_560236487ffe3ROK1ThWvPwTEF"
}
{
"type": "text",
"timestamp": 1763618629886,
"sessionID": "ses_560236487ffe3ROK1ThWvPwTEF",
"text": "Agent (Rust) ready. 7 tools available."
}
{
"type": "step_finish",
"timestamp": 1763618629916,
"sessionID": "ses_560236487ffe3ROK1ThWvPwTEF",
"reason": "stop"
}For full documentation, see the main README in the repository root.
Unlicense (Public Domain)