| name | zio-golem-development |
|---|---|
| description | Compile, publish, and test the ZIO Golem Scala.js SDK. Use when working on the golem/ subtree: building the SDK, publishing locally, compiling/running the gettingStarted demo, regenerating the agent_guest.wasm, or debugging end-to-end deployment. |
The Golem SDK for Scala.js lives under golem/ in the zio-blocks monorepo. It targets the Golem WIT API v1.5.0 and produces WASM components that run on the Golem platform via a QuickJS-based guest runtime.
golem/
├── core/ # zio-golem-core (Scala.js facades, agent framework)
├── model/ # zio-golem-model (WIT value types, RPC types)
├── macros/ # zio-golem-macros (Scala 3 macros, JVM-only)
├── sbt/ # zio-golem-sbt (SBT plugin, Scala 2.12)
├── mill/ # Mill plugin
├── wit/ # WIT definitions (main.wit + deps/)
│ ├── main.wit # Primary WIT — package golem:agent-guest, world agent-guest
│ ├── deps/ # WIT dependencies (copied from golem repo)
│ └── dts/ # Generated TypeScript d.ts (source of truth for JS exports)
├── tools/ # generate-agent-guest-wasm.sh and agent-wit/
├── examples/ # zioGolemExamples project
├── gettingStarted/ # Standalone demo project (separate sbt build)
├── quickstart/ # Quickstart template
└── docs/ # Documentation
- Scala 3.8.2 (
Scala3GoleminBuildHelper.scala) — All Golem Scala 3 projects. Prefix sbt commands with++3.8.2(without!— upstream deps likeschema,chunkcompile at their own Scala version; only golem projects with 3.8.2 in crossScalaVersions are affected). - Scala 2.12.21 — The SBT plugin (
zioGolemSbt) only. Use++2.12.21!(the!forces override).
Important:
sbt --clientmode preserves Scala version across invocations. Always specify the version explicitly to avoid version drift.
| Project | Description |
|---|---|
zioGolemCoreJS / zioGolemCoreJVM |
Core agent framework, Scala.js facades |
zioGolemModelJS / zioGolemModelJVM |
WIT value types, RPC types |
zioGolemMacros |
Scala 3 macros (JVM only, cross-used at compile time) |
zioGolemSbt |
SBT plugin (Scala 2.12) |
zioGolemExamples |
Example agents |
From the monorepo root (/home/vigoo/projects/zio-blocks):
# Compile examples (good smoke test)
sbt --client "++3.8.2; zioGolemExamples/fastLinkJS"
# Compile core
sbt --client "++3.8.2; zioGolemCoreJS/compile"
# Compile model
sbt --client "++3.8.2; zioGolemModelJS/compile"Use the standard AGENTS.md sbt logging pattern:
ROOT="$(git rev-parse --show-toplevel)" && mkdir -p "$ROOT/.git/agent-logs"
LOG="$ROOT/.git/agent-logs/sbt-$(date +%s)-$$.log"
sbt --client -Dsbt.color=false "++3.8.2; zioGolemExamples/fastLinkJS" >"$LOG" 2>&1
echo "Exit: $? | Log: $LOG"
# Query: tail -50 "$LOG" or grep -i error "$LOG"The gettingStarted project depends on 0.0.0-SNAPSHOT artifacts. All golem projects have publish / skip := true by default, so you must override it.
sbt --client '++3.8.2; set ThisBuild / version := "0.0.0-SNAPSHOT"; set ThisBuild / packageDoc / publishArtifact := false; set every (publish / skip) := false; typeidJVM/publishLocal; typeidJS/publishLocal; chunkJVM/publishLocal; chunkJS/publishLocal; markdownJVM/publishLocal; markdownJS/publishLocal; schemaJVM/publishLocal; schemaJS/publishLocal; zioGolemModelJVM/publishLocal; zioGolemModelJS/publishLocal; zioGolemMacros/publishLocal; zioGolemCoreJS/publishLocal; zioGolemCoreJVM/publishLocal'sbt --client '++2.12.21!; set ThisBuild / version := "0.0.0-SNAPSHOT"; set ThisBuild / packageDoc / publishArtifact := false; set every (publish / skip) := false; zioGolemSbt/publishLocal'Gotcha: The
golemPublishLocalalias inbuild.sbtdoes NOT work correctly — it doesn't overridepublish / skipand uses the wrong Scala 2.12 version. Always use the explicit commands above.
The gettingStarted project at golem/gettingStarted/ is a standalone sbt project (its own build.sbt, project/plugins.sbt). It depends on the SDK at 0.0.0-SNAPSHOT.
- Publish the SDK locally (both steps above).
cd golem/gettingStarted
rm -rf target project/target .bsp .generated .golem
sbt -batch -no-colors -Dsbt.supershell=false compilesbt golemPrepare— Generates.generated/agent_guest.wasm(extracted from plugin resources) and.generated/scala-js-template.yaml(component manifest template).sbt compile— Compiles the Scala agent code.sbt fastLinkJS— Links the Scala.js bundle (produces the JS that QuickJS will run).
build.sbt— EnablesScalaJSPlugin+GolemPlugin, setsscalaJSUseMainModuleInitializer := false, ESModule output.project/plugins.sbt— Addszio-golem-sbtandsbt-scalajs.golem.yaml— Declares app name, includes.generated/scala-js-template.yaml, defines componentscala:demo.repl-counter.rib— Rib script for end-to-end testing viagolem-cli repl.
golem server run --cleanThis starts the all-in-one Golem server on localhost:9881.
cd golem/gettingStarted
bash run.shThe script does:
sbt golemPrepare— Generate wasm + manifest templategolem-cli build --yes— Build the WASM component (links QuickJS runtime + Scala.js bundle)golem-cli deploy --yes— Deploy to local Golem servergolem-cli repl scala:demo --script-file repl-counter.rib— Run the demo
cd golem/gettingStarted
sbt golemPrepare
golem-cli build --yes
golem-cli deploy --yes --local
golem-cli repl scala:demo --script-file repl-counter.rib --localNote:
golem-cliv1.5.0-dev is at/home/vigoo/.cargo/bin/golem-cli. The--localflag targets the local server.
The agent_guest.wasm is the QuickJS-based WASM runtime that wraps the Scala.js bundle. Regenerate it when WIT definitions change.
./golem/tools/generate-agent-guest-wasm.sh- Resolves WIT deps via
wit-deps update. - Stages WIT package from
golem/wit/(skipping theall/dep directory). - Generates TypeScript d.ts definitions via
wasm-rquickjs generate-dts→ saved togolem/wit/dts/. - Generates QuickJS wrapper crate via
wasm-rquickjs generate-wrapper-crate. - Builds with
cargo component build --release. - Installs the wasm into
golem/sbt/src/main/resources/golem/wasm/agent_guest.wasmandgolem/mill/resources/golem/wasm/agent_guest.wasm. - Copies d.ts files to
golem/wit/dts/.
wit-deps(cargo install wit-deps-cli)wasm-rquickjsv0.1.0 (cargo install wasm-rquickjs-cli@0.1.0)- Rust toolchain +
cargo-component(cargo install cargo-component)
- Primary:
golem/wit/main.wit— Thegolem:agent-guestpackage definition. - Dependencies:
golem/wit/deps/— Copied from the main Golem repo at/home/vigoo/projects/golem/wit/deps/. - TypeScript reference:
golem/wit/dts/— Generated d.ts files showing exact JS types expected by the wasm runtime.exports.d.tsis the source of truth for what the JS module must export. - Legacy:
golem/tools/agent-wit/main.wit— May still be referenced butgolem/wit/main.witis authoritative.
- Delete
golem/wit/deps.lock(preventswit-depsfrom restoring stale versions). - Copy fresh deps from the Golem repo:
cp -r /home/vigoo/projects/golem/wit/deps/* golem/wit/deps/. - Run
wit-deps updatefrom thegolem/directory. - Regenerate
agent_guest.wasmusing the generate script.
Gotcha:
wit-depswith a staledeps.lockcan silently overwrite correct deps with old versions.
The TypeScript SDK at /home/vigoo/projects/golem/sdks/ts/wit/ is the reference for correct WIT definitions when in doubt.
| Error | Cause | Solution |
|---|---|---|
Function discover-agent-types not found in interface golem:agent/guest@1.5.0 |
Stale agent_guest.wasm built from old WIT |
Regenerate wasm with generate-agent-guest-wasm.sh |
Cannot find exported JS function guest.discoverAgentTypes |
Scala.js Guest object doesn't match WIT signature | Update Guest.scala to export all 4 functions with correct v1.5.0 signatures (including principal param) |
YAML deserialization error in golem.yaml about BuildCommand |
Old GolemPlugin manifest format | Update GolemPlugin.scala to use v1.5.0 format (componentWasm/outputWasm) |
wit-deps restoring stale 1.1.7 dependencies |
Stale deps.lock |
Delete golem/wit/deps.lock, copy fresh deps from Golem repo |
Provided exports: (empty) after deploy |
QuickJS fails to evaluate the JS module silently | JS crashes during initialization — check for ESM strict-mode issues, bundle size limits, or import path mismatches |
publish / skip preventing local publish |
Default setting in build.sbt |
Use set every (publish / skip) := false in the sbt command |
| Wrong Scala 2.12 version for plugin | golemPublishLocal alias uses 2.12.20 instead of 2.12.21 |
Use the explicit ++2.12.21! command instead of the alias |