From 2f8213ca9a56777a7a9748a2d1d8bc78d87a3174 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 26 Dec 2025 18:11:00 +0100 Subject: [PATCH] fix(a2ui): skip bundle when inputs unchanged --- package.json | 2 +- scripts/bundle-a2ui.sh | 45 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100755 scripts/bundle-a2ui.sh diff --git a/package.json b/package.json index c71658639..d30819ce8 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "protocol:gen": "tsx scripts/protocol-gen.ts", "protocol:gen:swift": "tsx scripts/protocol-gen-swift.ts", "protocol:check": "pnpm protocol:gen && pnpm protocol:gen:swift && git diff --exit-code -- dist/protocol.schema.json apps/macos/Sources/ClawdisProtocol/GatewayModels.swift", - "canvas:a2ui:bundle": "pnpm -s exec tsc -p vendor/a2ui/renderers/lit/tsconfig.json && rolldown -c apps/shared/ClawdisKit/Tools/CanvasA2UI/rolldown.config.mjs" + "canvas:a2ui:bundle": "bash scripts/bundle-a2ui.sh" }, "keywords": [], "author": "", diff --git a/scripts/bundle-a2ui.sh b/scripts/bundle-a2ui.sh new file mode 100755 index 000000000..f6f79d85d --- /dev/null +++ b/scripts/bundle-a2ui.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +HASH_FILE="$ROOT_DIR/src/canvas-host/a2ui/.bundle.hash" + +INPUT_PATHS=( + "$ROOT_DIR/package.json" + "$ROOT_DIR/pnpm-lock.yaml" + "$ROOT_DIR/vendor/a2ui/renderers/lit" + "$ROOT_DIR/apps/shared/ClawdisKit/Tools/CanvasA2UI" +) + +collect_files() { + local path + for path in "${INPUT_PATHS[@]}"; do + if [[ -d "$path" ]]; then + find "$path" -type f -print0 + else + printf '%s\0' "$path" + fi + done +} + +compute_hash() { + collect_files \ + | LC_ALL=C sort -z \ + | xargs -0 shasum -a 256 \ + | shasum -a 256 \ + | awk '{print $1}' +} + +current_hash="$(compute_hash)" +if [[ -f "$HASH_FILE" ]]; then + previous_hash="$(cat "$HASH_FILE")" + if [[ "$previous_hash" == "$current_hash" ]]; then + echo "A2UI bundle up to date; skipping." + exit 0 + fi +fi + +pnpm -s exec tsc -p vendor/a2ui/renderers/lit/tsconfig.json +rolldown -c apps/shared/ClawdisKit/Tools/CanvasA2UI/rolldown.config.mjs + +echo "$current_hash" > "$HASH_FILE"