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..f7963080 --- /dev/null +++ b/.agents/skills/update-command-spec-version/scripts/common.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Shared repo-path resolution for the update-command-spec-version scripts. +# +# 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 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..49ea0108 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,26 @@ #!/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). +# +# 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 main:refs/remotes/origin/main if [ -d "${WARP_DIR}" ]; then - echo "Fetching warp..." >&2 - git -C "${WARP_DIR}" fetch origin + echo "Fetching warp (${WARP_DIR})..." >&2 + git -C "${WARP_DIR}" fetch origin master:refs/remotes/origin/master 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..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 @@ -17,10 +17,33 @@ 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. + """ + 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}"