From 90c84f332f75af8085ffee799bf3f44d61ca6111 Mon Sep 17 00:00:00 2001 From: chuan Date: Mon, 22 Jun 2026 17:39:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=BC=95=E5=AF=BC=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E7=A7=BB=E5=88=B0=20scripts/=EF=BC=8Cbin/=20=E4=BB=85?= =?UTF-8?q?=E6=94=BE=E8=BF=90=E8=A1=8C=E6=97=B6=E4=BA=8C=E8=BF=9B=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - scripts/notify.cmd、scripts/notify.sh:下载目标改为同级 ../bin/notify.exe,首次创建 bin/ - hooks.json 指向 scripts/notify.cmd - bin/ 恢复完全忽略(不再需要脚本例外) --- .gitignore | 6 ------ hooks/hooks.json | 10 +++++----- {bin => scripts}/notify.cmd | 8 +++++--- {bin => scripts}/notify.sh | 8 +++++--- 4 files changed, 15 insertions(+), 17 deletions(-) rename {bin => scripts}/notify.cmd (88%) rename {bin => scripts}/notify.sh (89%) 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