Never run Git commands for upgrading in the user's business project repository. From the loaded SKILL.md, find the scripts/package-root.shin the same directory, and execute it to obtain the skill package's Git root directory. This script locates itself using its own real location and does not depend on the current working directory.
PACK_ROOT="$(bash "<当前 super-pm-upgrade skill 的绝对目录>/scripts/package-root.sh")" || exit 2
printf 'super-pm package: %s\n' "$PACK_ROOT"
If this command fails, the current installation is a copied installation or a non-Git installation;stop the Git upgrade process, and depending on the installation method use npx skills update or the platform's own update mechanism. Do not fall back to git pull the user's current project.
Check (read-only, except for network fetch)
Reset the absolute PACK_ROOTeach time the Bash tool is invoked, or explicitly set the command's working directory to that package. All of the following git commands must include -C "$PACK_ROOT":
PACK_ROOT="$(bash "<当前 skill 绝对目录>/scripts/package-root.sh")" || exit 2
git -C "$PACK_ROOT" status --short
git -C "$PACK_ROOT" branch --show-current
cat "$PACK_ROOT/VERSION"
git -C "$PACK_ROOT" fetch origin main --tags
git -C "$PACK_ROOT" log -1 --oneline HEAD
git -C "$PACK_ROOT" log -1 --oneline origin/main
Compare the current HEAD with origin/main. If there are uncommitted changes, it is non-fast-forward, it is not on the expected branch, or the remote is unavailable, stop and explain; do not automatically stash, reset, switch branches, or overwrite files. If the user only requests a "check", stop here.
Perform the upgrade (requires explicit user confirmation)
After informing the user of the target commit, current version, and impact, confirm. Do not run the following commands before confirmation:
PACK_ROOT="$(bash "<当前 skill 绝对目录>/scripts/package-root.sh")" || exit 2
OLD_COMMIT="$(git -C "$PACK_ROOT" rev-parse HEAD)"
test -z "$(git -C "$PACK_ROOT" status --porcelain)" || exit 1
git -C "$PACK_ROOT" merge --ff-only origin/main || exit 1
printf 'previous=%s\ncurrent=%s\n' "$OLD_COMMIT" "$(git -C "$PACK_ROOT" rev-parse HEAD)"
cat "$PACK_ROOT/VERSION"
Use only fast-forward merges; do not create new branches or worktrees. Verify the version and the actual skill manifest, then report the upgrade result; do not claim success without verification. Record OLD_COMMIT so the user can decide whether to roll back, butdo not automatically roll back. Rolling back requires confirmation again and ensuring the skill package workspace is clean; the business project must not be modified.
Interaction and fallback
If the environment has no AskUserQuestion, in ordinary chat ask only one question at a time and wait for the answer. If the user refuses the upgrade, stop. When there is a copied installation, insufficient permissions, network failure, or inability to fast-forward, explain the reason and the safe manual path; do not silently ignore errors.