跳到正文
DEV Community· İbrahim Kalaycı·· 1 小時前AI 評分50

使用 Rust(PyO3)、FastAPI 和 Tauri 2.0 構建離線優先的本機 AI 編碼工作室 AURA

Building an Offline-First Local AI Coding Studio with Rust (PyO3), FastAPI, and Tauri 2.0)

AI 導讀

İbrahim Kalaycı 構建了離線優先的本機 AI 編碼工作室 AURA,並以 GNU AGPLv3 開源整個項目。AURA 以 Rust HNSW 向量索引結合 BM25 詞法搜尋和 RRF,配合 AST 程式碼庫映射及本機 GGUF 模型推理。

正文

İbrahim Kalaycı

If you work on proprietary codebases or regulated systems, sending your source code to cloud LLM APIs is often a non-starter. I wanted a local, offline-capable coding assistant that goes beyond a basic chat window—something that can actually index a repository, reason across files, propose line-by-line diffs, and let me review or revert changes safely.

So I built AURA (AURA-CORE + AURA Studio), and recently removed the dual-licensing layer to release the entire project as 100% open source under GNU AGPLv3.

🔗 GitHub Repository: https://github.com/Shura5860/LocalAIProject

AURA Studio Desktop Preview

(Tip: If you record a short offline demo clip with Wi-Fi switched off, embed it right here!)


Why Build Another Local AI Tool?

Most local setups either stop at a chat wrapper around an inference daemon, or require spinning up separate Docker containers for vector databases, proxies, and UIs.

AURA takes a single-machine, embedded architecture approach:

  1. In-Process Rust Vector Engine (PyO3): Instead of running an external vector database over the network, the HNSW vector index lives directly inside the Python process via PyO3 C-FFI bindings, backed by a Write-Ahead Log (WAL) and atomic disk snapshots.
  2. Hybrid RAG 2.0: Combines dense vector search (Rust HNSW) with sparse lexical search (Okapi BM25) using Reciprocal Rank Fusion (RRF), plus AST-based repo mapping and Caller → Callee call-graph extraction.
  3. Local GGUF Inference with KV Prefix Caching: Runs quantized GGUF models locally via llama-cpp-python with LlamaRAMCache prefix caching, automatic context compaction, and Linux CPU thread affinity (sched_setaffinity) so the desktop UI stays responsive.

Composer-Style Diff Review, HITL Gates, and 1-Click Undo

Letting an autonomous agent edit files directly on disk without guardrails is risky. In AURA Studio (built with Tauri 2.0), file-modifying operations follow an explicit review workflow:

  • Visual Unified Diff Preview: Before apply_diff, write_file, or apply_multi_diff touches disk, AURA simulates the patch and renders a line-numbered red/green unified diff with +additions / -deletions counts.
  • Human-in-the-Loop (HITL) Approval: Critical actions (file edits, shell commands, Python execution, git rollbacks) pause in a pending state until you click Apply or Reject.
  • Snapshot-Backed 1-Click Undo: Every applied change captures a pre-edit snapshot of affected files (and tracks newly created files). You can revert any individual edit—or all changes from the session—directly from the Changed Files bar above the composer input.

Under the Hood: Agentic Core & Safety

  • Autonomous ReAct Agent:
    • Semantic Tool Pruning: Selects only the relevant tools per query instead of stuffing every tool schema into the prompt.
    • Disk Guard: Verifies target paths against the bound workspace before executing file operations to catch hallucinated paths early.
    • Levenshtein Fuzzy Diff Matching: Handles minor whitespace or indentation drift when applying code patches.
    • Flight Recorder: Writes step-by-step execution traces to .aura/traces/*.auratrace.json for offline debugging.
  • Multi-Agent Swarm Mode: Splits coding tasks across Architect (planning), Coder (diff patching), and Verifier (compiler/syntax checks with rollback on failure).
  • Defense in Depth:
    • Strict workspace realpath boundary checks (blocks path traversal and symlink escapes).
    • Linux Bubblewrap (bwrap) sandboxing for terminal commands.
    • SSRF protection on web fetching and XML quarantine envelopes for untrusted external content.
    • Localhost-bound API (127.0.0.1:8000) with restricted CORS and Tauri CSP.
  • Ecosystem Standards:
    • OpenAI-Compatible API (/v1/chat/completions, /v1/models, /v1/embeddings) so you can also connect tools like Continue, Aider, or Open-WebUI.
    • Model Context Protocol (MCP) stdio client bridge for external tools.
    • Automatic discovery of .cursorrules and .aura/rules.md.

Getting Started (Linux)

git clone https://github.com/Shura5860/LocalAIProject.git
cd LocalAIProject

python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install maturin numpy "httpx[http2]" duckduckgo_search sentence-transformers psutil fastapi uvicorn llama-cpp-python

# Build the in-process Rust vector engine
cd Rust-Python-Vector-Engine/vector_engine
maturin develop --release
cd ../..

# Launch AURA-CORE + AURA Studio
./start_assistant.sh

Looking for Feedback & Contributors

The project is tested on Linux (Arch, Ubuntu, Fedora) and licensed under GNU AGPLv3. I would love feedback from developers who work in air-gapped or privacy-strict environments:

  • What is still missing before you would trust a local agent on a real repository?
  • Which local models and workflows are you using right now?

Repo: https://github.com/Shura5860/LocalAIProject — issues, PRs, and architectural critiques are very welcome!

來源:DEV Community · dev.to