/upgrade-hpp — Automate HPP Version Upgrade to Esperanto
Purpose
Automates the workflow of upgrading a Hosted Payment Page (HPP) review version in the Esperanto repository. When an HPP PR with label 'qa:required' is created, a review version is published (e.g., "3.0.96-3287898"). This skill extracts that version from the PR comments and creates an upgrade PR in Esperanto automatically.
What it does:
- Auto-detects current repo (HPP or Esperanto)
- Gets HPP PR number (from current branch or user argument)
- Fetches HPP PR details (branch name and title)
- Fetches HPP PR comments and extracts review version
- Creates upgrade branch in Esperanto repo using HPP PR's branch name
- Runs
update_whpp_version.shscript to update package.json files - Commits, pushes, and creates Esperanto PR with HPP PR title + " | QA Reviewer App"
- Uses Esperanto's predefined PR template (no custom body)
Type: Standalone coordinator (spawns general-purpose sub-agent)
Usage
From HPP Repo (Auto-detect PR)
# On HPP PR branch with review version comment
cd /Users/thw6774/Documents/repos/hosted-payment-page
git checkout <HPP-PR-branch>
/upgrade-hpp
From HPP Repo (Explicit PR Number)
cd /Users/thw6774/Documents/repos/hosted-payment-page
/upgrade-hpp 296
From Esperanto Repo (Requires PR Number)
cd /Users/thw6774/Documents/repos/esperanto
/upgrade-hpp 296
Prerequisites
Required:
- GitHub MCP server configured (for PR comment fetching and creation)
ghCLI authenticated (for PR operations)- HPP and Esperanto repos cloned as siblings in
/Users/thw6774/Documents/repos/ - HPP PR must have comment matching: "A review version has been published: X.Y.Z-COMMIT"
Validation:
# Check GitHub MCP
grep -q "github" ~/.mcp.json || echo "❌ GitHub MCP not configured"
# Check gh CLI
gh auth status || echo "❌ gh CLI not authenticated"
# Check repo structure
ls -d /Users/thw6774/Documents/repos/{hosted-payment-page,esperanto} || echo "❌ Repos not found"
Instructions
You are the coordinator for the /upgrade-hpp skill. Follow the coordinator-agent pattern:
- Validate prerequisites
- Detect execution context
- Get HPP PR number
- Spawn sub-agent to execute upgrade
- Report results to user
- NEVER retry sub-agent work - report failures to user
Step 1: Validate Prerequisites
Check required tools and access:
# Validate GitHub MCP (check if mcp__github tools are available)
# If not available: ERROR "GitHub MCP not configured. See .mcp.json"
# Validate gh CLI
if ! command -v gh &> /dev/null; then
echo "❌ gh CLI not found. Install: brew install gh"
exit 1
fi
# Check gh auth
if ! gh auth status &> /dev/null; then
echo "❌ gh CLI not authenticated. Run: gh auth login"
exit 1
fi
Step 2: Detect Repo Context
Determine if running from HPP or Esperanto repo:
# Get current repo from git remote
REMOTE_URL=$(git remote get-url origin 2>/dev/null)
if [ -z "$REMOTE_URL" ]; then
echo "❌ Not in a git repository"
exit 1
fi
# Extract repo slug
REPO_SLUG=$(echo "$REMOTE_URL" | sed 's/.*[:/]\([^/]*\/[^/]*\)\.git/\1/' | sed 's/.*[:/]\([^/]*\/[^/]*\)$/\1/')
case "$REPO_SLUG" in
"krogertechnology/hosted-payment-page")
CURRENT_REPO="HPP"
echo "Detected: Hosted Payment Page repo"
;;
"krogertechnology/esperanto")
CURRENT_REPO="ESPERANTO"
echo "Detected: Esperanto repo"
;;
*)
echo "❌ Unknown repo: $REPO_SLUG"
echo "Must run from HPP or Esperanto repo"
exit 1
;;
esac
Step 3: Get HPP PR Number
Extract PR number from current branch or user argument:
# Check if user provided PR number as argument
if [ -n "$1" ]; then
PR_NUMBER="$1"
echo "Using provided HPP PR number: $PR_NUMBER"
else
# Try auto-detect if in HPP repo
if [ "$CURRENT_REPO" = "HPP" ]; then
PR_NUMBER=$(gh pr view --json number -q .number 2>/dev/null)
if [ -z "$PR_NUMBER" ]; then
# Not on a PR branch - ask user
# Use AskUserQuestion to get PR number
echo "❌ Not on HPP PR branch and no PR number provided"
echo "Usage: /upgrade-hpp <HPP-PR-NUMBER>"
exit 1
fi
echo "Auto-detected HPP PR: #$PR_NUMBER"
else
# In Esperanto repo - require argument
echo "❌ HPP PR number required when running from Esperanto repo"
echo "Usage: /upgrade-hpp <HPP-PR-NUMBER>"
exit 1
fi
fi
# Validate PR number is numeric
if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]]; then
echo "❌ Invalid PR number: $PR_NUMBER (must be numeric)"
exit 1
fi
Step 4: Determine Esperanto Repo Path
Find Esperanto repo location:
if [ "$CURRENT_REPO" = "HPP" ]; then
# We're in HPP - find sibling Esperanto repo
HPP_PATH=$(pwd)
PARENT_DIR=$(dirname "$HPP_PATH")
ESPERANTO_PATH="${PARENT_DIR}/esperanto"
if [ ! -d "$ESPERANTO_PATH/.git" ]; then
# Esperanto repo not found as sibling - ask user
# Use AskUserQuestion to get Esperanto path
echo "❌ Esperanto repo not found at: $ESPERANTO_PATH"
echo "Expected repos to be siblings in: $PARENT_DIR"
exit 1
fi
echo "Found Esperanto repo: $ESPERANTO_PATH"
else
# We're already in Esperanto
ESPERANTO_PATH=$(pwd)
echo "Using current Esperanto repo: $ESPERANTO_PATH"
fi
Step 5: Spawn Upgrade Sub-Agent
Use the Task tool to spawn a general-purpose sub-agent that executes the upgrade workflow:
Task Configuration:
subagent_type: "general-purpose"
description: "Upgrade HPP version in Esperanto"
model: "sonnet" # Complex workflow with multiple git operations
Sub-Agent Prompt:
Upgrade Hosted Payment Page version in Esperanto repo from HPP PR review version.
## CONTEXT
- **HPP PR Number**: <PR_NUMBER>
- **Current Repo**: <CURRENT_REPO>
- **Esperanto Path**: <ESPERANTO_PATH>
- **HPP Repo**: krogertechnology/hosted-payment-page
- **Esperanto Repo**: krogertechnology/esperanto
## TASKS
Execute the following tasks in sequence. On ANY error, stop immediately and report the failure.
### Task 1: Fetch HPP PR Details
Use `mcp__github__pull_request_read` to get PR details:
owner: "krogertechnology" repo: "hosted-payment-page" pullNumber: method: "get"
Extract from the response:
- **Branch name** (head.ref): The source branch name of the HPP PR
- **PR title**: The title of the HPP PR
Store these for later use:
- HPP_BRANCH_NAME
- HPP_PR_TITLE
### Task 2: Fetch HPP PR Comments
Use `mcp__github__pull_request_read` to get PR comments:
owner: "krogertechnology" repo: "hosted-payment-page" pullNumber: method: "get_comments"
### Task 3: Extract Review Version
Search comments for version pattern:
- **Pattern**: `A review version has been published: (\d+\.\d+\.\d+-[a-f0-9]+)`
- **Example**: "A review version has been published: 3.0.96-3287898"
- Extract the version string (e.g., "3.0.96-3287898")
**Error Handling**:
- If no match found: ERROR "No review version comment found in HPP PR #<PR_NUMBER>. Ensure PR has 'qa:required' label and version has been published."
- If multiple matches: Use the MOST RECENT comment (last in list)
### Task 4: Check for Existing Upgrade PR
Check if upgrade PR already exists in Esperanto using the HPP branch name:
```bash
gh pr list --head "<HPP_BRANCH_NAME>" --repo krogertechnology/esperanto --json number,title,state
Error Handling:
- If open PR found: Ask user via
AskUserQuestion:- Question: "An upgrade PR already exists for HPP #. What would you like to do?"
- Options:
- "Update existing PR" → Close existing and create new
- "Skip and exit" → Exit successfully with message
- "Create new anyway" → Continue with new PR
- If closed PR found: Continue (create new PR)
Task 5: Create Upgrade Branch in Esperanto
cd <ESPERANTO_PATH>
# Ensure on main and up to date
git fetch origin
git checkout main
git pull origin main
# Create upgrade branch using HPP PR's branch name
BRANCH="<HPP_BRANCH_NAME>"
git checkout -b "$BRANCH"
echo "Created branch: $BRANCH"
Branch naming: Use the same branch name as the HPP PR's head branch
- Example: If HPP PR branch is
dcppay-296-add-feature, Esperanto branch will bedcppay-296-add-feature
Task 6: Run Update Script
Navigate to script directory and execute:
cd <ESPERANTO_PATH>/@kroger/buy/kroger-hosted-payment-page/scripts
# Run update script with version
./update_whpp_version.sh "<VERSION>"
SCRIPT_EXIT=$?
if [ $SCRIPT_EXIT -ne 0 ]; then
echo "❌ Script failed with exit code: $SCRIPT_EXIT"
exit 1
fi
echo "✓ Script completed successfully"
Expected Changes:
- 3 package.json files should be modified:
@kroger/buy/kroger-hosted-payment-page/package.jsonpackage.json(root)@kroger/health/pharmacy/package.json
Task 7: Verify Changes
cd <ESPERANTO_PATH>
# Check git status
CHANGED_FILES=$(git status --porcelain | wc -l)
if [ $CHANGED_FILES -eq 0 ]; then
echo "❌ No files changed after script execution"
exit 1
fi
# Verify expected files are modified
git diff --name-only | grep -E "(package\.json|package-lock\.json|yarn\.lock)" || {
echo "❌ Unexpected file changes. Expected package.json modifications."
git status
exit 1
}
echo "✓ Verified expected file changes"
Task 8: Commit Changes
cd <ESPERANTO_PATH>
# Stage all package files
git add -A
# Create commit message
COMMIT_MSG="chore: upgrade hosted-payment-page to <VERSION>
Automated upgrade from HPP PR #<PR_NUMBER>
Review version published: <VERSION>
Refs: HPP-<PR_NUMBER>
"
git commit -m "$COMMIT_MSG"
echo "✓ Committed changes"
Task 9: Push Branch
git push -u origin "$BRANCH"
echo "✓ Pushed branch: $BRANCH"
Task 10: Create Esperanto PR
Use mcp__github__create_pull_request:
owner: "krogertechnology"
repo: "esperanto"
head: <BRANCH>
base: "main"
title: "<HPP_PR_TITLE> | QA Reviewer App"
draft: false
Important:
- Title: Use the HPP PR title exactly, then append " | QA Reviewer App"
- Example: If HPP title is "Add card validation", Esperanto title is "Add card validation | QA Reviewer App"
- Body: Do NOT provide a body parameter - let Esperanto use its predefined PR template markdown
Add Labels:
After PR creation, add labels using gh CLI:
gh pr edit <PR_NUMBER> --repo krogertechnology/esperanto \
--add-label "version-minor" \
--add-label "Autodeploy Stage Review App"
Task 11: Report Success
Display results in table format:
✓ HPP Upgrade Complete
| Field | Value |
|-------|-------|
| Esperanto PR | #<ESPERANTO_PR_NUMBER> |
| HPP Source PR | #<HPP_PR_NUMBER> |
| HPP PR Title | <HPP_PR_TITLE> |
| Esperanto PR Title | <HPP_PR_TITLE> | QA Reviewer App |
| Version | <VERSION> |
| Branch | <HPP_BRANCH_NAME> |
| Labels | version-minor, Autodeploy Stage Review App |
URL: <ESPERANTO_PR_URL>
Next: Monitor CI/CD checks in Esperanto PR for autodeploy to stage
ERROR HANDLING
Critical Errors (stop immediately):
- No review version comment found
- Script execution fails
- Git operations fail
- PR creation fails
- GitHub authentication fails
User Input Errors (ask for clarification):
- Esperanto repo not found at expected path
- Existing upgrade PR found
- Not on HPP PR branch (when auto-detecting)
All errors must:
- Log to stderr with clear error message
- Provide recovery steps
- Exit immediately (no retry)
### Step 6: Report Results
After sub-agent completes:
**On Success**:
- Display sub-agent's success message (includes PR details table)
- Do NOT summarize or add commentary
- Let user know next steps are in the message
**On Failure**:
- Display sub-agent's error message exactly
- Provide recovery guidance:
- Missing version comment → Check HPP PR has 'qa:required' label
- Script failure → Verify Esperanto repo state
- Auth failure → Check GitHub MCP and gh CLI auth
- Existing PR → User decides via AskUserQuestion
- **NEVER retry the sub-agent work yourself**
**Example Success Output**:
✓ HPP Upgrade Complete
| Field | Value |
|---|---|
| Esperanto PR | #789 |
| HPP Source PR | #296 |
| HPP PR Title | Add card validation |
| Esperanto PR Title | Add card validation |
| Version | 3.0.96-3287898 |
| Branch | dcppay-296-add-card-validation |
| Labels | version-minor, Autodeploy Stage Review App |
URL: https://github.com/krogertechnology/esperanto/pull/789
Next: Monitor CI/CD checks in Esperanto PR for autodeploy to stage
---
## Verification
After skill execution, verify:
```bash
# 1. Branch exists in Esperanto (should match HPP PR branch name)
cd /Users/thw6774/Documents/repos/esperanto
git branch --list "dcppay-*"
# 2. Package.json files updated
grep "@kroger/hosted-payment-page" @kroger/buy/kroger-hosted-payment-page/package.json
grep "@kroger/hosted-payment-page" package.json
grep "@kroger/hosted-payment-page" @kroger/health/pharmacy/package.json
# 3. PR created with correct labels
gh pr view <PR-NUMBER> --repo krogertechnology/esperanto --json labels,title,body
# 4. Verify labels
gh pr view <PR-NUMBER> --repo krogertechnology/esperanto --json labels -q '.labels[].name'
Security
Safe Operations:
- Read-only access to HPP PR (fetch comments only)
- Creates new branch (non-destructive)
- No force-push or destructive git operations
- Version string validated before script execution
Validation:
- Version format:
\d+\.\d+\.\d+-[a-f0-9]+ - PR number: numeric only
- Script path: verify exists before execution
No Secrets:
- GitHub auth via MCP/gh CLI
- No API tokens in skill code
- No PII or sensitive data
Related Files
| File | Purpose |
|---|---|
| context/repos/esperanto.md | PR template, branch naming |
| context/repos/hosted-payment-page.md | HPP repo identity |
| skills/push/SKILL.md | GitHub MCP PR creation pattern |
| skills/pull/SKILL.md | Repo detection pattern |
| skills/branch/SKILL.md | Branch creation pattern |