Files
VolcanicSecretary/docker-entrypoint.sh

30 lines
993 B
Bash

#!/bin/sh
set -e
PI_DIR="${PI_CODING_AGENT_DIR:-/pi-agent}"
PKG=pi-claude-code-provider
PKG_DIR="$PI_DIR/npm/node_modules/$PKG"
# Keep pi-claude-code-provider on the latest npm release: on every start compare the
# installed version with the registry and force a clean reinstall when they differ.
# If the registry is unreachable, keep whatever is installed.
installed=$(node -p "require('$PKG_DIR/package.json').version" 2>/dev/null || true)
latest=$(npm view "$PKG" version 2>/dev/null || true)
if [ -z "$installed" ] || { [ -n "$latest" ] && [ "$installed" != "$latest" ]; }; then
echo "[entrypoint] pi install npm:$PKG (installed: ${installed:-none}, latest: ${latest:-unknown})"
mkdir -p "$PI_DIR"
rm -rf "$PKG_DIR"
if ! /app/node_modules/.bin/pi install "npm:$PKG"; then
echo "[entrypoint] pi install failed; will retry on next start" >&2
fi
else
echo "[entrypoint] $PKG $installed is up to date"
fi
if [ $# -gt 0 ]; then
exec "$@"
else
exec node dist/main.js
fi