Files

Cursor Hooks 说明

结构

hooks/
├── run-hook.ps1           # Windows dispatcher读取 local-env.json 后分发)
├── session-init.ps1       # sessionStart hookPowerShell 版)
├── session-init.sh        # sessionStart hookbash 版)
├── check-changelog.ps1    # stop hookPowerShell 版)
├── check-changelog.sh     # stop hookbash 版)
└── README.md              # 本文件

跨平台适配

hooks.json 中的 command 字段是平台绑定的——Windows 用 powershellmacOS/Linux 用 bash

Windows当前

hooks.json 使用 powershell ... run-hook.ps1 作为入口dispatcher 根据 .cursor/local-env.jsonshell 字段决定执行 .ps1 还是 .sh 脚本。

迁移到 macOS / Linux

将 hooks.json 的 command 改为直接调用 .sh 脚本:

{
  "version": 1,
  "hooks": {
    "sessionStart": [{ "command": "bash .cursor/hooks/session-init.sh", "timeout": 5 }],
    "stop": [{ "command": "bash .cursor/hooks/check-changelog.sh", "timeout": 10, "loop_limit": 1 }]
  }
}

同时更新 .cursor/local-env.jsonshell 字段为 bashzsh