@@ -453,18 +453,48 @@ def test_run_hook_dispatches_post_tool_use() -> None:
453453 assert "additional_context" in out
454454
455455
456- def test_hooks_json_use_python_launcher_not_python3 () -> None :
456+ def _assert_hook_commands_avoid_python3 (payload : dict [str , object ]) -> None :
457+ hooks = payload ["hooks" ]
458+ assert isinstance (hooks , dict )
459+ for entries in hooks .values ():
460+ assert isinstance (entries , list )
461+ for entry in entries :
462+ assert isinstance (entry , dict )
463+ cmd = str (entry ["command" ])
464+ first = cmd .split ()[0 ].strip ('"' )
465+ assert first not in {"python3" , "python3.exe" }, cmd
466+ assert "run_hook.py" in cmd
467+
468+
469+ def test_plugin_hooks_json_use_python_launcher_not_python3 () -> None :
470+ """Plugin manifest hooks.json — not repo .cursor/hooks.json (local, gitignored)."""
457471 hooks_json = json .loads ((_HOOKS_DIR / "hooks.json" ).read_text (encoding = "utf-8" ))
472+ _assert_hook_commands_avoid_python3 (hooks_json )
473+
474+
475+ def test_install_project_hooks_writes_launcher_commands (tmp_path : Path ) -> None :
476+ """Project hooks are generated by install-project-hooks.py, not committed."""
477+ install_script = (
478+ _REPO_ROOT
479+ / "plugins"
480+ / "cursor-codeclone"
481+ / "scripts"
482+ / ("install-project-hooks.py" )
483+ )
484+ result = subprocess .run (
485+ [sys .executable , str (install_script ), str (tmp_path )],
486+ capture_output = True ,
487+ text = True ,
488+ timeout = 10 ,
489+ )
490+ assert result .returncode == 0 , result .stderr
458491 project_hooks = json .loads (
459- (_REPO_ROOT / ".cursor" / "hooks.json" ).read_text (encoding = "utf-8" )
460- )
461- for payload in (hooks_json , project_hooks ):
462- for entries in payload ["hooks" ].values ():
463- for entry in entries :
464- cmd = entry ["command" ]
465- first = cmd .split ()[0 ].strip ('"' )
466- assert first not in {"python3" , "python3.exe" }, cmd
467- assert "run_hook.py" in cmd
492+ (tmp_path / ".cursor" / "hooks.json" ).read_text (encoding = "utf-8" )
493+ )
494+ _assert_hook_commands_avoid_python3 (project_hooks )
495+ pre_cmd = project_hooks ["hooks" ]["preToolUse" ][0 ]["command" ]
496+ assert "pre-tool-use-gate" in pre_cmd
497+ assert "run_hook.py" in pre_cmd
468498
469499
470500def test_hooks_no_bash_scripts_remain () -> None :
0 commit comments