1 Commits

  • fix(hooks): rewrite patch_settings_cl_v2_simple.ps1 to avoid argv-dup bug
    - Use PATH-resolved `bash` as first token instead of quoted `.exe` path
      so Claude Code v2.1.116 argv duplication does not feed a binary to
      bash as its $0 (repro: exit 126 "cannot execute binary file").
    - Point the command at `observe-wrapper.sh` and pass distinct `pre` /
      `post` positional arguments so PreToolUse and PostToolUse are
      registered as separate entries.
    - Normalize the wrapper path to forward slashes before embedding in the
      hook command to avoid MSYS backslash surprises.
    - Write UTF-8 (no BOM) with CRLF normalized to LF so downstream JSON
      parsers never see mixed line endings.
    - Preserve existing hooks (legacy `observe.sh`, third-party entries)
      by appending only when the canonical command string is not already
      registered. Re-runs are idempotent ([SKIP] both phases).
    - Keep the script compatible with Windows PowerShell 5.1: fall back to
      a manual PSCustomObject → Hashtable conversion when
      `ConvertFrom-Json -AsHashtable` is unavailable, and materialize hook
      arrays as `System.Collections.ArrayList` so single-element arrays
      survive PS 5.1 `ConvertTo-Json` serialization.
    
    Companion to PR #1524 (settings.local.json shape fix) and PR #1540
    (install_hook_wrapper.ps1 argv-dup fix).