Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .agents/skills/update-command-spec-version/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -27,7 +39,9 @@ Run the scripts in order. The skill directory is wherever this SKILL.md lives; r
bash <skill-dir>/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

Expand Down
24 changes: 24 additions & 0 deletions .agents/skills/update-command-spec-version/scripts/common.sh
Original file line number Diff line number Diff line change
@@ -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
31 changes: 16 additions & 15 deletions .agents/skills/update-command-spec-version/scripts/ensure_repos.sh
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
Loading