MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _install_codebuddy_hook

Function _install_codebuddy_hook

graphify/install.py:2688–2705  ·  view source on GitHub ↗

Add graphify PreToolUse hook to .codebuddy/settings.json.

(project_dir: Path)

Source from the content-addressed store, hash-verified

2686 print("CodeBuddy will now check the knowledge graph before answering")
2687 print("codebase questions and rebuild it after code changes.")
2688def _install_codebuddy_hook(project_dir: Path) -> None:
2689 """Add graphify PreToolUse hook to .codebuddy/settings.json."""
2690 settings_path = project_dir / ".codebuddy" / "settings.json"
2691 settings_path.parent.mkdir(parents=True, exist_ok=True)
2692
2693 settings = _read_settings_for_merge(settings_path)
2694
2695 hooks = settings.setdefault("hooks", {})
2696 if not isinstance(hooks, dict):
2697 _refuse_to_modify(settings_path)
2698 pre_tool = hooks.setdefault("PreToolUse", [])
2699 if not isinstance(pre_tool, list):
2700 _refuse_to_modify(settings_path)
2701
2702 hooks["PreToolUse"] = _strip_graphify_hooks(pre_tool)
2703 hooks["PreToolUse"].extend(_claude_pretooluse_hooks())
2704 _write_settings_with_backup(settings_path, settings)
2705 print(f" .codebuddy/settings.json -> PreToolUse hooks registered")
2706def _uninstall_codebuddy_hook(project_dir: Path) -> None:
2707 """Remove graphify PreToolUse hook from .codebuddy/settings.json."""
2708 settings_path = project_dir / ".codebuddy" / "settings.json"

Callers 1

codebuddy_installFunction · 0.85

Calls 5

_read_settings_for_mergeFunction · 0.85
_refuse_to_modifyFunction · 0.85
_strip_graphify_hooksFunction · 0.85
_claude_pretooluse_hooksFunction · 0.85

Tested by

no test coverage detected