Files
VolcanicSecretary/docker-entrypoint.sh

32 lines
1.2 KiB
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.
# Install the exact version: an unversioned `npm install` keeps the range already in
# $PI_DIR/npm/package.json (e.g. ^0.2.0), which silently reinstalls the old release.
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${latest:+@$latest}"; 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