Assay — Module Reference
Description: Complete reference for all 40+ Assay modules — 17 Rust builtins and 23 embedded Lua stdlib modules, zero dependencies.

# Module Reference

40+ built-in modules, zero dependencies. Use `assay context <query>` for LLM-ready docs on any module.

    assay modules                    # list all modules
    assay context "grafana health"   # get detailed docs for LLM

## Rust Builtins

Available globally in all `.lua` scripts — no `require` needed.

### HTTP & Networking

Module | Key Functions | Description
--- | --- | ---
`http` | `http.get/post/put/patch/delete/serve` | HTTP client, server, and SSE streaming
`ws` | `ws.connect/send/recv/close` | WebSocket client

#### SSE Streaming Example

    http.serve(8080, {
      GET = {
        ["/events"] = function(req)
          return {
            sse = function(send)
              send({ data = "connected" })
              sleep(1)
              send({ event = "update", data = json.encode({count = 1}), id = "1" })
              -- stream closes when function returns
            end
          }
        end
      }
    })

The `send` callback accepts `event`, `data`, `id`, and `retry` fields. SSE headers (`text/event-stream`, `no-cache`, `keep-alive`) are set automatically.

### Serialization

Module | Key Functions | Description
--- | --- | ---
`json` | `json.parse/encode` | JSON parse and encode
`yaml` | `yaml.parse/encode` | YAML parse and encode
`toml` | `toml.parse/encode` | TOML parse and encode
`base64` | `base64.encode/decode` | Base64 encoding

### System

Module | Key Functions | Description
--- | --- | ---
`fs` | `fs.read/write` | Filesystem operations
`env` | `env.get` | Environment variables
`sleep` | `sleep(n)` | Pause execution
`time` | `time()` | Unix timestamp

### Cryptography

Module | Key Functions | Description
--- | --- | ---
`crypto` | `crypto.jwt_sign/hash/hmac/random` | JWT, hashing, HMAC
`regex` | `regex.match/find/replace` | Regular expressions

### Database

Module | Key Functions | Description
--- | --- | ---
`db` | `db.connect/query/execute/close` | SQL — Postgres, MySQL, SQLite

### Templates & Async

Module | Key Functions | Description
--- | --- | ---
`template` | `template.render/render_string` | Jinja2-compatible templates
`async` | `async.spawn/spawn_interval` | Async task execution

### Testing & Logging

Module | Key Functions | Description
--- | --- | ---
`assert` | `assert.eq/ne/gt/lt/contains/not_nil/matches` | Assertions
`log` | `log.info/warn/error` | Structured logging

## Stdlib Modules

23 embedded Lua modules loaded via `require("assay.<name>")`. All follow the client pattern: `M.client(url, opts)` → client object → `c:method()`.

### Monitoring & Observability

Module | require() | Description | Client Pattern
--- | --- | --- | ---
`assay.prometheus` | `require("assay.prometheus")` | PromQL queries, alerts, targets | `prom.query(url, expr)`
`assay.alertmanager` | `require("assay.alertmanager")` | Alert management, silences | `am.client(url)`
`assay.loki` | `require("assay.loki")` | Log push, query, labels | `loki.client(url)`
`assay.grafana` | `require("assay.grafana")` | Health, dashboards, datasources | `gf.client(url, opts)`

### Kubernetes & GitOps

Module | require() | Description | Client Pattern
--- | --- | --- | ---
`assay.k8s` | `require("assay.k8s")` | 30+ K8s resource types, CRDs | `k8s.client(url, opts)`
`assay.argocd` | `require("assay.argocd")` | Apps, sync, health, projects | `argo.client(url, opts)`
`assay.kargo` | `require("assay.kargo")` | Stages, freight, promotions | `kargo.client(url, opts)`
`assay.flux` | `require("assay.flux")` | GitRepositories, Kustomizations | `flux.client(url, opts)`
`assay.traefik` | `require("assay.traefik")` | Routers, services, middlewares | `traefik.client(url)`

### Security & Identity

Module | require() | Description | Client Pattern
--- | --- | --- | ---
`assay.vault` | `require("assay.vault")` | KV secrets, transit, PKI | `vault.client(url, opts)`
`assay.openbao` | `require("assay.openbao")` | OpenBao (Vault API-compatible) | `bao.client(url, opts)`
`assay.certmanager` | `require("assay.certmanager")` | Certificates, issuers, ACME | `cm.client(url, opts)`
`assay.eso` | `require("assay.eso")` | ExternalSecrets, SecretStores | `eso.client(url, opts)`
`assay.dex` | `require("assay.dex")` | OIDC discovery, JWKS, health | `dex.client(url)`
`assay.zitadel` | `require("assay.zitadel")` | OIDC identity, JWT machine auth | `zitadel.client(url, opts)`

### Infrastructure

Module | require() | Description | Client Pattern
--- | --- | --- | ---
`assay.crossplane` | `require("assay.crossplane")` | Providers, XRDs, compositions | `xp.client(url, opts)`
`assay.velero` | `require("assay.velero")` | Backups, restores, schedules | `velero.client(url, opts)`
`assay.temporal` | `require("assay.temporal")` | Workflows, task queues | `temporal.client(url, opts)`
`assay.harbor` | `require("assay.harbor")` | Projects, repos, vulnerability scanning | `harbor.client(url, opts)`

### Data & Storage

Module | require() | Description | Client Pattern
--- | --- | --- | ---
`assay.postgres` | `require("assay.postgres")` | PostgreSQL user/db management | `pg.client(url, opts)`
`assay.s3` | `require("assay.s3")` | S3-compatible storage, Sig V4 | `s3.client(url, opts)`

### Utilities

Module | require() | Description | Client Pattern
--- | --- | --- | ---
`assay.healthcheck` | `require("assay.healthcheck")` | HTTP checks, JSON path, latency | `hc.check(url, opts)`
`assay.unleash` | `require("assay.unleash")` | Feature flags, environments | `unleash.client(url, opts)`

## Custom Modules

Place `.lua` files in `./modules/` (project-local) or `~/.assay/modules/` (global). Or set `ASSAY_MODULES_PATH` to override the global directory. They are auto-discovered and appear in `assay modules` output.

    ./modules/
      myapi.lua        # require("assay.myapi")
    ~/.assay/modules/
      company.lua      # require("assay.company")

For LLM agents: llms.txt · llms-full.txt