mech.app
Dev Tools

CLI-Anything: Universal Command-Line Wrappers Turn Desktop Apps Into Agent Tools

Auto-generated CLI harnesses bridge AI agents to GUI-only software. Examine subprocess orchestration, state serialization, and the CLI-Hub distribution model.

Source: github.com
CLI-Anything: Universal Command-Line Wrappers Turn Desktop Apps Into Agent Tools

Most desktop software was built for humans clicking buttons. CAD tools, video editors, 3D modeling suites, and diagram apps expose no programmatic API. When agents need to use them, the only path is brittle browser automation or screen scraping. CLI-Anything generates typed command-line interfaces for GUI applications, turning them into agent-native tools through subprocess orchestration.

The project hit 35,000 stars in days and ranks #5 on GitHub’s Python trending list. It addresses a core infrastructure gap: agents can call cloud APIs and web services, but they cannot invoke FreeCAD, Blender, or draw.io without a human in the loop. CLI-Anything wraps these applications in stable CLI harnesses, handles state persistence across multi-step workflows, and distributes the wrappers through a package manager called CLI-Hub.

How CLI Generation Works

CLI-Anything does not reverse-engineer binary protocols or hook into private APIs. It generates a command-line interface by wrapping the application’s scripting layer (Python for Blender, JavaScript for Electron apps, Lua for game engines) and exposing high-level operations as CLI verbs.

Each harness follows a three-layer pattern:

  1. Command parser: Uses Click to define typed arguments and flags.
  2. Subprocess launcher: Spawns the target application in headless or GUI mode, injects the scripting payload, and monitors exit codes.
  3. Output serializer: Captures artifacts (files, screenshots, logs) and returns structured JSON to the orchestrating agent.

The generator scans the target application’s scripting documentation, identifies common operations (create, modify, export, render), and emits a CLI module. Developers can extend or override generated commands by contributing to the CLI-Hub repository.

Subprocess Orchestration and State Persistence

Agents often need multi-step workflows: load a CAD file, apply a transformation, export to STL, then render a preview. Each step requires the application to maintain state between invocations.

CLI-Anything handles this through two mechanisms:

  • Session files: The harness serializes application state (scene graph, layer stack, timeline) to a JSON or binary file after each command. The next command loads this file before executing.
  • Persistent process mode: For applications that support it, the harness keeps the subprocess alive and sends commands over stdin or a socket. This avoids startup overhead and preserves in-memory state.

The orchestration layer exposes three preview modes:

ModeBehaviorUse Case
PreviewExecute command, return artifact pathSingle-shot operations (export, compile)
Live PreviewStream intermediate outputs during executionLong-running renders, video encoding
Trajectory LoopAgent inspects output, issues refinement commandsIterative design (adjust lighting, tweak geometry)

Trajectory loops let agents refine outputs without restarting the workflow. The harness checkpoints state after each iteration, so the agent can roll back or branch.

CLI-Hub: Distribution and Versioning

CLI-Hub is a package manager for agent tool wrappers. Install it with pip install cli-anything-hub, then run cli-hub install freecad to fetch the FreeCAD harness.

The hub solves three problems:

  1. Discovery: Agents query the hub for available tools by category (CAD, video, diagramming) or capability (3D export, subtitle generation).
  2. Versioning: Each harness declares compatibility with specific application versions. The hub resolves dependencies and warns about breaking changes.
  3. Validation: Community contributions go through a PR review. The hub runs 2,269 unit and end-to-end tests before merging.

The hub is a static site hosted on GitHub Pages, backed by a JSON manifest. When you install a harness, the CLI downloads a Python module and registers it as a command-line tool. The manifest tracks download counts, test pass rates, and maintainer contact info.

Error Boundaries and Failure Modes

Desktop applications crash. They hang on malformed input, run out of memory, or fail to initialize GPU contexts. CLI-Anything wraps each subprocess call in a timeout and retry loop.

The harness monitors three failure signals:

  • Exit code: Non-zero indicates the application rejected the command.
  • Stderr pattern matching: The harness scans logs for known error strings (missing dependency, unsupported file format).
  • Output validation: After execution, the harness checks that expected artifacts exist and are non-empty.

When a command fails, the harness returns a structured error object:

{
  "status": "error",
  "error_type": "subprocess_timeout",
  "stderr": "FreeCAD: Segmentation fault in Part::TopoShape",
  "recovery_hint": "Reduce mesh complexity or increase timeout"
}

Agents can parse this and retry with adjusted parameters. The harness does not attempt automatic recovery (restarting the app, reducing quality settings) because those decisions depend on the agent’s goal.

Artifact Serialization

Agents need structured outputs. A CAD operation might produce an STL file, a thumbnail PNG, and a build log. CLI-Anything returns all artifacts as a JSON object:

{
  "status": "success",
  "artifacts": {
    "model": "/tmp/output.stl",
    "preview": "/tmp/preview.png",
    "log": "/tmp/build.log"
  },
  "metadata": {
    "vertices": 12483,
    "faces": 24960,
    "execution_time_ms": 3421
  }
}

The harness copies artifacts to a staging directory and returns absolute paths. Agents can upload them to object storage, pass them to the next tool, or present them to a human for approval.

For streaming outputs (video encoding, large renders), the harness writes chunks to a named pipe and returns the pipe path. The agent reads incrementally without waiting for completion.

Real-World Demos

The repository includes 18 demonstrations across CAD, 3D modeling, diagramming, and gameplay:

  • FreeCAD: Agent generates a parametric bracket from natural language specs, exports to STL.
  • Blender: Agent loads a scene, adjusts lighting, renders from multiple angles.
  • draw.io: Agent creates a system architecture diagram from a text description.
  • Subtitle generation: Agent transcribes video, generates SRT file, burns subtitles into output.

Each demo shows the agent issuing CLI commands, inspecting outputs, and refining results through trajectory loops. The demos run in CI on every commit, ensuring harnesses stay compatible with upstream application updates.

Technical Verdict

Use CLI-Anything when:

  • Your agents need to invoke desktop software that lacks a web API or SDK.
  • You can tolerate subprocess overhead (100-500ms startup per invocation).
  • The target application exposes a scripting layer (Python, JavaScript, Lua).
  • You need reproducible, version-controlled tool definitions for agent workflows.

Avoid it when:

  • The application has an official API (use that instead).
  • You need sub-100ms latency (subprocess orchestration adds overhead).
  • The application requires interactive input (CLI-Anything assumes headless or scriptable operation).
  • You are wrapping proprietary software with restrictive licensing (check terms before distributing harnesses).

The project fills a real gap. Most agent orchestration frameworks assume tools are HTTP endpoints or Python functions. CLI-Anything extends the tool surface to include the entire universe of desktop software, at the cost of subprocess complexity and platform-specific quirks. If your agents need to drive CAD tools or video editors, this is the only open infrastructure that handles the plumbing.