mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-01 19:25:10 +02:00
feat: smart update check with auto-upgrade, snooze backoff, config CLI (v0.3.9) (#62)
* feat: add bin/gstack-config CLI for reading/writing ~/.gstack/config.yaml Simple get/set/list interface for persistent gstack configuration. Used by update-check and upgrade skill for auto_upgrade and update_check settings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: smart update check with 12h cache, snooze backoff, config disable - Reduce cache TTL from 24h to 12h for faster update detection - Add exponential snooze backoff: 24h → 48h → 1 week (resets on new version) - Add update_check: false config option to disable checks entirely - Clear snooze file on just-upgraded - 14 new tests covering snooze levels, expiry, corruption, and config paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: upgrade skill with auto-upgrade, 4-option prompt, vendored sync - Auto-upgrade mode via config or GSTACK_AUTO_UPGRADE=1 env var - 4-option AskUserQuestion: upgrade once, always, not now, never - Step 4.5: sync local vendored copy after upgrading primary install - Snooze write with escalating backoff on "Not now" - Update preamble text in gen-skill-docs for new upgrade flow - Regenerate all SKILL.md files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: simplify upgrade instructions, move auto-upgrade to completed README now points to /gstack-upgrade instead of long paste commands. Auto-upgrade TODO moved to Completed section (v0.3.8). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: bump version and changelog (v0.3.9) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+78
-6
@@ -1,12 +1,13 @@
|
||||
---
|
||||
name: gstack-upgrade
|
||||
version: 1.0.0
|
||||
version: 1.1.0
|
||||
description: |
|
||||
Upgrade gstack to the latest version. Detects global vs vendored install,
|
||||
runs the upgrade, and shows what's new.
|
||||
allowed-tools:
|
||||
- Bash
|
||||
- Read
|
||||
- Write
|
||||
- AskUserQuestion
|
||||
---
|
||||
<!-- AUTO-GENERATED from SKILL.md.tmpl — do not edit directly -->
|
||||
@@ -20,13 +21,56 @@ Upgrade gstack to the latest version and show what's new.
|
||||
|
||||
This section is referenced by all skill preambles when they detect `UPGRADE_AVAILABLE`.
|
||||
|
||||
### Step 1: Ask the user
|
||||
### Step 1: Ask the user (or auto-upgrade)
|
||||
|
||||
Use AskUserQuestion:
|
||||
- Question: "gstack **v{new}** is available (you're on v{old}). Upgrade now? Takes ~10 seconds."
|
||||
- Options: ["Yes, upgrade now", "Later (ask again tomorrow)"]
|
||||
First, check if auto-upgrade is enabled:
|
||||
```bash
|
||||
_AUTO=""
|
||||
[ "${GSTACK_AUTO_UPGRADE:-}" = "1" ] && _AUTO="true"
|
||||
[ -z "$_AUTO" ] && _AUTO=$(~/.claude/skills/gstack/bin/gstack-config get auto_upgrade 2>/dev/null || true)
|
||||
echo "AUTO_UPGRADE=$_AUTO"
|
||||
```
|
||||
|
||||
**If "Later":** Run `touch ~/.gstack/last-update-check` to reset the 24h timer and continue with the current skill. Do not mention the upgrade again.
|
||||
**If `AUTO_UPGRADE=true` or `AUTO_UPGRADE=1`:** Skip AskUserQuestion. Log "Auto-upgrading gstack v{old} → v{new}..." and proceed directly to Step 2. If `./setup` fails during auto-upgrade, restore from backup (`.bak` directory) and warn the user: "Auto-upgrade failed — restored previous version. Run `/gstack-upgrade` manually to retry."
|
||||
|
||||
**Otherwise**, use AskUserQuestion:
|
||||
- Question: "gstack **v{new}** is available (you're on v{old}). Upgrade now?"
|
||||
- Options: ["Yes, upgrade now", "Always keep me up to date", "Not now", "Never ask again"]
|
||||
|
||||
**If "Yes, upgrade now":** Proceed to Step 2.
|
||||
|
||||
**If "Always keep me up to date":**
|
||||
```bash
|
||||
~/.claude/skills/gstack/bin/gstack-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 (first snooze = 24h, second = 48h, third+ = 1 week), then continue with the current skill. Do not mention the upgrade again.
|
||||
```bash
|
||||
_SNOOZE_FILE=~/.gstack/update-snoozed
|
||||
_REMOTE_VER="{new}"
|
||||
_CUR_LEVEL=0
|
||||
if [ -f "$_SNOOZE_FILE" ]; then
|
||||
_SNOOZED_VER=$(awk '{print $1}' "$_SNOOZE_FILE")
|
||||
if [ "$_SNOOZED_VER" = "$_REMOTE_VER" ]; then
|
||||
_CUR_LEVEL=$(awk '{print $2}' "$_SNOOZE_FILE")
|
||||
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_FILE"
|
||||
```
|
||||
Note: `{new}` is the remote version from the `UPGRADE_AVAILABLE` output — substitute it from the update check result.
|
||||
|
||||
Tell user the snooze duration: "Next reminder in 24h" (or 48h or 1 week, depending on level). Tip: "Set `auto_upgrade: true` in `~/.gstack/config.yaml` for automatic upgrades."
|
||||
|
||||
**If "Never ask again":**
|
||||
```bash
|
||||
~/.claude/skills/gstack/bin/gstack-config set update_check false
|
||||
```
|
||||
Tell user: "Update checks disabled. Run `~/.claude/skills/gstack/bin/gstack-config set update_check true` to re-enable."
|
||||
Continue with the current skill.
|
||||
|
||||
### Step 2: Detect install type
|
||||
|
||||
@@ -79,12 +123,40 @@ cd "$INSTALL_DIR" && ./setup
|
||||
rm -rf "$INSTALL_DIR.bak" "$TMP_DIR"
|
||||
```
|
||||
|
||||
### Step 4.5: Sync local vendored copy
|
||||
|
||||
After upgrading the primary install, check if there's also a local copy in the current project that needs updating:
|
||||
|
||||
```bash
|
||||
_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||
LOCAL_GSTACK=""
|
||||
if [ -n "$_ROOT" ] && [ -d "$_ROOT/.claude/skills/gstack" ]; then
|
||||
_RESOLVED_LOCAL=$(cd "$_ROOT/.claude/skills/gstack" && pwd -P)
|
||||
_RESOLVED_PRIMARY=$(cd "$INSTALL_DIR" && pwd -P)
|
||||
if [ "$_RESOLVED_LOCAL" != "$_RESOLVED_PRIMARY" ]; then
|
||||
LOCAL_GSTACK="$_ROOT/.claude/skills/gstack"
|
||||
fi
|
||||
fi
|
||||
echo "LOCAL_GSTACK=$LOCAL_GSTACK"
|
||||
```
|
||||
|
||||
If `LOCAL_GSTACK` is non-empty, update it by copying from the freshly-upgraded primary install (same approach as README vendored install):
|
||||
```bash
|
||||
mv "$LOCAL_GSTACK" "$LOCAL_GSTACK.bak"
|
||||
cp -Rf "$INSTALL_DIR" "$LOCAL_GSTACK"
|
||||
rm -rf "$LOCAL_GSTACK/.git"
|
||||
cd "$LOCAL_GSTACK" && ./setup
|
||||
rm -rf "$LOCAL_GSTACK.bak"
|
||||
```
|
||||
Tell user: "Also updated vendored copy at `$LOCAL_GSTACK` — commit `.claude/skills/gstack/` when you're ready."
|
||||
|
||||
### Step 5: Write marker + clear cache
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.gstack
|
||||
echo "$OLD_VERSION" > ~/.gstack/just-upgraded-from
|
||||
rm -f ~/.gstack/last-update-check
|
||||
rm -f ~/.gstack/update-snoozed
|
||||
```
|
||||
|
||||
### Step 6: Show What's New
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
---
|
||||
name: gstack-upgrade
|
||||
version: 1.0.0
|
||||
version: 1.1.0
|
||||
description: |
|
||||
Upgrade gstack to the latest version. Detects global vs vendored install,
|
||||
runs the upgrade, and shows what's new.
|
||||
allowed-tools:
|
||||
- Bash
|
||||
- Read
|
||||
- Write
|
||||
- AskUserQuestion
|
||||
---
|
||||
|
||||
@@ -18,13 +19,56 @@ Upgrade gstack to the latest version and show what's new.
|
||||
|
||||
This section is referenced by all skill preambles when they detect `UPGRADE_AVAILABLE`.
|
||||
|
||||
### Step 1: Ask the user
|
||||
### Step 1: Ask the user (or auto-upgrade)
|
||||
|
||||
Use AskUserQuestion:
|
||||
- Question: "gstack **v{new}** is available (you're on v{old}). Upgrade now? Takes ~10 seconds."
|
||||
- Options: ["Yes, upgrade now", "Later (ask again tomorrow)"]
|
||||
First, check if auto-upgrade is enabled:
|
||||
```bash
|
||||
_AUTO=""
|
||||
[ "${GSTACK_AUTO_UPGRADE:-}" = "1" ] && _AUTO="true"
|
||||
[ -z "$_AUTO" ] && _AUTO=$(~/.claude/skills/gstack/bin/gstack-config get auto_upgrade 2>/dev/null || true)
|
||||
echo "AUTO_UPGRADE=$_AUTO"
|
||||
```
|
||||
|
||||
**If "Later":** Run `touch ~/.gstack/last-update-check` to reset the 24h timer and continue with the current skill. Do not mention the upgrade again.
|
||||
**If `AUTO_UPGRADE=true` or `AUTO_UPGRADE=1`:** Skip AskUserQuestion. Log "Auto-upgrading gstack v{old} → v{new}..." and proceed directly to Step 2. If `./setup` fails during auto-upgrade, restore from backup (`.bak` directory) and warn the user: "Auto-upgrade failed — restored previous version. Run `/gstack-upgrade` manually to retry."
|
||||
|
||||
**Otherwise**, use AskUserQuestion:
|
||||
- Question: "gstack **v{new}** is available (you're on v{old}). Upgrade now?"
|
||||
- Options: ["Yes, upgrade now", "Always keep me up to date", "Not now", "Never ask again"]
|
||||
|
||||
**If "Yes, upgrade now":** Proceed to Step 2.
|
||||
|
||||
**If "Always keep me up to date":**
|
||||
```bash
|
||||
~/.claude/skills/gstack/bin/gstack-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 (first snooze = 24h, second = 48h, third+ = 1 week), then continue with the current skill. Do not mention the upgrade again.
|
||||
```bash
|
||||
_SNOOZE_FILE=~/.gstack/update-snoozed
|
||||
_REMOTE_VER="{new}"
|
||||
_CUR_LEVEL=0
|
||||
if [ -f "$_SNOOZE_FILE" ]; then
|
||||
_SNOOZED_VER=$(awk '{print $1}' "$_SNOOZE_FILE")
|
||||
if [ "$_SNOOZED_VER" = "$_REMOTE_VER" ]; then
|
||||
_CUR_LEVEL=$(awk '{print $2}' "$_SNOOZE_FILE")
|
||||
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_FILE"
|
||||
```
|
||||
Note: `{new}` is the remote version from the `UPGRADE_AVAILABLE` output — substitute it from the update check result.
|
||||
|
||||
Tell user the snooze duration: "Next reminder in 24h" (or 48h or 1 week, depending on level). Tip: "Set `auto_upgrade: true` in `~/.gstack/config.yaml` for automatic upgrades."
|
||||
|
||||
**If "Never ask again":**
|
||||
```bash
|
||||
~/.claude/skills/gstack/bin/gstack-config set update_check false
|
||||
```
|
||||
Tell user: "Update checks disabled. Run `~/.claude/skills/gstack/bin/gstack-config set update_check true` to re-enable."
|
||||
Continue with the current skill.
|
||||
|
||||
### Step 2: Detect install type
|
||||
|
||||
@@ -77,12 +121,40 @@ cd "$INSTALL_DIR" && ./setup
|
||||
rm -rf "$INSTALL_DIR.bak" "$TMP_DIR"
|
||||
```
|
||||
|
||||
### Step 4.5: Sync local vendored copy
|
||||
|
||||
After upgrading the primary install, check if there's also a local copy in the current project that needs updating:
|
||||
|
||||
```bash
|
||||
_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||
LOCAL_GSTACK=""
|
||||
if [ -n "$_ROOT" ] && [ -d "$_ROOT/.claude/skills/gstack" ]; then
|
||||
_RESOLVED_LOCAL=$(cd "$_ROOT/.claude/skills/gstack" && pwd -P)
|
||||
_RESOLVED_PRIMARY=$(cd "$INSTALL_DIR" && pwd -P)
|
||||
if [ "$_RESOLVED_LOCAL" != "$_RESOLVED_PRIMARY" ]; then
|
||||
LOCAL_GSTACK="$_ROOT/.claude/skills/gstack"
|
||||
fi
|
||||
fi
|
||||
echo "LOCAL_GSTACK=$LOCAL_GSTACK"
|
||||
```
|
||||
|
||||
If `LOCAL_GSTACK` is non-empty, update it by copying from the freshly-upgraded primary install (same approach as README vendored install):
|
||||
```bash
|
||||
mv "$LOCAL_GSTACK" "$LOCAL_GSTACK.bak"
|
||||
cp -Rf "$INSTALL_DIR" "$LOCAL_GSTACK"
|
||||
rm -rf "$LOCAL_GSTACK/.git"
|
||||
cd "$LOCAL_GSTACK" && ./setup
|
||||
rm -rf "$LOCAL_GSTACK.bak"
|
||||
```
|
||||
Tell user: "Also updated vendored copy at `$LOCAL_GSTACK` — commit `.claude/skills/gstack/` when you're ready."
|
||||
|
||||
### Step 5: Write marker + clear cache
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.gstack
|
||||
echo "$OLD_VERSION" > ~/.gstack/just-upgraded-from
|
||||
rm -f ~/.gstack/last-update-check
|
||||
rm -f ~/.gstack/update-snoozed
|
||||
```
|
||||
|
||||
### Step 6: Show What's New
|
||||
|
||||
Reference in New Issue
Block a user