129K lines of pure C11 — modular static libraries, 56 standalone binaries, zero external dependencies. Every component from HTTP to TLS to containers built in-house.
scorpiox code is written entirely in C11 with zero external runtime dependencies. The codebase compiles to 56 standalone static binaries — each tool is self-contained with no shared libraries needed at runtime. The architecture follows a layered library model: foundational utilities in libsxutil, networking and AI providers in libsxnet, and terminal UI in libsxui.
| Module | Type | Lines | Files | Purpose |
|---|---|---|---|---|
libsxutil |
library | 19,221 | 55 | Core utilities — config, logging, platform abstraction, conversation management, session handling, command parsing, PTY control, process monitoring, background tasks, tool definitions, WASM execution support |
libsxnet |
library | 21,149 | 36 | Networking and AI providers — HTTP client, streaming SSE, multi-provider AI backends (Anthropic, OpenAI, Gemini, Claude Code, Codex, ScorpioX), MCP protocol, FRP reverse proxy, JSON processing |
libsxui |
library | 11,092 | 15 | Terminal UI — rich TUI rendering, ANSI escape sequences, input handling, markdown rendering, syntax highlighting, diff viewer, image display |
libsxbridge |
library | 524 | 2 | C#/.NET bridge — P/Invoke compatible shared library interface for managed language interop |
sxterm |
library | 1,874 | 2 | Terminal control — raw terminal mode, input parsing, UTF-8 handling |
libtb4 |
library | 1,022 | 3 | Thunderbolt 4 raw Ethernet — direct frame I/O for LAN file transfer |
yyjson |
vendored | 19,556 | 2 | High-performance JSON parser — vendored, used via sx_json_yy wrapper layer |
mbedTLS |
vendored | 206,340 | 18 | TLS library — vendored for FRP crypto, email server TLS. Avoids OpenSSL dependency |
sx (main TUI) ├── sxui ────────┐ │ ├── sxutil │ │ └── sxnet │ ├── sxnet ───────┤ │ ├── sxutil │ │ └── mbedtls │ ├── sxutil ──────┤ │ └── yyjson │ ├── sxterm │ └── curl (system) │ │ sxbridge ──────────┘ └── sxutil ▪ vendored ▪ project lib ▪ dependency flow
| Name | Lines | Description |
|---|---|---|
sx |
6,176 | Main TUI — the primary interactive terminal UI (aliased as "scorpiox") |
scorpiox-tmux |
6,048 | Tmux mission control — terminal multiplexer management with sxmux backend |
scorpiox-multiplexer |
4,949 | Terminal multiplexer — built-in PTY-based terminal multiplexer |
scorpiox-server-email |
5,378 | Full SMTP + IMAP email server with TLS, DKIM, maildir storage |
scorpiox-server |
3,018 | HTTP server for Python script execution |
scorpiox-bashShell wrapperscorpiox-configConfiguration managementscorpiox-convConversation managerscorpiox-debugDebugging toolscorpiox-loggerLog viewerscorpiox-searchWeb search toolscorpiox-docsDocumentation readerscorpiox-agentAgentic executorscorpiox-tasksTask managerscorpiox-planmodePlan mode managerscorpiox-askuserquestionInteractive Q&A TUIscorpiox-voiceVoice recording & transcriptionscorpiox-emailEmail client (SMTP sender)scorpiox-executecurlCurl executorscorpiox-mcpMCP protocol clientscorpiox-hookEvent hook systemscorpiox-cronCrontab wrapper CLIscorpiox-sdkHeadless CLI for programmatic usagescorpiox-screenshotCross-platform screenshotscorpiox-renderimageTerminal image rendererscorpiox-rewindConversation rewind toolscorpiox-transcriptTranscript viewer TUIscorpiox-otpTOTP generatorscorpiox-usageToken usage trackingscorpiox-runtestTest runnerscorpiox-systempromptSystem prompt managementscorpiox-printlogsLog printerscorpiox-emit-sessionSession event telemetryscorpiox-frpFRP-compatible reverse proxy clientscorpiox-dnsLightweight LAN DNS serverscorpiox-beamFast LAN file transferscorpiox-thunderbolt4Raw Ethernet file transfer over TB4scorpiox-hostSession gateway server + CLI clientscorpiox-trafficNetwork traffic monitoringscorpiox-sshpassSSH wrapper with PTY password feedingscorpiox-geminiAnthropic-to-Gemini API proxyscorpiox-openaiAnthropic-to-OpenAI API proxyscorpiox-pwshRemote PowerShell via REST APIscorpiox-spaceship-cliDNS management via Spaceship APIscorpiox-claudecode-fetchtokenClaude Code token fetcherscorpiox-codex-fetchtokenCodex token fetcherscorpiox-whatsappWhatsApp CLIscorpiox-imessageiMessage CLIscorpiox-podmanPodman container executionscorpiox-unshareRootless container runtime using user namespaces — pure libcscorpiox-initContainer init binary — PID 1 inside containersscorpiox-vmKVM virtual machine runner — direct kernel boot via KVM ioctlsscorpiox-wslWSL2 stateless executionscorpiox-busyboxBusyBox applet managerscorpiox-vault-gitGit repo offline backupscorpiox-mirror-gitGit fleet mirror tool| Pattern | Detail |
|---|---|
| Memory Management | Manual malloc/calloc/realloc/free — no arenas, some pool patterns. 176 pool refs, 121 malloc, 31 calloc, 51 realloc, 753 free calls in core libs. |
| String Handling | Safe C string functions — snprintf (2064 calls), strncpy (543), strdup (390). Standard libc approach, no strlcpy. |
| Error Handling | fprintf(stderr, ...) for error reporting (1384 calls), errno checking (354 refs), perror (23), exit() for fatal errors (76 calls). |
| JSON | yyjson (vendored) for high-performance parsing, sx_json_yy wrapper layer in libsxutil, sx_json helpers in libsxnet. |
| HTTP | libcurl for HTTP client, custom SSE streaming parser, WASM-specific HTTP via Emscripten fetch API. |
| TLS | mbedTLS (vendored) for FRP crypto and email server TLS — avoids OpenSSL dependency. |
| Platform Abstraction | sx_platform.h with compile-time #ifdef SX_LINUX/SX_MACOS/SX_WINDOWS/EMSCRIPTEN, runtime detection. |
| Provider Pattern | Plugin-like multi-provider system — sx_provider.c dispatches to provider-specific implementations (Anthropic, OpenAI, Gemini, Claude Code, Codex, ScorpioX). |
| Logging | Custom sx_log module with severity levels, file-based log output. |
| Option | Description |
|---|---|
SX_STATIC_LINK |
Build fully static executables (ON by default) |
SX_CROSS_ARM64 |
Cross-compile for ARM64/aarch64 |
SX_BUILD_TESTS |
Build unit tests |
SX_BUILD_DLL |
Build shared library for C# P/Invoke |
SX_GENERATE_MODELS |
Generate model header from API |
| Directory | Lines | % | |
|---|---|---|---|
scorpiox/libsxutil/ |
19,221 | 5.4% | |
scorpiox/libsxnet/ |
21,149 | 6.0% | |
scorpiox/libsxui/ |
11,092 | 3.1% | |
scorpiox/libsxbridge/ |
524 | 0.1% | |
scorpiox/libtb4/ |
1,022 | 0.3% | |
scorpiox/ (executables) |
75,158 | 21.2% | |
bridge/ |
1,229 | 0.3% | |
vendor/yyjson/ |
19,556 | 5.5% | |
vendor/mbedtls/ |
206,340 | 58.1% | |
| Project code (excl. vendor) | 129,395 | 36.4% | |
| Total (with vendor) | 355,291 | 100% |