aphrodite 1.4.6

aphrodite: Chat Completions proxy with CCR, tool relay, and programmatic CCR for Hermes agent integration.
Documentation

aphroditeβ€πŸ’‹β€Core Engine

CCR compression proxy + cdylib - classify, compress, store, preview. Sub-ms, 26 content types, 12,800Γ— max ratio.

The core compression engine. Produces both the aphrodite binary (HTTP proxy on :9797/:9798) and libaphrodite.dylib (best-effort cdylib for external embedding; the Hermes plugin loads the bridge crate's libaphrodite_hermes.dylib instead - see crates/aphrodite-hermes/README.md).

crates.io Β· docs


Install

# From source (monorepo)
cargo build --release -p aphrodite
# then bootstrap the runtime home (~/.hermes/aphrodite/: binaries/,
# directives/, hotreload/, ccr.db)
aphrodite setup

# From crates.io
cargo install aphrodite

What it does

tool output β†’ classify β†’ template β†’ store β†’ <<<CCR:hash|type|size>>>
                                              β”‚
                                              β–Ό
                                         Agent (honest preview, not raw output)

Four pipeline stages, all under 1ms:

  1. Classify - 26-type regex classifier (diff, build_output, code_rust, …)
  2. Template - TOML-driven preview templates per content type
  3. Store - blake3 hash β†’ SQLite or in-memory β†’ CCR marker
  4. Preview - Structured [type:metadata] the LLM reads instantly

Architecture

src/
β”œβ”€β”€ lib.rs               ← 25 C ABI exports for dylib loading
β”œβ”€β”€ proxy.rs             ← HTTP proxy (:9797 cache, :9798 token)
β”œβ”€β”€ hooks.rs             ← transform_tool_result, terminal, pre/post LLM
β”œβ”€β”€ session.rs           ← Turn lifecycle, conversation index, catalog
β”œβ”€β”€ state.rs             ← AphroditeState, inline store, LRU, markers
β”œβ”€β”€ marker.rs            ← CCR marker formatting + parsing (<<<CCR:…>>>)
β”œβ”€β”€ catalog.rs           ← Full/compact/TOC catalog display
β”œβ”€β”€ chain_split.rs       ← Fine-grained chain splitting (SEG_MARKER segments)
β”œβ”€β”€ resolve.rs           ← Recursive CCR expansion (5 levels deep)
β”œβ”€β”€ stage2.rs            ← Semantic reduction for JSON, build, diff, code
β”œβ”€β”€ struct_extract.rs    ← Code structure maps (Rust, Python, Go, JS/TS)
β”œβ”€β”€ config.rs            ← CLI args + TOML multi-config
β”œβ”€β”€ config_loader.rs     ← TOML + env var loading
β”œβ”€β”€ directives.rs        ← Conversational directives: load, inject, list/swap/add/remove/reset
β”œβ”€β”€ flow.rs              ← Per-turn injected-context assembler (directives + nudges + recall catalog)
β”œβ”€β”€ setup.rs             ← `aphrodite setup` one-shot bootstrap (Gatekeeper-safe artifact install)
β”œβ”€β”€ prefetch.rs          ← Background file read + compress threads
β”œβ”€β”€ poll_worker.rs       ← Auto-backgrounding of slow tool calls
β”œβ”€β”€ preview.rs           ← detect_type, build_preview (shared across proxy + dylib)
β”œβ”€β”€ main.rs              ← Binary entry point
└── retrieve.rs          ← POST /retrieve - hash β†’ content, filter, paginate, truncated flag

C ABI (25 functions)

The 25 #[no_mangle] extern "C" exports in lib.rs (22 written out plus 3 macro-generated: aphrodite_compress, aphrodite_transform, aphrodite_terminal) form the core C ABI. The aphrodite-hermes bridge crate links this crate as an rlib and exposes its own higher-level ABI (libaphrodite_hermes.dylib - see crates/aphrodite-hermes/README.md); the Python plugin's ctypes bindings (_bindings.py) are generated from the bridge header, not from these exports.


Dependencies

  • headroom-core - Content transforms + classifier + SQLite backend (vendored fork at vendor/headroom/)
  • axum / tokio / tower-http - HTTP proxy (optional, gated behind proxy feature)
  • serde / serde_json - Serialization
  • blake3 - Content-addressed hashing

See Also

License

CC0-1.0 - public domain.