refactor: 引导脚本移到 scripts/,bin/ 仅放运行时二进制

- scripts/notify.cmd、scripts/notify.sh:下载目标改为同级 ../bin/notify.exe,首次创建 bin/
- hooks.json 指向 scripts/notify.cmd
- bin/ 恢复完全忽略(不再需要脚本例外)
This commit is contained in:
2026-06-22 17:39:33 +08:00
Unverified
parent 0de6fe4064
commit 90c84f332f
4 changed files with 15 additions and 17 deletions
-6
View File
@@ -475,9 +475,3 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk
# 引导脚本要进库(notify.exe 等仍被上面的 [Bb]in/ 忽略)
!/bin/
/bin/*
!/bin/notify.cmd
!/bin/notify.sh
+5 -5
View File
@@ -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
}
]
+5 -3
View File
@@ -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
+5 -3
View File
@@ -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