Architecture

163K lines of pure C11. Zero external runtime dependencies. 78 static binaries composed from 8 libraries. Vendored mbedTLS, yyjson, stb_image — nothing else.

163,869
Own Code
517
Source Files
78
Executables
0
External Deps

Overview

scorpiox code is a pure C11 AI coding assistant — no C++, no Rust, no Go. The codebase is organized into layered static libraries that compose into 78 standalone executables. Every binary is statically linked: copy it anywhere and it runs.

Language
C11 (ISO/IEC 9899:2011)
Build System
CMake ≥ 3.16
Dependencies
Zero external — pure C with libc only
Vendored
mbedTLS · yyjson · stb_image
Platforms
Linux · macOS · Windows · Android · iOS · WASM
Linking
Static — single binary per tool

Core Modules

Module Type Lines Files Purpose
libsxutil static library 23,736 61 Core utilities — config, logging, platform abstraction, session, conversation, exec, slash commands, background tasks, process monitoring, JSON (yyjson), PTY, WSL, KQL, metrics
libsxnet static library 22,785 38 Network layer — multi-provider AI API clients (Claude Code, Codex, OpenAI, Gemini, Vertex AI, Anthropic, Scorpiox), streaming HTTP, agent orchestration, MCP, FRP tunnel
libsxhttp static library 630 2 Lightweight HTTP-only — subset of libsxnet for tools that need HTTP without the full provider stack
libsxui static library 11,366 17 Terminal UI — display rendering, input handling, bash terminal embed, file explorer, session resume, infobox overlays, image display (sixel via stb_image)
libsxterm static library 1,951 2 Terminal abstraction — raw mode, ANSI escape sequences, cursor movement, screen management, key parsing, resize handling
libsxbridge static library 625 2 Bridge binary auto-download — fetches and executes external bridge binaries from distribution server
libtb4 static library 1,043 3 Thunderbolt 4 raw Ethernet transport — TCP-like stream semantics over raw Ethernet frames using BPF
yyjson vendored 19,556 2 Fast JSON parser/serializer — vendored C99 library, zero dependencies
mbedTLS vendored 208,584 67 Lightweight TLS/crypto — AES-128-CFB, PBKDF2-SHA1, TLS 1.2/1.3 client; replaces OpenSSL
stb_image header only 20,391 3 Image loading/writing/resizing — single-header PNG, JPEG, BMP support

Dependency Graph

Layer 4 ┌─────────────────────────────────────────────────┐ tools │ 78 executables (sx, scorpiox-server, ...) │ └──────────────────┬──────────────────────────────┘ │ compose from Layer 3 ┌──────────────────▼──────────────────────────────┐ UI │ libsxui — TUI display, input, file explorer │ └──────────────────┬──────────────────────────────┘ │ depends on Layer 2 ┌──────────────────▼──────────────────────────────┐ net │ libsxnet — 8+ AI providers, HTTP, MCP, FRP │ │ libsxhttp — lightweight HTTP subset │ └──────────────────┬──────────────────────────────┘ │ depends on Layer 1 ┌──────────────────▼──────────────────────────────┐ util │ libsxutil — config, logging, exec, platform │ │ libsxterm — terminal raw mode, ANSI sequences │ │ libsxbridge — bridge binary downloader │ │ libtb4 — Thunderbolt 4 Ethernet transport │ └──────────────────┬──────────────────────────────┘ │ depends on Layer 0 ┌──────────────────▼──────────────────────────────┐ vendor │ yyjson (JSON) · mbedTLS (TLS/crypto) │ │ stb_image (PNG/JPEG/BMP) │ └─────────────────────────────────────────────────┘

Executables

Major Components

Main TUI — the primary interactive AI terminal client
HTTP server — serves scorpiox API and manages sessions
Terminal multiplexer — tmux-like session management
Virtual machine manager — container/VM lifecycle
Agent orchestrator — manages tool-use agentic workflows
DNS server/resolver
Linux namespace isolation — container-like sandboxing via unshare(2)
Configuration manager — interactive config editor
Host server — manages remote connections
MCP (Model Context Protocol) server/client
Git mirror — automated repository mirroring
URL fetcher — headless browser-like page fetching with HTML-to-text
Thunderbolt 4 networking — raw Ethernet stream transport
Full email server — SMTP + IMAP with TLS, DKIM, maildir
OpenAI API client — direct OpenAI endpoint access
WhatsApp bridge — messaging integration
iMessage bridge — messaging integration (macOS)
Beam — streaming data transfer
Bash command executor with sandboxing
Transcript viewer — replay conversation sessions

Utility Tools (40)

Minimal vi editor
Advanced grep with context
Network traffic monitor
Cron-like task scheduler
Git/event hook runner
WSL integration tool
Alternative terminal multiplexer
SDK/DLL builder
Interactive question TUI
Permission prompt TUI
Programmatic file editor
Screenshot capture
System init/bootstrap
Google Maps API client
SMTP email sender
Task manager
Web search client
Session rewind tool
Busybox-style multi-tool binary
API usage tracker
Documentation browser
Plan mode manager
Curl command executor
Voice input (speech-to-text)
Skill loader/runner
SSH password helper
Google Weather API client
Encrypted git vault
Debug information dumper
Image renderer (sixel)
Podman container manager
BMP to PNG converter
Smart file reader with line ranges
Test runner
TOTP/HOTP generator
Log viewer/manager
Log printer
Conversation file manager
System prompt manager
KQL query executor

Design Patterns

Pattern
Provider Interface
sx_provider — pluggable backends for 8+ AI services via function pointers
Pattern
Layered Static Libraries
sxutil → sxnet → sxui — strict dependency direction, no circular deps
Pattern
Arena Allocation
procmon and agent subsystems use arena-based memory for bulk allocation/free
Pattern
Platform Abstraction
sx_platform.h — compile-time #ifdef for Windows/Linux/macOS/WASM
Pattern
State Machine
sx_state — conversation progression via explicit state transitions
Pattern
Streaming SSE Parser
sx_claude — incremental Server-Sent Events parser for real-time AI streaming

Build System

Build Type
CMake with static linking
C Standard
-std=c11
Total Targets
78 executables + 8 static libraries + 2 shared
Shared Libraries
scorpiox-server-dll · scorpiox-email-dll

Security Hardening

-fstack-protector-strong
-D_FORTIFY_SOURCE=2
-Wl,-z,noexecstack
-Wl,-z,relro,-z,now
-fcf-protection (GCC)

Link-time Dependencies

libcurl (static) · OpenSSL/LibreSSL (static) · zlib · nghttp2/nghttp3 · brotli · zstd · psl · idn2

Design Principles

Lines of Code

Own Code — 163,869 lines

Tool executables
100,287
libsxutil
23,736
libsxnet
22,785
libsxui (incl. stb)
11,366
libsxterm
1,951
bridge (ws2tcp)
1,250
libtb4
1,043
libsxbridge
625
Tests
896

Vendored Code — 248,531 lines

mbedTLS
208,584
stb_image
20,391
yyjson
19,556
Total: 412,400 lines across 517 files. Own code: 163,869 (39.7%) · Vendor code: 248,531 (60.3%). Vendor code is all compile-time — zero runtime dependency on external packages.