Skip to content

Commit 2595cc7

Browse files
authored
fix(agents): sound scripts exit silently on error conditions (#147)
1 parent 9140ef0 commit 2595cc7

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

src/agents/plugins/claude/plugin/sounds/play-random-sound.ps1

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@ $ErrorActionPreference = "Stop"
1313
# Expand environment variables in the path (e.g., %USERPROFILE%)
1414
$SoundDir = [System.Environment]::ExpandEnvironmentVariables($Directory)
1515

16-
# Check if directory exists
16+
# Check if directory exists - exit silently if not found
1717
if (-not (Test-Path -Path $SoundDir -PathType Container)) {
18-
Write-Error "Error: Directory not found: $SoundDir"
19-
exit 1
18+
exit 0
2019
}
2120

2221
# Find all audio files (WAV and MP3)
2322
$AudioFiles = Get-ChildItem -Path $SoundDir -File -Include *.wav,*.mp3 -ErrorAction SilentlyContinue
2423

2524
# Check if any audio files were found
2625
if ($AudioFiles.Count -eq 0) {
27-
Write-Error "Error: No WAV or MP3 files found in $SoundDir"
28-
exit 1
26+
exit 0
2927
}
3028

3129
# Select a random file
@@ -108,8 +106,7 @@ elseif (Play-WithSoundPlayer -FilePath $SelectedFile.FullName) {
108106
}
109107

110108
if (-not $played) {
111-
Write-Error "Error: No audio player found. Install mpg123 via Chocolatey: choco install mpg123"
112-
exit 1
109+
exit 0
113110
}
114111

115112
exit 0

src/agents/plugins/claude/plugin/sounds/play-random-sound.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ set -e
1010
if [ $# -eq 0 ]; then
1111
echo "Usage: $0 <directory>" >&2
1212
echo "Example: $0 ~/.codemie/claude-plugin/sounds/acolyte" >&2
13-
exit 1
13+
exit 0
1414
fi
1515

1616
# Expand tilde in the directory path
1717
SOUND_DIR="${1/#\~/$HOME}"
1818

19-
# Check if directory exists
19+
# Check if directory exists - exit silently if not found
2020
if [ ! -d "$SOUND_DIR" ]; then
21-
echo "Error: Directory not found: $SOUND_DIR" >&2
22-
exit 1
21+
exit 0
2322
fi
2423

2524
# Find all audio files and store in array (compatible way)
@@ -31,7 +30,7 @@ done < <(find "$SOUND_DIR" -maxdepth 1 -type f \( -iname "*.wav" -o -iname "*.mp
3130
# Check if any audio files were found
3231
if [ ${#WAV_FILES[@]} -eq 0 ]; then
3332
echo "Error: No WAV or MP3 files found in $SOUND_DIR" >&2
34-
exit 1
33+
exit 0
3534
fi
3635

3736
# Select a random file
@@ -53,7 +52,7 @@ elif command -v mpg123 &> /dev/null; then
5352
mpg123 -q "$SELECTED_FILE" &
5453
else
5554
echo "Error: No audio player found. Install afplay (macOS), aplay, paplay, or mpg123" >&2
56-
exit 1
55+
exit 0
5756
fi
5857

5958
exit 0

0 commit comments

Comments
 (0)