From e860e88646e87023389d98e9400ce0192c5889ca Mon Sep 17 00:00:00 2001 From: CLAUDE <355856132+HoTT-stuff@users.noreply.github.com> Date: Sat, 5 Dec 2026 08:42:55 +0000 Subject: [PATCH 1/2] fix(just): real build and test recipes; one justfile The root had both justfile and Justfile, so `just` refused to run ("multiple candidate justfiles"). Justfile's build and test recipes only echoed success. This folds the lowercase justfile's recipes into Justfile and deletes it. - build: compile every examples/*.affine (pseudo face) to out/*.wasm. - test: type-check every example, then build them all. A type error fails the run; no examples is also a failure. - check, run, preview, lint, build-file: the old lowercase recipes, now through scripts/affinescript.sh. - setup-compiler: scripts/install-affinescript.sh builds the pinned compiler (affinescript 4a55253, the standards pin) into .affinescript/ (gitignored). The old `hello` recipe is dropped: `eval` of examples/hello.affine fails with "Unhandled effect: println", because the example declares its own IO effect and nothing handles it. --- .gitignore | 3 ++ Justfile | 72 ++++++++++++++++++++------------- justfile | 29 ------------- scripts/affinescript.sh | 27 +++++++++++++ scripts/install-affinescript.sh | 44 ++++++++++++++++++++ 5 files changed, 118 insertions(+), 57 deletions(-) delete mode 100644 justfile create mode 100755 scripts/affinescript.sh create mode 100755 scripts/install-affinescript.sh diff --git a/.gitignore b/.gitignore index deaa35b..f75b1c0 100644 --- a/.gitignore +++ b/.gitignore @@ -108,3 +108,6 @@ sync_report*.txt # Allow the brand shim binary (a shell script, not a compiled artefact) !bin/ !bin/* + +# Pinned AffineScript compiler (scripts/install-affinescript.sh) +/.affinescript/ diff --git a/Justfile b/Justfile index 78547e2..8a81eea 100644 --- a/Justfile +++ b/Justfile @@ -584,16 +584,25 @@ verify: # BUILD & COMPILE # ═══════════════════════════════════════════════════════════════════════════════ -# Build the project (debug mode) +# Build the pinned AffineScript compiler into .affinescript/ (once) +setup-compiler: + scripts/install-affinescript.sh + +# Compile every PseudoScript example to typed-wasm under out/ build *args: - @echo "Building {{project}} (debug)..." - # TODO: Replace with your build command - # Examples: - # cargo build {{args}} # Rust - # mix compile {{args}} # Elixir - # zig build {{args}} # Zig - # deno task build {{args}} # Deno/ReScript - @echo "Build complete" + #!/usr/bin/env bash + set -euo pipefail + shopt -s nullglob + files=(examples/*.affine) + [ ${#files[@]} -gt 0 ] || { echo "no examples/*.affine to build" >&2; exit 1; } + mkdir -p out + for f in "${files[@]}"; do + scripts/affinescript.sh compile --face pseudo "$f" -o "out/$(basename "$f" .affine).wasm" "$@" + done + +# Compile one file to typed-wasm +build-file FILE OUT="out.wasm": + scripts/affinescript.sh compile --face pseudo {{FILE}} -o {{OUT}} # Build in release mode with optimizations build-release *args: @@ -628,16 +637,26 @@ clean-all: clean # TEST & QUALITY # ═══════════════════════════════════════════════════════════════════════════════ -# Run all tests +# Type-check every PseudoScript example, then build them all test *args: - @echo "Running tests..." - # TODO: Replace with your test command - # Examples: - # cargo test {{args}} - # mix test {{args}} - # zig build test {{args}} - # deno test {{args}} - @echo "Tests passed!" + #!/usr/bin/env bash + set -euo pipefail + shopt -s nullglob + files=(examples/*.affine) + [ ${#files[@]} -gt 0 ] || { echo "no examples/*.affine to test" >&2; exit 1; } + for f in "${files[@]}"; do + scripts/affinescript.sh check --face pseudo "$f" "$@" + done + just build + echo "${#files[@]} example(s) checked and built" + +# Type-check one file +check FILE: + scripts/affinescript.sh check --face pseudo {{FILE}} + +# Show the canonical lowering of a file (debug) +preview FILE: + scripts/affinescript.sh preview-pseudocode {{FILE}} # Run tests with verbose output test-verbose: @@ -748,22 +767,19 @@ fmt-check: # gleam format --check # Run linter +# Lint every PseudoScript example lint: - @echo "Linting source files..." - # TODO: Replace with your linter - # Examples: - # cargo clippy -- -D warnings - # mix credo --strict - # gleam check + #!/usr/bin/env bash + set -euo pipefail + for f in examples/*.affine; do scripts/affinescript.sh lint --face pseudo "$f"; done # ═══════════════════════════════════════════════════════════════════════════════ # RUN & EXECUTE # ═══════════════════════════════════════════════════════════════════════════════ -# Run the application -run *args: build - # TODO: Replace with your run command - echo "Run not configured yet" +# Evaluate a file with the interpreter +run FILE: + scripts/affinescript.sh eval --face pseudo {{FILE}} # Run with verbose output run-verbose *args: build diff --git a/justfile b/justfile deleted file mode 100644 index eca5c03..0000000 --- a/justfile +++ /dev/null @@ -1,29 +0,0 @@ -# SPDX-License-Identifier: MPL-2.0 -# SPDX-FileCopyrightText: 2024-2026 Jonathan D.A. Jewell (hyperpolymath) -# justfile — PseudoScript task runner - -default: - @just --list - -# Type-check a file -check FILE: - affinescript check --face pseudo {{FILE}} - -# Evaluate a file with the interpreter -run FILE: - affinescript eval --face pseudo {{FILE}} - -# Compile to typed-wasm -build FILE OUT="out.wasm": - affinescript compile --face pseudo {{FILE}} -o {{OUT}} - -# Show the canonical lowering of a file (debug) -preview FILE: - affinescript preview-pseudocode {{FILE}} - -# Lint a file -lint FILE: - affinescript lint --face pseudo {{FILE}} - -# Smoke-test the hello example -hello: (run "examples/hello.affine") diff --git a/scripts/affinescript.sh b/scripts/affinescript.sh new file mode 100755 index 0000000..20477da --- /dev/null +++ b/scripts/affinescript.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# +# Run the AffineScript compiler. +# Compiler: $AFFINESCRIPT if set, else the pinned build from +# scripts/install-affinescript.sh, else `affinescript` on PATH. +set -euo pipefail + +root=$(cd "$(dirname "$0")/.." && pwd) +pinned="$root/.affinescript/compiler" + +if [ -z "${AFFINESCRIPT:-}" ]; then + if [ -x "$pinned/_build/default/bin/main.exe" ]; then + AFFINESCRIPT="$pinned/_build/default/bin/main.exe" + elif command -v affinescript >/dev/null 2>&1; then + AFFINESCRIPT=affinescript + else + echo "affinescript not found. Run 'just setup-compiler' (scripts/install-affinescript.sh) first." >&2 + exit 127 + fi +fi +if [ -z "${AFFINESCRIPT_STDLIB:-}" ] && [ -d "$pinned/stdlib" ]; then + export AFFINESCRIPT_STDLIB="$pinned/stdlib" +fi + +# shellcheck disable=SC2086 # AFFINESCRIPT may be a multi-word command +exec $AFFINESCRIPT "$@" diff --git a/scripts/install-affinescript.sh b/scripts/install-affinescript.sh new file mode 100755 index 0000000..a3e967a --- /dev/null +++ b/scripts/install-affinescript.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# +# Build the pinned AffineScript compiler into .affinescript/compiler. +# scripts/affinescript.sh finds it there; nothing is installed globally. +# +# Needs git, OCaml >= 4.14 and dune >= 3.14, plus the compiler's OCaml +# libraries (menhir, sedlex, ppx_deriving, ppx_sexp_conv, sexplib0, fmt, +# cmdliner, yojson, js_of_ocaml, js_of_ocaml-ppx). With opam on PATH the +# script installs those itself; otherwise they must come from the system +# (for example Debian/Ubuntu: ocaml-dune menhir libmenhir-ocaml-dev +# libsedlex-ocaml-dev libppx-deriving-ocaml-dev libppx-sexp-conv-ocaml-dev +# libsexplib0-ocaml-dev libfmt-ocaml-dev libcmdliner-ocaml-dev +# libyojson-ocaml-dev libjs-of-ocaml-dev js-of-ocaml). +set -euo pipefail + +# The only compiler pin. Keep it equal to TOOL_LANE_COMPILER_REF in +# any CI workflow that builds the compiler. +COMPILER_REPO="https://github.com/hyperpolymath/affinescript.git" +COMPILER_REF="4a55253703e13a96a768656a7ed548919c341261" + +root=$(cd "$(dirname "$0")/.." && pwd) +dir="$root/.affinescript/compiler" + +if [ ! -d "$dir/.git" ]; then + mkdir -p "$(dirname "$dir")" + git clone --quiet "$COMPILER_REPO" "$dir" +fi +git -C "$dir" fetch --quiet origin "$COMPILER_REF" 2>/dev/null || git -C "$dir" fetch --quiet origin +git -C "$dir" checkout --quiet --detach "$COMPILER_REF" + +cd "$dir" +if command -v opam >/dev/null 2>&1; then + opam install . --deps-only -y + opam exec -- dune build bin/main.exe +else + command -v dune >/dev/null 2>&1 || { + echo "dune not found: install opam, or the system OCaml packages listed at the top of $0" >&2 + exit 1 + } + dune build bin/main.exe +fi +"$dir/_build/default/bin/main.exe" --version +echo "AffineScript compiler ready at $dir (pin $COMPILER_REF)" From 3f212a4ce865d339157e5ae6b1b80f23ceed6101 Mon Sep 17 00:00:00 2001 From: CLAUDE <355856132+HoTT-stuff@users.noreply.github.com> Date: Sat, 5 Dec 2026 09:12:01 +0000 Subject: [PATCH 2/2] fix(just): keep paths with spaces in one piece The launcher now runs the compiler it picks as one quoted word, so a checkout path with a space works. A user-set AFFINESCRIPT still runs as a multi-word command. The build-file, check, preview and run recipes now quote FILE and OUT. --- Justfile | 8 ++++---- scripts/affinescript.sh | 11 ++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Justfile b/Justfile index 8a81eea..1fc55e5 100644 --- a/Justfile +++ b/Justfile @@ -602,7 +602,7 @@ build *args: # Compile one file to typed-wasm build-file FILE OUT="out.wasm": - scripts/affinescript.sh compile --face pseudo {{FILE}} -o {{OUT}} + scripts/affinescript.sh compile --face pseudo {{quote(FILE)}} -o {{quote(OUT)}} # Build in release mode with optimizations build-release *args: @@ -652,11 +652,11 @@ test *args: # Type-check one file check FILE: - scripts/affinescript.sh check --face pseudo {{FILE}} + scripts/affinescript.sh check --face pseudo {{quote(FILE)}} # Show the canonical lowering of a file (debug) preview FILE: - scripts/affinescript.sh preview-pseudocode {{FILE}} + scripts/affinescript.sh preview-pseudocode {{quote(FILE)}} # Run tests with verbose output test-verbose: @@ -779,7 +779,7 @@ lint: # Evaluate a file with the interpreter run FILE: - scripts/affinescript.sh eval --face pseudo {{FILE}} + scripts/affinescript.sh eval --face pseudo {{quote(FILE)}} # Run with verbose output run-verbose *args: build diff --git a/scripts/affinescript.sh b/scripts/affinescript.sh index 20477da..404de4e 100755 --- a/scripts/affinescript.sh +++ b/scripts/affinescript.sh @@ -9,11 +9,12 @@ set -euo pipefail root=$(cd "$(dirname "$0")/.." && pwd) pinned="$root/.affinescript/compiler" +compiler="" if [ -z "${AFFINESCRIPT:-}" ]; then if [ -x "$pinned/_build/default/bin/main.exe" ]; then - AFFINESCRIPT="$pinned/_build/default/bin/main.exe" + compiler="$pinned/_build/default/bin/main.exe" elif command -v affinescript >/dev/null 2>&1; then - AFFINESCRIPT=affinescript + compiler=affinescript else echo "affinescript not found. Run 'just setup-compiler' (scripts/install-affinescript.sh) first." >&2 exit 127 @@ -23,5 +24,9 @@ if [ -z "${AFFINESCRIPT_STDLIB:-}" ] && [ -d "$pinned/stdlib" ]; then export AFFINESCRIPT_STDLIB="$pinned/stdlib" fi -# shellcheck disable=SC2086 # AFFINESCRIPT may be a multi-word command +# A path chosen here is one word, even if the checkout path has spaces. +if [ -n "$compiler" ]; then + exec "$compiler" "$@" +fi +# shellcheck disable=SC2086 # a user-set AFFINESCRIPT may be a multi-word command exec $AFFINESCRIPT "$@"