Skip to content

Repository files navigation

Abacus Logo

Abacus

Production-grade LLM Agent Kernel
Multi-mode orchestration · Mathematical context compression · Built-in safety · External Agent System

v2.7.0  ·  MIT License  ·  Rust 1.75+  ·  Bun + OpenTUI  ·  macOS / Linux


What is Abacus?

Abacus is a terminal-native LLM agent kernel that orchestrates AI reasoning across four collaborative modes. It provides a rich TUI experience with real-time streaming, tool execution, and multi-expert consultation — all from your terminal.

v2.7.0 New Features:

  • TypeScript TUI — Migrated from Rust ratatui to OpenTUI (Zig-native rendering) + XState + Zustand
  • External Agent System — Install and manage external agents via MCP protocol
  • OKLCH Theme System — 11 themes with perceptually uniform colors
  • Scene-Aware UI — Trading/Coding/Editing scenarios with adaptive layouts
  • 21 Tool Clusters — Full coverage of 72 tools with intelligent routing

Clarify Mode — single-agent deep reasoning:

┌─────────────────────────────────────────────────────────────────────────────────┐
│ ⠋ ABACUS ▸ Refactor auth module · 澄清                         deepseek-v4    │
├──────────────────────────────────────────────────────────┬──────────────────────┤
│                                                          │ 📊 [====------] 38% │
│  User: 帮我把 session 认证改成 JWT                        │    415K↑ 5K↓ c78%   │
│                                                          │ 🔧 12/14 · 调8✓7    │
│  Session:                                                │ 🧠 3域 12行为        │
│  ## 方案确认                                              │ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌  │
│  我决定使用 JWT token 替代 session cookie。                │ 现场                 │
│  原因:无状态、易扩展、前后端解耦。                          │ ▸ 12:03 分析代码     │
│                                                          │   ⚙ fs_read auth.rs │
│  ```rust                                                 │ ▸ 12:04 方案生成     │
│  impl AuthService {                                      │   ✓ 2 工具完成       │
│      pub fn verify_token(&self, token: &str)             │ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌  │
│          -> Result<Claims, AuthError>                     │ Focus · 澄清 · 3轮  │
│  }                                                       │   JWT 认证重构       │
│  ```                                                     │   → 方案已确认       │
│                                                          │                      │
├──────────────────────────────────────────────────────────┬──────────────────────┤
│ ╭──────────────────────────────────────────────────────╮ │ deepseek(✓) · v4     │
│ │ ⠋ Thinking 澄清 · 分析认证模块  3.2s                │ │ ⬡ 52K/128K/1M · 3轮 │
│ │ Ask anything...                           ⏎ Enter   │ │ thinking · ¥0.08     │
│ ╰──────────────────────────────────────────────────────╯ │                      │
├──────────────────────────────────────────────────────────┴──────────────────────┤
│ ● 澄清                                            1.2K tok  Cmd+↑↓ Ctrl+B Esc │
└─────────────────────────────────────────────────────────────────────────────────┘

Plan Mode — two-phase: research → approval → execute:

┌─────────────────────────────────────────────────────────────────────────────────┐
│ ● ABACUS ▸ Refactor auth module · 澄清 · [📋 规划]             deepseek-v4    │
├──────────────────────────────────────────────────────────┬──────────────────────┤
│                                                          │ 📊 [======----] 58% │
│  Session:                                                │    820K↑ 12K↓ c65%  │
│  📋 计划已就绪 — 3 阶段, 12 步骤                          │ 🔧 14/14 · 调12✓10  │
│                                                          │ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌  │
│  选择执行策略:                                            │ Focus · 规划 2/3     │
│  [A] 自动执行 — 工具调用自动放行                           │  目标 重构auth模块   │
│  [S] 逐步确认 — 每步操作需确认                            │  ✓ 分析现有代码      │
│  [T] 团队分发 — 多专家并行执行                            │  ⟳ 生成迁移方案      │
│  [C] 取消                                                │  ○ 执行重构          │
│                                                          │  ████░░░░░░ 2/3     │
│  输入 A/S/T/C:                                           │                      │
│                                                          │                      │
├──────────────────────────────────────────────────────────┬──────────────────────┤
│ ╭──────────────────────────────────────────────────────╮ │ deepseek(✓) · v4     │
│ │ ● Ready · 澄清                                      │ │ ⬡ 75K/128K/1M · 8轮 │
│ │ 输入 A/S/T/C 选择策略...                    ⏎ Enter │ │ thinking · ¥0.32     │
│ ╰──────────────────────────────────────────────────────╯ │                      │
├──────────────────────────────────────────────────────────┴──────────────────────┤
│ ● 澄清 · 📋 规划就绪                              4.8K tok  Cmd+↑↓ Ctrl+B Esc │
└─────────────────────────────────────────────────────────────────────────────────┘

Meeting Mode — multi-expert consultation:

┌─────────────────────────────────────────────────────────────────────────────────┐
│ ⠙ ABACUS ▸ 性能优化方案 · 会诊                                 deepseek-v4    │
├──────────────────────────────────────────────────────────┬──────────────────────┤
│                                                          │ 📊 [=======---] 72% │
│  User: @架构师 @DBA 这个查询太慢了怎么优化                  │    1.1M↑ 8K↓ c80%   │
│                                                          │ 🔧 14/14 · 调15✓12  │
│  🔊 架构师:                                              │ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌  │
│  建议从两个层面入手:                                      │ Focus · 会诊 2/3位   │
│  1. 应用层:添加 Redis 缓存热点查询                        │  🔊 架构师 (后端)    │
│  2. 数据层:对 user_id 添加复合索引                        │  🔊 DBA (数据库)     │
│                                                          │  ○  前端 (前端)      │
│  🔊 DBA:                                                 │  阶段 ● 发言中       │
│  补充几点:                                               │                      │
│  - EXPLAIN 显示全表扫描,缺少 (user_id, created_at) 索引   │                      │
│  - 建议分区表(按月),历史数据走冷存储                      │                      │
│                                                          │                      │
├──────────────────────────────────────────────────────────┬──────────────────────┤
│ ╭──────────────────────────────────────────────────────╮ │ deepseek(✓) · v4     │
│ │ ⠹ Working 会诊 · DBA 发言中  5.1s                   │ │ ⬡ 92K/128K/1M · 5轮 │
│ │ Ask anything...                             ⏎ Enter │ │ thinking · ¥0.56     │
│ ╰──────────────────────────────────────────────────────╯ │                      │
├──────────────────────────────────────────────────────────┴──────────────────────┤
│ ● 会诊 · DBA 发言中                                6.2K tok  Cmd+↑↓ Ctrl+B Esc │
└─────────────────────────────────────────────────────────────────────────────────┘

Prerequisites

Abacus is a pre-compiled binary with no runtime dependencies. You only need:

  • macOS 12+ (Monterey) or Linux (glibc 2.31+, e.g. Ubuntu 20.04+)
  • A terminal emulator (Terminal.app, iTerm2, Warp, Kitty, Alacritty, etc.)
  • An LLM API key (DeepSeek / OpenAI / Anthropic / any OpenAI-compatible endpoint)

For building from source, you additionally need:

  • Rust 1.75+ (curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh)
  • A C linker (macOS: Xcode Command Line Tools; Linux: build-essential)
  • Protocol Buffers compiler (brew install protobuf on macOS; apt install protobuf-compiler on Linux)

Install

Option 1: One-line Install (Recommended)

curl -fsSL https://github.com/lucasli000/abacus/releases/latest/download/install.sh | sh

This auto-detects your platform (macOS/Linux, ARM64/x86_64), downloads the correct binary, and installs to /usr/local/bin/.

To install to a custom path:

INSTALL_DIR=~/.local/bin curl -fsSL https://github.com/lucasli000/abacus/releases/latest/download/install.sh | sh

Option 2: Manual Download

Go to Releases and download for your platform:

Platform File Size
macOS Apple Silicon (M1/M2/M3/M4) abacus-aarch64-apple-darwin.tar.gz ~19 MB
Linux x86_64 abacus-x86_64-unknown-linux-gnu.tar.gz ~22 MB

Then install:

# 1. Extract
tar -xzf abacus-aarch64-apple-darwin.tar.gz

# 2. Move to PATH
sudo mv abacus /usr/local/bin/

# 3. (macOS only) Remove quarantine flag
xattr -d com.apple.quarantine /usr/local/bin/abacus 2>/dev/null || true

# 4. Verify
abacus

Option 3: Build from Source

# Install Rust (if not already)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env

# Clone and build
git clone https://github.com/lucasli000/abacus.git
cd abacus/pkg
cargo build --release --package abacus-cli

# Install
sudo cp target/release/abacus /usr/local/bin/

First Run

# Start Abacus — it launches a full-screen TUI
abacus

On first run, a setup wizard will guide you through:

  1. Choosing an LLM provider (DeepSeek / OpenAI / Anthropic / custom)
  2. Entering your API key
  3. Selecting a default model

Config is saved to ~/.abacus/config.yaml. You can skip the wizard in CI:

export ABACUS_API_KEY=sk-xxx

Verify Installation

If Abacus launches and shows the TUI interface, installation is successful. The program uses the full terminal screen — press Ctrl+D or type /quit to exit.

Uninstall

rm /usr/local/bin/abacus
rm -rf ~/.abacus  # Remove config + data (optional)

Troubleshooting

Problem Solution
zsh: killed abacus macOS code signing issue. Run: codesign --sign - --force /usr/local/bin/abacus
permission denied Run: chmod +x /usr/local/bin/abacus
command not found Ensure /usr/local/bin is in your $PATH
"abacus" cannot be opened (macOS) Run: xattr -d com.apple.quarantine /usr/local/bin/abacus
Error in the HTTP2 framing layer Network issue (common in China). Use mirror: see below
Blank screen / no output Ensure your terminal supports alternate screen (most modern terminals do)

China mainland users — if downloads fail due to network issues:

# Option A: Use mirror proxy
curl -fsSL https://gh-proxy.com/https://github.com/lucasli000/abacus/releases/download/v2.5.5/abacus-aarch64-apple-darwin.tar.gz | tar -xz
sudo mv abacus /usr/local/bin/

# Option B: Use local SOCKS proxy
curl -x socks5://127.0.0.1:7890 -fsSL https://github.com/lucasli000/abacus/releases/latest/download/install.sh | sh

Features

Four Orchestration Modes

Mode Description Use Case
Clarify Single-agent deep reasoning with progressive gate Default — ask questions, write code, debug
Plan Two-phase: Research → Approval → Execute Complex multi-step tasks, user selects strategy (A/S/T)
Team Multi-agent parallel with ToolAgent delegation Large refactoring, parallel tool operations
Meeting Multi-expert weighted consultation Cross-domain problems needing diverse expertise

Core Engine

  • Mathematical Context Compression — Information Bottleneck + H2O Heavy-Hitter + ARC + Greedy Knapsack. 38% message reduction, 100% key decision retention.
  • ToolActionClassifier — Rule-based safety (hard_deny/soft_deny/allow). Zero LLM overhead.
  • ToolAgent — Batch delegation for read-only ops. 4 built-in types: Explorer, Researcher, Coder, Mathematician.
  • MCIP — Multi-level permission gate (role → confirm → capability).
  • ProgressiveGate — Complexity-aware output strategy.
  • Dynamic Timeout — Complexity + tool count + LLM self-extension.
  • Self-Learning — EffectivenessTracker records tool outcomes. Experience injector marks unreliable tools. Anti-pattern detector catches environment issues.
  • Unicode Injection Defense — Zero-width character normalization prevents prompt injection bypass.
  • Configurable Safety Rules — User-defined injection patterns with priority override.

TUI

  • Real-time streaming with thinking visualization
  • Soft-wrap input with cursor tracking
  • Right panel: dashboard + timeline + focus
  • 12 built-in themes
  • Inline suggestions (Tab)
  • Honest Data Display — No fake data when provider/model not connected. Shows "Not connected" instead of placeholders.
  • Formatted Tool Output — JSON parsed into structured display: ⚙ command + │ ⤷ stdout
  • Symbol System — Consistent visual language: ▸ You / ◈ Think / ⚙ Tool / ◇ Abacus
  • Markdown in Thinking — Thinking cards render markdown with syntax highlighting
  • Right-aligned Metadata — Model name and timestamps aligned to card header right side

Quick Start

# Interactive TUI (default)
abacus

# Single query
abacus ask "explain this error"

# Specific model
abacus --model deepseek-v4 ask "optimize this"

# Mode switching inside TUI
/clarify          # Single-agent (default)
/plan <goal>      # Two-phase planning
/team <task>      # Multi-agent parallel
/meeting          # Multi-expert consultation
@expert msg       # Auto-route to Meeting

First Run — Setup Wizard

┌─ Abacus Setup ──────────────────────────────┐
│                                              │
│  1. Choose LLM provider                     │
│     → OpenAI / Anthropic / DeepSeek / ...   │
│                                              │
│  2. Enter API key                           │
│                                              │
│  3. Select default model                    │
│                                              │
└──────────────────────────────────────────────┘

Auto-detects 9 providers from URL. Config: ~/.abacus/config.yaml

Architecture

abacus/pkg/
├── crates/
│   ├── abacus-cli/          TUI + CLI (ratatui + clap)
│   ├── abacus-core/         Engine kernel (pipeline, context, tools, safety)
│   ├── abacus-orchestrator/ Meeting/Team orchestration
│   ├── abacus-types/        Shared types
│   └── abacus-server/       HTTP/SSE server (axum)
├── assets/                  Logo + icons
└── scripts/                 Install script

Multi-Provider Support

Provider Models Status
OpenAI GPT-4o, o1, o3
Anthropic Claude Sonnet/Opus
DeepSeek V3, V4, R1
Google Gemini 2.x
Moonshot / 智谱 / 通义 / SiliconFlow / Groq Various
Any OpenAI-compatible Custom

Development

cargo check --workspace        # Type check
cargo test --workspace         # Run tests (1814 tests)
cargo build --release --package abacus-cli  # Release build

Test Coverage

  • 1814 unit tests across all crates
  • 0 warnings, 0 errors
  • Theme WCAG contrast validation (12 themes × 4 color roles)

License

MIT — see LICENSE

About

Abacus — LLM Agent Kernel: TUI Clarify→Plan→Team→Meeting DAG, CLI, and HTTP+SSE server.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages