groove-admin-cursor-hooks

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- groove:managed — do not edit; changes will be overwritten by groove update -->
<!-- groove:managed — do not edit; changes will be overwritten by groove update -->

groove-admin-cursor-hooks

groove-admin-cursor-hooks

Install groove's Cursor native hooks. These run outside the model — deterministic, unconditional — and complement groove's advisory markdown hooks (
.groove/hooks/start.md
,
end.md
).
Use
--disable <hook>
to remove a specific hook. Use
--list
to show current status.
安装groove的Cursor原生钩子。这些钩子在模型外部运行——具有确定性、无条件性——是对groove的建议性Markdown钩子(
.groove/hooks/start.md
end.md
)的补充。
使用
--disable <hook>
移除特定钩子。使用
--list
查看当前状态。

Outcome

执行结果

Selected hooks are registered in
.cursor/hooks.json
and shell scripts are written to
.groove/hooks/cursor/
. Hooks fire automatically on Cursor lifecycle events without any model involvement.
选中的钩子将注册到
.cursor/hooks.json
中,同时Shell脚本会写入到
.groove/hooks/cursor/
目录。钩子会在Cursor生命周期事件触发时自动运行,无需模型参与。

Available hooks

可用钩子

NameEventMatcherWhat it does
context-reprime
sessionStart
Runs the prime script with
--json
— ensures full workflow context is loaded after every session start and compaction
daily-end-reminder
stop
If hour is 16–21 local time and
.groove/index.md
exists, prints a reminder to run
/groove-daily-end
git-activity-buffer
postToolUse
Shell
If the command contains
git commit
, appends a timestamped line to
.groove/.cache/git-activity-buffer.txt
block-managed-paths
preToolUse
Write
If
file_path
starts with
.agents/skills/groove
or
skills/groove
, exits with code 2 to block the write with an explanatory message
version-check
postToolUse
Checks for a new groove version once per hour; calls
groove-utilities-check
名称事件匹配器功能
context-reprime
sessionStart
运行带有
--json
参数的初始化脚本——确保每次会话启动和压缩后加载完整的工作流上下文
daily-end-reminder
stop
如果当地时间为16-21点且存在
.groove/index.md
,则打印提醒以运行
/groove-daily-end
git-activity-buffer
postToolUse
Shell
如果命令包含
git commit
,则向
.groove/.cache/git-activity-buffer.txt
追加带时间戳的行
block-managed-paths
preToolUse
Write
如果
file_path
.agents/skills/groove
skills/groove
开头,则以代码2退出,阻止写入并显示说明消息
version-check
postToolUse
每小时检查一次groove的新版本;调用
groove-utilities-check

Steps

操作步骤

--list

--list

Read
.cursor/hooks.json
if it exists. Report which groove hooks are registered and which scripts exist in
.groove/hooks/cursor/
. Exit.
如果
.cursor/hooks.json
存在则读取该文件。报告已注册的groove钩子以及
.groove/hooks/cursor/
目录中存在的脚本。然后退出。

--disable <hook>

--disable <hook>

Remove the named hook's entry from
.cursor/hooks.json
(leave the script in place). Report removed / not found. Exit.
.cursor/hooks.json
中移除指定钩子的条目(保留脚本文件)。报告移除结果/未找到。然后退出。

Default (install)

默认操作(安装)

  1. Ask which hooks to enable (default: all five):
    Which hooks to install? (all / comma-separated: context-reprime, daily-end-reminder, git-activity-buffer, block-managed-paths, version-check)
    Press enter for all.
  2. Read
    .cursor/hooks.json
    if it exists; parse as JSON (default
    {"version": 1, "hooks": {}}
    ). Never discard existing non-groove entries.
  3. Create
    .groove/hooks/cursor/
    directory if absent. Make each script executable (
    chmod +x
    ).
  4. For each selected hook: write the shell script and merge the hook entry into
    .cursor/hooks.json
    .
  5. Write
    .cursor/hooks.json
    with the merged result.
  6. Report summary:
    ✓ context-reprime     — sessionStart hook → groove-utilities-prime.sh --json
    ✓ daily-end-reminder  — stop hook → .groove/hooks/cursor/daily-end-reminder.sh
    ✓ git-activity-buffer — postToolUse/Shell hook → .groove/hooks/cursor/git-activity-buffer.sh
    ✓ block-managed-paths — preToolUse/Write hook → .groove/hooks/cursor/block-managed-paths.sh
    ✓ version-check       — postToolUse hook → .groove/hooks/cursor/version-check.sh
    ✓ .cursor/hooks.json updated
  1. 询问要启用哪些钩子(默认:全部五个):
    Which hooks to install? (all / comma-separated: context-reprime, daily-end-reminder, git-activity-buffer, block-managed-paths, version-check)
    Press enter for all.
  2. 如果
    .cursor/hooks.json
    存在则读取该文件;解析为JSON(默认值
    {"version": 1, "hooks": {}}
    )。绝不丢弃现有非groove条目。
  3. 如果
    .groove/hooks/cursor/
    目录不存在则创建该目录。设置每个脚本为可执行权限(
    chmod +x
    )。
  4. 对于每个选中的钩子:写入Shell脚本并将钩子条目合并到
    .cursor/hooks.json
    中。
  5. 将合并后的结果写入
    .cursor/hooks.json
  6. 报告摘要:
    ✓ context-reprime     — sessionStart hook → groove-utilities-prime.sh --json
    ✓ daily-end-reminder  — stop hook → .groove/hooks/cursor/daily-end-reminder.sh
    ✓ git-activity-buffer — postToolUse/Shell hook → .groove/hooks/cursor/git-activity-buffer.sh
    ✓ block-managed-paths — preToolUse/Write hook → .groove/hooks/cursor/block-managed-paths.sh
    ✓ version-check       — postToolUse hook → .groove/hooks/cursor/version-check.sh
    ✓ .cursor/hooks.json updated

Shell script templates

Shell脚本模板

Write these verbatim to
.groove/hooks/cursor/
. Never overwrite an existing script without showing a diff and confirming.
将这些内容原封不动写入
.groove/hooks/cursor/
目录。未经显示差异并确认,绝不覆盖现有脚本。

daily-end-reminder.sh

daily-end-reminder.sh

bash
#!/usr/bin/env bash
bash
#!/usr/bin/env bash

groove: stop hook — remind about /groove-daily-end during work hours

groove: stop hook — remind about /groove-daily-end during work hours

hour=$(date +%H) if [ -f ".groove/index.md" ] && [ "$hour" -ge 16 ] && [ "$hour" -le 21 ]; then echo "groove: end of work hours — consider running /groove-daily-end" fi
undefined
hour=$(date +%H) if [ -f ".groove/index.md" ] && [ "$hour" -ge 16 ] && [ "$hour" -le 21 ]; then echo "groove: end of work hours — consider running /groove-daily-end" fi
undefined

git-activity-buffer.sh

git-activity-buffer.sh

bash
#!/usr/bin/env bash
bash
#!/usr/bin/env bash

groove: postToolUse/Shell hook — buffer git commits for memory log

groove: postToolUse/Shell hook — buffer git commits for memory log

input=$(cat) command=$(echo "$input" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('tool_input',{}).get('command',''))" 2>/dev/null) if echo "$command" | grep -q "git commit"; then msg=$(echo "$command" | grep -oP '(?<=-m ")[^"]+' | head -1) mkdir -p .groove/.cache echo "$(date '+%Y-%m-%d %H:%M') | ${msg:-<no message>}" >> .groove/.cache/git-activity-buffer.txt fi
undefined
input=$(cat) command=$(echo "$input" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('tool_input',{}).get('command',''))" 2>/dev/null) if echo "$command" | grep -q "git commit"; then msg=$(echo "$command" | grep -oP '(?<=-m ")[^"]+' | head -1) mkdir -p .groove/.cache echo "$(date '+%Y-%m-%d %H:%M') | ${msg:-<no message>}" >> .groove/.cache/git-activity-buffer.txt fi
undefined

block-managed-paths.sh

block-managed-paths.sh

bash
#!/usr/bin/env bash
bash
#!/usr/bin/env bash

groove: preToolUse/Write hook — block edits to managed groove paths

groove: preToolUse/Write hook — block edits to managed groove paths

input=$(cat) path=$(echo "$input" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('tool_input',{}).get('file_path',''))" 2>/dev/null) if echo "$path" | grep -qE '^(.agents/skills/groove|skills/groove)'; then echo "groove: blocked — '$path' is managed by groove update. Edit under skills/ and rsync to .agents/skills/." >&2 exit 2 fi
undefined
input=$(cat) path=$(echo "$input" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('tool_input',{}).get('file_path',''))" 2>/dev/null) if echo "$path" | grep -qE '^(.agents/skills/groove|skills/groove)'; then echo "groove: blocked — '$path' is managed by groove update. Edit under skills/ and rsync to .agents/skills/." >&2 exit 2 fi
undefined

version-check.sh

version-check.sh

bash
#!/usr/bin/env bash
bash
#!/usr/bin/env bash

groove: postToolUse hook — check for new groove version (once per hour)

groove: postToolUse hook — check for new groove version (once per hour)

CACHE=".groove/.cache/last-version-check-ts" mkdir -p .groove/.cache now=$(date +%s) if [ -f "$CACHE" ]; then last=$(cat "$CACHE") diff=$((now - last)) [ "$diff" -lt 3600 ] && exit 0 fi echo "$now" > "$CACHE" bash .agents/skills/groove-utilities-check/scripts/check.sh 2>/dev/null || true
undefined
CACHE=".groove/.cache/last-version-check-ts" mkdir -p .groove/.cache now=$(date +%s) if [ -f "$CACHE" ]; then last=$(cat "$CACHE") diff=$((now - last)) [ "$diff" -lt 3600 ] && exit 0 fi echo "$now" > "$CACHE" bash .agents/skills/groove-utilities-check/scripts/check.sh 2>/dev/null || true
undefined

.cursor/hooks.json
template

.cursor/hooks.json
模板

Merge these into the
hooks
key. Preserve all other keys.
json
{
  "version": 1,
  "hooks": {
    "sessionStart": [
      {
        "command": "bash .agents/skills/groove-utilities-prime/scripts/groove-utilities-prime.sh --json"
      }
    ],
    "stop": [
      {
        "command": "bash .groove/hooks/cursor/daily-end-reminder.sh"
      }
    ],
    "postToolUse": [
      {
        "matcher": "Shell",
        "command": "bash .groove/hooks/cursor/git-activity-buffer.sh"
      },
      {
        "command": "bash .groove/hooks/cursor/version-check.sh"
      }
    ],
    "preToolUse": [
      {
        "matcher": "Write",
        "command": "bash .groove/hooks/cursor/block-managed-paths.sh"
      }
    ]
  }
}
When merging: if a
hooks
key already exists, append groove entries to the relevant event arrays. Do not create duplicates — check if a groove command entry already exists before appending.
将这些内容合并到
hooks
键中。保留所有其他键。
json
{
  "version": 1,
  "hooks": {
    "sessionStart": [
      {
        "command": "bash .agents/skills/groove-utilities-prime/scripts/groove-utilities-prime.sh --json"
      }
    ],
    "stop": [
      {
        "command": "bash .groove/hooks/cursor/daily-end-reminder.sh"
      }
    ],
    "postToolUse": [
      {
        "matcher": "Shell",
        "command": "bash .groove/hooks/cursor/git-activity-buffer.sh"
      },
      {
        "command": "bash .groove/hooks/cursor/version-check.sh"
      }
    ],
    "preToolUse": [
      {
        "matcher": "Write",
        "command": "bash .groove/hooks/cursor/block-managed-paths.sh"
      }
    ]
  }
}
合并时:如果
hooks
键已存在,则将groove条目追加到相关事件数组中。不要创建重复项——追加前检查groove命令条目是否已存在。

Constraints

约束条件

  • Never overwrite non-groove entries in
    .cursor/hooks.json
  • Never overwrite an existing script without diff + confirmation
  • Scripts use
    python3
    to parse JSON stdin — if python3 is absent, skip that hook and warn
  • block-managed-paths
    uses exit code 2 (Cursor's convention to block the tool use)
  • After install: remind the user that hooks take effect on the next Cursor session restart
  • .groove/hooks/cursor/
    follows the
    git.hooks
    git strategy from
    .groove/index.md
  • Create
    .cursor/
    directory if it does not exist
  • 绝不覆盖
    .cursor/hooks.json
    中的非groove条目
  • 未经差异对比+确认,绝不覆盖现有脚本
  • 脚本使用
    python3
    解析JSON标准输入——如果python3不存在,则跳过该钩子并发出警告
  • block-managed-paths
    使用退出代码2(Cursor阻止工具使用的约定)
  • 安装完成后:提醒用户钩子将在下次Cursor会话重启后生效
  • .groove/hooks/cursor/
    遵循
    .groove/index.md
    中的
    git.hooks
    git策略
  • 如果
    .cursor/
    目录不存在则创建该目录