From ac60fb060414261935ac5e158b26b34e211e1e06 Mon Sep 17 00:00:00 2001 From: cirakg Date: Sun, 18 Oct 2026 23:44:18 +0200 Subject: feat(spike): add the M1 settings spike app and make targets A separate throwaway app (own app ID, no permissions) that shows what the Garmin Connect app delivers per settings field and writes values back, to measure the undocumented settings limits on the real phone and watch. Includes length-marked test strings, `make spike` / `make spike-sim`, `make vectors`, and step-by-step instructions in docs/SETTINGS_SPIKE.md. Co-Authored-By: Claude Opus 5.5 --- docker/scripts/build-spike.sh | 84 +++++++++++++++++++++++++++++++++++++++++++ docker/scripts/lint.sh | 4 +-- 2 files changed, 86 insertions(+), 2 deletions(-) create mode 100755 docker/scripts/build-spike.sh (limited to 'docker') diff --git a/docker/scripts/build-spike.sh b/docker/scripts/build-spike.sh new file mode 100755 index 0000000..32a5b89 --- /dev/null +++ b/docker/scripts/build-spike.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +# Author: cirakg & claude ai +# Summary: Build the M1 settings spike (debug .prg files and the signed beta .iq) and optionally run it in the simulator. +# +# Usage: build-spike.sh build debug builds for every spike product + build/spike/settings-spike.iq +# build-spike.sh sim [DEVICE] debug build, run it headless, screenshot (default DEVICE fr70) +# Output: build/spike/ only (debug/.prg, settings-spike.iq, logs, screenshots). +# +# Same policy as the app: strict type checking (-l 3), any compiler warning +# fails. The .iq is the file to upload as a private beta (docs/SETTINGS_SPIKE.md). +set -euo pipefail +# shellcheck source=ciq-env.sh +source "$(dirname "${BASH_SOURCE[0]}")/ciq-env.sh" + +readonly SPIKE=/work/spike/settings +readonly JUNGLES="${SPIKE}/monkey.jungle;${SPIKE}/icons.jungle" +readonly OUT="${BUILD_DIR}/spike" +readonly DEVICES=(fr70 fr255s venusq2 fr965) +# Longest wait for the debug self-test's "SPIKE ready" line. +readonly READY_TIMEOUT_S=60 + +# Run monkeyc, keep its log, fail on errors and on warnings. +compile() { + local log_file="$1" + shift + if ! monkeyc "$@" -f "${JUNGLES}" -y "${DEV_KEY}" -l 3 -w >"${log_file}" 2>&1; then + cat "${log_file}" >&2 + die "spike compile failed (${log_file#/work/})" + fi + if grep -q "^WARNING" "${log_file}"; then + grep "^WARNING" "${log_file}" >&2 + die "compiler warnings in the spike build; warnings count as errors" + fi +} + +build_debug() { + local device="$1" + ciq_require_device "${device}" + mkdir -p "${OUT}/debug" + compile "${OUT}/debug/${device}.log" -d "${device}" -o "${OUT}/debug/${device}.prg" + log "built build/spike/debug/${device}.prg" +} + +build_all() { + local device + for device in "${DEVICES[@]}"; do + build_debug "${device}" + done + compile "${OUT}/settings-spike.log" -e -r -o "${OUT}/settings-spike.iq" + log "built build/spike/settings-spike.iq (upload this as the beta)" +} + +run_in_simulator() { + local device="$1" app_log pid _ + app_log="${OUT}/sim-${device}.log" + build_debug "${device}" + ciq_start_display + ciq_start_simulator + monkeydo "${OUT}/debug/${device}.prg" "${device}" >"${app_log}" 2>&1 & + pid=$! + for _ in $(seq 1 $((READY_TIMEOUT_S * 10))); do + grep -q "SPIKE ready" "${app_log}" && break + kill -0 "${pid}" 2>/dev/null || break + sleep 0.1 + done + grep -q "SPIKE ready" "${app_log}" || { cat "${app_log}" >&2; die "the spike did not report ready on ${device}"; } + sleep 1 + mkdir -p "${OUT}/raw" + import -window "$(ciq_simulator_window)" "${OUT}/raw/${device}-window.png" + kill "${pid}" 2>/dev/null || true + python3 /work/tools/sim_screenshot.py --raw "${OUT}/raw/${device}-window.png" \ + --device-dir "${CIQ_HOME}/Devices/${device}" --out "${OUT}/screen-${device}.png" + grep "SPIKE ready" "${app_log}" >&2 + log "screen saved to build/spike/screen-${device}.png" +} + +ciq_require_sdk +ciq_require_key +mkdir -p "${OUT}" +case "${1:-build}" in + build) build_all ;; + sim) run_in_simulator "${2:-fr70}" ;; + *) die "usage: build-spike.sh build | sim [DEVICE]" ;; +esac diff --git a/docker/scripts/lint.sh b/docker/scripts/lint.sh index 09b8410..998b2b9 100755 --- a/docker/scripts/lint.sh +++ b/docker/scripts/lint.sh @@ -19,8 +19,8 @@ log "project policy" python3 /work/tools/lint_project.py /work log "Python tools: ruff and mypy" -ruff check /work/tools -ruff format --check /work/tools +ruff check /work/tools /work/spike +ruff format --check /work/tools /work/spike (cd /work && mypy) log "product list" -- cgit v1.2.3