diff options
Diffstat (limited to 'scripts/sync-to-codex-plugin.sh')
| -rwxr-xr-x | scripts/sync-to-codex-plugin.sh | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/scripts/sync-to-codex-plugin.sh b/scripts/sync-to-codex-plugin.sh index 16fd89a..fc0a8e8 100755 --- a/scripts/sync-to-codex-plugin.sh +++ b/scripts/sync-to-codex-plugin.sh @@ -4,7 +4,8 @@ # # Sync this superpowers checkout → prime-radiant-inc/openai-codex-plugins. # Clones the fork fresh into a temp dir, rsyncs tracked upstream plugin content -# (including committed Codex files under .codex-plugin/ and assets/), commits, +# (including committed Codex files under .codex-plugin/ and assets/), preserves +# OpenAI-owned marketplace metadata already in the destination plugin, commits, # pushes a sync branch, and opens a PR. # Path/user agnostic — auto-detects upstream from script location. # @@ -223,6 +224,7 @@ fi DEST="$DEST_REPO/$DEST_REL" PREVIEW_REPO="$DEST_REPO" PREVIEW_DEST="$DEST" +SYNC_SOURCE="" overlay_destination_paths() { local repo="$1" @@ -291,7 +293,7 @@ apply_to_preview_checkout() { mkdir -p "$PREVIEW_DEST" fi - rsync "${RSYNC_ARGS[@]}" "$UPSTREAM/" "$PREVIEW_DEST/" + rsync "${RSYNC_ARGS[@]}" "$SYNC_SOURCE/" "$PREVIEW_DEST/" } preview_checkout_has_changes() { @@ -316,6 +318,36 @@ for pat in "${EXCLUDES[@]}"; do RSYNC_ARGS+=(--exclude="$pat"); done append_git_ignored_directory_excludes append_git_ignored_file_excludes +copy_preserved_destination_metadata() { + local destination="$1" + local source="$2" + local path + local rel + + [[ -d "$destination/skills" ]] || return 0 + + while IFS= read -r -d '' path; do + rel="${path#"$destination"/}" + mkdir -p "$source/$(dirname "$rel")" + cp -p "$path" "$source/$rel" + done < <(find "$destination/skills" -path '*/agents/openai.yaml' -type f -print0) +} + +prepare_sync_source() { + local destination="$1" + + [[ -n "$CLEANUP_DIR" ]] || CLEANUP_DIR="$(mktemp -d)" + + SYNC_SOURCE="$CLEANUP_DIR/source-overlay" + rm -rf "$SYNC_SOURCE" + mkdir -p "$SYNC_SOURCE" + + rsync "${RSYNC_ARGS[@]}" "$UPSTREAM/" "$SYNC_SOURCE/" >/dev/null + copy_preserved_destination_metadata "$destination" "$SYNC_SOURCE" +} + +prepare_sync_source "$PREVIEW_DEST" + # ============================================================================= # Dry run preview (always shown) # ============================================================================= @@ -331,7 +363,7 @@ if [[ $BOOTSTRAP -eq 1 ]]; then fi echo "" echo "=== Preview (rsync --dry-run) ===" -rsync "${RSYNC_ARGS[@]}" --dry-run --itemize-changes "$UPSTREAM/" "$PREVIEW_DEST/" +rsync "${RSYNC_ARGS[@]}" --dry-run --itemize-changes "$SYNC_SOURCE/" "$PREVIEW_DEST/" echo "=== End preview ===" echo "" @@ -368,7 +400,7 @@ echo "Syncing upstream content..." if [[ $BOOTSTRAP -eq 1 ]]; then mkdir -p "$DEST" fi -rsync "${RSYNC_ARGS[@]}" "$UPSTREAM/" "$DEST/" +rsync "${RSYNC_ARGS[@]}" "$SYNC_SOURCE/" "$DEST/" # Bail early if nothing actually changed cd "$DEST_REPO" |
