mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-06 13:45:35 +02:00
./setup --prefix creates gstack-* symlinks but SKILL.md still says name: qa, so Claude Code ignores the prefix. Now: - New bin/gstack-patch-names shared helper patches name: field via sed - setup calls it after link_claude_skill_dirs - gstack-relink calls it after symlink loop - gen-skill-docs.ts prints warning when skill_prefix is true Edge cases: gstack-upgrade not double-prefixed, root gstack skill never prefixed, prefix removal restores original names, SKILL.md without frontmatter is a safe no-op. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
# gstack-patch-names — patch name: field in SKILL.md frontmatter for prefix mode
|
||||
# Usage: gstack-patch-names <gstack-dir> <true|false|1|0>
|
||||
set -euo pipefail
|
||||
|
||||
GSTACK_DIR="$1"
|
||||
DO_PREFIX="$2"
|
||||
|
||||
# Normalize prefix arg
|
||||
case "$DO_PREFIX" in true|1) DO_PREFIX=1 ;; *) DO_PREFIX=0 ;; esac
|
||||
|
||||
PATCHED=0
|
||||
for skill_dir in "$GSTACK_DIR"/*/; do
|
||||
[ -f "$skill_dir/SKILL.md" ] || continue
|
||||
dir_name="$(basename "$skill_dir")"
|
||||
[ "$dir_name" = "node_modules" ] && continue
|
||||
cur=$(grep -m1 '^name:' "$skill_dir/SKILL.md" 2>/dev/null | sed 's/^name:[[:space:]]*//' | tr -d '[:space:]' || true)
|
||||
[ -z "$cur" ] && continue
|
||||
[ "$cur" = "gstack" ] && continue # never prefix root skill
|
||||
if [ "$DO_PREFIX" -eq 1 ]; then
|
||||
case "$cur" in gstack-*) continue ;; esac
|
||||
new="gstack-$cur"
|
||||
else
|
||||
case "$cur" in gstack-*) ;; *) continue ;; esac
|
||||
[ "$dir_name" = "$cur" ] && continue # inherently prefixed (gstack-upgrade)
|
||||
new="${cur#gstack-}"
|
||||
fi
|
||||
tmp="$(mktemp "${skill_dir}/SKILL.md.XXXXXX")"
|
||||
sed "1,/^---$/s/^name:[[:space:]]*${cur}/name: ${new}/" "$skill_dir/SKILL.md" > "$tmp" && mv "$tmp" "$skill_dir/SKILL.md"
|
||||
PATCHED=$((PATCHED + 1))
|
||||
done
|
||||
if [ "$PATCHED" -gt 0 ]; then
|
||||
echo " patched name: field in $PATCHED skills"
|
||||
fi
|
||||
Reference in New Issue
Block a user