dev: just seed-node, a node in the test ensemble filled with sample content

scripts/seed-content.sh synthesizes PDFs, pictures, a comic, tagged music
and a video (typst/ImageMagick/ffmpeg, fixed seeds); the recipe imports
them into a fresh node joined to PERSONAL_TEST_ENSEMBLE_PK and adds notes,
humans and clippings through the CLI, then leaves its daemon serving them.
Seeding one node is how a GUI and an emulator get matching screens to
compare, which the Android visual review needs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Greg ShuflinandClaude Opus 5.5 committed 2026-11-02 22:12:05 -08:00
1 parent 695a34cb43
commit bf0fce0c9a
2 files changed
+190

No files matched your search

+94
View File
@@ -554,6 +554,100 @@ scratch-store dir name="scratch":
syn -s "{{dir}}" init -n "{{name}}" --new-ensemble >/dev/null
syn -s "{{dir}}" status
# Create a node in `dir` holding a representative spread of content — PDFs,
# pictures, a comic, music, a video, notes, humans and clippings — for checking
# screens against something other than an empty state. It joins the ensemble of
# `keyphrase` (by default the personal test ensemble), so every other member
# syncs the same data from it: seed one node, then point a GUI and an emulator
# at the same ensemble and they show matching screens. The files come from
# `scripts/seed-content.sh` (needs typst, ImageMagick, ffmpeg and zip) and are
# all synthesized. The node's daemon is left running, to serve them. Keep `dir`
# short (`test/store-dirs/seed`): the daemon's socket lives in it, and a Unix
# socket path has a ~108-byte limit.
[doc: "Create a node joined to the test ensemble and fill it with sample content"]
[group: "dev"]
seed-node dir name="seed" keyphrase=PERSONAL_TEST_ENSEMBLE_PK:
#!/usr/bin/env bash
set -euo pipefail
if [ -e "{{dir}}" ]; then
echo "'{{dir}}' already exists; delete it or pick another directory" >&2
exit 1
fi
content=$(mktemp -d)/content
scripts/seed-content.sh "$content"
syn() { cargo run -q --manifest-path rust/Cargo.toml --bin syn -- -s "{{dir}}" "$@"; }
# `Created note "…" [id]` — the id is what the next command needs.
created_id() { sed -n 's/.*\[\(.*\)\]$/\1/p'; }
syn init -n "{{name}}" --keyphrase "{{keyphrase}}" >/dev/null
# Several commands below start a daemon on their own; starting it up front
# keeps every write going through one process. A daemon that is still
# starting can answer "database is busy", so wait until it answers a read.
syn daemon start >/dev/null
until syn notes notebook list >/dev/null 2>&1; do sleep 1; done
for kind in pdfs pictures comics music video; do
syn docs import "$content/$kind"
done
syn music build-library >/dev/null
book=$(syn notes notebook new "Field notes" | created_id)
trips=$(syn notes collection new "$book" "Trips" | created_id)
note() { # PARENT TITLE, body on stdin
local id
id=$(syn notes note new "$1" "$2" | created_id)
syn notes note write "$id" >/dev/null
}
note "$book" "Reading list" <<'MD'
# Reading list
- [ ] *A Field Guide to the Small Ferns of the Pacific Northwest*
- [x] The quarterly report, both drafts
- [ ] Something with no ferns in it
See also [[Ideas for the garden]].
MD
note "$book" "Ideas for the garden" <<'MD'
# Ideas for the garden
A shady corner by the north fence wants **sword fern** and *deer fern*;
the rest of the bed gets more sun than either likes.
> Ferns don't flower, so the interest has to come from texture.
| Plant | Light | Water |
| ---------- | ----- | ------ |
| Sword fern | shade | low |
| Deer fern | shade | medium |
MD
note "$trips" "Coast weekend - packing list for the long drive" <<'MD'
# Packing
1. Rain shell
2. Field guide
3. Thermos
```sh
syn docs sync <id> # pull the guide onto the phone before leaving
```
MD
syn humans add "Ada Okafor" --nickname Ada --birth-date 1988-04-12 \
--fact job="Structural engineer" --fact city=Portland --notes "Met at the fern society."
syn humans add "Bram de Vries" --birth-date=--09-30 --fact city=Utrecht
syn humans add "Chen Wei" --fact job=Cartographer --fact "favorite fern=Maidenhair"
syn humans add "Dolores Ibarra-Castellanos" --nickname Lola --gender female \
--notes "Long name, for checking how a row truncates."
syn clippings capture --url https://example.org/ferns --page-title "On ferns" \
"Ferns reproduce by spores rather than seeds, which is why none of them flower."
syn clippings capture --url https://example.org/coast --page-title "Coast trail conditions" \
"The north section of the trail is closed until spring; the south loop is open."
syn clippings capture "A clipping with no source page at all."
rm -rf "$(dirname "$content")"
syn status
echo "Its daemon is running and serving this to the ensemble; stop it with: syn -s {{dir}} daemon stop"
# Create two test stores (node_a, node_b) with deterministic keypairs for local P2P experimentation.
# Pass `reset=true` to wipe and recreate existing stores.
[doc: "Create two deterministic test stores (node_a, node_b) for local P2P experimentation"]
+96
View File
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
# Generate a small, representative set of media files for seeding a node:
# PDFs, pictures, a comic, tagged music and a video. Everything is synthesized
# (typst, ImageMagick, ffmpeg) rather than copied from anywhere, so it is safe
# to sync into any ensemble and to show in a screenshot.
#
# Used by `just seed-node`, which imports the result and adds the records the
# CLI writes directly (notes, humans, clippings). Run it on its own to get the
# files without a node:
#
# scripts/seed-content.sh /tmp/seed
#
# The set is chosen to exercise the UI, not to be realistic in bulk:
# - two PDF titles that differ only at the end ("- draft" / "- final"), and one
# long enough to truncate, so a middle ellipsis can be checked by eye;
# - a portrait picture among landscape ones, for grid cropping;
# - a comic with a cover and paneled pages, and an album with embedded art.
#
# Output is deterministic: plasma fractals take a fixed seed, so re-running
# produces the same pixels and a re-shot screenshot differs only where the app
# changed.
set -euo pipefail
out=${1:?usage: seed-content.sh OUT_DIR}
for tool in typst magick ffmpeg zip; do
command -v "$tool" >/dev/null || { echo "seed-content: needs '$tool' on PATH" >&2; exit 1; }
done
if [ -e "$out" ]; then
echo "seed-content: '$out' already exists; delete it or pick another directory" >&2
exit 1
fi
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
mkdir -p "$out"/{pdfs,pictures,comics,music,video}
pdf() { # TITLE PAGES
local title=$1 pages=$2 src="$work/pdf.typ"
{
echo '#set page(paper: "a5", margin: 2cm)'
echo "#set document(title: \"$title\")"
echo '#set text(size: 10pt)'
echo "= $title"
for i in $(seq 1 "$pages"); do
echo "== Section $i"
echo '#lorem(220)'
if [ "$i" -lt "$pages" ]; then echo '#pagebreak()'; fi
done
} >"$src"
typst compile "$src" "$out/pdfs/$title.pdf"
}
pdf "Quarterly report - draft" 4
pdf "Quarterly report - final" 5
pdf "A Field Guide to the Small Ferns of the Pacific Northwest" 12
pdf "Lease agreement" 3
picture() { # NAME SIZE FILL
magick -seed 7 -size "$2" "$3" -blur 0x2 "$out/pictures/$1.jpg"
}
picture IMG_20260411_143001 1600x1200 plasma:steelblue-navy
picture IMG_20260512_091502 1600x1200 plasma:orange-purple
picture IMG_20260613_184503 1600x1200 'gradient:#2b5876-#4e4376'
picture IMG_20260714_120004 1600x1200 plasma:seagreen-khaki
picture IMG_20260815_201505 1600x1200 'gradient:#ffd89b-#19547b'
picture IMG_20260916_073006 1600x1200 plasma:tomato-gold
picture "Tall portrait" 1200x1800 plasma:gray20-gray70
comic="$work/comic"
mkdir -p "$comic"
magick -size 1200x1800 'gradient:#0b1d3a-#e8a23a' -gravity north -fill white \
-pointsize 120 -annotate +0+160 'The Lighthouse' \
-pointsize 90 -annotate +0+320 'Keeper' \
-pointsize 60 -annotate +0+1600 'Vol. 1' \
"$comic/000.png"
for p in 1 2 3 4 5 6 7; do
magick -size 1200x1800 xc:white -fill none -stroke black -strokewidth 8 \
-draw 'rectangle 60,60 1140,620' -draw 'rectangle 60,680 580,1240' \
-draw 'rectangle 620,680 1140,1240' -draw 'rectangle 60,1300 1140,1740' \
-stroke none -fill gray30 -pointsize 60 -annotate +100+160 "Page $p" \
"$comic/$(printf %03d "$p").png"
done
(cd "$comic" && zip -q "$out/comics/The Lighthouse Keeper, Vol. 1.cbz" ./*.png)
magick -size 600x600 'gradient:#1a52d8-#05070c' "$work/cover.jpg"
n=0
for hz in 220 330 440 550; do
n=$((n + 1))
ffmpeg -loglevel error -f lavfi -i "sine=frequency=$hz:duration=20" -i "$work/cover.jpg" \
-map 0:a -map 1:v -c:a libmp3lame -b:a 96k -c:v mjpeg -disposition:v attached_pic \
-metadata artist="Test Pattern" -metadata album="Calibration Tones" \
-metadata title="Tone $hz Hz" -metadata track="$n" -metadata date=2026 \
"$out/music/0$n - Tone $hz Hz.mp3"
done
ffmpeg -loglevel error -f lavfi -i testsrc2=size=1280x720:rate=24:duration=12 \
-f lavfi -i "sine=frequency=330:duration=12" \
-c:v libx264 -pix_fmt yuv420p -c:a aac -shortest "$out/video/Test signal.mp4"