diff --git a/Dockerfile b/Dockerfile index d014f85..70a7726 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,11 +33,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends python3-venv \ && /opt/tilion/bin/python -c "import tilion_fortress as t; tag = t._CHANNELS['latest']['tag']; t._download('linux-x64', t._host(tag), tag)" # Claude Code CLI must be on PATH: pi-claude-code-provider shells out to `claude`. -# Pinned to the version pi-claude-code-provider 0.4.0 is tested against (its -# src/compatibility.ts). The provider rejects any stream-json record ahead of -# system/init, so an unpinned newer CLI can break every turn with -# "Claude emitted a record before initialization". Bump together with the provider. -RUN npm install -g @anthropic-ai/claude-code@2.1.278 +RUN npm install -g @anthropic-ai/claude-code COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 27dd033..b253351 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -2,23 +2,24 @@ set -e PI_DIR="${PI_CODING_AGENT_DIR:-/pi-agent}" -# Marker version bumped from `.installed` to `.installed.v2` so existing volumes with a -# previously-patched pi-claude-code-provider get a clean reinstall (we removed the -# claude-args.ts sed patch — see commit history). -MARKER="$PI_DIR/.pi-claude-code-provider.installed.v2" +PKG=pi-claude-code-provider +PKG_DIR="$PI_DIR/npm/node_modules/$PKG" -if [ ! -f "$MARKER" ]; then - echo "[entrypoint] pi install npm:pi-claude-code-provider" +# 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" - # Wipe any previous (possibly-patched) install so pi restores the canonical package. - rm -rf "$PI_DIR/npm/node_modules/pi-claude-code-provider" - if /app/node_modules/.bin/pi install npm:pi-claude-code-provider; then - touch "$MARKER" - else + 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] pi-claude-code-provider already installed" + echo "[entrypoint] $PKG $installed is up to date" fi if [ $# -gt 0 ]; then