OpenWriterControle/plugins/claude-code/hooks/run-hook.cmd
Darren Hinde cdce9469c9
fix(plugin): add Windows hook wrapper, fix manifest check, remove bundled context (#243)
* fix(shellcheck): declare and assign separately in router.sh (SC2155)

* feat(plugin): enhance context management and skill invocation

- Update .context-manifest.json to include profile and detailed source information.
- Revise context-scout.md to clarify context root discovery and navigation.
- Modify commands to replace deprecated skills with updated ones (brainstorming → approach, systematic-debugging → debugger).
- Streamline install-context.md for clarity and remove interactive profile selection.
- Improve oac-status.md to provide a more comprehensive status report.
- Add OAC system paths to session-start.sh for better context management.
- Remove obsolete skills and improve documentation for existing commands.

* fix(plugin): fix hook JSON escaping and unconditional session firing

- Fix double-escaped skill catalogue: use $'\n' real newlines instead of
  literal \n strings so escape_for_json encodes them correctly as \n in JSON
- Fix OAC_SYSTEM_PATHS embedded raw into JSON string: build with real newlines
  and pass through escape_for_json before interpolation
- Remove SessionStart matcher so hook fires on every session start
  unconditionally (startup, resume, clear, compact and any future types)
- Remove redundant async:false field; add explicit timeout:30

* fix(plugin): add Windows hook wrapper, fix manifest check, remove bundled context

- Add run-hook.cmd polyglot wrapper for Windows compatibility — routes
  session-start through bash on Windows (Git Bash, MSYS2, Cygwin) and
  falls back silently if no bash found so plugin still loads
- Fix warning manifest check to look in correct locations: project-local
  .claude/.context-manifest.json and global ~/.claude/.context-manifest.json
  instead of the plugin root (which is never writable for marketplace users)
- Update warning message skill name: install-context -> context-setup
- Restore SessionStart matcher (startup|resume|clear|compact) for explicit
  session type filtering
- Remove bundled scripts/context/ tree (250+ files) — context is downloaded
  at runtime via /install-context, not shipped with the plugin
2026-02-23 14:19:29 +00:00

46 lines
No EOL
1.4 KiB
Batchfile
Executable file

: << 'CMDBLOCK'
@echo off
REM Cross-platform polyglot wrapper for hook scripts.
REM On Windows: cmd.exe runs the batch portion, which finds and calls bash.
REM On Unix: the shell interprets this as a script (: is a no-op in bash).
REM
REM Hook scripts use extensionless filenames (e.g. "session-start" not
REM "session-start.sh") so Claude Code's Windows auto-detection -- which
REM prepends "bash" to any command containing .sh -- doesn't interfere.
REM
REM Usage: run-hook.cmd <script-name> [args...]
if "%~1"=="" (
echo run-hook.cmd: missing script name >&2
exit /b 1
)
set "HOOK_DIR=%~dp0"
REM Try Git for Windows bash in standard locations
if exist "C:\Program Files\Git\bin\bash.exe" (
"C:\Program Files\Git\bin\bash.exe" "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9
exit /b %ERRORLEVEL%
)
if exist "C:\Program Files (x86)\Git\bin\bash.exe" (
"C:\Program Files (x86)\Git\bin\bash.exe" "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9
exit /b %ERRORLEVEL%
)
REM Try bash on PATH (e.g. user-installed Git Bash, MSYS2, Cygwin)
where bash >nul 2>nul
if %ERRORLEVEL% equ 0 (
bash "%HOOK_DIR%%~1" %2 %3 %4 %5 %6 %7 %8 %9
exit /b %ERRORLEVEL%
)
REM No bash found - exit silently rather than error
REM (plugin still works, just without SessionStart context injection)
exit /b 0
CMDBLOCK
# Unix: run the named script directly
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SCRIPT_NAME="$1"
shift
exec bash "${SCRIPT_DIR}/${SCRIPT_NAME}" "$@"