Skip to content

Tooling across platforms

Krueger ships as Scala libraries on three platforms (JVM, Scala.js, Scala Native) and as browser-facing tooling through the published docs site and WASM-backed playgrounds.

Scala library (JVM, Scala.js, Scala Native)

Section titled “Scala library (JVM, Scala.js, Scala Native)”

Use krueger-core (and krueger-trees for the query DSL) from Mill, sbt, or Maven. See Installation and Usage.

The top-level entrypoint is io.eleven19.krueger.Krueger (parseModule, parseModuleToAst, parseCst, …). Generated API HTML for each platform lives under /krueger/api/.

The site at eleven19.github.io/krueger includes this handbook plus a single browser playground:

RouteStackPurpose
/krueger/try/SvelteKit + Scala.jsInteractive playground with a runtime backend selector (WASM or JS).

To build that tree locally, see Contributing → Docs site.

The try-wasm playground loads an ES module that exports a Krueger object (@JSExportTopLevel from KruegerJs.scala). Typical methods:

MethodRole
parseCst(source)Parse Elm source to a CST handle (opaque across the JS boundary).
parseAst(source)Parse to an AST handle.
parseQuery(queryText)Parse a query expression to a handle.
runQuery(queryHandle, cstRoot)Run a parsed query against a CST root from parseCst.
prettyQuery(queryHandle)Canonical string form of a parsed query (no envelope).
tokenize(source)Lexical tokens for editor highlighting.

Most calls return a plain envelope object:

{
ok: boolean,
value: /* opaque handle, matches, or tokens — depends on API */,
logs: string[],
errors: [{ phase, message, span? }, ...]
}

On success, opaque handles must be passed back into runQuery / prettyQuery without serializing them through JSON. On failure, inspect errors (and optional logs).

Inside the Scala codebase, the compiler exposes a canonical UTF-8 JSON contract (invoke(operation, inputJson) → outputJson) shared by JVM tests, future host-callable WASM ABIs, and the browser adapter. That contract is documented for contributors in the repository design note docs/superpowers/specs/2026-04-24-wasm-shared-api-surface-design.md. Most web authors should use the stable Krueger.* methods above instead of calling invoke directly.