Files
gstack/setup
T
Garry Tan 3d901066cd Initial release — gstack v0.0.1
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 01:32:16 -07:00

42 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# gstack setup — build browser binary + register all skills with Claude Code
set -e
GSTACK_DIR="$(cd "$(dirname "$0")" && pwd)"
SKILLS_DIR="$(dirname "$GSTACK_DIR")"
# 1. Build browse binary if needed
if [ ! -x "$GSTACK_DIR/browse/dist/browse" ]; then
echo "Building browse binary..."
cd "$GSTACK_DIR" && bun install && bun run build
fi
# 2. Only create skill symlinks if we're inside a .claude/skills directory
SKILLS_BASENAME="$(basename "$SKILLS_DIR")"
if [ "$SKILLS_BASENAME" = "skills" ]; then
linked=()
for skill_dir in "$GSTACK_DIR"/*/; do
if [ -f "$skill_dir/SKILL.md" ]; then
skill_name="$(basename "$skill_dir")"
# Skip node_modules
[ "$skill_name" = "node_modules" ] && continue
target="$SKILLS_DIR/$skill_name"
# Create or update symlink; skip if a real file/directory exists
if [ -L "$target" ] || [ ! -e "$target" ]; then
ln -snf "gstack/$skill_name" "$target"
linked+=("$skill_name")
fi
fi
done
echo "gstack ready."
echo " browse: $GSTACK_DIR/browse/dist/browse"
if [ ${#linked[@]} -gt 0 ]; then
echo " linked skills: ${linked[*]}"
fi
else
echo "gstack ready."
echo " browse: $GSTACK_DIR/browse/dist/browse"
echo " (skipped skill symlinks — not inside .claude/skills/)"
fi