Help and docs
Sign in

grindlemire/dotfiles code browser

main 0375daa
Bash · 96 lines · 3.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env bash
# Symlink every skill in this directory into Claude and Codex skill dirs.
# Existing symlinks are replaced; existing real directories are left alone (with a warning).

set -euo pipefail

SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TARGET="${1:-all}"

case "$TARGET" in
  all)
    DEST_DIRS=("${HOME}/.claude/skills" "${HOME}/.agents/skills")
    ;;
  claude)
    DEST_DIRS=("${HOME}/.claude/skills")
    ;;
  codex)
    DEST_DIRS=("${HOME}/.agents/skills")
    ;;
  *)
    echo "usage: $0 [all|claude|codex]" >&2
    exit 2
    ;;
esac

link_skill() {
  local skill_path="$1"
  local dest_dir="$2"
  local skill
  local target

  skill="$(basename "$skill_path")"
  target="$dest_dir/$skill"

  if [ -L "$target" ]; then
    rm "$target"
  elif [ -e "$target" ]; then
    echo "skip: $target exists and is not a symlink (remove it manually to replace)"
    return
  fi

  ln -s "$skill_path" "$target"
  echo "linked: $target"
}

for dest_dir in "${DEST_DIRS[@]}"; do
  mkdir -p "$dest_dir"
done

for skill_path in "$SRC_DIR"/*/; do
  for dest_dir in "${DEST_DIRS[@]}"; do
    link_skill "$skill_path" "$dest_dir"
  done
done

# Trial plugins — only for the test sandboxes, never the regular ~/.claude or
# ~/.codex installs. Installed from the author's own marketplace so they track
# upstream HEAD (the claude-plugins-official entry pins an old commit).
# `tc`  (CLAUDE_CONFIG_DIR=~/.claude-test)
# `tcx` (CODEX_HOME=~/.codex-test)
TRIAL_MARKETPLACE_REPO="mattpocock/skills"
TRIAL_MARKETPLACE="mattpocock"
TRIAL_PLUGIN="mattpocock-skills@${TRIAL_MARKETPLACE}"

if { [ "$TARGET" = "all" ] || [ "$TARGET" = "claude" ]; } && command -v claude >/dev/null; then
  if ! CLAUDE_CONFIG_DIR="${HOME}/.claude-test" claude plugin list 2>/dev/null | grep -q "$TRIAL_PLUGIN"; then
    CLAUDE_CONFIG_DIR="${HOME}/.claude-test" claude plugin marketplace add "$TRIAL_MARKETPLACE_REPO"
    CLAUDE_CONFIG_DIR="${HOME}/.claude-test" claude plugin install "$TRIAL_PLUGIN"
  fi
fi
if { [ "$TARGET" = "all" ] || [ "$TARGET" = "codex" ]; } && command -v codex >/dev/null; then
  if ! CODEX_HOME="${HOME}/.codex-test" codex plugin list 2>/dev/null | grep -q "$TRIAL_PLUGIN"; then
    CODEX_HOME="${HOME}/.codex-test" codex plugin marketplace add "$TRIAL_MARKETPLACE_REPO"
    CODEX_HOME="${HOME}/.codex-test" codex plugin add "$TRIAL_PLUGIN"
  fi
fi

# Selected stable skills (from skills/) that should ALSO appear in the test
# sandboxes, alongside the trial plugins above. e.g. humanizer lives in the
# stable set but is wanted in tc / tcx too.
STABLE_TEST_SKILLS=(humanizer)
for skill in "${STABLE_TEST_SKILLS[@]}"; do
  skill_path="$SRC_DIR/$skill"
  if [ ! -d "$skill_path" ]; then
    echo "warn: stable skill '$skill' not found at $skill_path" >&2
    continue
  fi
  if [ "$TARGET" = "all" ] || [ "$TARGET" = "claude" ]; then
    mkdir -p "${HOME}/.claude-test/skills"
    link_skill "$skill_path" "${HOME}/.claude-test/skills"
  fi
  if [ "$TARGET" = "all" ] || [ "$TARGET" = "codex" ]; then
    mkdir -p "${HOME}/.codex-test/skills"
    link_skill "$skill_path" "${HOME}/.codex-test/skills"
  fi
done