| name | pm-upgrade |
| version | 0.2.0 |
| description | Upgrade nanopm to the latest version. Detects install type, runs the upgrade, shows what's new. Also handles inline upgrade prompts when UPGRADE_AVAILABLE appears in any skill preamble. |
| allowed-tools | Bash, Read, AskUserQuestion |
Multi-host portability rules. When invoking AskUserQuestion:
- The
header field MUST be a short noun phrase (≤ 12 characters). Mistral Vibe
rejects longer headers with string_too_long. Pick from: Start, Target,
Scope, Audience, Methodology, Feature, Question.
- The
options list MUST have at least 2 items. Vibe rejects empty/single-option
calls. For free-text input, always provide ≥ 2 framing options (e.g. Yes, here's the input /
Skip) — never call ask_user_question with options: [].
Preamble (run first)
source ~/.nanopm/lib/nanopm.sh 2>/dev/null || \
source .nanopm/lib/nanopm.sh 2>/dev/null || \
{ echo "ERROR: nanopm not installed. Run: curl -fsSL https://raw.githubusercontent.com/nmrtn/nanopm/main/setup | bash"; exit 1; }
nanopm_preamble
Inline upgrade flow
This section is followed by all skill preambles when they detect UPGRADE_AVAILABLE {old} {new} in the preamble output.
Step 1: Ask or auto-upgrade
Check if auto-upgrade is configured:
source ~/.nanopm/lib/nanopm.sh 2>/dev/null || source .nanopm/lib/nanopm.sh 2>/dev/null || true
_AUTO=$(nanopm_config_get "auto_upgrade")
echo "AUTO_UPGRADE=${_AUTO:-false}"
If AUTO_UPGRADE=true: skip AskUserQuestion. Log "Auto-upgrading nanopm v{old} → v{new}..." and proceed to Step 2.
Otherwise, ask via AskUserQuestion:
- Question: "nanopm v{new} is available (you have v{old}). Upgrade now?"
- Options:
- "Yes, upgrade now"
- "Always keep me up to date (auto-upgrade)"
- "Not now (remind me later)"
- "Never ask again"
If "Yes, upgrade now": proceed to Step 2.
If "Always keep me up to date":
source ~/.nanopm/lib/nanopm.sh 2>/dev/null || source .nanopm/lib/nanopm.sh 2>/dev/null || true
nanopm_config_set "auto_upgrade" "true"
Tell user: "Auto-upgrade enabled — future updates will install automatically." Then proceed to Step 2.
If "Not now": write snooze state with escalating backoff. Then continue with the originally invoked skill without upgrading.
_SNOOZE="$HOME/.nanopm/update-snoozed"
_REMOTE_VER="{new}"
_CUR_LEVEL=0
if [ -f "$_SNOOZE" ]; then
_SV=$(awk '{print $1}' "$_SNOOZE")
if [ "$_SV" = "$_REMOTE_VER" ]; then
_CUR_LEVEL=$(awk '{print $2}' "$_SNOOZE")
case "$_CUR_LEVEL" in *[!0-9]*) _CUR_LEVEL=0 ;; esac
fi
fi
_NEW_LEVEL=$(( _CUR_LEVEL + 1 ))
[ "$_NEW_LEVEL" -gt 3 ] && _NEW_LEVEL=3
echo "$_REMOTE_VER $_NEW_LEVEL $(date +%s)" > "$_SNOOZE"
Tell user the snooze duration: level 1 → "next reminder in 24h"; level 2 → "48h"; level 3 → "1 week".
If "Never ask again":
source ~/.nanopm/lib/nanopm.sh 2>/dev/null || source .nanopm/lib/nanopm.sh 2>/dev/null || true
nanopm_config_set "update_check_disabled" "1"
rm -f "$HOME/.nanopm/update-snoozed"
Tell user: "Update checks disabled. Re-enable with: nanopm_config_set update_check_disabled 0 in your shell."
Step 2: Detect install type
_LOCAL_REPO=""
if [ -f "$(git rev-parse --show-toplevel 2>/dev/null)/pm-upgrade/SKILL.md" ] 2>/dev/null; then
_LOCAL_REPO=$(git rev-parse --show-toplevel)
fi
[ -z "$_LOCAL_REPO" ] && [ -f "$HOME/Code/nanopm/pm-upgrade/SKILL.md" ] && \
_LOCAL_REPO="$HOME/Code/nanopm"
echo "LOCAL_REPO=${_LOCAL_REPO:-none}"
Step 3: Save current version
_OLD_VER=$(cat ~/.nanopm/VERSION 2>/dev/null || echo "unknown")
echo "OLD_VERSION=$_OLD_VER"
Step 4: Run upgrade
If LOCAL_REPO is set (git install):
cd "$_LOCAL_REPO"
git pull origin main
bash setup
If LOCAL_REPO is not set (curl / vendored install):
curl -fsSL https://raw.githubusercontent.com/nmrtn/nanopm/main/setup | bash
If the upgrade fails, tell the user: "Upgrade failed. Your current version (v{old}) is still active. Check your network connection or run the setup script manually."
Step 5: Clear update cache
rm -f ~/.nanopm/last-update-check
rm -f ~/.nanopm/update-snoozed
Step 6: Show what's new
Fetch the changelog from GitHub:
_CHANGELOG=$(curl -fsSL --max-time 5 \
"https://raw.githubusercontent.com/nmrtn/nanopm/main/CHANGELOG.md" 2>/dev/null || echo "")
echo "$_CHANGELOG"
Find the section for the new version in the changelog. Summarize as 4-6 bullets grouped by theme (new skills, improvements, fixes). Don't list every line — focus on user-facing changes.
Format:
nanopm v{new} — upgraded from v{old}!
What's new:
- [bullet 1]
- [bullet 2]
...
Step 7: Continue
After showing what's new, continue with the originally invoked skill (if this was an inline upgrade triggered by UPGRADE_AVAILABLE). If invoked standalone as /pm-upgrade, done.
Standalone usage
When invoked directly as /pm-upgrade:
- Force a fresh update check:
source ~/.nanopm/lib/nanopm.sh
_CHECK=$(nanopm_update_check)
echo "CHECK: $_CHECK"
-
If UPGRADE_AVAILABLE {old} {new} in output: follow Steps 1-6 above.
-
If no UPGRADE_AVAILABLE output: tell the user "You're already on the latest version (v{current})."
STATUS: DONE