Featured image of post sth: An HTML Preview Server for AI Agents

sth: An HTML Preview Server for AI Agents

语速

I’ve open sourced a small tool: static-html, with the command-line name sth.

What it does is simple: it provides an HTTP service that lets you register locally generated HTML files and preview them in a browser.

Why This Tool Is Needed

The problem stems from AI Agent output.

Nowadays I use agents like Claude Code and OpenCode for my work, and they often need to output complex content—code review summaries, comparative analyses, quotations, architecture design documents. When this content is sent to Telegram as plain text, the formatting gets completely messed up, tables become unreadable, and code syntax highlighting is lost.

In short, it’s just a big mess.

The initial approach was to have agents directly generate HTML files locally and open them in a browser. But the problems were:

  • The agent runs on a server without a graphical interface
  • Locally generated file paths are unpredictable and management is chaotic
  • No history—previously sent content can’t be found

So I needed a service where an agent could “send” an HTML file and get back a URL that could be opened in any device’s browser. The agent would handle mobile and PC compatibility.

What sth Does

sth is a lightweight HTTP service written in Go with just two core commands:

1
2
3
4
5
# Start the service
sth start

# Send an HTML file
sth send ./report.html

sth send packages the target HTML file along with resource files from the same directory (CSS, JS, images, etc.) and uploads them, then returns a URL. Opening this URL displays the complete page effect.

In practice, it runs on my intranet development machine, and agents specify the remote address via the --server parameter:

1
sth send ./report.html --server http://dev-1:3939

My Actual Usage

Currently sth mainly runs on my development server, working in tandem with the Hermes Agent.

Hermes is my daily AI assistant running on Telegram. When it needs to output complex content—such as code review conclusions, technical solution comparisons, project quotations—it calls the html-report skill to generate a beautifully formatted HTML file, then sends it to the preview server via sth send, and finally sends me the URL.

The entire workflow is:

1
2
3
4
User question -> Hermes Agent analysis
  -> Generate HTML report (html-report skill)
    -> sth send to preview server
      -> Return URL -> Send to Telegram

This way I can tap the link on my phone and see a well-formatted report instead of a blob of plain text.

Metadata Management

Beyond basic sending and previewing, sth also supports tagging, categorizing, and associating sessions with projects:

1
2
3
4
5
sth tag <session-id> code-review pricing
sth categorize <session-id> "Technical Review"
sth project <session-id> hydrogen-permeation
sth list --project hydrogen-permeation
sth search "quotation" --tag pricing

This feature solves a practical problem: over time, sent reports accumulate. Through tags and project categorization, you can quickly find previous outputs.

The difference between list and search is: list matches metadata fields exactly, while search performs full-text search. They can be used in combination.

Technical Details

  • Language: Go 1.24+
  • Storage: SQLite (github.com/mattn/go-sqlite3, requires CGO)
  • Deployment: Single binary file, just manage with systemd
  • Build: go build -o dist/sth ./cmd/html-server

It’s just that simple, no unnecessary dependencies.

Open Source

This tool was previously a private repo, but I just made it public today: sun-praise/static-html.

If you’re also using AI Agents for daily development work and have encountered the problem where “complex agent output can’t be read in chat tools,” give sth a try. It’s lightweight enough and does what it needs to do.