Skip to content

Commit bb741eb

Browse files
hyperpolymathgitbot-fleetclaude
authored
fix(shim): harden CafeScripto shim discovery + pin canonical (#32)
Hardens the `bin/cafe` shim (discovery: $AFFINESCRIPT → PATH → sibling checkout, actionable not-found message) and adds `.affinescript-pin` (canonical commit lock). Part of Milestone A of the face-sealing plan. Binding contract: `docs/specs/FACE-CONTRACT.adoc` in hyperpolymath/affinescript (PR #685). Draft — lands after the contract PR is reviewed. --------- Co-authored-by: gitbot-fleet <gitbot@hyperpolymath.example.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 177d51b commit bb741eb

3 files changed

Lines changed: 60 additions & 9 deletions

File tree

.affinescript-pin

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# AffineScript canonical pin — the compiler commit this face is validated against.
2+
# Version-lock per docs/specs/FACE-CONTRACT.adoc (hyperpolymath/affinescript).
3+
# Update deliberately (after re-running the face conformance gate), not casually.
4+
repo = https://github.com/hyperpolymath/affinescript.git
5+
commit = 4b36de2fad7bc18408aec9b71c6c3acf1afe8d09
6+
face = cafe

.github/workflows/governance.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@ permissions:
3232
jobs:
3333
governance:
3434
uses: hyperpolymath/standards/.github/workflows/governance-reusable.yml@d7c22711e830e1f383846472f6e9b99debdb201e
35-
timeout-minutes: 10

bin/cafe

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,60 @@
22
# SPDX-License-Identifier: MPL-2.0
33
# SPDX-FileCopyrightText: 2024-2026 Jonathan D.A. Jewell (hyperpolymath)
44
#
5-
# cafe — CafeScripto shim. Forwards arguments to the affinescript CLI
6-
# with --face cafe injected right after the subcommand. Source files
7-
# should still use the canonical .affine extension and a face: cafescripto
8-
# pragma; this shim only saves typing the --face flag for routine use.
5+
# cafe — CafeScripto shim (brand surface only; carries no compiler).
6+
#
7+
# Locates the canonical `affinescript` compiler and injects `--face cafe`.
8+
# Source files use the canonical `.affine` extension plus a `face: cafescripto`
9+
# pragma; this shim only saves typing the flag. Discovery order and the binding
10+
# contract are normative in docs/specs/FACE-CONTRACT.adoc (hyperpolymath/affinescript).
11+
set -euo pipefail
12+
FACE="cafe"
13+
BRAND="CafeScripto"
14+
15+
# Resolve this script's own directory (follow symlinks) for sibling discovery.
16+
SOURCE="${BASH_SOURCE[0]}"
17+
while [ -h "$SOURCE" ]; do
18+
DIR="$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)"
19+
SOURCE="$(readlink "$SOURCE")"
20+
[ "${SOURCE#/}" = "$SOURCE" ] && SOURCE="$DIR/$SOURCE"
21+
done
22+
SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)"
23+
24+
find_affinescript() {
25+
# 1. explicit override
26+
if [ -n "${AFFINESCRIPT:-}" ] && [ -x "${AFFINESCRIPT:-}" ]; then
27+
printf '%s' "$AFFINESCRIPT"; return 0
28+
fi
29+
# 2. on PATH (e.g. `opam install affinescript`)
30+
if command -v affinescript >/dev/null 2>&1; then
31+
printf '%s' affinescript; return 0
32+
fi
33+
# 3. a sibling canonical checkout, built (`dune build`)
34+
local c
35+
for c in \
36+
"$SCRIPT_DIR/../../γ-affinescript/affinescript/_build/default/bin/main.exe" \
37+
"$SCRIPT_DIR/../../../γ-affinescript/affinescript/_build/default/bin/main.exe" \
38+
"$SCRIPT_DIR/../affinescript/_build/default/bin/main.exe" \
39+
"$HOME/developer/repos/γ-affinescript/affinescript/_build/default/bin/main.exe"; do
40+
if [ -x "$c" ]; then printf '%s' "$c"; return 0; fi
41+
done
42+
return 1
43+
}
44+
45+
if ! AS="$(find_affinescript)"; then
46+
cat >&2 <<MSG
47+
error: the canonical \`affinescript\` compiler was not found.
48+
$BRAND is a brand surface only — it needs the compiler installed. Try one of:
49+
• opam install affinescript (then re-run)
50+
• export AFFINESCRIPT=/path/to/affinescript
51+
• build a sibling checkout: (in γ-affinescript/affinescript) dune build
52+
See docs/specs/FACE-CONTRACT.adoc in hyperpolymath/affinescript.
53+
MSG
54+
exit 127
55+
fi
956

1057
if [ $# -eq 0 ]; then
11-
exec affinescript
58+
exec "$AS"
1259
fi
13-
subcmd="$1"
14-
shift
15-
exec affinescript "$subcmd" --face cafe "$@"
60+
subcmd="$1"; shift
61+
exec "$AS" "$subcmd" --face "$FACE" "$@"

0 commit comments

Comments
 (0)