Skip to content

majiayu000/sage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

540 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Sage πŸ¦€

Blazing fast code agent in pure Rust

The fastest open-source alternative to Claude Code.
10x faster startup β€’ Single binary β€’ Works offline with Ollama

Rust License CI Release

Installation β€’ Features β€’ Documentation β€’ Contributing


Why Sage?

Claude Code Aider Sage
Startup Time ~500ms ~800ms ~50ms
Binary Size ~200MB ~100MB ~15MB
Offline Mode ❌ βœ… βœ… Ollama
Open Source ❌ βœ… βœ…
MCP Support βœ… ❌ βœ…
Memory System ❌ ❌ βœ…
Single Binary ❌ ❌ βœ…

πŸš€ Quick Install

macOS / Linux:

curl -fsSL https://raw.githubusercontent.com/majiayu000/sage/main/install.sh | bash

Windows (PowerShell):

irm https://raw.githubusercontent.com/majiayu000/sage/main/install.ps1 | iex

Homebrew:

brew install majiayu000/sage/sage

Cargo:

cargo install --git https://github.com/majiayu000/sage sage-cli

⚑ Quick Start

# Interactive mode (default)
sage

# Execute task interactively
sage "Create a Python script that fetches GitHub trending repos"

# Print mode - execute and exit (non-interactive)
sage -p "Explain this code"

# Continue most recent session
sage -c

# Resume specific session
sage -r <session-id>

✨ Features

πŸš€ Performance

  • 10x faster startup - Rust native, no runtime overhead
  • Single ~15MB binary - No dependencies, instant install
  • Efficient memory - Low footprint, handles large codebases

πŸ€– Multi-LLM Support

  • Anthropic - Claude Sonnet, Opus (with prompt caching)
  • OpenAI - GPT-4, GPT-4 Turbo
  • Google - Gemini Pro
  • Ollama - Llama, Mistral, CodeLlama (offline)
  • Azure OpenAI - Enterprise deployments
  • OpenRouter - Access 100+ models
  • Doubao - ByteDance models
  • GLM - Zhipu AI models

πŸ› οΈ 40+ Built-in Tools

Category Tools
File Ops Read, Write, Edit, Glob, Grep, NotebookEdit
Shell Bash, KillShell, Task, TaskOutput
Web WebSearch, WebFetch, Browser
Planning TodoWrite, EnterPlanMode, ExitPlanMode
Git Full Git integration

🧠 Advanced Features

  • Memory System - Learns your coding patterns across sessions
  • Checkpoints - Save and restore agent state
  • Trajectory Recording - Full execution history for debugging
  • MCP Protocol - Extend with Model Context Protocol servers
  • Plugin System - Custom tool development

πŸ’¬ Claude Code Compatible

  • 16+ Slash Commands - /resume, /undo, /cost, /plan, /compact, /title, etc.
  • Session Resume - Continue where you left off (sage -c or sage -r <id>)
  • Interactive Mode - Multi-turn conversations
  • File Change Tracking - Built-in undo support

πŸ“– Usage

Interactive Mode

# Start interactive session
sage

# Or with initial task
sage "Create a REST API with user authentication"
> Create a REST API with user authentication

[Sage creates files, runs commands, shows progress...]

> /cost
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Session Cost & Usage            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Input tokens:  12,450           β”‚
β”‚ Output tokens: 3,200            β”‚
β”‚ Total cost:    $0.047           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

> /resume
[Shows list of previous sessions...]
To resume: sage -r <session-id>

Print Mode (One-Shot)

# Execute task and exit (non-interactive)
sage -p "Add error handling to main.rs"

# With maximum steps
sage --max-steps 30 -p "Refactor the auth module"

Session Management

# Continue most recent session
sage -c

# Resume specific session by ID
sage -r abc123

Slash Commands

Command Description
/help Show help information
/clear Clear conversation history
/compact Summarize and compact context
/resume [id] Resume previous session
/cost Show token usage and cost
/undo [msg-id] Undo file changes
/plan [open|clear] View/manage execution plan
/checkpoint [name] Save current state
/restore [id] Restore to checkpoint
/context Show context usage
/status Show agent status
/tasks List background tasks
/commands List all slash commands
/title <title> Set session title
/init Initialize Sage in project
/config Manage configuration
/login Configure API key for provider
/logout Clear stored credentials

Login/Logout Demo

Login Command Demo

βš™οΈ Configuration

Create sage_config.json or use environment variables:

{
  "default_provider": "anthropic",
  "model_providers": {
    "anthropic": {
      "model": "claude-sonnet-4-20250514",
      "api_key": "${ANTHROPIC_API_KEY}",
      "enable_prompt_caching": true
    },
    "ollama": {
      "model": "codellama",
      "base_url": "http://localhost:11434"
    }
  },
  "max_steps": 20,
  "working_directory": "."
}

Environment Variables

# API Keys
export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."

# Configuration
export SAGE_DEFAULT_PROVIDER="anthropic"
export SAGE_MAX_STEPS="30"

πŸ“¦ SDK

Use Sage as a library in your Rust projects:

use sage_sdk::{SageAgentSdk, RunOptions};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Load from config file
    let sdk = SageAgentSdk::with_config_file("sage_config.json")?;

    // Or create with default config
    // let sdk = SageAgentSdk::new()?;

    // Run a task
    let options = RunOptions::new("Create a README file");
    let result = sdk.run(options).await?;

    println!("Execution completed: {:?}", result.outcome());

    Ok(())
}

πŸ—οΈ Architecture

sage/
β”œβ”€β”€ crates/
β”‚   β”œβ”€β”€ sage-core/      # Core agent logic, LLM providers, session, tools
β”‚   β”œβ”€β”€ sage-cli/       # Command-line interface
β”‚   β”œβ”€β”€ sage-sdk/       # High-level SDK for embedding
β”‚   └── sage-tools/     # Built-in tool implementations
β”œβ”€β”€ docs/               # Documentation
β”œβ”€β”€ examples/           # Usage examples
└── benchmarks/         # Performance benchmarks

πŸ§ͺ Benchmarks

Run the startup benchmark:

./benchmarks/startup.sh
Code Agent Startup Benchmark
━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Agent            Avg (ms)
────────────────────────────
sage             45
claude           520
aider            780

Sage is 11.5x faster than Claude Code

πŸ“š Documentation

🀝 Contributing

Contributions are welcome! Please read our Contributing Guide.

# Clone
git clone https://github.com/majiayu000/sage
cd sage

# Build
cargo build --release

# Test
cargo test

# Run
./target/release/sage --help

πŸ“„ License

MIT License - see LICENSE for details.

πŸ™ Acknowledgments

Inspired by:


⭐ Star us on GitHub if you find Sage useful!

Made with πŸ¦€ by the Sage Team

About

Fast Rust CLI for batch-extracting structured observations from Claude Code and Codex sessions using LLM analysis

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors