mirror of
https://github.com/garrytan/gstack.git
synced 2026-07-10 18:07:11 +02:00
Merge remote-tracking branch 'origin/main' into garrytan/plan-mode-disk-write
This commit is contained in:
+13
-9
@@ -5,13 +5,17 @@ DIR="$(cd "$(dirname "$0")/.." && pwd)/dist"
|
||||
if test -x "$DIR/find-browse"; then
|
||||
exec "$DIR/find-browse" "$@"
|
||||
fi
|
||||
# Fallback: basic discovery
|
||||
# Fallback: basic discovery with priority chain
|
||||
ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||
if [ -n "$ROOT" ] && test -x "$ROOT/.claude/skills/gstack/browse/dist/browse"; then
|
||||
echo "$ROOT/.claude/skills/gstack/browse/dist/browse"
|
||||
elif test -x "$HOME/.claude/skills/gstack/browse/dist/browse"; then
|
||||
echo "$HOME/.claude/skills/gstack/browse/dist/browse"
|
||||
else
|
||||
echo "ERROR: browse binary not found. Run: cd <skill-dir> && ./setup" >&2
|
||||
exit 1
|
||||
fi
|
||||
for MARKER in .codex .agents .claude; do
|
||||
if [ -n "$ROOT" ] && test -x "$ROOT/$MARKER/skills/gstack/browse/dist/browse"; then
|
||||
echo "$ROOT/$MARKER/skills/gstack/browse/dist/browse"
|
||||
exit 0
|
||||
fi
|
||||
if test -x "$HOME/$MARKER/skills/gstack/browse/dist/browse"; then
|
||||
echo "$HOME/$MARKER/skills/gstack/browse/dist/browse"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
echo "ERROR: browse binary not found. Run: cd <skill-dir> && ./setup" >&2
|
||||
exit 1
|
||||
|
||||
@@ -27,16 +27,21 @@ function getGitRoot(): string | null {
|
||||
export function locateBinary(): string | null {
|
||||
const root = getGitRoot();
|
||||
const home = homedir();
|
||||
const markers = ['.codex', '.agents', '.claude'];
|
||||
|
||||
// Workspace-local takes priority (for development)
|
||||
if (root) {
|
||||
const local = join(root, '.claude', 'skills', 'gstack', 'browse', 'dist', 'browse');
|
||||
if (existsSync(local)) return local;
|
||||
for (const m of markers) {
|
||||
const local = join(root, m, '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;
|
||||
for (const m of markers) {
|
||||
const global = join(home, m, 'skills', 'gstack', 'browse', 'dist', 'browse');
|
||||
if (existsSync(global)) return global;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -21,4 +21,30 @@ describe('locateBinary', () => {
|
||||
expect(existsSync(result)).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
test('priority chain checks .codex, .agents, .claude markers', () => {
|
||||
// Verify the source code implements the correct priority order.
|
||||
// We read the function source to confirm the markers array order.
|
||||
const src = require('fs').readFileSync(require('path').join(__dirname, '../src/find-browse.ts'), 'utf-8');
|
||||
// The markers array should list .codex first, then .agents, then .claude
|
||||
const markersMatch = src.match(/const markers = \[([^\]]+)\]/);
|
||||
expect(markersMatch).not.toBeNull();
|
||||
const markers = markersMatch![1];
|
||||
const codexIdx = markers.indexOf('.codex');
|
||||
const agentsIdx = markers.indexOf('.agents');
|
||||
const claudeIdx = markers.indexOf('.claude');
|
||||
// All three must be present
|
||||
expect(codexIdx).toBeGreaterThanOrEqual(0);
|
||||
expect(agentsIdx).toBeGreaterThanOrEqual(0);
|
||||
expect(claudeIdx).toBeGreaterThanOrEqual(0);
|
||||
// .codex before .agents before .claude
|
||||
expect(codexIdx).toBeLessThan(agentsIdx);
|
||||
expect(agentsIdx).toBeLessThan(claudeIdx);
|
||||
});
|
||||
|
||||
test('function signature accepts no arguments', () => {
|
||||
// locateBinary should be callable with no arguments
|
||||
expect(typeof locateBinary).toBe('function');
|
||||
expect(locateBinary.length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user