From cfda9cb46f48de8736be8e132d77c0b29adb5aa1 Mon Sep 17 00:00:00 2001 From: Hiten Shah Date: Sun, 22 Mar 2026 20:27:59 -0700 Subject: [PATCH] fix(preamble): make .pending-* glob pattern zsh-compatible (fixes #313) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Problem:** When running gstack skills in zsh, users see this error: (eval):22: no matches found: /Users/.../.gstack/analytics/.pending-* **Root Cause:** The Preamble code in gen-skill-docs.ts (line 167) contains: for _PF in ~/.gstack/analytics/.pending-*; do ... In zsh, glob patterns that don't match any files cause an error: 'no matches found: pattern' In bash, the loop simply iterates zero times. This breaks all gstack skills for zsh users (common on macOS). **Solution:** Check if any .pending-* files exist BEFORE attempting the for loop: [ -n "$(ls ~/.gstack/analytics/.pending-* 2>/dev/null)" ] && for ... This approach: - ✅ Works in both bash and zsh - ✅ Silently skips the loop when no pending files exist (normal case) - ✅ Executes the loop when pending files are present - ✅ Uses ls with error suppression (2>/dev/null) for portability **Testing:** - ✅ No pending files: loop skipped, no error - ✅ Pending files exist: loop runs normally - ✅ Compatible with bash and zsh - ✅ TypeScript syntax check passes **Impact:** Fixes all gstack skills for zsh users (macOS default shell). Fixes #313 --- scripts/gen-skill-docs.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/gen-skill-docs.ts b/scripts/gen-skill-docs.ts index 8bb16bf9..ca707218 100644 --- a/scripts/gen-skill-docs.ts +++ b/scripts/gen-skill-docs.ts @@ -162,7 +162,8 @@ echo "TELEMETRY: \${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics echo '{"skill":"${ctx.skillName}","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true -for _PF in ~/.gstack/analytics/.pending-*; do [ -f "$_PF" ] && ${ctx.paths.binDir}/gstack-telemetry-log --event-type skill_run --skill _pending_finalize --outcome unknown --session-id "$_SESSION_ID" 2>/dev/null || true; break; done +# zsh-compatible: check if .pending-* files exist before looping +[ -n "$(ls ~/.gstack/analytics/.pending-* 2>/dev/null)" ] && for _PF in ~/.gstack/analytics/.pending-*; do [ -f "$_PF" ] && ${ctx.paths.binDir}/gstack-telemetry-log --event-type skill_run --skill _pending_finalize --outcome unknown --session-id "$_SESSION_ID" 2>/dev/null || true; break; done \`\`\``; }