#!/bin/sh
# Committed shim for the npm-distributed claudespace (AD-3). Resolves its
# own real location through the npm-created symlink, then execs the bundled
# Nuitka binary with the hardcoded dispatch token - kept out of node's way
# on the steady-state path so a Stop-hook fire costs no interpreter startup
# beyond the binary itself.
set -eu

resolve_link() {
    link="$1"
    while [ -L "$link" ]; do
        target=$(readlink "$link")
        case "$target" in
            /*) link="$target" ;;
            *) link="$(dirname "$link")/$target" ;;
        esac
    done
    printf '%s\n' "$link"
}

SELF="$(resolve_link "$0")"
BIN_DIR="$(cd "$(dirname "$SELF")" && pwd)"
PKG_ROOT="$(cd "$BIN_DIR/.." && pwd)"

exec "$PKG_ROOT/libexec/claudespace.dist/claudespace-bin" claudespace "$@"
