From a0692056bc58bbbd818cd93c646eed68cc9dbff8 Mon Sep 17 00:00:00 2001 From: Willem van den Ende Date: Mon, 26 Oct 2026 21:08:00 +0000 Subject: [PATCH] demo skill: read the dev port from config; make deps installs JS packages The skill assumed port 4000, but config/dev.exs serves on 8056 (and honours $PORT), so a fresh demo run failed its liveness check and every rodney URL pointed at the wrong port. - demo skill: resolve DEMO_PORT from the app config with `mix run --no-start -e 'Application.get_env(:firehose, FirehoseWeb.Endpoint)[:http][:port]'` (Endpoint.config/1 raises without a started endpoint), derive $DEMO_BASE_URL from it, start the server on that port from app/, and use $DEMO_BASE_URL in every rodney example. The skill also points at .tmp/phx-demo.log and names the assets/node_modules highlight.js failure as a diagnosable cause. - app/Makefile: new `assets` target that runs `npm install` only when node_modules/.package-lock.json is missing, and `deps` now depends on it. A fresh clone gets a working JS bundle from `make deps`/`make test`; later runs never touch the network, so offline runs keep working. Verified: guard skips with node_modules present and installs after moving it aside; the skill's DEMO_PORT command prints 8056 and follows PORT=9999; make check and make test (179 + 162) green. --- .pi/skills/demo/SKILL.md | 32 ++++++++++++++++++++++++++------ app/Makefile | 16 +++++++++++++--- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/.pi/skills/demo/SKILL.md b/.pi/skills/demo/SKILL.md index 3be9966..a41d750 100644 --- a/.pi/skills/demo/SKILL.md +++ b/.pi/skills/demo/SKILL.md @@ -56,17 +56,37 @@ From these sources, produce a demo outline: Interactions: any clicks, form fills, or navigation sequences to perform If no plan exists and commits are ambiguous, ask the user for a brief description of what to demo. -3. Check dev server +3. Resolve the dev port, then check the server -curl -s -o /dev/null -w "%{http_code}" http://localhost:4000/ 2>/dev/null +Never assume a port. The port lives in the project config: `app/config/dev.exs` +sets `port: String.to_integer(System.get_env("PORT") || "8056")`, so `$PORT` +wins and the config default is the fallback. Ask the app, from the repo root: + + DEMO_PORT=$(cd app && mise exec -- mix run --no-start -e \ + 'IO.puts(Application.get_env(:firehose, FirehoseWeb.Endpoint)[:http][:port])') + DEMO_BASE_URL="http://localhost:${DEMO_PORT}" + + curl -s -o /dev/null -w "%{http_code}" "$DEMO_BASE_URL/" + +Use `Application.get_env/2`, not `FirehoseWeb.Endpoint.config(:http)`: with +`--no-start` the endpoint's ETS table does not exist and `config/1` raises. If the server is not reachable: The Phoenix dev server is not running. Start it now? - mix phx.server & + mkdir -p .tmp && (cd app && PORT=$DEMO_PORT mise exec -- mix phx.server \ + > ../.tmp/phx-demo.log 2>&1 &) -After starting, wait up to 10 seconds and verify connectivity. If it still fails, proceed with backend-only evidence (skip all browser screenshots) and note the limitation in the demo document. +Then poll `$DEMO_BASE_URL` for up to 10 seconds. If it still fails, read +`.tmp/phx-demo.log`: a bundle error about `highlight.js` (or any module) means +`app/assets/node_modules` is missing - run `make -C app assets` (root +`make deps` does it too). Only when the server really cannot come up, proceed +with backend-only evidence (skip all browser screenshots) and note the +limitation in the demo document. + +Use `$DEMO_BASE_URL` for every URL below - there is no default port to fall +back on. 4. Handle authentication The app requires authentication for LiveView routes. Before capturing UI screenshots: @@ -84,7 +104,7 @@ The app requires authentication for LiveView routes. Before capturing UI screens Log in via rodney: rodney start - rodney open http://localhost:4000/users/log-in + rodney open "$DEMO_BASE_URL/users/log-in" rodney wait "input[name='user[email]']" rodney input "input[name='user[email]']" "demo@example.com" rodney input "input[name='user[password]']" "demodemo1234" @@ -136,7 +156,7 @@ For each UI page identified in step 2, navigate with rodney, screenshot, and emb Static page capture: -rodney open http://localhost:4000/ +rodney open "$DEMO_BASE_URL/" rodney waitidle rodney screenshot demos/screenshots/-.png diff --git a/app/Makefile b/app/Makefile index 0427c64..36dbd80 100644 --- a/app/Makefile +++ b/app/Makefile @@ -3,7 +3,7 @@ MISE_BIN ?= mise MISE_EXEC = $(MISE_BIN) exec -- -.PHONY: check precommit deps compile test test.coverage coverage format credo verify +.PHONY: check precommit deps assets compile test test.coverage coverage format credo verify # Run all static analysis checks (no database required) check: credo format @@ -11,8 +11,18 @@ check: credo format # Precommit target for CI/pre-commit hooks precommit: check compile -# Sync dependencies -deps: +# Install JS dependencies (esbuild bundle, playwright). `mix phx.server` and +# `mix assets.deploy` need them: without `assets/node_modules` the bundle fails +# to resolve highlight.js and LiveView never loads. +# +# Guarded on npm's own install marker, so a clone pays for it once and later +# runs never touch the network: `make test` keeps working offline. +assets: + @test -f assets/node_modules/.package-lock.json || \ + (echo "==> assets: npm install (first run)"; cd assets && npm install) + +# Sync dependencies (Hex packages + JS packages) +deps: assets $(MISE_EXEC) mix deps.get # Compile the project