Skip to content

Latest commit

 

History

History
201 lines (152 loc) · 5.01 KB

File metadata and controls

201 lines (152 loc) · 5.01 KB

link-assistant-agent (Rust)

A minimal, public domain AI CLI agent compatible with OpenCode's JSON interface

Crates.io License: Unlicense

This is the Rust implementation. See also the JavaScript/Bun implementation.

Status

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.

Implemented Features

  • 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 commands
    • read - Read file contents
    • write - Write files
    • edit - Edit files with string replacement
    • list - List directory contents
    • glob - File pattern matching
    • grep - Text search with regex support

Not Yet Implemented

  • 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

Requirements

  • Rust 1.70 or newer (includes Cargo, Rust's package manager)

Installation

Step 1: Install Rust (skip if already installed)

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 --version

Step 2: Build from source

cd rust
cargo build --release

# The binary will be at target/release/agent
./target/release/agent --help

From crates.io

cargo install link-assistant-agent

Quick Start

Plain text input:

echo "hi" | ./target/release/agent

JSON input:

echo '{"message":"hi"}' | ./target/release/agent

Direct prompt:

./target/release/agent -p "hello world"

Dry run mode (no API calls):

./target/release/agent --dry-run -p "test"

CLI Options

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 version

Development

Building

cargo build

Running Tests

cargo test

Running with Logging

RUST_LOG=debug cargo run -- -p "hello"

Project Structure

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

JSON Output Format

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"
}

Documentation

For full documentation, see the main README in the repository root.

License

Unlicense (Public Domain)