Unpin Claude Code CLI and auto-update pi-claude-code-provider on start

This commit is contained in:
EugeneTes
2026-09-25 06:33:29 +00:00
parent a5e5796d18
commit bdf7aa6b3e
2 changed files with 14 additions and 17 deletions

View File

@@ -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)" && /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`. # 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 RUN npm install -g @anthropic-ai/claude-code
# 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
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh RUN chmod +x /usr/local/bin/docker-entrypoint.sh

View File

@@ -2,23 +2,24 @@
set -e set -e
PI_DIR="${PI_CODING_AGENT_DIR:-/pi-agent}" PI_DIR="${PI_CODING_AGENT_DIR:-/pi-agent}"
# Marker version bumped from `.installed` to `.installed.v2` so existing volumes with a PKG=pi-claude-code-provider
# previously-patched pi-claude-code-provider get a clean reinstall (we removed the PKG_DIR="$PI_DIR/npm/node_modules/$PKG"
# claude-args.ts sed patch — see commit history).
MARKER="$PI_DIR/.pi-claude-code-provider.installed.v2"
if [ ! -f "$MARKER" ]; then # Keep pi-claude-code-provider on the latest npm release: on every start compare the
echo "[entrypoint] pi install npm:pi-claude-code-provider" # 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" mkdir -p "$PI_DIR"
# Wipe any previous (possibly-patched) install so pi restores the canonical package. rm -rf "$PKG_DIR"
rm -rf "$PI_DIR/npm/node_modules/pi-claude-code-provider" if ! /app/node_modules/.bin/pi install "npm:$PKG"; then
if /app/node_modules/.bin/pi install npm:pi-claude-code-provider; then
touch "$MARKER"
else
echo "[entrypoint] pi install failed; will retry on next start" >&2 echo "[entrypoint] pi install failed; will retry on next start" >&2
fi fi
else else
echo "[entrypoint] pi-claude-code-provider already installed" echo "[entrypoint] $PKG $installed is up to date"
fi fi
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then