diff --git a/.gitignore b/.gitignore index 271a104..154e127 100644 --- a/.gitignore +++ b/.gitignore @@ -475,9 +475,3 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk - -# 引导脚本要进库(notify.exe 等仍被上面的 [Bb]in/ 忽略) -!/bin/ -/bin/* -!/bin/notify.cmd -!/bin/notify.sh diff --git a/hooks/hooks.json b/hooks/hooks.json index 44d2f26..4511ca6 100644 --- a/hooks/hooks.json +++ b/hooks/hooks.json @@ -6,7 +6,7 @@ "hooks": [ { "type": "command", - "command": "${CLAUDE_PLUGIN_ROOT}/bin/notify.cmd save", + "command": "${CLAUDE_PLUGIN_ROOT}/scripts/notify.cmd save", "timeout": 30 } ] @@ -18,7 +18,7 @@ "hooks": [ { "type": "command", - "command": "${CLAUDE_PLUGIN_ROOT}/bin/notify.cmd input", + "command": "${CLAUDE_PLUGIN_ROOT}/scripts/notify.cmd input", "timeout": 30 } ] @@ -30,7 +30,7 @@ "hooks": [ { "type": "command", - "command": "${CLAUDE_PLUGIN_ROOT}/bin/notify.cmd input", + "command": "${CLAUDE_PLUGIN_ROOT}/scripts/notify.cmd input", "timeout": 30 } ] @@ -42,7 +42,7 @@ "hooks": [ { "type": "command", - "command": "${CLAUDE_PLUGIN_ROOT}/bin/notify.cmd notify", + "command": "${CLAUDE_PLUGIN_ROOT}/scripts/notify.cmd notify", "timeout": 30 } ] @@ -54,7 +54,7 @@ "hooks": [ { "type": "command", - "command": "${CLAUDE_PLUGIN_ROOT}/bin/notify.cmd cleanup", + "command": "${CLAUDE_PLUGIN_ROOT}/scripts/notify.cmd cleanup", "timeout": 10 } ] diff --git a/bin/notify.cmd b/scripts/notify.cmd similarity index 88% rename from bin/notify.cmd rename to scripts/notify.cmd index 7bfbcc8..e73dcdb 100644 --- a/bin/notify.cmd +++ b/scripts/notify.cmd @@ -4,8 +4,9 @@ rem Download URL (notify.exe is fetched from here on first run) -- edit as need set "DOWNLOAD_URL=https://github.com/OWNER/REPO/releases/latest/download/notify.exe" rem ============================================================ setlocal -set "EXE=%~dp0notify.exe" -set "LOCK=%~dp0notify.download.lock" +set "BIN=%~dp0..\bin" +set "EXE=%BIN%\notify.exe" +set "LOCK=%BIN%\notify.download.lock" rem only bootstrap on first run; the common path runs the exe directly (keeps piped stdin intact) if not exist "%EXE%" call :bootstrap @@ -15,7 +16,8 @@ endlocal exit /b :bootstrap -set "TMP=%~dp0notify.exe.%RANDOM%.tmp" +if not exist "%BIN%" mkdir "%BIN%" 2>nul +set "TMP=%BIN%\notify.exe.%RANDOM%.tmp" rem mkdir is atomic; success = this process downloads, failure = someone else is downloading mkdir "%LOCK%" 2>nul if errorlevel 1 goto :waitdl diff --git a/bin/notify.sh b/scripts/notify.sh similarity index 89% rename from bin/notify.sh rename to scripts/notify.sh index b52bb32..1e78318 100644 --- a/bin/notify.sh +++ b/scripts/notify.sh @@ -5,15 +5,17 @@ DOWNLOAD_URL="https://github.com/OWNER/REPO/releases/latest/download/notify.exe" # ============================================================ DIR="$(cd "$(dirname "$0")" && pwd)" -EXE="$DIR/notify.exe" -LOCK="$DIR/notify.download.lock" +BIN="$DIR/../bin" +EXE="$BIN/notify.exe" +LOCK="$BIN/notify.download.lock" if [ ! -f "$EXE" ]; then + mkdir -p "$BIN" 2>/dev/null # mkdir 是原子操作,用作锁:成功=本进程负责下载,失败=已有进程在下 if mkdir "$LOCK" 2>/dev/null; then # 双重检查,避免刚好别人下完 if [ ! -f "$EXE" ]; then - TMP="$DIR/notify.exe.$$.tmp" + TMP="$BIN/notify.exe.$$.tmp" if curl -fsSL "$DOWNLOAD_URL" -o "$TMP"; then mv -f "$TMP" "$EXE" # 原子改名,避免半截 exe chmod +x "$EXE" 2>/dev/null