From be2fda288d8f6902f844a7256182434ad2fd1e7e Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Fri, 27 Mar 2026 08:50:28 -0600 Subject: [PATCH] test: add prefix config tests + README switching instructions 8 structural tests for persistent prefix setting: config reading, --prefix flag, config persistence, interactive prompt, TTY fallback, reverse cleanup, cleanup ordering, welcome. --- README.md | 4 +++ test/gen-skill-docs.test.ts | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/README.md b/README.md index 7ad49c20..fa61e86d 100644 --- a/README.md +++ b/README.md @@ -259,6 +259,10 @@ Data is stored in [Supabase](https://supabase.com) (open source Firebase alterna **Stale install?** Run `/gstack-upgrade` — or set `auto_upgrade: true` in `~/.gstack/config.yaml` +**Want shorter commands?** `cd ~/.claude/skills/gstack && ./setup --no-prefix` — switches from `/gstack-qa` to `/qa`. Your choice is remembered for future upgrades. + +**Want namespaced commands?** `cd ~/.claude/skills/gstack && ./setup --prefix` — switches from `/qa` to `/gstack-qa`. Useful if you run other skill packs alongside gstack. + **Codex says "Skipped loading skill(s) due to invalid SKILL.md"?** Your Codex skill descriptions are stale. Fix: `cd ~/.codex/skills/gstack && git pull && ./setup --host codex` — or for repo-local installs: `cd "$(readlink -f .agents/skills/gstack)" && git pull && ./setup --host codex` **Windows users:** gstack works on Windows 11 via Git Bash or WSL. Node.js is required in addition to Bun — Bun has a known bug with Playwright's pipe transport on Windows ([bun#4253](https://github.com/oven-sh/bun/issues/4253)). The browse server automatically falls back to Node.js. Make sure both `bun` and `node` are on your PATH. diff --git a/test/gen-skill-docs.test.ts b/test/gen-skill-docs.test.ts index 88308ff5..9941dbd4 100644 --- a/test/gen-skill-docs.test.ts +++ b/test/gen-skill-docs.test.ts @@ -1685,6 +1685,56 @@ describe('setup script validation', () => { ); expect(claudeInstallSection).toContain('cleanup_old_claude_symlinks'); }); + + // --- Persistent config + interactive prompt tests --- + + test('setup reads skill_prefix from config', () => { + expect(setupContent).toContain('get skill_prefix'); + expect(setupContent).toContain('GSTACK_CONFIG'); + }); + + test('setup supports --prefix flag', () => { + expect(setupContent).toContain('--prefix)'); + expect(setupContent).toContain('SKILL_PREFIX=1; SKILL_PREFIX_FLAG=1'); + }); + + test('--prefix and --no-prefix persist to config', () => { + expect(setupContent).toContain('set skill_prefix'); + }); + + test('interactive prompt shows when no config', () => { + expect(setupContent).toContain('Short names'); + expect(setupContent).toContain('Namespaced'); + expect(setupContent).toContain('Choice [1/2]'); + }); + + test('non-TTY defaults to flat names', () => { + // Should check if stdin is a TTY before prompting + expect(setupContent).toContain('-t 0'); + }); + + test('cleanup_prefixed_claude_symlinks exists and uses readlink', () => { + expect(setupContent).toContain('cleanup_prefixed_claude_symlinks'); + const fnStart = setupContent.indexOf('cleanup_prefixed_claude_symlinks()'); + const fnEnd = setupContent.indexOf('}', setupContent.indexOf('removed[@]}', fnStart)); + const fnBody = setupContent.slice(fnStart, fnEnd); + expect(fnBody).toContain('readlink'); + expect(fnBody).toContain('gstack-$skill_name'); + }); + + test('reverse cleanup runs before link when prefix is disabled', () => { + const claudeInstallSection = setupContent.slice( + setupContent.indexOf('INSTALL_CLAUDE'), + setupContent.lastIndexOf('link_claude_skill_dirs') + ); + expect(claudeInstallSection).toContain('cleanup_prefixed_claude_symlinks'); + }); + + test('welcome message references SKILL_PREFIX', () => { + // gstack-upgrade is always called gstack-upgrade (it's the actual dir name) + // but the welcome section should exist near the prefix logic + expect(setupContent).toContain('Run /gstack-upgrade anytime'); + }); }); describe('discover-skills hidden directory filtering', () => {