---
id: 17558
lang: en
title: "The uison framework builds a 0.9 MB utility instead of 5.1 MB and makes it readable for AI agents"
published_at: "2026-10-29 08:00:16"
source_name: "Habr AI"
source_url: "https://habr.com/ru/articles/1100946/?utm_campaign=1100946&utm_source=habrahabr&utm_medium=rss"
canonical_url: "https://news.hamidun.com/en/news/17558"
categories: ["research", "autonomous"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# The uison framework builds a 0.9 MB utility instead of 5.1 MB and makes it readable for AI agents

> **Краткая суть (BLUF):** Agents like Claude Code struggle with graphical programs: they need a screenshot and have to guess button coordinates. The uison framework in Rust describes the screen as JSON built from 9 shapes, and with the --mcp flag the app hands the agent the screen as text. The Disk Usage utility for macOS built on uison weighs 0.9 MB, while the egui version weighs 5.1 MB. For internal tools, this means not having to build two interfaces.  • Runs on Windows, macOS, Linux, Android, iOS, and in the browser (WASM) • Memory after a disk scan: 97 MB versus 152 MB for egui • Over SSH, the server only needs sshd, with no X11, VNC, or browser

Agents like Claude Code can write code, but they are still clumsy with graphical programs. To press a button, they have to take a screenshot, guess the coordinates, and hope nothing has shifted. The author of the uison project, which was published on Habr, proposes a different approach: the interface is described from the start as data in JSON format, so the same program can be shown to both a human and an agent. The bottom layer of the framework can draw only 9 simple shapes (rectangle, line, text, and so on), which keeps the code compact. In a test on the Disk Usage utility for macOS, the uison version takes up 0.9 MB, while the same program built on the popular Rust library egui takes 5.1 MB. MCP mode (the standard protocol through which Claude Code, Cursor, and other AI clients call external tools) turns the app into a set of commands for an agent, and WASM lets it run directly in the browser.

## How it works: 9 primitives and JSON

The lowest level renders only a JSON frame made of nine primitives: rectangle, line, circle, triangle, polygon, text string, image, clipping region (needed for scrolling), and an invisible zone for mouse and touch input. Everything above that level, including rows, buttons, icons, and your own elements, is reduced to these nine shapes on the way down.

This simplifies porting to new platforms: you only need to implement nine drawing methods and event handling. Windows (x64 and ARM), macOS, Linux, Android, iOS/iPadOS, and the browser via WASM are currently supported. On macOS, the framework uses AppKit and CoreGraphics; on Windows, Direct2D; on Linux, its own code for the Wayland and X11 protocols with dynamic library loading, so the binary depends only on libc. The Android APK builds without Gradle.

To avoid redrawing unnecessary parts, each new frame is compared with the previous one element by element, and the backend updates only the areas that changed. Lists are virtualized: a frame for a mailbox with 2,000 emails contains just a couple dozen rows. You can describe your own elements in Rust, C, C++, or directly in JSON, and the repository includes examples even in assembly.

## Modes for people, SSH, and agents

The same application runs in different modes without changing the source code. Launching it without flags opens a regular window. With the `--console` flag, the program writes JSON frames to stdout and reads events from stdin, so it can run on a server and be operated over SSH as if it were local. The server only needs sshd, and the player itself loads and starts the program. The player can also be built for Android to control a remote utility from a phone.

For agents, there are the `--agent` and `--mcp` modes. In them, the program exposes not coordinates and colors but the meaning of the screen: element roles, names, and states. With `--mcp`, it connects to Claude Code with a single command, `claude mcp add todo -- ./todo --mcp`. The agent calls `snapshot`, receives the screen as text, and acts using the `click`, `type`, and `choose` tools. The response contains only the difference: for example, after entering "Milk" into a to-do list, the agent sees that an item and a delete button were added, and the counter changed from "1 of 3" to "1 of 4". The agent cannot press an inactive button, just as a human cannot; the program reports that it is inactive.

The author showed that the idea extends beyond utilities: HTML and CSS can be converted into the same JSON to produce a simple browser, while uison itself knows nothing about the web.

## Size, memory, and limitations

The comparison was made on the open-source Disk Usage program for macOS in two versions: one on egui and one on uison, both in Rust.

- Size on macOS arm64: 5.1 MB for egui and 0.9 MB for uison (82% smaller). With `opt-level = "s"`, egui is 4.5 MB, so the difference is about fivefold.
- External dependencies in Cargo.lock: 362 for egui, none for uison, only the project's own crates.
- Memory of an empty window: 122 MB versus 55 MB.
- Memory after scanning: 152 MB versus 97 MB, which is 36% less.
- Peak memory during scanning is slightly higher for uison: 183–184 MB versus 167–176 MB.
- Lines of code: 3,198 for egui and 3,547 plus 479 lines of JSON screen description for uison.

This is a comparison of a single utility written by the author himself, so the figures cannot be transferred to arbitrary applications. The author states directly that uison does not replace Qt or other full-featured GUI frameworks. It is intended for utilities, developer tools, and applications with buttons, lists, tables, and forms. Games and complex graphics need other solutions, and JSON at the lowest level was deliberately placed above render speed.

## What to do with this

If you build internal tools that both people and agents will use, this approach is worth a look. One interface without a separate API and without screenshot recognition saves development time and reduces errors in automation. The project is open: there is the uisonlab/uison repository, an SSH player, a WASM demo on GitHub Pages, and lessons in Russian for Rust, C, and C++. To get started, `cargo add uison` and a couple dozen lines of code are enough.

---
- **Первоисточник:** [Habr AI](https://habr.com/ru/articles/1100946/?utm_campaign=1100946&utm_source=habrahabr&utm_medium=rss)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/17558
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
