#!/usr/bin/env bash # # migrate-backlog-statuses.sh [--dry-run] # # Migrate a Backlog.md repo to the unified status vocabulary: # ๐ŸŸฆ Backlog ยท ๐ŸŸข In progress ยท ๐Ÿšง Paused ยท ๐Ÿ Done # # Updates backlog/config.yml (statuses + default_status) and rewrites each task's # status via the backlog CLI using the mapping below. Idempotent: tasks already # on the new vocab are left alone. # # This is the pilot rollout helper โ€” run it per repo for the later full rollout. # Claude project docs (Humdrum/Claude/Projects/*.md) are migrated separately: # - frontmatter `status:` โ†’ one of the four (judgement: ๐ŸŸกโ†’๐ŸŸข, ๐Ÿ”ดโ†’๐Ÿšง, etc.) # - any ```base``` filters referencing "Done" โ†’ "๐Ÿ Done" # set -euo pipefail repo="${1:?usage: migrate-backlog-statuses.sh [--dry-run]}" dry=""; [ "${2:-}" = "--dry-run" ] && dry=1 cd "$repo" [ -f backlog/config.yml ] || { echo "no backlog/config.yml in $repo โ€” skipping"; exit 0; } NEW_STATUSES='["๐ŸŸฆ Backlog", "๐ŸŸข In progress", "๐Ÿšง Paused", "๐Ÿ Done"]' map_status() { case "$1" in "To Do"|"Todo"|"Backlog") echo "๐ŸŸฆ Backlog" ;; "In Progress"|"In progress"|"Doing") echo "๐ŸŸข In progress" ;; "Paused"|"Blocked"|"On Hold"|"Hold") echo "๐Ÿšง Paused" ;; "Done"|"Shipped"|"Complete"|"Completed") echo "๐Ÿ Done" ;; *) echo "" ;; # already new vocab, or unknown โ€” leave it esac } echo "== $repo ==" # config: statuses array (CLI refuses arrays, so edit the file) + default_status if [ -z "$dry" ]; then tmp=$(mktemp) awk -v repl="statuses: $NEW_STATUSES" '/^statuses:/{print repl; next} {print}' backlog/config.yml > "$tmp" && mv "$tmp" backlog/config.yml backlog config set defaultStatus "๐ŸŸฆ Backlog" >/dev/null 2>&1 || true fi echo " config: statuses + default_status โ†’ new vocab" # tasks: map current status โ†’ new shopt -s nullglob for f in backlog/tasks/*.md; do id=$(awk -F': ' '/^id:/{print $2; exit}' "$f") cur=$(awk '/^status:/{sub(/^status:[ ]*/,""); gsub(/^["'\'']|["'\'']$/,""); print; exit}' "$f") new=$(map_status "$cur") [ -z "$new" ] && continue [ "$new" = "$cur" ] && continue echo " $id: $cur โ†’ $new" [ -z "$dry" ] && backlog task edit "$id" -s "$new" --plain >/dev/null 2>&1 done echo " done"