#!/usr/bin/env bash
set -euo pipefail

# Resolve relative to this file: hosts and CLI callers may use a different cwd.
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"

# Keep dependencies private to this skill and reproducible across preparations.
# Bun reuses installed packages on warm starts. Do not run dependency scripts.
bun install --frozen-lockfile --ignore-scripts

# Exercise the real entry point (including Vault) and the lazily loaded Usage
# dependency without making API calls or reading/printing a credential.
bun --no-install --preload ./preload.ts -e '
    const { UsageClient } = await import("@meistrari/usage")
    if (typeof tela.listProjects !== "function" || typeof tela.createAgent !== "function"
        || typeof tela.isVaultReference !== "function" || typeof UsageClient !== "function")
        throw new Error("Tela skill startup check failed")
'
