#!/usr/bin/env bash # surfaces-actions.sh: the deterministic half of the surfaces skill (ideal/surfaces.md). Sets up # end to end and visual regression for the project that owns the current directory, so review has # something to run. Setup is not a stage: it takes no task folder, the way the tool skill does. It # writes into the tree the current directory runs in, a task's worktree or, with none active, the # code path (active_tree_for in scripts/lib/task-helpers.sh). # # surfaces-actions.sh [--run-mode ] read # surfaces-actions.sh [--run-mode ...] show # surfaces-actions.sh [--run-mode ...] install [--viewport =x]... # surfaces-actions.sh [--run-mode ...] register --url --kind ... [--mask ]... # [--path ]... [--critical] [--enable] [--reason ] # surfaces-actions.sh [--run-mode ...] register --command --kind e2e --reason [--critical] [--enable] # surfaces-actions.sh unregister # surfaces-actions.sh [--run-mode ...] baseline []... --check-recipe =... # [--value =]... [--confirmed] # surfaces-actions.sh decline # surfaces-actions.sh step [--part ] # # The recipe flags are `--recipe =` or `--lookup-failed =`, one # per framework the project records, the flags review's `checks` takes. A kind is `e2e` or # `visual-regression`, the review recipe's own surface row ids. The surface file is # `.visual-review/surfaces.json` in the resolved tree (scripts/surfaces-schema.json), read by # scripts/lib/surfaces.sh, the reader review uses. The project record's `surfaces.registryPath` # holds that same relative path, and this script is its one producer. Every action prints # `key: value` lines and paths; a recipe command's own output goes to /records/, never to # stdout. # # Exit codes, each with the meaning the tool and review scripts give it: # 0 did what was asked, including `install` printing not-applicable when no framework has a recipe # 1 no project owns this directory # 3 could not do its job: a bad argument, a refused command, a differing file, a recipe with no # block, a lookup nobody completed, an id registered with different fields, an absent accept row, # a command surface beside a page surface for e2e, an e2e surface with no reason, an id # unregister does not find, or `register --url`, `unregister` or `baseline` before `install` # wrote the surface file # 4 a recipe command ran and failed; its own output, in the file, is the answer # 70 `--confirmed` or `decline` was passed with nobody present # # Portability: bash 3.2+ and zsh. No mapfile, no associative arrays, no variable as a case pattern. set -uo pipefail trap '' PIPE # a closed pipe must not kill the writes after a print; research-actions.sh says why if [ -n "${ZSH_VERSION:-}" ]; then SCRIPT_SOURCE="$0"; else SCRIPT_SOURCE="${BASH_SOURCE[0]}"; fi PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$(cd -- "$(dirname -- "$SCRIPT_SOURCE")/../../.." >/dev/null 2>&1 && pwd -P)}" STEPS_DIR="${PLUGIN_ROOT}/skills/surfaces/references" command -v jq >/dev/null 2>&1 || { printf 'surfaces-actions: jq is required and was not found on PATH\n' >&2; exit 3; } die() { printf 'surfaces-actions: %s\n' "$2" >&2; exit "$1"; } die3() { die 3 "$1"; } # write_atomic in task-helpers.sh refuses through this name for lib_name in registry task-helpers records-hash recipes paths surfaces project-commit; do # shellcheck source=/dev/null . "${PLUGIN_ROOT}/scripts/lib/${lib_name}.sh" || die 3 "the library failed to load: ${lib_name}.sh" done RUN_MODE="interactive" if [ "${1:-}" = "--run-mode" ]; then [ $# -ge 2 ] || die 3 "--run-mode needs a value"; RUN_MODE="$2"; shift 2; fi case "$RUN_MODE" in interactive|autonomous) ;; *) die 3 "run mode must be interactive or autonomous, got $RUN_MODE" ;; esac ACTION="${1:-}"; [ -n "$ACTION" ] || die 3 "needs an action: read, show, install, register, unregister, baseline, decline or step" shift TAB="$(printf '\t')" if [ "$ACTION" = "step" ]; then names="$(md_basenames_in "$STEPS_DIR")" part=1 if [ "$#" -eq 3 ] && [ "$2" = "--part" ]; then part="$3"; set -- "$1"; fi [ "$#" -eq 1 ] || die 3 "step: one step name is required. The steps are: $names" case "$1" in */*|.|..|'') die 3 "step: a step name is one name and never a path; got: $1" ;; esac [ -f "$STEPS_DIR/$1.md" ] || die 3 "step: this skill ships no step file named $1. The steps are: $names" step_part "$STEPS_DIR" "$1" "$part" "$PLUGIN_ROOT/skills/surfaces/scripts/surfaces-actions.sh" case "$?" in 0) exit 0 ;; 2) die 3 "step: $1 has no part $part. Run step $1 to see the first part and the count of parts." ;; *) die 3 "step: $STEPS_DIR/$1.md could not be read." ;; esac fi # ---------------------------------------------------------------- the project MATCH="$(registry_resolve_by_directory "$(pwd -P)" 2>/dev/null || true)" PROJECT_DIR="$(printf '%s' "$MATCH" | jq -r '.path // empty' 2>/dev/null)" [ -n "$PROJECT_DIR" ] && [ -d "$PROJECT_DIR" ] || die 1 "no project owns $(pwd -P)" PROJECT_FILE="$PROJECT_DIR/project.json" [ "$(json_file_state "$PROJECT_FILE")" = "ok" ] || die 3 "$PROJECT_FILE is missing or unreadable" CODE_PATH="$(project_code_path_value "$PROJECT_DIR")" [ -n "$CODE_PATH" ] && [ -d "$CODE_PATH" ] || die 3 "$PROJECT_FILE records no codePath on disk" TREE="$(active_tree_for "$CODE_PATH" "$(pwd -P)")" # shellcheck disable=SC2034 # read by cr_resolve_recipe in scripts/lib/recipes.sh FRAMEWORKS="$(jq -r '.frameworks // [] | .[]' "$PROJECT_FILE")" SURFACE_REL=".visual-review/surfaces.json" SURFACE_FILE="$TREE/$SURFACE_REL" RECORDS_DIR="$PROJECT_DIR/records" # The project record's `surfaces` field, initialised on the first write. $1 a jq filter over it. # Commits project.json in the project folder too, so a person never finds it modified and # uncommitted after this skill runs (live-run row 44). A project folder that is not a repository, # or a failed commit, is reported and left as is: the field itself is already written. write_project_field() { local doc subject why doc="$(jq --arg sf "$SURFACE_REL" '.surfaces = ((.surfaces // {registryPath: null, e2e: {enabled: false, declined: false}, visualRegression: {enabled: false, declined: false}}) | '"$1"')' "$PROJECT_FILE")" \ || die 3 "$ACTION: could not update the surfaces field" write_atomic "$PROJECT_FILE" "$doc" case "$ACTION" in decline) subject="Decline $KIND surfaces"; why="a person declined" ;; *) subject="Install $KIND surfaces"; why="installed through the surfaces skill" ;; esac commit_project "$PROJECT_DIR" "$subject" "$why" "" "" "project" "surfaces" "project.json" \ || printf 'surfaces-actions: the surfaces field was written but not committed.\n' >&2 } # Warns that another branch holds a surface file while this one writes a new one here, since the # two meet at merge (gap row 278). git shows the clash there as a conflict on one file. Install and # a command's register both write a new file. warn_surface_file_elsewhere() { local branch [ ! -f "$SURFACE_FILE" ] || return 0 branch="$(sf_branch_with "$TREE" "$SURFACE_REL")" [ -z "$branch" ] || printf 'warning: %s: branch %s holds %s too, so the two files meet when both branches reach the trunk\n' "$ACTION" "$branch" "$SURFACE_REL" } # The paths git lists as changed in the tree, an untracked file one by one, one per line. tree_changes() { git -C "$TREE" status --porcelain --untracked-files=all | cut -c4-; } # Other uncommitted work in the tree is a warning, never a refusal. install and baseline run # commands whose files nobody names in advance, so the list taken here is what their commit leaves # out. A file already changed before the step stays out, even when the step changed it again. OTHER_WORK="" note_other_work() { OTHER_WORK="$(tree_changes)" [ -z "$OTHER_WORK" ] \ || printf 'warning: %s: the tree holds other uncommitted work, which this commit leaves out: %s\n' "$ACTION" "$(printf '%s' "$OTHER_WORK" | tr '\n' ' ')" } # Commits the paths this step changed, the ones git lists now and did not list at note_other_work. # $1 the line when it changed none, $2 the commit message. commit_own_changes() { local before own before="$(mktemp)" || die 3 "$ACTION: could not create a temporary file" printf '%s\n' "$OTHER_WORK" >"$before" own="$(tree_changes | grep -vxF -f "$before")" rm -f "$before" if [ -z "$own" ]; then printf 'committed: none, %s\n' "$1"; return 0; fi recipe_commit_if_changed "$TREE" "$ACTION" "$1" "$2" "$own" } # Loads the surface file and refuses every state but ok: missing is a step out of order. require_surface_file() { sf_load_surfaces "$SURFACE_FILE" case "$SF_STATE" in ok) ;; missing) die 3 "$ACTION: there is no surface file at $SURFACE_FILE. Run install first." ;; *) die 3 "$ACTION: $SURFACE_FILE is $SF_STATE" ;; esac } # ----------------------------------------------------------------- the recipe # cr_resolve_recipe in scripts/lib/recipes.sh sets RECIPE and RECIPE_FW, or ends the action. VIEWPORTS_JSON="[]"; VALUES=""; KIND=""; KEY="" # Maps a kind word to the project record's key, or dies at 3 naming both kinds. Sets KEY and KIND. $1 the kind. kind_key() { case "$1" in e2e) KEY="e2e" ;; visual-regression) KEY="visualRegression" ;; *) die 3 "$ACTION: the kind is e2e or visual-regression, got: ${1:-nothing}" ;; esac KIND="$1" } # The `## Viewports` block of the recipe, or the --viewport list, into VIEWPORTS_JSON. A global, # because a refusal inside a `$(...)` capture would exit that subshell alone. load_viewports() { local out one if [ -z "$VIEWPORTS_ARG" ]; then out="$(fenced_blocks_under "$RECIPE" Viewports json | jq -c 'if type == "array" then . else empty end' 2>/dev/null)" VIEWPORTS_JSON="${out:-[]}"; return 0 fi out='[]' while IFS= read -r one; do [ -n "$one" ] || continue out="$(jq -nc --argjson have "$out" --arg one "$one" '$have + [($one | capture("^(?[^=]+)=(?[0-9]+)x(?[0-9]+)$") | {name, width: (.w | tonumber), height: (.h | tonumber)})]' 2>/dev/null)" || die 3 "$ACTION: --viewport takes =x, got: $one" done </dev/null)" printf 'SEED:\n'; fenced_blocks_under "$RECIPE" Surfaces json | jq -r '.[] | " \(.id) url=\(.url) kinds=\(.kinds | join(","))"' 2>/dev/null printf 'DISCOVERY:\n'; recipe_prose_under "$RECIPE" Discovery rm -rf "$files_dir"; exit 0 fi recipe_files_refuse_differing install "$RECIPE" "$list" "$TREE" "$files_dir" warn_surface_file_elsewhere note_other_work load_viewports [ "$RUN_MODE" = "interactive" ] && { printf 'ABOUT TO RUN, from %s:\n' "$RECIPE"; printf '%s\n' "$steps" | sed 's/^/ /'; } mkdir -p "$RECORDS_DIR" "$TREE/.visual-review" || die 3 "install: could not create the records folder" OUTFILE="$RECORDS_DIR/surfaces-$KIND-install.txt"; : >"$OUTFILE" cd "$TREE" || die 3 "install: could not enter $TREE" run_recipe_lines install "$RECIPE" "$steps" "$OUTFILE" "install:" recipe_files_write install "$list" "$TREE" "$files_dir"; rm -rf "$files_dir" sf_load_surfaces "$SURFACE_FILE" case "$SF_STATE" in missing) doc="$(jq -n --argjson v "$VIEWPORTS_JSON" '{schemaVersion: 1, viewports: $v, surfaces: []}')" ;; ok) doc="$(jq --argjson v "$VIEWPORTS_JSON" --arg given "$VIEWPORTS_ARG" \ 'if $given != "" or ((.viewports // []) | length) == 0 then .viewports = $v else . end' "$SURFACE_FILE")" ;; *) die 3 "install: $SURFACE_FILE is $SF_STATE, and the surface file is never overwritten" ;; esac write_atomic "$SURFACE_FILE" "$doc" write_project_field '.registryPath = $sf | .'"$KEY"'.enabled = true' printf 'INSTALLED: %s per %s\nfiles: %s written, %s replaced, %s kept\nsurface-file: %s\nproject-file: %s\n' \ "$KIND" "$RECIPE" "$RF_WRITTEN" "$RF_REPLACED" "$RF_KEPT" "$SURFACE_FILE" "$PROJECT_FILE" commit_own_changes "install wrote nothing new" "New $KIND surfaces setup, installed through the surfaces skill" recipe_output_summary 0 "$OUTFILE" 1 } # -------------------------------------------------------------------- register do_register() { local id="${1:-}" url="" command="" kinds='[]' masks='[]' paths='[]' critical=false enabled=false reason="" row have doc [ -n "$id" ] || die 3 "register: a surface id is required" case "$id" in *[!a-z0-9-]*|-*|*-|*--*) die 3 "register: a surface id is kebab case, got: $id" ;; esac shift while [ "$#" -gt 0 ]; do case "$1" in --enable) enabled=true; shift; continue ;; --critical) critical=true; shift; continue ;; --url|--command|--kind|--mask|--path|--reason) [ "$#" -ge 2 ] || die 3 "register: $1 needs a value" ;; *) die 3 "register: unrecognized argument: $1" ;; esac case "$1" in --url) url="$2" ;; # A command line is refused the way a recipe's install line is, then kept as an argv that # review runs without a shell (gap row 289). --command) refuse_if_unsafe surfaces-actions "the --command value" "$2" || exit 3 command="$(printf '%s' "$2" | jq -Rc '[ splits("[ \t]+") | select(length > 0) ]')" ;; --kind) case "$2" in e2e|visual-regression|visual-parity) ;; *) die 3 "register: a kind is e2e, visual-regression or visual-parity, got: $2" ;; esac kinds="$(printf '%s' "$kinds" | jq -c --arg k "$2" '. + [$k] | unique')" ;; --mask) masks="$(printf '%s' "$masks" | jq -c --arg m "$2" '. + [$m]')" ;; --path) paths="$(printf '%s' "$paths" | jq -c --arg g "$2" '. + [$g]')" ;; # One line, because `read` prints one line per surface and a newline would forge another. --reason) [ "$(printf '%s' "$2" | wc -l | tr -d '[:space:]')" = "0" ] || die 3 "register: --reason is one line, and it holds a newline" reason="$(pc_trim "$2")" ;; esac shift 2 done [ -n "$url$command" ] || die 3 "register: --url or --command is required" [ -z "$url" ] || [ -z "$command" ] || die 3 "register: a surface is a page or a command, so --url and --command never go together" [ "$command" != "[]" ] || die 3 "register: --command holds no word" [ "$kinds" != "[]" ] || die 3 "register: at least one --kind is required" [ -z "$command" ] || [ "$kinds" = '["e2e"]' ] || die 3 "register: a command surface has the e2e kind alone, because there is no page to capture" # An end to end test is added on purpose: a core journey, or behaviour no lower test can reach. [ -n "$reason" ] || [ "$(printf '%s' "$kinds" | jq 'index("e2e") == null')" = "true" ] \ || die 3 "register: an e2e surface needs --reason: the core journey it walks, or the behaviour no lower test can reach" # A command surface needs no recipe and no harness, so it writes the surface file and turns end # to end on when nothing has: a command-line project has no install to run first. sf_load_surfaces "$SURFACE_FILE" if [ -n "$command" ] && [ "$SF_STATE" = "missing" ]; then warn_surface_file_elsewhere mkdir -p "$TREE/.visual-review" || die 3 "register: could not create $TREE/.visual-review" write_atomic "$SURFACE_FILE" "$(jq -n '{schemaVersion: 1, viewports: [], surfaces: []}')" KIND="e2e"; write_project_field '.registryPath = $sf | .e2e.enabled = true' fi require_surface_file # Review runs either the recipe's e2e row over pages or each command, never both in one project. [ "$(printf '%s' "$kinds" | jq 'index("e2e") != null')" = "false" ] \ || [ "$(printf '%s' "$SF_SURFACES" | jq --argjson cmd "$([ -n "$command" ] && echo true || echo false)" \ '[ .[] | select((.kinds | index("e2e")) and (has("command") != $cmd)) ] | length')" = "0" ] \ || die 3 "register: the surface file holds an e2e surface of the other form, and review runs either commands or the recipe's page suite for e2e. Register $id with the same form, or use another kind." # The key order is the reader's own, so a re-register compares equal to what sf_load_surfaces read. row="$(jq -nc --arg id "$id" --arg url "$url" --argjson kinds "$kinds" --argjson enabled "$enabled" --argjson masks "$masks" \ --argjson paths "$paths" --argjson critical "$critical" --argjson command "${command:-null}" --arg reason "$reason" \ '{id: $id, url: $url, kinds: $kinds, enabled: $enabled, masks: $masks, paths: $paths, critical: $critical} + (if $reason == "" then {} else {reason: $reason} end) + (if $command == null then {} else {command: $command} end)')" have="$(printf '%s' "$SF_SURFACES" | jq -c --arg id "$id" '[ .[] | select(.id == $id) ][0] // empty')" if [ -n "$have" ]; then [ "$have" = "$row" ] && { printf 'surface: %s unchanged\n' "$id"; exit 0; } die 3 "register: $id is already registered with different fields. Registered: $have. Given: $row. A duplicate id makes the file invalid, so edit the file or choose another id." fi doc="$(jq --argjson row "$row" '.surfaces += [$row | if .url == "" then del(.url) else . end]' "$SURFACE_FILE")" || die 3 "register: could not read $SURFACE_FILE" write_atomic "$SURFACE_FILE" "$doc" printf 'surface: %s enabled=%s kinds=%s paths=%s critical=%s\nsurface-file: %s\n' "$id" "$enabled" \ "$(printf '%s' "$kinds" | jq -r 'join(",")')" "$(printf '%s' "$paths" | jq 'length')" "$critical" "$SURFACE_FILE" recipe_commit_if_changed "$TREE" "$ACTION" "register wrote nothing new" "Register the $id surface through the surfaces skill" "$SURFACE_REL" } # ------------------------------------------------------------------ unregister # Removes one surface, once a person decided at test cleanup that a lower test covers it. Its # baselines stay on disk, because the suite names them and this script does not. do_unregister() { local id="${1:-}" doc [ "$#" -eq 1 ] && [ -n "$id" ] || die 3 "unregister: one surface id is required" require_surface_file printf '%s' "$SF_SURFACES" | jq -e --arg id "$id" 'any(.[]; .id == $id)' >/dev/null \ || die 3 "unregister: $id is not a surface in $SURFACE_FILE" doc="$(jq --arg id "$id" '.surfaces |= map(select(.id != $id))' "$SURFACE_FILE")" || die 3 "unregister: could not read $SURFACE_FILE" write_atomic "$SURFACE_FILE" "$doc" printf 'unregistered: %s\nsurface-file: %s\n' "$id" "$SURFACE_FILE" recipe_commit_if_changed "$TREE" "$ACTION" "unregister wrote nothing new" "Unregister the $id surface through the surfaces skill" "$SURFACE_REL" } # -------------------------------------------------------------------- baseline do_baseline() { local ids="" confirmed=false rows_file fw rp accept count names result rc one rows_file="$(mktemp)" || die 3 "baseline: could not create a temporary file" while [ "$#" -gt 0 ]; do case "$1" in --check-recipe) [ "$#" -ge 2 ] || die 3 "baseline: --check-recipe needs =" cr_recipe_pair baseline --check-recipe "$2"; fw="${CR_PAIR%%"$TAB"*}"; rp="${CR_PAIR#*"$TAB"}" : >"$rows_file.one"; cc_parse_recipe "$rp" "Surface commands" "surface_commands" "$rows_file.one" jq -c --arg fw "$fw" '. + {framework: $fw}' "$rows_file.one" >>"$rows_file" 2>/dev/null; rm -f "$rows_file.one"; shift 2 ;; --value) [ "$#" -ge 2 ] || die 3 "baseline: --value needs ="; pc_refuse_forged_value baseline "$2" case "$2" in *=*) ;; *) die 3 "baseline: --value takes =, got: $2" ;; esac VALUES="$VALUES${2%%=*}$TAB${2#*=} "; shift 2 ;; --confirmed) confirmed=true; shift ;; -*) die 3 "baseline: unrecognized argument: $1" ;; *) ids="$ids $1"; shift ;; esac done accept="$(jq -sc '[ .[] | select(.id == "visual-regression-accept" and has("argv")) ]' "$rows_file")"; rm -f "$rows_file" count="$(printf '%s' "$accept" | jq 'length')" # Two accept rows are two answers to one question: the first framework in project.json runs it. if [ "$count" -gt 1 ]; then accept="$(cr_by_project_order "$accept" "$PROJECT_FILE")" printf 'warning: baseline: %s each declare a visual-regression-accept row. %s is taken, the first in project.json\n' \ "$(printf '%s' "$accept" | jq -r '[ .[].framework ] | join(" and ")')" "$(printf '%s' "$accept" | jq -r '.[0].framework')" accept="$(printf '%s' "$accept" | jq -c '.[:1]')"; count=1 fi [ "$count" -eq 1 ] || die 3 "baseline: no review recipe given carries a visual-regression-accept row with a command, so there is no command that writes a baseline. Pass --check-recipe =." require_surface_file [ -n "$(pc_trim "$ids")" ] || ids="$(printf '%s' "$SF_SURFACES" | jq -r '[ .[] | select(.enabled and (.kinds | index("visual-regression"))) | .id ] | join(" ")')" ids="$(pc_trim "$ids")" [ -n "$ids" ] || die 3 "baseline: no enabled visual-regression surface is registered, so there is nothing to baseline" names="$(jq -r '[ .viewports[].name ] | join(",")' "$SURFACE_FILE")" # Walked as a here-document rather than `for id in $ids`, because zsh does not split an unquoted expansion. while IFS= read -r one; do [ -n "$one" ] || continue printf '%s' "$SF_SURFACES" | jq -e --arg id "$one" '[ .[] | select(.id == $id and (.kinds | index("visual-regression"))) ] | length == 1' >/dev/null \ || die 3 "baseline: $one is not a registered visual-regression surface in $SURFACE_FILE" printf 'baseline: %s viewports=%s\n' "$one" "$names" done <" ;; *) die 3 "baseline: the accept row holds no token to run" ;; esac [ "$rc" = "0" ] || { recipe_output_summary 4 "$OUTFILE" 1; exit 4; } # Review refuses a dirty tree, and the message is the record of why these baselines changed. commit_own_changes "the accept row wrote nothing" "New visual regression baselines for $ids, confirmed by a person through the surfaces skill" printf 'baselines: %s\n' "$ids" recipe_output_summary 0 "$OUTFILE" 1 } # --------------------------------------------------------------------- decline # A person declined one kind's setup. Takes a kind the way install does, since the two kinds are # separate capabilities: a person may take one and refuse the other. do_decline() { local kind="${1:-}" kind_key "$kind" cr_require_person decline "a person declined the setup" write_project_field '.'"$KEY"'.declined = true' printf 'declined: %s\nproject-file: %s\n' "$kind" "$PROJECT_FILE" } # ------------------------------------------------------------------------ read do_read() { printf 'project: %s\ncode-path: %s\n' "$PROJECT_DIR" "$TREE" printf 'surfaces-field: %s\n' "$(jq -r 'if .surfaces == null then "none" else "e2e=\(if .surfaces.e2e.enabled then "on" elif .surfaces.e2e.declined then "declined" else "off" end) visual-regression=\(if .surfaces.visualRegression.enabled then "on" elif .surfaces.visualRegression.declined then "declined" else "off" end)" end' "$PROJECT_FILE")" sf_load_surfaces "$SURFACE_FILE" printf 'surface-file: %s (%s)\n' "$SURFACE_FILE" "$SF_STATE" # Every setup offer reads this line first: scope's, design's and this skill's own (gap row 278). [ "$SF_STATE" != "missing" ] || printf 'surface-branch: %s\n' "$(sf_branch_with "$TREE" "$SURFACE_REL" | grep . || echo none)" [ "$SF_STATE" != "ok" ] || printf '%s' "$SF_SURFACES" | jq -r '.[] | "surface: \(.id) kinds=\(.kinds | join(",")) enabled=\(.enabled) \(if has("command") then "command=" + (.command | join(" ")) else "url=" + .url end) masks=\(.masks | length) paths=\(.paths | length) critical=\(.critical)\(if has("reason") then " reason=" + .reason else "" end)"' # A version 5 project holds a YAML registry beside the file. It is named, left in place, and its # ids and URLs are candidates for discovery. [ ! -f "$TREE/.visual-review/registry.yml" ] || printf 'registry-v5: %s\n' "$TREE/.visual-review/registry.yml" } case "$ACTION" in read) do_read ;; show|install) do_show_or_install "$@" ;; register) do_register "$@" ;; unregister) do_unregister "$@" ;; baseline) do_baseline "$@" ;; decline) do_decline "$@" ;; *) die 3 "unknown action $ACTION, expected read, show, install, register, unregister, baseline, decline or step" ;; esac