30 lines
999 B
Bash
Executable File
30 lines
999 B
Bash
Executable File
#!/bin/sh
|
|
# Neuron launcher: prefer the compiled binary from a local build,
|
|
# fall back to running from source under Bun.
|
|
SELF="$0"
|
|
while [ -L "$SELF" ]; do
|
|
LINK="$(readlink "$SELF")"
|
|
case "$LINK" in
|
|
/*) SELF="$LINK" ;;
|
|
*) SELF="$(dirname "$SELF")/$LINK" ;;
|
|
esac
|
|
done
|
|
DIR="$(cd "$(dirname "$SELF")" && pwd)"
|
|
PKG="$DIR/.."
|
|
ARCH=$(uname -m)
|
|
case "$ARCH" in
|
|
arm64) TARGET="opencode-darwin-arm64" ;;
|
|
x86_64) TARGET="opencode-darwin-x64" ;;
|
|
*) TARGET="" ;;
|
|
esac
|
|
if [ -n "$TARGET" ] && [ -x "$PKG/dist/$TARGET/bin/opencode" ]; then
|
|
BIN="$PKG/dist/$TARGET/bin/opencode"
|
|
# launch-integrity record: every run logs WHO ran and WHAT its fingerprint was
|
|
LOG_DIR="${XDG_STATE_HOME:-$HOME/.local/state}"
|
|
SUM=$(shasum -a 256 "$BIN" | cut -d" " -f1)
|
|
mkdir -p "$LOG_DIR"
|
|
echo "{\"t\":\"$(date -u +%FT%TZ)\",\"event\":\"launch\",\"bin\":\"$TARGET\",\"sha256\":\"$SUM\"}" >> "$LOG_DIR/neuron-guard.jsonl"
|
|
exec "$BIN" "$@"
|
|
fi
|
|
exec bun run --conditions=browser "$PKG/src/index.ts" "$@"
|