mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-06 21:46:40 +02:00
Merge remote-tracking branch 'origin/main' into garrytan/fix-skill-ordering
This commit is contained in:
@@ -24,12 +24,14 @@ esac
|
||||
HOST="claude"
|
||||
LOCAL_INSTALL=0
|
||||
SKILL_PREFIX=1
|
||||
SKILL_PREFIX_FLAG=0
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--host) [ -z "$2" ] && echo "Missing value for --host (expected claude, codex, kiro, or auto)" >&2 && exit 1; HOST="$2"; shift 2 ;;
|
||||
--host=*) HOST="${1#--host=}"; shift ;;
|
||||
--local) LOCAL_INSTALL=1; shift ;;
|
||||
--no-prefix) SKILL_PREFIX=0; shift ;;
|
||||
--prefix) SKILL_PREFIX=1; SKILL_PREFIX_FLAG=1; shift ;;
|
||||
--no-prefix) SKILL_PREFIX=0; SKILL_PREFIX_FLAG=1; shift ;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
@@ -39,6 +41,44 @@ case "$HOST" in
|
||||
*) echo "Unknown --host value: $HOST (expected claude, codex, kiro, or auto)" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
# ─── Resolve skill prefix preference ─────────────────────────
|
||||
# Priority: CLI flag > saved config > interactive prompt (or flat default for non-TTY)
|
||||
GSTACK_CONFIG="$SOURCE_GSTACK_DIR/bin/gstack-config"
|
||||
if [ "$SKILL_PREFIX_FLAG" -eq 0 ]; then
|
||||
_saved_prefix="$("$GSTACK_CONFIG" get skill_prefix 2>/dev/null || true)"
|
||||
if [ "$_saved_prefix" = "true" ]; then
|
||||
SKILL_PREFIX=1
|
||||
elif [ "$_saved_prefix" = "false" ]; then
|
||||
SKILL_PREFIX=0
|
||||
else
|
||||
# No saved preference — prompt interactively (or default flat for non-TTY)
|
||||
if [ -t 0 ]; then
|
||||
echo ""
|
||||
echo "Skill naming: how should gstack skills appear?"
|
||||
echo ""
|
||||
echo " 1) Short names: /qa, /ship, /review"
|
||||
echo " Recommended. Clean and fast to type."
|
||||
echo ""
|
||||
echo " 2) Namespaced: /gstack-qa, /gstack-ship, /gstack-review"
|
||||
echo " Use this if you run other skill packs alongside gstack to avoid conflicts."
|
||||
echo ""
|
||||
printf "Choice [1/2] (default: 1): "
|
||||
read -r _prefix_choice </dev/tty 2>/dev/null || _prefix_choice=""
|
||||
case "$_prefix_choice" in
|
||||
2) SKILL_PREFIX=1 ;;
|
||||
*) SKILL_PREFIX=0 ;;
|
||||
esac
|
||||
else
|
||||
SKILL_PREFIX=0
|
||||
fi
|
||||
# Save the choice for future runs
|
||||
"$GSTACK_CONFIG" set skill_prefix "$([ "$SKILL_PREFIX" -eq 1 ] && echo true || echo false)" 2>/dev/null || true
|
||||
fi
|
||||
else
|
||||
# Flag was passed explicitly — persist the choice
|
||||
"$GSTACK_CONFIG" set skill_prefix "$([ "$SKILL_PREFIX" -eq 1 ] && echo true || echo false)" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# --local: install to .claude/skills/ in the current working directory
|
||||
if [ "$LOCAL_INSTALL" -eq 1 ]; then
|
||||
if [ "$HOST" = "codex" ]; then
|
||||
@@ -266,6 +306,38 @@ cleanup_old_claude_symlinks() {
|
||||
fi
|
||||
}
|
||||
|
||||
# ─── Helper: remove old prefixed Claude skill symlinks ────────────────────────
|
||||
# Reverse migration: when switching from gstack- prefixed names to flat names,
|
||||
# clean up stale gstack-* symlinks that point into the gstack directory.
|
||||
cleanup_prefixed_claude_symlinks() {
|
||||
local gstack_dir="$1"
|
||||
local skills_dir="$2"
|
||||
local removed=()
|
||||
for skill_dir in "$gstack_dir"/*/; do
|
||||
if [ -f "$skill_dir/SKILL.md" ]; then
|
||||
skill_name="$(basename "$skill_dir")"
|
||||
[ "$skill_name" = "node_modules" ] && continue
|
||||
# Only clean up prefixed symlinks for dirs that AREN'T already prefixed
|
||||
# (e.g., remove gstack-qa but NOT gstack-upgrade which is the real dir name)
|
||||
case "$skill_name" in gstack-*) continue ;; esac
|
||||
prefixed_target="$skills_dir/gstack-$skill_name"
|
||||
# Only remove if it's a symlink pointing into gstack/
|
||||
if [ -L "$prefixed_target" ]; then
|
||||
link_dest="$(readlink "$prefixed_target" 2>/dev/null || true)"
|
||||
case "$link_dest" in
|
||||
gstack/*|*/gstack/*)
|
||||
rm -f "$prefixed_target"
|
||||
removed+=("gstack-$skill_name")
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ ${#removed[@]} -gt 0 ]; then
|
||||
echo " cleaned up prefixed symlinks: ${removed[*]}"
|
||||
fi
|
||||
}
|
||||
|
||||
# ─── Helper: link generated Codex skills into a skills parent directory ──
|
||||
# Installs from .agents/skills/gstack-* (the generated Codex-format skills)
|
||||
# instead of source dirs (which have Claude paths).
|
||||
@@ -393,9 +465,11 @@ fi
|
||||
|
||||
if [ "$INSTALL_CLAUDE" -eq 1 ]; then
|
||||
if [ "$SKILLS_BASENAME" = "skills" ]; then
|
||||
# Clean up old unprefixed symlinks from previous installs
|
||||
# Clean up stale symlinks from the opposite prefix mode
|
||||
if [ "$SKILL_PREFIX" -eq 1 ]; then
|
||||
cleanup_old_claude_symlinks "$SOURCE_GSTACK_DIR" "$INSTALL_SKILLS_DIR"
|
||||
else
|
||||
cleanup_prefixed_claude_symlinks "$SOURCE_GSTACK_DIR" "$INSTALL_SKILLS_DIR"
|
||||
fi
|
||||
link_claude_skill_dirs "$SOURCE_GSTACK_DIR" "$INSTALL_SKILLS_DIR"
|
||||
if [ "$LOCAL_INSTALL" -eq 1 ]; then
|
||||
@@ -497,8 +571,8 @@ if [ "$INSTALL_CODEX" -eq 1 ]; then
|
||||
fi
|
||||
|
||||
# 8. First-time welcome + legacy cleanup
|
||||
if [ ! -d "$HOME/.gstack" ]; then
|
||||
mkdir -p "$HOME/.gstack"
|
||||
if [ ! -f "$HOME/.gstack/.welcome-seen" ]; then
|
||||
echo " Welcome! Run /gstack-upgrade anytime to stay current."
|
||||
touch "$HOME/.gstack/.welcome-seen"
|
||||
fi
|
||||
rm -f /tmp/gstack-latest-version
|
||||
|
||||
Reference in New Issue
Block a user