#!/bin/sh set -e # Check if bun version matches package.json EXPECTED_VERSION=$(grep '"packageManager"' package.json | sed 's/.*"bun@\([^"]*\)".*/\1/') CURRENT_VERSION=$(bun --version) if [ "$CURRENT_VERSION" != "$EXPECTED_VERSION" ]; then echo "Error: Bun version $CURRENT_VERSION does not match expected version $EXPECTED_VERSION from package.json" exit 1 fi # Update bundled models.json before push echo "Updating bundled models..." BEFORE=$(git hash-object packages/opencode/assets/models.json 2>/dev/null) bun run scripts/update-models.ts || echo "Warning: models update failed, continuing with existing models.json" AFTER=$(git hash-object packages/opencode/assets/models.json 2>/dev/null) # Only abort if models.json content actually changed (ignore timestamp) if [ "$BEFORE" != "$AFTER" ]; then echo "Models changed, auto-committing..." git add packages/opencode/assets/ git commit -m "chore: update bundled models" echo "Error: models updated and committed. Please push again." exit 1 fi bun typecheck || echo "Warning: typecheck failed, fix before merge" # keep in sync with packages/script/src/index.ts semver qualifier bun -e ' import { semver } from "bun"; const pkg = await Bun.file("package.json").json(); const expectedBunVersion = pkg.packageManager?.split("@")[1]; if (!expectedBunVersion) { throw new Error("packageManager field not found in root package.json"); } const expectedBunVersionRange = `^${expectedBunVersion}`; if (!semver.satisfies(process.versions.bun, expectedBunVersionRange)) { throw new Error(`This script requires bun@${expectedBunVersionRange}, but you are using bun@${process.versions.bun}`); } if (process.versions.bun !== expectedBunVersion) { console.warn(`Warning: Bun version ${process.versions.bun} differs from expected ${expectedBunVersion}`); } ' bun typecheck