mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-28 19:04:07 +01:00
* fix(land-and-deploy): never merge over red, pending or missing CI (#2995) /land-and-deploy gated only on required checks, so a repo with none (every GitHub Free private repo, any repo without branch protection) skipped the CI wait and could merge over red CI. The verdict now comes from bin/gstack-ci-gate, a tested helper bound to the head SHA: all checks by default, cancel/unknown buckets fail, NO_CHECKS needs explicit per-head approval, and both merge commands (including --auto) run only after a PASS for the same SHA they pin with --match-head-commit. Co-authored-by: harshitgavita-07 <harshit.gavita@gmail.com> * fix(slug): give nested-group projects their own state bucket and verify checkpoint identity (#3003, #2901) gstack-slug kept only the last two remote path segments, so customer-a/product/repo and customer-b/product/repo shared one bucket and /context-restore could present another project's checkpoint. - One canonical-remote rule (bash + TS, golden vectors) used by all six resolvers: lowercased host, no userinfo/port/.git, Azure DevOps and Bitbucket Server normalized. 3+ segment remotes get <last-two>-<16 hex>; two-segment remotes (all of GitHub) are unchanged. - Versioned sticky cache (v2:) keeps cache hits git-free. - context-save stamps the credential-free remote and root; context-restore only treats this project's checkpoints as latest, reports foreign/unverified ones first, and treats a different root with the same remote (Conductor handoff) as information. - gstack-slug --adopt-legacy copies only files the user confirms. - question-preference-hook reads the same versioned cache, so never-ask preferences fire; unknown identity asks instead of auto-deciding. * fix(gbrain): brain context loads, managed sync works, memory sync stops duplicating (#2883, #2985, #2922) - brain-context-load called 'gbrain list_pages' (an MCP tool name), so every skill's brain context was 0 bytes. It now uses 'gbrain list' with gbrain's real filter flags, and prints one line when queries fail. - The code-stage sync always passes --no-pull (managed gbrain >= 0.51 refuses without it); a gbrain that rejects the flag fails with an upgrade message and is never retried without it. stderr is streamed with a bounded tail and quoted in failure summaries. - /sync-gbrain gains --sources (and GSTACK_MEMORY_INGEST_SOURCES); by default it skips types already synced through a federated curated source, so curated pages stop being re-duplicated. Co-authored-by: Vitor Cepeda Lopes <vitor@vitorcepedalopes.com> Co-authored-by: harshitgavita-07 <harshit.gavita@gmail.com> * fix(codex,cso): clean Codex reviews stop failing; semgrep and trivy SARIF results import (#2769, #3011) - Codex review gate is PASS / FAIL / UNVERIFIED. Untagged output (what a clean 'codex review --base' prints) is UNVERIFIED, not FAIL, and never a false PASS; P2/P3-only output passes. - import-sarif resolves semgrep's undeclared %SRCROOT% and trivy's ROOTPATH (including git-URL targets) through explicit, captured mappings; declared bases must sit inside the source root or the run's checkout, URIs are percent-decoded, and rejected results are counted with rule, base and path instead of silently dropped. * fix: version strings are not IPs, failed update checks are not 'up to date', private security reporting (#2856, #2786, #2984) - The pre-push redact hook exempts a root VERSION file that is only a version string and the version token in CHANGELOG release headings; the engine allowlist is untouched. - gstack-update-check caches an unreadable remote as CHECK_FAILED with a short TTL instead of UP_TO_DATE; /gstack-upgrade never reports 'latest' after a failed check. - SECURITY.md points reporters at GitHub private vulnerability reporting. - pr-title-sync (pull_request_target, write token) pins actions/checkout to a reviewed SHA. * fix(autoplan): publication guard accepts real Claude Code journals (#3007, #3009, #2968, #2977, #2986, #3006) The guard required a session journal to start with a user message, but Claude Code starts it with SessionStart hook attachments (and a forked compacted session starts with a compact_boundary), so every phase was denied for anyone with a SessionStart hook. Windows path spellings (C:/, /c/, drive case) were rejected too. - Reader accepts the captured startup, compact, clear and fork shapes (claude 2.1.284 fixture), computes root uniqueness over every candidate, and returns typed reason codes instead of one string. - Hard denials (competing root, foreign cwd, sidechain, agent, cycle, malformed, identity) say what happened and how to run the reviews by hand; unflushed journals still retry. - A well-formed, stable journal whose root shape is unrecognized now warns ('phase publication was NOT verified') and continues, without overriding Claude Code's own permission check; no bypass switch. - Windows paths fold before validation, so '..' is still rejected. - Periodic drift canary runs the reader on fresh journals from the pinned claude. Co-authored-by: Charles M Berg <77517285+CharlesBerg85@users.noreply.github.com> Co-authored-by: laurenbdaniels-coder <264343335+laurenbdaniels-coder@users.noreply.github.com> Co-authored-by: Jordan Mayer <176445995+maydaycyber@users.noreply.github.com> Co-authored-by: elmesery-dev <elmesery.dev@gmail.com> * v1.91.13.0: severe bug fix wave release notes, stale gbrain verbs in docs * test: seed the versioned slug cache in the memory-injection deny case (#2901) The preference hook now resolves the project bucket from gstack-slug's v2 slug-cache entry instead of basename(cwd); this fixture still wrote preferences under the basename bucket without the entry the skill preamble always writes first. * fix: full-suite follow-ups for the fix wave - gstack-slug's --help heredoc is over 512B, so it gets the BASH_COMPAT=50 pipe-deadlock guard like the other bins. - Refresh the codex/factory ship goldens for the plan-gates slug change. - The periodic lane gains the autoplan journal drift canary (107 paid files); raise the eval-slices cap to 25 so every slice still starts at once until its recorded duration lets the planner pack it. * fix(plan-eng-review): clearer Step 0 sequencing, write routes and section outputs The workflow judge scored plan-eng-review's instructions at actionability 3.67 (bar 4) on text unchanged from main. Resolve the ambiguities it named together, without changing any gate or output: Step 0 names the Read's order and keeps one STOP; the pending-call, read-only, forbidden-write and failed-save rules become one Write routes block; header/label limits and grid checks are concrete; Performance gets a checklist; each section has a stated output shape; Lake Score is defined. Same total length (parity cap). --------- Co-authored-by: harshitgavita-07 <harshit.gavita@gmail.com> Co-authored-by: Vitor Cepeda Lopes <vitor@vitorcepedalopes.com> Co-authored-by: Charles M Berg <77517285+CharlesBerg85@users.noreply.github.com> Co-authored-by: laurenbdaniels-coder <264343335+laurenbdaniels-coder@users.noreply.github.com> Co-authored-by: Jordan Mayer <176445995+maydaycyber@users.noreply.github.com> Co-authored-by: elmesery-dev <elmesery.dev@gmail.com>
396 lines
18 KiB
Markdown
396 lines
18 KiB
Markdown
---
|
|
name: gstack-upgrade
|
|
version: 1.1.0
|
|
description: Upgrade gstack to the latest version.
|
|
triggers:
|
|
- upgrade gstack
|
|
- update gstack version
|
|
- get latest gstack
|
|
allowed-tools:
|
|
- Bash
|
|
- Read
|
|
- Write
|
|
- AskUserQuestion
|
|
---
|
|
<!-- AUTO-GENERATED from SKILL.md.tmpl — do not edit directly -->
|
|
<!-- Regenerate: bun run gen:skill-docs -->
|
|
|
|
|
|
## When to invoke this skill
|
|
|
|
Detects global vs vendored install,
|
|
runs the upgrade, and shows what's new. Use when asked to "upgrade gstack",
|
|
"update gstack", or "get latest version".
|
|
|
|
Voice triggers (speech-to-text aliases): "upgrade the tools", "update the tools", "gee stack upgrade", "g stack upgrade".
|
|
|
|
# /gstack-upgrade
|
|
|
|
Upgrade gstack to the latest version and show what's new.
|
|
|
|
## Inline upgrade flow
|
|
|
|
This section is referenced by all skill preambles when they detect `UPGRADE_AVAILABLE`.
|
|
|
|
### Step 1: Ask the user (or auto-upgrade)
|
|
|
|
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 `AUTO_UPGRADE=true` or `AUTO_UPGRADE=1`:** Skip AskUserQuestion. Log "Auto-upgrading gstack v{old} → v{new}..." and proceed directly to Step 2. On setup failure, follow Step 4's install-specific recovery: vendored installs restore their backup; git installs stop with the pre-upgrade commit recorded, without a destructive reset. Never claim restoration unless it actually succeeded.
|
|
|
|
**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
|
|
eval "$(~/.claude/skills/gstack/bin/gstack-paths)"; : "${GSTACK_STATE_ROOT:?gstack-paths failed; reinstall with ./setup or /gstack-upgrade}"
|
|
_SNOOZE_FILE="$GSTACK_STATE_ROOT/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
|
|
|
|
```bash
|
|
if [ -d "$HOME/.claude/skills/gstack/.git" ]; then
|
|
INSTALL_TYPE="global-git"
|
|
INSTALL_DIR="$HOME/.claude/skills/gstack"
|
|
elif [ -d "$HOME/.gstack/repos/gstack/.git" ]; then
|
|
INSTALL_TYPE="global-git"
|
|
INSTALL_DIR="$HOME/.gstack/repos/gstack"
|
|
elif [ -d ".claude/skills/gstack/.git" ]; then
|
|
INSTALL_TYPE="local-git"
|
|
INSTALL_DIR=".claude/skills/gstack"
|
|
elif [ -d ".agents/skills/gstack/.git" ]; then
|
|
INSTALL_TYPE="local-git"
|
|
INSTALL_DIR=".agents/skills/gstack"
|
|
elif [ -d ".claude/skills/gstack" ]; then
|
|
INSTALL_TYPE="vendored"
|
|
INSTALL_DIR=".claude/skills/gstack"
|
|
elif [ -d "$HOME/.claude/skills/gstack" ]; then
|
|
INSTALL_TYPE="vendored-global"
|
|
INSTALL_DIR="$HOME/.claude/skills/gstack"
|
|
else
|
|
echo "ERROR: gstack not found"
|
|
exit 1
|
|
fi
|
|
echo "Install type: $INSTALL_TYPE at $INSTALL_DIR"
|
|
```
|
|
|
|
The install type and directory path printed above will be used in all subsequent steps.
|
|
Resolve `INSTALL_DIR` to an absolute path. Carry `INSTALL_TYPE`, `INSTALL_DIR`, `OLD_VERSION`, and later `NEW_VERSION` forward explicitly: if tool calls use fresh shells, reassign them from captured output before running a block. Do not rely on a prior call's working directory or shell variables.
|
|
|
|
### Step 3: Save old version
|
|
|
|
Use the install directory from Step 2's output below:
|
|
|
|
```bash
|
|
OLD_VERSION=$(cat "$INSTALL_DIR/VERSION" 2>/dev/null || echo "unknown")
|
|
echo "OLD_VERSION=$OLD_VERSION"
|
|
```
|
|
|
|
### Step 4: Upgrade
|
|
|
|
Use the install type and directory detected in Step 2:
|
|
|
|
**For git installs** (global-git, local-git):
|
|
|
|
Fast-forward first (#2517) — the same policy the session-update auto-upgrade
|
|
uses. `--autostash` carries local edits over the pull; render-footprint dirt
|
|
is discarded first because it is regenerable and poisons stashes (#2569):
|
|
```bash
|
|
cd "$INSTALL_DIR"
|
|
# Discard render-footprint dirt (#2569): pre-v1.67 gbrain-enabled installs
|
|
# ran gen:skill-docs:user IN PLACE, leaving generated SKILL.md / sections
|
|
# files permanently modified. They are regenerable (setup re-renders to
|
|
# ~/.gstack/render), so discarding is lossless.
|
|
git checkout -- 'SKILL.md' '*/SKILL.md' '*/sections/*.md' 2>/dev/null || true
|
|
git fetch origin
|
|
PRE_UPGRADE_COMMIT=$(git rev-parse HEAD)
|
|
echo "PRE_UPGRADE_COMMIT=$PRE_UPGRADE_COMMIT"
|
|
if git pull --ff-only --autostash origin main; then
|
|
if ./setup; then echo "FF_OK"; else echo "SETUP_FAILED: git update succeeded; stop and inspect setup output (previous commit: $PRE_UPGRADE_COMMIT)" >&2; exit 1; fi
|
|
else
|
|
echo "FF_REFUSED"
|
|
fi
|
|
```
|
|
|
|
If the output ends with `FF_OK`, the upgrade is done — skip the fallback
|
|
below entirely.
|
|
On `SETUP_FAILED`, STOP; keep user changes and report the recovery commit. There is no `.bak` on the git path. Do not enter the divergence fallback merely because setup failed. Enter it only on `FF_REFUSED`, after inspecting the pull error; network/auth failures stop for repair, not reset.
|
|
|
|
**Fallback (ff-only refused — local commits or divergence).** `git reset
|
|
--hard` DESTROYS things: a clean tree with unpushed local commits still loses
|
|
those commits. Gate it (#2517):
|
|
|
|
1. Run `git status --porcelain` and `git rev-list origin/main..HEAD --oneline`
|
|
in `$INSTALL_DIR`.
|
|
2. If BOTH are empty, the reset is provably safe — run the fallback block
|
|
below without asking.
|
|
3. Otherwise ask via AskUserQuestion (one-way door — destructive), listing
|
|
exactly what will be discarded: each dirty file and each unpushed commit
|
|
by hash + subject. Options: **A)** Discard them and upgrade (reset) —
|
|
requires the explicit letter; **B)** Abort the upgrade so the user can
|
|
rescue their work first (recommended when local commits exist). Never
|
|
proceed on a vague reply.
|
|
|
|
```bash
|
|
cd "$INSTALL_DIR"
|
|
STASH_OUTPUT=$(git stash 2>&1)
|
|
git reset --hard origin/main
|
|
./setup
|
|
```
|
|
If `$STASH_OUTPUT` contains "Saved working directory", warn the user: "Note: local changes were stashed (any modified generated SKILL.md/sections files were discarded first — they regenerate on setup). Run `git stash pop` in the skill directory to restore your own changes."
|
|
|
|
**For vendored installs** (vendored, vendored-global):
|
|
```bash
|
|
PARENT=$(dirname "$INSTALL_DIR")
|
|
# A stale .bak from a previously crashed upgrade would make the mv below NEST
|
|
# the live install inside it and the failure-restore arm would "restore" the
|
|
# stale backup. It may also be the only good copy from that crashed run —
|
|
# abort and let the human inspect, never delete it silently.
|
|
[ -e "$INSTALL_DIR.bak" ] && { echo "ERROR: stale backup exists at $INSTALL_DIR.bak (from a previous failed upgrade?) — inspect it, salvage/remove it, then re-run." >&2; exit 1; }
|
|
TMP_DIR=$(mktemp -d) || { echo "ERROR: mktemp failed — aborting upgrade (install untouched)." >&2; exit 1; }
|
|
git clone --depth 1 https://github.com/garrytan/gstack.git "$TMP_DIR/gstack" || { echo "ERROR: clone failed — aborting upgrade (install untouched)." >&2; rm -rf "$TMP_DIR"; exit 1; }
|
|
mv "$INSTALL_DIR" "$INSTALL_DIR.bak" || { rm -rf "$TMP_DIR"; exit 1; }
|
|
if mv "$TMP_DIR/gstack" "$INSTALL_DIR"; then
|
|
if (cd "$INSTALL_DIR" && ./setup); then
|
|
rm -rf "$INSTALL_DIR.bak" "$TMP_DIR"
|
|
else
|
|
rm -rf "$INSTALL_DIR"
|
|
mv "$INSTALL_DIR.bak" "$INSTALL_DIR" || { echo "ERROR: restore failed; backup retained." >&2; exit 1; }
|
|
rm -rf "$TMP_DIR"
|
|
echo "ERROR: setup failed; previous install restored." >&2
|
|
exit 1
|
|
fi
|
|
else
|
|
mv "$INSTALL_DIR.bak" "$INSTALL_DIR"
|
|
echo "ERROR: swap failed — previous install restored; upgrade aborted." >&2
|
|
rm -rf "$TMP_DIR"
|
|
exit 1
|
|
fi
|
|
```
|
|
|
|
### Step 4.5: Handle local vendored copy
|
|
|
|
Use the install directory from Step 2. Check if there's also a local vendored copy, and whether team mode is active:
|
|
|
|
```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
|
|
_TEAM_MODE=$(~/.claude/skills/gstack/bin/gstack-config get team_mode 2>/dev/null || echo "false")
|
|
echo "LOCAL_GSTACK=$LOCAL_GSTACK"
|
|
echo "TEAM_MODE=$_TEAM_MODE"
|
|
```
|
|
|
|
**If `LOCAL_GSTACK` is non-empty AND `TEAM_MODE` is `true`:** Remove the vendored copy. Team mode uses the global install as the single source of truth.
|
|
|
|
```bash
|
|
cd "$_ROOT"
|
|
git rm -r --cached .claude/skills/gstack/ 2>/dev/null || true
|
|
if ! grep -qF '.claude/skills/gstack/' .gitignore 2>/dev/null; then
|
|
echo '.claude/skills/gstack/' >> .gitignore
|
|
fi
|
|
rm -rf "$LOCAL_GSTACK"
|
|
```
|
|
Tell user: "Removed vendored copy at `$LOCAL_GSTACK` (team mode active — global install is the source of truth). Commit the `.gitignore` change when ready."
|
|
|
|
**If `LOCAL_GSTACK` is non-empty AND `TEAM_MODE` is NOT `true`:** Update it by copying from the freshly-upgraded primary install (same approach as README vendored install):
|
|
```bash
|
|
[ -e "$LOCAL_GSTACK.bak" ] && { echo "ERROR: stale vendored backup; inspect it before retrying." >&2; exit 1; }
|
|
mv "$LOCAL_GSTACK" "$LOCAL_GSTACK.bak" || exit 1
|
|
if cp -Rf "$INSTALL_DIR" "$LOCAL_GSTACK" && rm -rf "$LOCAL_GSTACK/.git" && (cd "$LOCAL_GSTACK" && ./setup); then
|
|
rm -rf "$LOCAL_GSTACK.bak"
|
|
echo "LOCAL_SYNC_OK"
|
|
else
|
|
rm -rf "$LOCAL_GSTACK"
|
|
mv "$LOCAL_GSTACK.bak" "$LOCAL_GSTACK" || { echo "ERROR: restore failed; backup retained." >&2; exit 1; }
|
|
echo "ERROR: sync failed; previous vendored copy restored." >&2
|
|
exit 1
|
|
fi
|
|
```
|
|
Only on `LOCAL_SYNC_OK`, tell user: "Also updated vendored copy at `$LOCAL_GSTACK` — commit `.claude/skills/gstack/` when you're ready." Otherwise stop and report the recovery outcome; do not continue migrations or announce success.
|
|
|
|
### Step 4.75: Run version migrations
|
|
|
|
After `./setup` completes, run any migration scripts for versions between the old
|
|
and new version. Migrations handle state fixes that `./setup` alone can't cover
|
|
(stale config, orphaned files, directory structure changes).
|
|
|
|
```bash
|
|
MIGRATIONS_DIR="$INSTALL_DIR/gstack-upgrade/migrations"
|
|
if [ -d "$MIGRATIONS_DIR" ]; then
|
|
for migration in $(find "$MIGRATIONS_DIR" -maxdepth 1 -name 'v*.sh' -type f 2>/dev/null | sort -V); do
|
|
# Extract version from filename: v0.15.2.0.sh → 0.15.2.0
|
|
m_ver="$(basename "$migration" .sh | sed 's/^v//')"
|
|
# Run if this migration version is newer than old version
|
|
# (simple string compare works for dotted versions with same segment count)
|
|
if [ "$OLD_VERSION" != "unknown" ] && [ "$(printf '%s\n%s' "$OLD_VERSION" "$m_ver" | sort -V | head -1)" = "$OLD_VERSION" ] && [ "$OLD_VERSION" != "$m_ver" ]; then
|
|
echo "Running migration $m_ver..."
|
|
# GSTACK_INSTALL_DIR: migrations that clean the INSTALL (not just
|
|
# ~/.gstack state) default to ~/.claude/skills/gstack when unset —
|
|
# a repo-local install would silently no-op without this.
|
|
GSTACK_INSTALL_DIR="$INSTALL_DIR" bash "$migration" || echo " Warning: migration $m_ver had errors (non-fatal)"
|
|
fi
|
|
done
|
|
fi
|
|
```
|
|
|
|
Migrations are idempotent bash scripts in `gstack-upgrade/migrations/`. Each is named
|
|
`v{VERSION}.sh` and runs only when upgrading from an older version. See CONTRIBUTING.md
|
|
for how to add new migrations.
|
|
|
|
### Step 4.8: Stop any stale daemon (unconditional)
|
|
|
|
A browse daemon started before the upgrade keeps serving the OLD binary's code
|
|
until it is stopped — it survives `git reset --hard` and `./setup` because the
|
|
running process holds the old executable (#2551). Always run this step, using
|
|
the install directory detected in Step 2.
|
|
|
|
```bash
|
|
INSTALL_DIR_PLACEHOLDER="<install dir from Step 2>"
|
|
NEW_HASH=$(cat "$INSTALL_DIR_PLACEHOLDER/browse/dist/.version" 2>/dev/null || echo "")
|
|
_STATE_FILE="${BROWSE_STATE_FILE:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)/.gstack/browse.json}"
|
|
if [ -z "$NEW_HASH" ] || [ ! -f "$_STATE_FILE" ]; then
|
|
echo "DAEMON_CHECK=none (no state file or no fresh build hash)"
|
|
else
|
|
DAEMON_PID=$(sed -n 's/.*"pid"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' "$_STATE_FILE" | head -1)
|
|
DAEMON_PORT=$(sed -n 's/.*"port"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' "$_STATE_FILE" | head -1)
|
|
OLD_HASH=$(sed -n 's/.*"binaryVersion"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$_STATE_FILE" | head -1)
|
|
if [ -z "$DAEMON_PID" ] || ! kill -0 "$DAEMON_PID" 2>/dev/null; then
|
|
echo "DAEMON_CHECK=dead (no live daemon to stop)"
|
|
elif [ "$OLD_HASH" = "$NEW_HASH" ]; then
|
|
echo "DAEMON_CHECK=current (daemon already runs the new binary)"
|
|
elif curl -fsS --max-time 2 "http://127.0.0.1:$DAEMON_PORT/health" 2>/dev/null | grep -q '"status":"healthy"'; then
|
|
echo "DAEMON_CHECK=stale-responsive pid=$DAEMON_PID hash=${OLD_HASH:-unknown} -> $NEW_HASH"
|
|
"$INSTALL_DIR_PLACEHOLDER/browse/dist/browse" stop && echo "DAEMON_STOPPED=yes"
|
|
else
|
|
echo "DAEMON_CHECK=stale-busy pid=$DAEMON_PID hash=${OLD_HASH:-unknown} -> $NEW_HASH"
|
|
fi
|
|
fi
|
|
```
|
|
|
|
Replace `<install dir from Step 2>` with the actual install directory before
|
|
running. Interpret the `DAEMON_CHECK` result:
|
|
|
|
1. **`stale-responsive` + `DAEMON_STOPPED=yes`:** Tell the user "Stopped the
|
|
old browse daemon (binary {OLD_HASH} → {NEW_HASH}). The next browse command
|
|
starts a fresh daemon on the new binary."
|
|
2. **`stale-busy`:** The daemon runs the old binary but is mid-work — DEFER to
|
|
it, never kill a busy daemon during upgrade. Tell the user: "A browse daemon
|
|
is still running the pre-upgrade binary ({OLD_HASH} → {NEW_HASH}) but is
|
|
busy right now. When it finishes, stop it with `browse stop` — or force it
|
|
immediately with `browse --force-restart stop` (loses that session's
|
|
tabs/cookies/logins)."
|
|
3. **`none` / `dead` / `current`:** Nothing to do — say nothing.
|
|
|
|
### Step 5: Write marker + clear cache
|
|
|
|
```bash
|
|
eval "$(~/.claude/skills/gstack/bin/gstack-paths)"; : "${GSTACK_STATE_ROOT:?gstack-paths failed; reinstall with ./setup or /gstack-upgrade}"
|
|
mkdir -p "$GSTACK_STATE_ROOT"
|
|
echo "$OLD_VERSION" > "$GSTACK_STATE_ROOT"/just-upgraded-from
|
|
rm -f "$GSTACK_STATE_ROOT"/last-update-check
|
|
rm -f "$GSTACK_STATE_ROOT"/update-snoozed
|
|
```
|
|
|
|
### Step 6: Show What's New
|
|
|
|
Read `$INSTALL_DIR/CHANGELOG.md`. Find all version entries between the old version and the new version. Summarize as 5-7 bullets grouped by theme. Don't overwhelm — focus on user-facing changes. Skip internal refactors unless they're significant.
|
|
|
|
Format:
|
|
```
|
|
gstack v{new} — upgraded from v{old}!
|
|
|
|
What's new:
|
|
- [bullet 1]
|
|
- [bullet 2]
|
|
- ...
|
|
|
|
Happy shipping!
|
|
```
|
|
|
|
### Step 7: Continue
|
|
|
|
After showing What's New, continue with whatever skill the user originally invoked. The upgrade is done — no further action needed.
|
|
|
|
---
|
|
|
|
## Standalone usage
|
|
|
|
When invoked directly as `/gstack-upgrade` (not from a preamble):
|
|
|
|
1. Force a fresh update check (bypass cache):
|
|
```bash
|
|
~/.claude/skills/gstack/bin/gstack-update-check --force 2>/dev/null || \
|
|
.claude/skills/gstack/bin/gstack-update-check --force 2>/dev/null || true
|
|
```
|
|
Use the output to determine if an upgrade is available.
|
|
|
|
2. If `UPGRADE_AVAILABLE <old> <new>`: follow Steps 2-6 above.
|
|
|
|
If `CHECK_FAILED ...`: the remote version could not be read, so the update
|
|
status is unknown. Show the line (it names the URL that failed) and tell the
|
|
user the check failed; never report "already on the latest version". Stop.
|
|
|
|
3. If no output (primary is up to date): check for a stale local vendored copy.
|
|
|
|
Run the Step 2 bash block above to detect the primary install type and directory (`INSTALL_TYPE` and `INSTALL_DIR`). Then run the Step 4.5 detection bash block above to check for a local vendored copy (`LOCAL_GSTACK`) and team mode status (`TEAM_MODE`).
|
|
|
|
**If `LOCAL_GSTACK` is empty** (no local vendored copy): tell the user "You're already on the latest version (v{version})."
|
|
|
|
**If `LOCAL_GSTACK` is non-empty AND `TEAM_MODE` is `true`:** Remove the vendored copy using the Step 4.5 team-mode removal bash block above. Tell user: "Global v{version} is up to date. Removed stale vendored copy (team mode active). Commit the `.gitignore` change when ready."
|
|
|
|
**If `LOCAL_GSTACK` is non-empty AND `TEAM_MODE` is NOT `true`**, compare versions:
|
|
```bash
|
|
PRIMARY_VER=$(cat "$INSTALL_DIR/VERSION" 2>/dev/null || echo "unknown")
|
|
LOCAL_VER=$(cat "$LOCAL_GSTACK/VERSION" 2>/dev/null || echo "unknown")
|
|
echo "PRIMARY=$PRIMARY_VER LOCAL=$LOCAL_VER"
|
|
```
|
|
|
|
**If versions differ:** follow the Step 4.5 sync bash block above to update the local copy from the primary. Tell user: "Global v{PRIMARY_VER} is up to date. Updated local vendored copy from v{LOCAL_VER} → v{PRIMARY_VER}. Commit `.claude/skills/gstack/` when you're ready."
|
|
|
|
**If versions match:** tell the user "You're on the latest version (v{PRIMARY_VER}). Global and local vendored copy are both up to date."
|