Skip to content

juice094/clarity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,012 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

🦀 Clarity

Rust 原生个人 AI 运行时 — 一个核心,所有入口。

ReAct 智能体 · MCP 工具生态 · BM25+向量记忆 · 多入口(TUI/桌面/Web/托盘/移动端 FFI)

CI License: AGPL-3.0 Rust GitHub release Issues

English · 中文


📋 简介

一个统一的运行时,在所有入口编排 LLM、工具和记忆 — 终端、桌面、浏览器、无头脚本、系统托盘、移动端 FFI。每个前端均以单二进制分发,零外部运行时依赖(无需 Python、Node.js 或 Ollama)。桌面 GUI 采用纯 Rust 实现(eframe/egui),零 Web 依赖。

预构建安装包:Windows .msi / .exe 与 Linux 二进制可在 GitHub Releases 下载,无需 Rust 工具链。

定位边界:Clarity 是「本地优先的 AI 开发运行时」,聚焦编码/工程工作流。无原生消息通道客户端(clarity-channels 当前仅实现 WeChat iLink;Discord/Slack/Telegram 未启用)、无 Voice/Canvas。移动端已实现基于 clarity-mobile-core(UniFFI)的 Android 应用,支持 DeepSeek 账密登录、本地多轮对话与 Claw Gateway 连接,EndToEndFlowTest 14/14 通过。需要多通道 inbox 或语音交互 → OpenClaw 更合适。


🌟 核心亮点

亮点 说明
🧠 Agent 运行时 ReAct/Plan 循环 + MCP 工具生态,Approval 四层(Interactive/Smart/Plan/Yolo)
🖥️ 纯 Rust 多前端 TUI (ratatui) · 桌面 GUI (eframe/egui) · Web IDE (Axum) · 无头 CLI · 系统托盘 · 移动端 FFI
🤖 本地 LLM Candle 原生 GGUF 推理(Qwen2 / DeepSeek-R1-Distill),离线自动回退,零外部依赖
🧩 混合记忆 SQLite + BM25 + 向量搜索,跨会话持久化
💰 预算保护 每轮/每日 USD 成本上限,超预算前自动拦截

完整路线图 → docs/planning/ROADMAP.md


🔧 技术栈

层级 技术
Agent 核心 ReAct/Plan 循环, MCP stdio/SSE/WebSocket
本地推理 Candle (GGUF: Qwen2, DeepSeek-R1-Distill)
记忆存储 SQLite (WAL) + BM25 + 向量搜索
桌面 GUI eframe/egui(纯 Rust,零 Web 依赖)
事件总线 clarity-wire SPMC 通道

📁 项目结构

crates/
├── clarity-contract        # 共享契约层:LlmProvider/Tool/AgentError trait、FederationMessage
├── clarity-wire           # UI ↔ Agent 事件总线(SPMC)+ ViewCommand 协议通道
├── clarity-memory         # BM25 + 向量混合搜索,chunking,四级压缩归档
├── clarity-mcp            # MCP 客户端 — stdio / SSE / HTTP / WebSocket 四传输
├── clarity-llm            # LLM provider 抽象 + 内置 provider + Candle GGUF 本地推理
├── clarity-tools          # 内置工具库:file / shell / web / devkit / …
├── clarity-channels       # 外部通道抽象;当前实现 WeChat iLink;Webhook 默认可用
├── clarity-subagents      # 子代理执行器 + 并行调度器,消费 clarity-core
├── clarity-thread-store   # Thread 持久化抽象;依赖 clarity-rollout
├── clarity-rollout        # JSONL rollout 持久化(设计受 Codex 启发)
├── clarity-secrets        # 凭证加密与本地安全存储
├── clarity-telemetry      # 统一遥测:WideEvent、metrics、traces、config audit
├── clarity-core           # Agent 循环(ReAct/Plan)、Approval、Skill、MCP 集成
├── clarity-gateway        # Axum HTTP/WebSocket 服务端,Web IDE,session store
├── clarity-egui           # 桌面 GUI(主前端栈),eframe + egui 纯 Rust
├── clarity-tui            # ratatui 终端界面
├── clarity-claw           # 统一客户端 Claw 节点:UI 无关库 + 系统托盘常驻二进制(Gateway WebSocket 客户端、OpenClaw/KimiClaw 兼容层、设备发现/身份/配对、角色上下文同步)
├── clarity-headless       # 无头 CLI(脚本 / CI 场景)
├── clarity-mobile-core    # 移动端 UniFFI FFI 核心(Android/iOS)
├── clarity-slint          # 桌面 GUI 实验栈(Slint),不参与默认 CI
├── clarity-anthropic-proxy # Anthropic Messages API 网关(默认 DeepSeek device,协议转换在 clarity-llm)
└── clarity-tauri          # 已归档 — 不参与默认 workspace 构建

架构依赖方向

contract ← {wire, memory, mcp, llm, tools, channels, secrets, rollout}
               ↑
          thread-store (→ rollout)
                                  ↓
                               core ← {gateway, egui, tui, claw, headless, mobile-core}
                                  ↑
                    {subagents, telemetry}(消费 core / 横切关注)

关键不变量

  • clarity-core零依赖于任何前端或网络 crate
  • clarity-contract零内部依赖,所有人基于它构建
  • 前端 crate 永不互相 import — 跨前端通信走 clarity-wire

详见 docs/ARCHITECTURE.mddocs/architecture/architecture-positioning.md


🚀 快速开始

# 1. 克隆仓库
git clone https://github.com/juice094/clarity.git && cd clarity

# 2. 编译并运行桌面 GUI
cargo run -p clarity-egui

# 3. 或安装指定前端
cargo install --path crates/clarity-egui   # 桌面 GUI
cargo install --path crates/clarity-tui    # 终端界面
cargo install --path crates/clarity-gateway # Web IDE
cargo install --path crates/clarity-headless # 无头 CLI

无 API Key?~/models/ 放入 .gguf 模型 → 设置中选择 本地 (GGUF) → 自动离线推理。


🤝 参与贡献

详见 CONTRIBUTING.md — 环境搭建、架构总览、编码规范。快速验证:

cargo test --workspace --lib                                   # 2030+ 个测试
cargo clippy --workspace --lib --bins --tests --exclude clarity-slint -- -D warnings
cargo audit --deny unsound --deny yanked

💬 社区与支持


📄 许可证

AGPL-3.0 — Copyright (c) 2026 juice094。若修改 Clarity 并通过网络提供服务,须向所有用户公开修改后的源代码。如需商业授权,请开 issue 讨论。


About

Rust 原生个人 AI 运行时:单二进制编排 LLM、MCP 工具、BM25+向量记忆。支持 TUI / 桌面 GUI / Web IDE / 无头 CLI / 系统托盘。本地优先,AGPL-3.0。

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Used by

Contributors

Languages