From 61e817c53ae7190ab383d4efa8ba50c75e167c73 Mon Sep 17 00:00:00 2001 From: Oz Date: Mon, 13 Jul 2026 21:13:44 +0000 Subject: [PATCH 1/3] Resolve update-command-spec-version repo paths dynamically The update-command-spec-version skill scripts hardcoded ~/warp and ~/command-signatures, so they only worked when both repos happened to be checked out at those exact paths. Resolve both dynamically instead: - command-signatures is inferred from the script location via git rev-parse --show-toplevel (the scripts live inside the repo). - warp is taken from $WARP_DIR when set, else assumed to be a sibling of command-signatures. Shared resolution lives in scripts/common.sh (sourced by the bash scripts) and is mirrored in list_merged_prs.py. ensure_repos.sh now only fetches the command-signatures checkout it runs from rather than switching branches / pulling into it. Co-Authored-By: Oz --- .../update-command-spec-version/SKILL.md | 16 +++++++++++- .../scripts/common.sh | 26 +++++++++++++++++++ .../scripts/ensure_repos.sh | 24 +++++++---------- .../scripts/get_current_hash.sh | 3 ++- .../scripts/get_latest_hash.sh | 5 ++-- .../scripts/list_merged_prs.py | 26 ++++++++++++++++++- .../scripts/submit_pr.sh | 4 ++- .../scripts/update_and_branch.sh | 4 ++- 8 files changed, 87 insertions(+), 21 deletions(-) create mode 100755 .agents/skills/update-command-spec-version/scripts/common.sh diff --git a/.agents/skills/update-command-spec-version/SKILL.md b/.agents/skills/update-command-spec-version/SKILL.md index cd133e59..6dc2eeb8 100644 --- a/.agents/skills/update-command-spec-version/SKILL.md +++ b/.agents/skills/update-command-spec-version/SKILL.md @@ -17,6 +17,18 @@ All scripts live in this skill's `scripts/` directory. - Python 3 (for `list_merged_prs.py`) - Rust toolchain with `cargo` (for updating `Cargo.lock`) +## Repo locations + +The scripts resolve both repos dynamically (see `scripts/common.sh`) instead of +assuming fixed `~/warp` / `~/command-signatures` paths: + +- **command-signatures** is inferred from the script location — these scripts + live inside the repo, so the enclosing git worktree is always used. +- **warp** is taken from the `WARP_DIR` environment variable when set; otherwise + it is assumed to be a sibling of the command-signatures repo (same parent + directory, named `warp`). Export `WARP_DIR=/path/to/warp` if your checkout + lives elsewhere. + ## Step-by-step procedure Run the scripts in order. The skill directory is wherever this SKILL.md lives; reference scripts relative to it. @@ -27,7 +39,9 @@ Run the scripts in order. The skill directory is wherever this SKILL.md lives; r bash /scripts/ensure_repos.sh ``` -This clones or fetches both `~/warp` and `~/command-signatures`. +This fetches the command-signatures repo the scripts live in, and fetches (or +clones, if missing) the warp repo resolved from `$WARP_DIR` or the sibling +directory. See **Repo locations** above. ### 2. Get the current and latest hashes diff --git a/.agents/skills/update-command-spec-version/scripts/common.sh b/.agents/skills/update-command-spec-version/scripts/common.sh new file mode 100755 index 00000000..3f0d98d4 --- /dev/null +++ b/.agents/skills/update-command-spec-version/scripts/common.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Shared repo-path resolution for the update-command-spec-version scripts. +# +# Rather than assuming fixed ~/warp and ~/command-signatures locations, both +# repos are resolved dynamically: +# CMD_SIGS_DIR - the command-signatures repo, inferred from this script's own +# location (these scripts live inside that repo), so it always +# points at the checkout the skill ships from. +# WARP_DIR - the warp repo, taken from the $WARP_DIR environment variable +# when set; otherwise assumed to be a sibling of the +# command-signatures repo (same parent directory, named "warp"). + +# Directory this file lives in (resolved through symlinks). +_COMMON_SH_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# The command-signatures repo root that contains these scripts. +CMD_SIGS_DIR="$(git -C "${_COMMON_SH_DIR}" rev-parse --show-toplevel)" + +# The warp repo: prefer $WARP_DIR, else a sibling of command-signatures. +if [ -n "${WARP_DIR:-}" ]; then + WARP_DIR="${WARP_DIR}" +else + WARP_DIR="$(dirname "${CMD_SIGS_DIR}")/warp" +fi + +export CMD_SIGS_DIR WARP_DIR diff --git a/.agents/skills/update-command-spec-version/scripts/ensure_repos.sh b/.agents/skills/update-command-spec-version/scripts/ensure_repos.sh index e560448d..4be87e93 100755 --- a/.agents/skills/update-command-spec-version/scripts/ensure_repos.sh +++ b/.agents/skills/update-command-spec-version/scripts/ensure_repos.sh @@ -1,25 +1,21 @@ #!/bin/bash set -euo pipefail -WARP_DIR="${HOME}/warp" -CMD_SIGS_DIR="${HOME}/command-signatures" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${SCRIPT_DIR}/common.sh" + +# command-signatures is the repo these scripts live in, so it always exists. +# Only refresh its remotes; never mutate the working tree or checked-out branch +# (the skill reads origin/main directly via get_latest_hash.sh). +echo "Fetching command-signatures (${CMD_SIGS_DIR})..." >&2 +git -C "${CMD_SIGS_DIR}" fetch origin if [ -d "${WARP_DIR}" ]; then - echo "Fetching warp..." >&2 + echo "Fetching warp (${WARP_DIR})..." >&2 git -C "${WARP_DIR}" fetch origin else - echo "Cloning warp..." >&2 + echo "Cloning warp into ${WARP_DIR}..." >&2 git clone ssh://git@github.com/warpdotdev/warp.git "${WARP_DIR}" fi -if [ -d "${CMD_SIGS_DIR}" ]; then - echo "Fetching command-signatures..." >&2 - git -C "${CMD_SIGS_DIR}" fetch origin - git -C "${CMD_SIGS_DIR}" checkout main --quiet - git -C "${CMD_SIGS_DIR}" pull origin main --quiet -else - echo "Cloning command-signatures..." >&2 - git clone ssh://git@github.com/warpdotdev/command-signatures.git "${CMD_SIGS_DIR}" -fi - echo "Both repositories are ready." >&2 diff --git a/.agents/skills/update-command-spec-version/scripts/get_current_hash.sh b/.agents/skills/update-command-spec-version/scripts/get_current_hash.sh index 7422106f..8c3204cc 100755 --- a/.agents/skills/update-command-spec-version/scripts/get_current_hash.sh +++ b/.agents/skills/update-command-spec-version/scripts/get_current_hash.sh @@ -1,7 +1,8 @@ #!/bin/bash set -euo pipefail -WARP_DIR="${HOME}/warp" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${SCRIPT_DIR}/common.sh" # Read Cargo.toml from origin/master so we don't depend on local checkout state. HASH=$(git -C "${WARP_DIR}" show origin/master:Cargo.toml \ diff --git a/.agents/skills/update-command-spec-version/scripts/get_latest_hash.sh b/.agents/skills/update-command-spec-version/scripts/get_latest_hash.sh index a118bd7b..88b1a77f 100755 --- a/.agents/skills/update-command-spec-version/scripts/get_latest_hash.sh +++ b/.agents/skills/update-command-spec-version/scripts/get_latest_hash.sh @@ -1,9 +1,10 @@ #!/bin/bash set -euo pipefail -CMD_SIGS_DIR="${HOME}/command-signatures" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${SCRIPT_DIR}/common.sh" -# After ensure_repos.sh has pulled, origin/main is up to date. +# After ensure_repos.sh has fetched, origin/main is up to date. HASH=$(git -C "${CMD_SIGS_DIR}" rev-parse origin/main) if [ -z "${HASH}" ]; then diff --git a/.agents/skills/update-command-spec-version/scripts/list_merged_prs.py b/.agents/skills/update-command-spec-version/scripts/list_merged_prs.py index 44549711..77797f07 100755 --- a/.agents/skills/update-command-spec-version/scripts/list_merged_prs.py +++ b/.agents/skills/update-command-spec-version/scripts/list_merged_prs.py @@ -17,10 +17,34 @@ import sys -REPO_DIR = os.path.expanduser("~/command-signatures") GH_REPO = "warpdotdev/command-signatures" +def _resolve_repo_dir(): + """Infer the command-signatures repo root from this script's own location. + + These scripts live inside the command-signatures repo, so the enclosing + git worktree is always the right checkout — no fixed ~/command-signatures + assumption. + """ + script_dir = os.path.dirname(os.path.abspath(__file__)) + result = subprocess.run( + ["git", "-C", script_dir, "rev-parse", "--show-toplevel"], + capture_output=True, + text=True, + ) + if result.returncode != 0: + print( + f"Error resolving command-signatures repo dir:\n{result.stderr}", + file=sys.stderr, + ) + sys.exit(1) + return result.stdout.strip() + + +REPO_DIR = _resolve_repo_dir() + + def run(cmd): result = subprocess.run(cmd, capture_output=True, text=True) if result.returncode != 0: diff --git a/.agents/skills/update-command-spec-version/scripts/submit_pr.sh b/.agents/skills/update-command-spec-version/scripts/submit_pr.sh index 151ee9ec..0b18934f 100755 --- a/.agents/skills/update-command-spec-version/scripts/submit_pr.sh +++ b/.agents/skills/update-command-spec-version/scripts/submit_pr.sh @@ -6,9 +6,11 @@ if [ $# -ne 2 ]; then exit 1 fi +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${SCRIPT_DIR}/common.sh" + NEW_HASH="$1" PR_BODY_FILE="$2" -WARP_DIR="${HOME}/warp" SHORT_HASH="${NEW_HASH:0:8}" BRANCH_NAME="completions-bot/update-command-signatures-${SHORT_HASH}" PR_TITLE="[Completions] Bump command-signatures to ${SHORT_HASH}" diff --git a/.agents/skills/update-command-spec-version/scripts/update_and_branch.sh b/.agents/skills/update-command-spec-version/scripts/update_and_branch.sh index eaa6481e..1550e246 100755 --- a/.agents/skills/update-command-spec-version/scripts/update_and_branch.sh +++ b/.agents/skills/update-command-spec-version/scripts/update_and_branch.sh @@ -6,8 +6,10 @@ if [ $# -ne 1 ]; then exit 1 fi +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${SCRIPT_DIR}/common.sh" + NEW_HASH="$1" -WARP_DIR="${HOME}/warp" CARGO_TOML="${WARP_DIR}/Cargo.toml" BRANCH_NAME="completions-bot/update-command-signatures-${NEW_HASH:0:8}" From e9cdee2176c8bc76ef4ca84fdf1bd603830e9cf6 Mon Sep 17 00:00:00 2001 From: Oz Date: Mon, 13 Jul 2026 21:20:25 +0000 Subject: [PATCH 2/3] ensure_repos.sh: fetch exact origin refspecs Address review feedback: a bare 'git fetch origin' follows the checkout's configured refspec, so branch-limited or shallow clones could leave origin/main / origin/master (read later by get_latest_hash.sh and get_current_hash.sh) missing or stale. Fetch each exact ref explicitly. Co-Authored-By: Oz --- .../update-command-spec-version/scripts/ensure_repos.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.agents/skills/update-command-spec-version/scripts/ensure_repos.sh b/.agents/skills/update-command-spec-version/scripts/ensure_repos.sh index 4be87e93..49ea0108 100755 --- a/.agents/skills/update-command-spec-version/scripts/ensure_repos.sh +++ b/.agents/skills/update-command-spec-version/scripts/ensure_repos.sh @@ -7,12 +7,17 @@ source "${SCRIPT_DIR}/common.sh" # command-signatures is the repo these scripts live in, so it always exists. # Only refresh its remotes; never mutate the working tree or checked-out branch # (the skill reads origin/main directly via get_latest_hash.sh). +# +# Fetch the *exact* remote ref each later script reads (origin/main here, +# origin/master in warp) with an explicit refspec. A bare `git fetch origin` +# follows the checkout's configured refspec, so a branch-limited or shallow +# clone could otherwise leave origin/main / origin/master missing or stale. echo "Fetching command-signatures (${CMD_SIGS_DIR})..." >&2 -git -C "${CMD_SIGS_DIR}" fetch origin +git -C "${CMD_SIGS_DIR}" fetch origin main:refs/remotes/origin/main if [ -d "${WARP_DIR}" ]; then echo "Fetching warp (${WARP_DIR})..." >&2 - git -C "${WARP_DIR}" fetch origin + git -C "${WARP_DIR}" fetch origin master:refs/remotes/origin/master else echo "Cloning warp into ${WARP_DIR}..." >&2 git clone ssh://git@github.com/warpdotdev/warp.git "${WARP_DIR}" From c2f8158699d9a9b7f9db79b75e7e192504605d76 Mon Sep 17 00:00:00 2001 From: Oz Date: Mon, 13 Jul 2026 21:24:54 +0000 Subject: [PATCH 3/3] Trim path-resolution comments to current-state only Drop the references to the previous hardcoded ~/warp / ~/command-signatures paths from the code comments; comments now describe only current behavior. Co-Authored-By: Oz --- .../skills/update-command-spec-version/scripts/common.sh | 6 ++---- .../update-command-spec-version/scripts/list_merged_prs.py | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.agents/skills/update-command-spec-version/scripts/common.sh b/.agents/skills/update-command-spec-version/scripts/common.sh index 3f0d98d4..f7963080 100755 --- a/.agents/skills/update-command-spec-version/scripts/common.sh +++ b/.agents/skills/update-command-spec-version/scripts/common.sh @@ -1,14 +1,12 @@ #!/bin/bash # Shared repo-path resolution for the update-command-spec-version scripts. # -# Rather than assuming fixed ~/warp and ~/command-signatures locations, both -# repos are resolved dynamically: # CMD_SIGS_DIR - the command-signatures repo, inferred from this script's own # location (these scripts live inside that repo), so it always # points at the checkout the skill ships from. # WARP_DIR - the warp repo, taken from the $WARP_DIR environment variable -# when set; otherwise assumed to be a sibling of the -# command-signatures repo (same parent directory, named "warp"). +# when set; otherwise a sibling of the command-signatures repo +# (same parent directory, named "warp"). # Directory this file lives in (resolved through symlinks). _COMMON_SH_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" diff --git a/.agents/skills/update-command-spec-version/scripts/list_merged_prs.py b/.agents/skills/update-command-spec-version/scripts/list_merged_prs.py index 77797f07..8c77995d 100755 --- a/.agents/skills/update-command-spec-version/scripts/list_merged_prs.py +++ b/.agents/skills/update-command-spec-version/scripts/list_merged_prs.py @@ -24,8 +24,7 @@ def _resolve_repo_dir(): """Infer the command-signatures repo root from this script's own location. These scripts live inside the command-signatures repo, so the enclosing - git worktree is always the right checkout — no fixed ~/command-signatures - assumption. + git worktree is always the right checkout. """ script_dir = os.path.dirname(os.path.abspath(__file__)) result = subprocess.run(