From f4a298551abb82e5153b0f08e9726c29c0092178 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sat, 14 Mar 2026 02:02:17 -0500 Subject: [PATCH] fix: replace find-browse with direct path in SKILL.md setup blocks Agents were skipping the find-browse binary and guessing bin/browse (wrong path). Now the setup block explicitly checks browse/dist/browse with workspace-local priority, global fallback. Also adds || true to update check to prevent misleading exit code 1. Adds {{UPDATE_CHECK}} and {{BROWSE_SETUP}} template placeholders to gen-skill-docs.ts so all skills share a single source of truth. --- SKILL.md | 11 ++++++----- SKILL.md.tmpl | 27 ++------------------------- browse/SKILL.md | 21 ++++++++++++++++++++- browse/SKILL.md.tmpl | 11 +++-------- scripts/gen-skill-docs.ts | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 67 insertions(+), 39 deletions(-) diff --git a/SKILL.md b/SKILL.md index e83874f2..2ecb0be5 100644 --- a/SKILL.md +++ b/SKILL.md @@ -20,7 +20,7 @@ allowed-tools: ```bash _UPD=$(~/.claude/skills/gstack/bin/gstack-update-check 2>/dev/null || .claude/skills/gstack/bin/gstack-update-check 2>/dev/null || true) -[ -n "$_UPD" ] && echo "$_UPD" +[ -n "$_UPD" ] && echo "$_UPD" || true ``` If output shows `UPGRADE_AVAILABLE `: read `~/.claude/skills/gstack/gstack-upgrade/SKILL.md` and follow the "Inline upgrade flow" (AskUserQuestion → upgrade if yes, `touch ~/.gstack/last-update-check` if no). If `JUST_UPGRADED `: tell user "Running gstack v{to} (just updated!)" and continue. @@ -33,8 +33,11 @@ Auto-shuts down after 30 min idle. State persists between calls (cookies, tabs, ## SETUP (run this check BEFORE any browse command) ```bash -B=$(browse/bin/find-browse 2>/dev/null || ~/.claude/skills/gstack/browse/bin/find-browse 2>/dev/null) -if [ -n "$B" ]; then +_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) +B="" +[ -n "$_ROOT" ] && [ -x "$_ROOT/.claude/skills/gstack/browse/dist/browse" ] && B="$_ROOT/.claude/skills/gstack/browse/dist/browse" +[ -z "$B" ] && B=~/.claude/skills/gstack/browse/dist/browse +if [ -x "$B" ]; then echo "READY: $B" else echo "NEEDS_SETUP" @@ -58,8 +61,6 @@ If `NEEDS_SETUP`: ### Test a user flow (login, signup, checkout, etc.) ```bash -B=~/.claude/skills/gstack/browse/dist/browse - # 1. Go to the page $B goto https://app.example.com/login diff --git a/SKILL.md.tmpl b/SKILL.md.tmpl index ed6d7fff..5ab56a87 100644 --- a/SKILL.md.tmpl +++ b/SKILL.md.tmpl @@ -14,35 +14,14 @@ allowed-tools: --- -## Update Check (run first) - -```bash -_UPD=$(~/.claude/skills/gstack/bin/gstack-update-check 2>/dev/null || .claude/skills/gstack/bin/gstack-update-check 2>/dev/null || true) -[ -n "$_UPD" ] && echo "$_UPD" -``` - -If output shows `UPGRADE_AVAILABLE `: read `~/.claude/skills/gstack/gstack-upgrade/SKILL.md` and follow the "Inline upgrade flow" (AskUserQuestion → upgrade if yes, `touch ~/.gstack/last-update-check` if no). If `JUST_UPGRADED `: tell user "Running gstack v{to} (just updated!)" and continue. +{{UPDATE_CHECK}} # gstack browse: QA Testing & Dogfooding Persistent headless Chromium. First call auto-starts (~3s), then ~100-200ms per command. Auto-shuts down after 30 min idle. State persists between calls (cookies, tabs, sessions). -## SETUP (run this check BEFORE any browse command) - -```bash -B=$(browse/bin/find-browse 2>/dev/null || ~/.claude/skills/gstack/browse/bin/find-browse 2>/dev/null) -if [ -n "$B" ]; then - echo "READY: $B" -else - echo "NEEDS_SETUP" -fi -``` - -If `NEEDS_SETUP`: -1. Tell the user: "gstack browse needs a one-time build (~10 seconds). OK to proceed?" Then STOP and wait. -2. Run: `cd && ./setup` -3. If `bun` is not installed: `curl -fsSL https://bun.sh/install | bash` +{{BROWSE_SETUP}} ## IMPORTANT @@ -56,8 +35,6 @@ If `NEEDS_SETUP`: ### Test a user flow (login, signup, checkout, etc.) ```bash -B=~/.claude/skills/gstack/browse/dist/browse - # 1. Go to the page $B goto https://app.example.com/login diff --git a/browse/SKILL.md b/browse/SKILL.md index 37cbd741..2694ac44 100644 --- a/browse/SKILL.md +++ b/browse/SKILL.md @@ -20,7 +20,7 @@ allowed-tools: ```bash _UPD=$(~/.claude/skills/gstack/bin/gstack-update-check 2>/dev/null || .claude/skills/gstack/bin/gstack-update-check 2>/dev/null || true) -[ -n "$_UPD" ] && echo "$_UPD" +[ -n "$_UPD" ] && echo "$_UPD" || true ``` If output shows `UPGRADE_AVAILABLE `: read `~/.claude/skills/gstack/gstack-upgrade/SKILL.md` and follow the "Inline upgrade flow" (AskUserQuestion → upgrade if yes, `touch ~/.gstack/last-update-check` if no). If `JUST_UPGRADED `: tell user "Running gstack v{to} (just updated!)" and continue. @@ -30,6 +30,25 @@ If output shows `UPGRADE_AVAILABLE `: read `~/.claude/skills/gstack/g Persistent headless Chromium. First call auto-starts (~3s), then ~100ms per command. State persists between calls (cookies, tabs, login sessions). +## SETUP (run this check BEFORE any browse command) + +```bash +_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) +B="" +[ -n "$_ROOT" ] && [ -x "$_ROOT/.claude/skills/gstack/browse/dist/browse" ] && B="$_ROOT/.claude/skills/gstack/browse/dist/browse" +[ -z "$B" ] && B=~/.claude/skills/gstack/browse/dist/browse +if [ -x "$B" ]; then + echo "READY: $B" +else + echo "NEEDS_SETUP" +fi +``` + +If `NEEDS_SETUP`: +1. Tell the user: "gstack browse needs a one-time build (~10 seconds). OK to proceed?" Then STOP and wait. +2. Run: `cd && ./setup` +3. If `bun` is not installed: `curl -fsSL https://bun.sh/install | bash` + ## Core QA Patterns ### 1. Verify a page loads correctly diff --git a/browse/SKILL.md.tmpl b/browse/SKILL.md.tmpl index 6b2f274e..62e52cd3 100644 --- a/browse/SKILL.md.tmpl +++ b/browse/SKILL.md.tmpl @@ -14,20 +14,15 @@ allowed-tools: --- -## Update Check (run first) - -```bash -_UPD=$(~/.claude/skills/gstack/bin/gstack-update-check 2>/dev/null || .claude/skills/gstack/bin/gstack-update-check 2>/dev/null || true) -[ -n "$_UPD" ] && echo "$_UPD" -``` - -If output shows `UPGRADE_AVAILABLE `: read `~/.claude/skills/gstack/gstack-upgrade/SKILL.md` and follow the "Inline upgrade flow" (AskUserQuestion → upgrade if yes, `touch ~/.gstack/last-update-check` if no). If `JUST_UPGRADED `: tell user "Running gstack v{to} (just updated!)" and continue. +{{UPDATE_CHECK}} # browse: QA Testing & Dogfooding Persistent headless Chromium. First call auto-starts (~3s), then ~100ms per command. State persists between calls (cookies, tabs, login sessions). +{{BROWSE_SETUP}} + ## Core QA Patterns ### 1. Verify a page loads correctly diff --git a/scripts/gen-skill-docs.ts b/scripts/gen-skill-docs.ts index 381278ca..214acc2d 100644 --- a/scripts/gen-skill-docs.ts +++ b/scripts/gen-skill-docs.ts @@ -94,9 +94,43 @@ function generateSnapshotFlags(): string { return lines.join('\n'); } +function generateUpdateCheck(): string { + return `## Update Check (run first) + +\`\`\`bash +_UPD=$(~/.claude/skills/gstack/bin/gstack-update-check 2>/dev/null || .claude/skills/gstack/bin/gstack-update-check 2>/dev/null || true) +[ -n "$_UPD" ] && echo "$_UPD" || true +\`\`\` + +If output shows \`UPGRADE_AVAILABLE \`: read \`~/.claude/skills/gstack/gstack-upgrade/SKILL.md\` and follow the "Inline upgrade flow" (AskUserQuestion → upgrade if yes, \`touch ~/.gstack/last-update-check\` if no). If \`JUST_UPGRADED \`: tell user "Running gstack v{to} (just updated!)" and continue.`; +} + +function generateBrowseSetup(): string { + return `## SETUP (run this check BEFORE any browse command) + +\`\`\`bash +_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) +B="" +[ -n "$_ROOT" ] && [ -x "$_ROOT/.claude/skills/gstack/browse/dist/browse" ] && B="$_ROOT/.claude/skills/gstack/browse/dist/browse" +[ -z "$B" ] && B=~/.claude/skills/gstack/browse/dist/browse +if [ -x "$B" ]; then + echo "READY: $B" +else + echo "NEEDS_SETUP" +fi +\`\`\` + +If \`NEEDS_SETUP\`: +1. Tell the user: "gstack browse needs a one-time build (~10 seconds). OK to proceed?" Then STOP and wait. +2. Run: \`cd && ./setup\` +3. If \`bun\` is not installed: \`curl -fsSL https://bun.sh/install | bash\``; +} + const RESOLVERS: Record string> = { COMMAND_REFERENCE: generateCommandReference, SNAPSHOT_FLAGS: generateSnapshotFlags, + UPDATE_CHECK: generateUpdateCheck, + BROWSE_SETUP: generateBrowseSetup, }; // ─── Template Processing ──────────────────────────────────── @@ -141,6 +175,8 @@ function findTemplates(): string[] { const candidates = [ path.join(ROOT, 'SKILL.md.tmpl'), path.join(ROOT, 'browse', 'SKILL.md.tmpl'), + path.join(ROOT, 'qa', 'SKILL.md.tmpl'), + path.join(ROOT, 'setup-browser-cookies', 'SKILL.md.tmpl'), ]; for (const p of candidates) { if (fs.existsSync(p)) templates.push(p);