Files
gstack/browse/src/find-browse.ts
T
Garry Tan 6b69c46a27 feat: daily update check + /gstack-upgrade skill (v0.3.4) (#42)
* feat: add daily update check script + /gstack-upgrade skill

bin/gstack-update-check: pure bash, checks VERSION against remote once/day,
outputs UPGRADE_AVAILABLE or JUST_UPGRADED. Uses ~/.gstack/ for state.

gstack-upgrade/SKILL.md: new skill with inline upgrade flow for all preambles.
Detects global-git, local-git, vendored installs. Shows What's New from CHANGELOG.

browse/test/gstack-update-check.test.ts: 10 test cases covering all branch paths.

* refactor: remove version check from find-browse, simplify to binary locator

Delete checkVersion(), readCache(), writeCache(), fetchRemoteSHA(),
resolveSkillDir(), CacheEntry interface, REPO_URL/CACHE_PATH/CACHE_TTL
constants, and META output from find-browse.ts.

Version checking is now handled by bin/gstack-update-check (previous commit).

* feat: add update check preamble to all 9 skills

Every skill now runs bin/gstack-update-check on invocation. If an upgrade
is available, reads gstack-upgrade/SKILL.md inline upgrade flow.

Also adds AskUserQuestion to 5 skills that lacked it (gstack root, browse,
qa, retro, setup-browser-cookies) and Bash to plan-eng-review.

Simplifies qa and setup-browser-cookies setup blocks (removes META parsing).

* chore: bump version and changelog (v0.3.4)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove unused import + add corrupt cache test

Address pre-landing review findings:
- Remove unused mkdirSync import from gstack-update-check.test.ts
- Add Path I test: corrupt cache file falls through to remote fetch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 22:17:25 -07:00

57 lines
1.6 KiB
TypeScript

/**
* find-browse — locate the gstack browse binary.
*
* Compiled to browse/dist/find-browse (standalone binary, no bun runtime needed).
* Outputs the absolute path to the browse binary on stdout, or exits 1 if not found.
*/
import { existsSync } from 'fs';
import { join } from 'path';
import { homedir } from 'os';
// ─── Binary Discovery ───────────────────────────────────────────
function getGitRoot(): string | null {
try {
const proc = Bun.spawnSync(['git', 'rev-parse', '--show-toplevel'], {
stdout: 'pipe',
stderr: 'pipe',
});
if (proc.exitCode !== 0) return null;
return proc.stdout.toString().trim();
} catch {
return null;
}
}
export function locateBinary(): string | null {
const root = getGitRoot();
const home = homedir();
// Workspace-local takes priority (for development)
if (root) {
const local = join(root, '.claude', 'skills', 'gstack', 'browse', 'dist', 'browse');
if (existsSync(local)) return local;
}
// Global fallback
const global = join(home, '.claude', 'skills', 'gstack', 'browse', 'dist', 'browse');
if (existsSync(global)) return global;
return null;
}
// ─── Main ───────────────────────────────────────────────────────
function main() {
const bin = locateBinary();
if (!bin) {
process.stderr.write('ERROR: browse binary not found. Run: cd <skill-dir> && ./setup\n');
process.exit(1);
}
console.log(bin);
}
main();