Skip to content
thefahienPublic

About

Turn commands, processes, health checks, JSON APIs and Prometheus queries into live tabs in a herdr pane

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

herdeck

A small framework for putting live service views into a herdr pane. One hotkey opens a tabbed popup; every tab is declared in a TOML file. Point a tab at a command, your processes, a set of health checks, any JSON API or a Prometheus query and it becomes a scrollable, colour-coded table that refreshes in the background. Anything those can't express is a small script in any language that prints JSON.

herdeck switching between tabs for services, GPUs, AI quotas and a custom exec tab

●1:Processes   2:Disk   3:Services   4:Containers   5:Nodes   6:GPUs   7:AI quotas   12:04:51
──────────────────────────────────────────────────────────────────────────────────────────────
 3/4 up
 SERVICE    STATE  CODE  LATENCY  TREND       TARGET
 website    UP     200   38 ms    ▃▄▃▅▃▄      https://example.com/
 api        UP     200   12 ms    ▂▂▃▂▂▂      http://localhost:8080/health
 worker     DOWN   503   120 ms   ▅▆█▇▆█      http://localhost:9000/ready
 postgres   UP     tcp   1 ms     ▁▁▁▁▁▁      localhost:5432
──────────────────────────────────────────────────────────────────────────────────────────────
 expected 200
 Tab/1-9/click:tabs · j/k/wheel:rows · r:refresh · ?:help · q:close                   [OK]
  • One static Rust binary (ratatui). Linux and macOS, x86_64 and arm64. Nothing else to install.
  • Keyboard and mouse: Tab/1-9/click to switch tabs, j k/wheel/click for rows.
  • Fetching never blocks the UI. A source that fails after working shows its last data as Stale; a tab that isn't set up yet says what to add. herdeck never shows made-up data unless you ask for it with --demo.
  • Runs on its own too: herdeck in any terminal, herdeck --once for plain text.

Tab types

type shows typical use
command output of any shell command as lines (with regex highlighting), a whitespace table, or JSON / JSON lines mapped to columns logs, df, docker ps, kubectl get pods -o json, systemctl list-units, gh run list --json
processes local processes with CPU / memory bars, filtered by regex or user "is my worker still running and how hot is it"
http HTTP checks (status, body text, latency trend) and TCP port checks service health board
json any HTTP API returning JSON, with dotted paths to the rows and fields job queues, internal status endpoints, CI APIs
prometheus PromQL queries as columns, one row per label value, optional trend sparklines node CPU / RAM / load, request rates, queue depth
exec any program (any language) that prints herdeck's JSON row format anything else
gpu, ai-quotas two richer built-in examples: GPU cards with lane switching, and Claude / Codex / Antigravity plan quotas through a CLIProxyAPI container see examples/tabs.toml

Columns for json, command (json / jsonl / table) and prometheus take the same options: bar = 100 (draw a meter against that maximum), scale, unit, format = "{:.2f}", spark = true, and colour rules ok_values, warn_values, bad_values, warn_above, bad_above, warn_below, bad_below.

Install as a herdr plugin

herdr plugin install thefahien/herdeck

The install step downloads the release binary for your OS and CPU and checks it against the release's SHA256SUMS; with no matching release it builds from source with cargo. Updates: run the same command again (add --ref vX.Y.Z to pin a version).

Bind one key in ~/.config/herdr/config.toml on the machine you attach from, then run herdr config check && herdr server reload-config:

[[keys.command]]
key = "alt+v"
type = "plugin_action"
command = "herdeck.open"
description = "herdeck"

herdeck.split opens the same deck in a persistent split pane.

Herdr desktop app

herdeck also ships as a native mod for the Herdr desktop app: the same deck as a GPU-drawn panel (real bars and sparklines, theme colours, mouse and keyboard), as a pane, a tab or an overlay. It runs herdeck --json through sh, sources ~/.config/herdeck/env like the plugin pane does, and reads nothing else. Mods are unsandboxed code: read app/mods/herdeck/main.js before you add it.

  1. Install herdeck on the machine (needs a build with --json; see docs/json.md).
  2. Ask your Herdr agent to "add the mod at github.com/thefahien/herdeck/tree/main/app", or by hand: cp -R app/mods/herdeck ~/.config/herdr-app/mods/, merge app/keys.json into your keys.json, then herdr-app check ~/.config/herdr-app/mods/herdeck.
  3. Open it with ctrl-shift-h, or herdr-app do pane.split --direction right --mod herdeck.

Details, behaviour and the full spec: app/RECIPE.md.

Configure

First run

The first time herdeck opens (in herdr or a terminal) there is no deck yet, so it asks which tabs you want. It offers only tabs that work right away on your machine (processes, disks, docker containers and systemd services if you have them, logs); Processes and Disk are ticked. Press Enter and the deck is written to ~/.config/herdeck/tabs.toml.

Everything else is a tab you add to that file yourself: health checks, Prometheus, a JSON API, any command, or your own script (see the tab types below). A tab that is missing a setting says what to add instead of showing data.

Without the picker, for scripts and agents:

herdeck init --list                        # the starter tabs, and which work here
herdeck init                               # Processes + Disk
herdeck init --with processes,containers   # or pick them
herdeck --once                             # check every tab as plain text

Setting herdeck up with an AI agent: point it at docs/setup.md. herdeck --demo shows every tab type with sample data, to look around first. examples/tabs.toml has one of every tab type with comments.

A tab is a [[tab]] table with name, type, an optional interval (seconds) and the type's own keys:

[[tab]]
name = "Containers"
type = "command"
command = "docker ps -a --format '{{json .}}'"
format = "jsonl"
interval = 10
[[tab.column]]
title = "Name"
path = "Names"
[[tab.column]]
title = "State"
path = "State"
ok_values = ["running"]
bad_values = ["exited", "dead"]

[[tab]]
name = "Nodes"
type = "prometheus"
url = "${PROMETHEUS_URL:-http://localhost:9090}"
label = "instance"
[[tab.metric]]
title = "CPU"
query = '100 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[1m])) * 100'
bar = 100
[[tab.metric]]
title = "Load"
query = "node_load1"
format = "{:.2f}"
bad_above = 8

examples/tabs.toml has one of every type. Config lookup: --config PATH, then $HERDECK_CONFIG, then ~/.config/herdeck/tabs.toml.

Trust: a deck runs shell commands (command tabs) and programs (exec tabs). Treat tabs.toml like a shell script and don't load decks you haven't read.

Secrets: any string may use ${NAME} or ${NAME:-default}. In command strings the shell expands variables itself (values are never pasted into the command line). Plugin panes don't inherit your shell, so put variables in ~/.config/herdeck/env; the pane script sources it with sh (NAME=value lines, quote values that contain spaces or $). Tokens are only sent where the tab sends them, redirects are never followed, and TLS is always verified (use plain http for a local endpoint with a self-signed certificate).

The two richer examples

gpu reads GET <url>/api/state and expects:

{"gpus": [{
  "id": "gpu0", "label": "GPU 0: RTX 4090", "active": "render",
  "card": {"util": 45, "vram_used_mb": 12288, "vram_total_mb": 24576, "temp_c": 58, "power_w": 240},
  "util_hist": [10, 20, 45],
  "procs": [{"pid": "1042", "name": "python worker.py", "mem": "11.8 GiB"}],
  "lanes": [{"id": "render", "label": "Render"}, {"id": "llm", "label": "LLM"}]
}]}

lanes are optional. Switching (after a y/N prompt) sends POST <url>/api/switch {"gpu": id, "lane": id, "force": bool} with Authorization: Bearer <token>, only over https or to localhost.

ai-quotas shows plan usage for the Claude, Codex and Antigravity accounts logged into a CLIProxyAPI container. Over SSH it reads the first claude-*, codex-* and antigravity-* auth file in the container (auth_dir, default /root/.cli-proxy-api) and calls each provider's usage endpoint with that token; it also counts requests per model from the container log. Tokens are never written to disk or shown. Those usage endpoints are undocumented, may change without notice, and using them may fall under each provider's terms; it's an example of what a custom view can do, not a supported API client.

Write your own tab

An exec tab runs any program and renders the JSON it prints. Use any language:

[[tab]]
name = "Queue"
type = "exec"
command = "python3 ~/.config/herdeck/queue.py"   # or a list, run without a shell
interval = 5

The program prints one JSON object:

{
  "header": "3 jobs",
  "columns": ["JOB", "PROGRESS", "STATE"],
  "rows": [
    ["encode", {"bar": 50, "max": 100}, {"text": "running", "tone": "accent"}],
    {"section": "finished"},
    ["upload", {"bar": 100}, {"text": "failed", "tone": "bad"}]
  ],
  "details": ["shown under the table while row 1 is selected"]
}

A cell is a string or number, {"text": .., "tone": "ok|warn|bad|accent|dim"}, {"bar": value, "max": 100, "text": ".."} or {"spark": [1, 2, 3]}. A row is a list of cells, an object keyed by column title, or {"section": "Title"}. Exit non-zero with a message on stderr to report an error; the tab keeps showing the last good output as Stale. examples/weather.py is a complete example.

If your program already prints plain JSON, use a command tab with format = "json" and [[tab.column]] mappings instead. To add a built-in tab type, see CONTRIBUTING.md.

Keys

key action
Tab ] / Shift+Tab [ next / previous tab
1-9, click jump to a tab
j k, arrows, wheel, click move / select a row
PgUp PgDn g G page, top, bottom
r refresh the tab now
? help
q / Esc close

GPU tab only: s opens a lane-switch prompt for the selected card (s or arrows pick the lane, y confirms); the line under the table shows its lanes and processes.

CLI

The plugin keeps its binary in bin/herdeck inside the plugin directory; you can also cargo install --git https://github.com/thefahien/herdeck and run it in any terminal.

herdeck                      # interactive
herdeck --once               # every tab once, as text (also when stdout isn't a TTY)
herdeck --json               # every tab once, as one JSON document (docs/json.md)
herdeck --tab Services       # start on a tab (number or name)
herdeck --config deck.toml   # another deck
herdeck --types              # list tab types

herdeck --json [--tab N|NAME] [--timeout SECS] prints the fetched tabs as JSON, for programs that draw the deck themselves. The format is described in docs/json.md.

Develop

cargo build --release && target/release/herdeck
sh scripts/check.sh          # what CI runs: fmt, clippy, tests, build, pty e2e, --json contract, privacy scan

See CONTRIBUTING.md for the layout and the release process. python3 scripts/demo-svg.py re-records docs/demo.svg from herdeck --demo (sample data only).

License

MIT

About

Turn commands, processes, health checks, JSON APIs and Prometheus queries into live tabs in a herdr pane

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages