From 84cb7a41011ceff6ad11e4808eb542f33f73cb1f Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sun, 19 Apr 2026 06:22:29 +0800 Subject: [PATCH] fix(context-skills): respect GSTACK_HOME in storage path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The skill templates hardcoded CHECKPOINT_DIR="\$HOME/.gstack/projects/\$SLUG/checkpoints" which ignored any GSTACK_HOME override. Tests setting GSTACK_HOME via env were writing to the test's expected path but the skill was writing to the real user's ~/.gstack. The files existed — just not where the assertion looked. 0/8 pass despite Skill tool routing working correctly in the 3rd paid run. Fix: \${GSTACK_HOME:-\$HOME/.gstack} in all three call sites (context-save save flow, context-save list flow, context-restore restore flow). Default behavior unchanged for real users (no GSTACK_HOME set). Tests can now redirect storage to a tmp dir by setting GSTACK_HOME via env: (added to runSkillTest in 5f316e0e). Also follows the existing convention from the preamble, which already uses \${GSTACK_HOME:-\$HOME/.gstack} for the learnings file lookup. Inconsistency between preamble and skill body was the real bug — two different storage-root resolutions in the same skill. All SKILL.md files regenerated. Golden fixtures updated. --- context-restore/SKILL.md | 2 +- context-restore/SKILL.md.tmpl | 2 +- context-save/SKILL.md | 4 ++-- context-save/SKILL.md.tmpl | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/context-restore/SKILL.md b/context-restore/SKILL.md index eede99b7..f059ca32 100644 --- a/context-restore/SKILL.md +++ b/context-restore/SKILL.md @@ -755,7 +755,7 @@ Parse the user's input: ```bash eval "$(~/.claude/skills/gstack/bin/gstack-slug 2>/dev/null)" && mkdir -p ~/.gstack/projects/$SLUG -CHECKPOINT_DIR="$HOME/.gstack/projects/$SLUG/checkpoints" +CHECKPOINT_DIR="${GSTACK_HOME:-$HOME/.gstack}/projects/$SLUG/checkpoints" if [ ! -d "$CHECKPOINT_DIR" ]; then echo "NO_CHECKPOINTS" else diff --git a/context-restore/SKILL.md.tmpl b/context-restore/SKILL.md.tmpl index d9303289..1fe9f938 100644 --- a/context-restore/SKILL.md.tmpl +++ b/context-restore/SKILL.md.tmpl @@ -62,7 +62,7 @@ Parse the user's input: ```bash {{SLUG_SETUP}} -CHECKPOINT_DIR="$HOME/.gstack/projects/$SLUG/checkpoints" +CHECKPOINT_DIR="${GSTACK_HOME:-$HOME/.gstack}/projects/$SLUG/checkpoints" if [ ! -d "$CHECKPOINT_DIR" ]; then echo "NO_CHECKPOINTS" else diff --git a/context-save/SKILL.md b/context-save/SKILL.md index a3a60581..e190cb72 100644 --- a/context-save/SKILL.md +++ b/context-save/SKILL.md @@ -811,7 +811,7 @@ allowlist: only `a-z 0-9 - .` survive. ```bash eval "$(~/.claude/skills/gstack/bin/gstack-slug 2>/dev/null)" && mkdir -p ~/.gstack/projects/$SLUG -CHECKPOINT_DIR="$HOME/.gstack/projects/$SLUG/checkpoints" +CHECKPOINT_DIR="${GSTACK_HOME:-$HOME/.gstack}/projects/$SLUG/checkpoints" mkdir -p "$CHECKPOINT_DIR" TIMESTAMP=$(date +%Y%m%d-%H%M%S) # Bash-side title sanitize. Pass the raw title as $1 when running this block. @@ -897,7 +897,7 @@ Restore later with /context-restore. ```bash eval "$(~/.claude/skills/gstack/bin/gstack-slug 2>/dev/null)" && mkdir -p ~/.gstack/projects/$SLUG -CHECKPOINT_DIR="$HOME/.gstack/projects/$SLUG/checkpoints" +CHECKPOINT_DIR="${GSTACK_HOME:-$HOME/.gstack}/projects/$SLUG/checkpoints" if [ -d "$CHECKPOINT_DIR" ]; then echo "CHECKPOINT_DIR=$CHECKPOINT_DIR" # Use find + sort instead of ls -1t: filename YYYYMMDD-HHMMSS prefix is the diff --git a/context-save/SKILL.md.tmpl b/context-save/SKILL.md.tmpl index 81dbf4f8..8343873f 100644 --- a/context-save/SKILL.md.tmpl +++ b/context-save/SKILL.md.tmpl @@ -118,7 +118,7 @@ allowlist: only `a-z 0-9 - .` survive. ```bash {{SLUG_SETUP}} -CHECKPOINT_DIR="$HOME/.gstack/projects/$SLUG/checkpoints" +CHECKPOINT_DIR="${GSTACK_HOME:-$HOME/.gstack}/projects/$SLUG/checkpoints" mkdir -p "$CHECKPOINT_DIR" TIMESTAMP=$(date +%Y%m%d-%H%M%S) # Bash-side title sanitize. Pass the raw title as $1 when running this block. @@ -204,7 +204,7 @@ Restore later with /context-restore. ```bash {{SLUG_SETUP}} -CHECKPOINT_DIR="$HOME/.gstack/projects/$SLUG/checkpoints" +CHECKPOINT_DIR="${GSTACK_HOME:-$HOME/.gstack}/projects/$SLUG/checkpoints" if [ -d "$CHECKPOINT_DIR" ]; then echo "CHECKPOINT_DIR=$CHECKPOINT_DIR" # Use find + sort instead of ls -1t: filename YYYYMMDD-HHMMSS prefix is the