@citedy/game-sounds 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/game-sounds +164 -56
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citedy/game-sounds",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Game sound effects for Claude Code — Warcraft, StarCraft & more. Work work! 🔨",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -4,25 +4,42 @@
4
4
 
5
5
  set -euo pipefail
6
6
 
7
+ # Colors
8
+ BOLD='\033[1m'
9
+ DIM='\033[2m'
10
+ GREEN='\033[32m'
11
+ YELLOW='\033[33m'
12
+ CYAN='\033[36m'
13
+ MAGENTA='\033[35m'
14
+ RESET='\033[0m'
15
+
16
+ # Pack icons
17
+ pack_icon() {
18
+ case "$1" in
19
+ warcraft) echo "⚔️" ;;
20
+ starcraft) echo "🚀" ;;
21
+ diablo) echo "🔥" ;;
22
+ command-conquer) echo "🏗️" ;;
23
+ mario) echo "🍄" ;;
24
+ zelda) echo "🗡️" ;;
25
+ *) echo "🎮" ;;
26
+ esac
27
+ }
28
+
7
29
  # Find config file
8
30
  find_config() {
9
- # 1. Script's own plugin directory
10
31
  local script_dir="$(cd "$(dirname "$0")/.." && pwd)"
11
32
  [[ -f "$script_dir/config.json" ]] && echo "$script_dir/config.json" && return 0
12
- # 2. Marketplace cache
13
33
  for f in "$HOME"/.claude/plugins/cache/citedy/game-sounds/*/config.json; do
14
34
  [[ -f "$f" ]] && echo "$f" && return 0
15
35
  done
16
- # 3. Manual clone location
17
36
  [[ -f "$HOME/.claude/plugins/game-sounds/config.json" ]] && echo "$HOME/.claude/plugins/game-sounds/config.json" && return 0
18
37
  echo "Error: config.json not found" >&2
19
38
  return 1
20
39
  }
21
40
 
22
- # Find sounds root
23
41
  find_sounds() {
24
- local config="$1"
25
- echo "$(dirname "$config")/sounds"
42
+ echo "$(dirname "$1")/sounds"
26
43
  }
27
44
 
28
45
  CONFIG=$(find_config)
@@ -44,41 +61,114 @@ with open('$CONFIG', 'w') as f:
44
61
  " 2>/dev/null
45
62
  }
46
63
 
47
- case "${1:-help}" in
64
+ # Arrow key interactive menu
65
+ interactive_select() {
66
+ local current="$1"
67
+ shift
68
+ local packs=("$@")
69
+ local selected=0
70
+ local count=${#packs[@]}
71
+
72
+ # Find current pack index
73
+ for i in "${!packs[@]}"; do
74
+ [[ "${packs[$i]}" == "$current" ]] && selected=$i
75
+ done
76
+
77
+ # Hide cursor
78
+ tput civis 2>/dev/null || true
79
+ trap 'tput cnorm 2>/dev/null; exit' EXIT INT TERM
80
+
81
+ while true; do
82
+ # Clear menu area
83
+ for ((i=0; i<count+2; i++)); do
84
+ echo -ne "\033[2K"
85
+ [[ $i -lt $((count+1)) ]] && echo -ne "\033[1B"
86
+ done
87
+ # Move back up
88
+ for ((i=0; i<count+1; i++)); do
89
+ echo -ne "\033[1A"
90
+ done
91
+
92
+ # Draw menu
93
+ echo -e "${BOLD}Select a sound pack:${RESET} ${DIM}(↑/↓ arrows, Enter to confirm)${RESET}"
94
+ for i in "${!packs[@]}"; do
95
+ local pack="${packs[$i]}"
96
+ local icon=$(pack_icon "$pack")
97
+ local scount=$(find "$SOUNDS_DIR/$pack" -name "*.mp3" 2>/dev/null | wc -l | tr -d ' ')
98
+ local active=""
99
+ [[ "$pack" == "$current" ]] && active=" ${GREEN}(active)${RESET}"
100
+
101
+ if [[ $i -eq $selected ]]; then
102
+ echo -e " ${CYAN}❯${RESET} ${BOLD}$icon $pack${RESET} ${DIM}($scount sounds)${RESET}$active"
103
+ else
104
+ echo -e " $icon ${DIM}$pack ($scount sounds)${RESET}$active"
105
+ fi
106
+ done
107
+ echo -ne "\033[2K"
108
+
109
+ # Read keypress
110
+ IFS= read -rsn1 key
111
+ case "$key" in
112
+ $'\x1b')
113
+ read -rsn2 -t 0.1 key2
114
+ case "$key2" in
115
+ '[A') # Up arrow
116
+ ((selected > 0)) && ((selected--))
117
+ ;;
118
+ '[B') # Down arrow
119
+ ((selected < count - 1)) && ((selected++))
120
+ ;;
121
+ esac
122
+ ;;
123
+ '') # Enter
124
+ tput cnorm 2>/dev/null || true
125
+ echo ""
126
+ echo "${packs[$selected]}"
127
+ return 0
128
+ ;;
129
+ 'q'|'Q') # Quit
130
+ tput cnorm 2>/dev/null || true
131
+ echo ""
132
+ return 1
133
+ ;;
134
+ esac
135
+ done
136
+ }
137
+
138
+ case "${1:-}" in
48
139
  switch|pack|p)
49
140
  if [[ -z "${2:-}" ]]; then
50
- # Interactive selection
51
- echo "Available packs:"
52
- echo ""
53
- i=1
54
- packs=()
55
141
  current=$(read_config active_pack warcraft)
142
+ packs=()
56
143
  for dir in "$SOUNDS_DIR"/*/; do
57
- pack=$(basename "$dir")
58
- count=$(find "$dir" -name "*.mp3" 2>/dev/null | wc -l | tr -d ' ')
59
- marker=""
60
- [[ "$pack" == "$current" ]] && marker=" (active)"
61
- echo " $i) $pack ($count sounds)$marker"
62
- packs+=("$pack")
63
- i=$((i + 1))
144
+ packs+=("$(basename "$dir")")
64
145
  done
146
+
65
147
  echo ""
66
- read -p "Select pack [1-${#packs[@]}]: " choice
67
- if [[ "$choice" =~ ^[0-9]+$ ]] && (( choice >= 1 && choice <= ${#packs[@]} )); then
68
- selected="${packs[$((choice - 1))]}"
148
+ result=$(interactive_select "$current" "${packs[@]}") || exit 0
149
+ selected=$(echo "$result" | tail -1)
150
+
151
+ if [[ -n "$selected" && -d "$SOUNDS_DIR/$selected" ]]; then
69
152
  write_config active_pack "\"$selected\""
70
- echo "Switched to: $selected"
71
- else
72
- echo "Invalid choice"
73
- exit 1
153
+ icon=$(pack_icon "$selected")
154
+ count=$(find "$SOUNDS_DIR/$selected" -name "*.mp3" 2>/dev/null | wc -l | tr -d ' ')
155
+ echo -e "${GREEN}✔${RESET} Switched to ${BOLD}$icon $selected${RESET} ($count sounds)"
156
+
157
+ # Play preview sound
158
+ plugin_root="$(dirname "$CONFIG")"
159
+ CLAUDE_PLUGIN_ROOT="$plugin_root" bash "$plugin_root/scripts/play-sound.sh" session-start 2>/dev/null
74
160
  fi
75
161
  else
76
162
  pack="$2"
77
163
  if [[ -d "$SOUNDS_DIR/$pack" ]]; then
78
164
  write_config active_pack "\"$pack\""
79
- echo "Switched to: $pack"
165
+ icon=$(pack_icon "$pack")
166
+ count=$(find "$SOUNDS_DIR/$pack" -name "*.mp3" 2>/dev/null | wc -l | tr -d ' ')
167
+ echo -e "${GREEN}✔${RESET} Switched to ${BOLD}$icon $pack${RESET} ($count sounds)"
168
+ plugin_root="$(dirname "$CONFIG")"
169
+ CLAUDE_PLUGIN_ROOT="$plugin_root" bash "$plugin_root/scripts/play-sound.sh" session-start 2>/dev/null
80
170
  else
81
- echo "Pack '$pack' not found. Available:"
171
+ echo -e "${YELLOW}Pack '$pack' not found.${RESET} Available:"
82
172
  ls -1 "$SOUNDS_DIR"
83
173
  exit 1
84
174
  fi
@@ -87,62 +177,80 @@ case "${1:-help}" in
87
177
 
88
178
  list|ls|l)
89
179
  current=$(read_config active_pack warcraft)
90
- echo "Sound packs:"
180
+ echo ""
181
+ echo -e "${BOLD}🎮 Sound Packs${RESET}"
91
182
  echo ""
92
183
  for dir in "$SOUNDS_DIR"/*/; do
93
184
  pack=$(basename "$dir")
94
185
  count=$(find "$dir" -name "*.mp3" 2>/dev/null | wc -l | tr -d ' ')
95
- marker=""
96
- [[ "$pack" == "$current" ]] && marker=" *"
97
- echo " $pack ($count sounds)$marker"
186
+ icon=$(pack_icon "$pack")
187
+ if [[ "$pack" == "$current" ]]; then
188
+ echo -e " $icon ${BOLD}$pack${RESET} ${DIM}($count sounds)${RESET} ${GREEN}← active${RESET}"
189
+ else
190
+ echo -e " $icon ${DIM}$pack ($count sounds)${RESET}"
191
+ fi
98
192
  done
99
193
  echo ""
100
- echo "* = active pack"
101
194
  ;;
102
195
 
103
196
  volume|vol|v)
104
197
  if [[ -z "${2:-}" ]]; then
105
198
  vol=$(read_config volume 0.5)
106
- echo "Volume: $vol"
199
+ echo -e "🔊 Volume: ${BOLD}$vol${RESET}"
107
200
  else
108
201
  vol="$2"
109
202
  write_config volume "$vol"
110
- echo "Volume set to: $vol"
203
+ echo -e "${GREEN}✔${RESET} Volume set to ${BOLD}$vol${RESET}"
111
204
  fi
112
205
  ;;
113
206
 
114
207
  test|t)
115
208
  category="${2:-session-start}"
116
209
  plugin_root="$(dirname "$CONFIG")"
210
+ pack=$(read_config active_pack warcraft)
211
+ icon=$(pack_icon "$pack")
117
212
  CLAUDE_PLUGIN_ROOT="$plugin_root" bash "$plugin_root/scripts/play-sound.sh" "$category"
118
- echo "Played: $category"
213
+ echo -e "🔊 Playing ${BOLD}$category${RESET} from $icon $pack"
119
214
  ;;
120
215
 
121
216
  status|s)
122
217
  pack=$(read_config active_pack warcraft)
123
218
  vol=$(read_config volume 0.5)
124
219
  count=$(find "$SOUNDS_DIR/$pack" -name "*.mp3" 2>/dev/null | wc -l | tr -d ' ')
125
- echo "Pack: $pack ($count sounds)"
126
- echo "Volume: $vol"
220
+ icon=$(pack_icon "$pack")
221
+ echo ""
222
+ echo -e "${BOLD}🎮 Game Sounds${RESET}"
223
+ echo -e " Pack: $icon ${BOLD}$pack${RESET} ($count sounds)"
224
+ echo -e " Volume: 🔊 ${BOLD}$vol${RESET}"
225
+ echo ""
127
226
  ;;
128
227
 
129
- help|--help|-h|*)
130
- cat <<'HELP'
131
- game-sounds — manage Claude Code game sound packs
132
-
133
- Commands:
134
- switch [pack] Switch sound pack (interactive if no pack given)
135
- list List available packs
136
- volume [0.0-1.0] Get/set volume
137
- test [category] Play a test sound
138
- status Show current config
139
-
140
- Examples:
141
- game-sounds switch starcraft
142
- game-sounds switch # interactive picker
143
- game-sounds volume 0.3
144
- game-sounds test task-complete
145
- game-sounds list
146
- HELP
228
+ help|--help|-h)
229
+ echo ""
230
+ echo -e "${BOLD}🎮 game-sounds${RESET} — manage Claude Code game sound packs"
231
+ echo ""
232
+ echo -e " ${CYAN}switch${RESET} [pack] Interactive pack picker (or direct switch)"
233
+ echo -e " ${CYAN}list${RESET} List all available packs"
234
+ echo -e " ${CYAN}volume${RESET} [0.0-1.0] Get or set volume"
235
+ echo -e " ${CYAN}test${RESET} [category] Play a test sound"
236
+ echo -e " ${CYAN}status${RESET} Show current config"
237
+ echo ""
238
+ echo -e " ${DIM}game-sounds switch # arrow-key picker${RESET}"
239
+ echo -e " ${DIM}game-sounds switch starcraft # direct switch${RESET}"
240
+ echo -e " ${DIM}game-sounds volume 0.3 # quieter${RESET}"
241
+ echo -e " ${DIM}game-sounds test task-complete # preview a sound${RESET}"
242
+ echo ""
243
+ ;;
244
+
245
+ *)
246
+ # No args = show status + hint
247
+ pack=$(read_config active_pack warcraft)
248
+ vol=$(read_config volume 0.5)
249
+ count=$(find "$SOUNDS_DIR/$pack" -name "*.mp3" 2>/dev/null | wc -l | tr -d ' ')
250
+ icon=$(pack_icon "$pack")
251
+ echo ""
252
+ echo -e "${BOLD}🎮 Game Sounds${RESET} — $icon ${BOLD}$pack${RESET} ($count sounds) 🔊 $vol"
253
+ echo -e " ${DIM}Run${RESET} ${CYAN}game-sounds switch${RESET} ${DIM}to change pack${RESET}"
254
+ echo ""
147
255
  ;;
148
256
  esac