()
| 13 | let cachedSlug: string | null = null; |
| 14 | |
| 15 | export function getCurrentProjectSlug(): string { |
| 16 | if (cachedSlug) return cachedSlug; |
| 17 | const explicit = process.env.GSTACK_PROJECT_SLUG; |
| 18 | if (explicit) { |
| 19 | cachedSlug = explicit; |
| 20 | return explicit; |
| 21 | } |
| 22 | try { |
| 23 | const slugBin = path.join(os.homedir(), '.claude/skills/gstack/bin/gstack-slug'); |
| 24 | const out = execSync(slugBin, { encoding: 'utf8', timeout: 2000 }).trim(); |
| 25 | const m = out.match(/SLUG="?([^"\n]+)"?/); |
| 26 | cachedSlug = m ? m[1]! : (out || 'unknown'); |
| 27 | } catch { |
| 28 | cachedSlug = 'unknown'; |
| 29 | } |
| 30 | return cachedSlug; |
| 31 | } |
| 32 | |
| 33 | /** Reset cache; for tests only. */ |
| 34 | export function _resetProjectSlugCache(): void { |
no outgoing calls
no test coverage detected