Install the graphify skill and CODEBUDDY.md section for CodeBuddy.
(project_dir: Path | None = None)
| 2660 | print(f"{target.name} was empty after removal - deleted {target.resolve()}") |
| 2661 | return True |
| 2662 | def codebuddy_install(project_dir: Path | None = None) -> None: |
| 2663 | """Install the graphify skill and CODEBUDDY.md section for CodeBuddy.""" |
| 2664 | _copy_skill_file("codebuddy", project=bool(project_dir), project_dir=project_dir) |
| 2665 | target = (project_dir or Path(".")) / "CODEBUDDY.md" |
| 2666 | |
| 2667 | if target.exists(): |
| 2668 | content, newline = _read_keep_newline(target) |
| 2669 | new_content = _replace_or_append_section( |
| 2670 | content, _CODEBUDDY_MD_MARKER, _always_on("claude-md") |
| 2671 | ) |
| 2672 | else: |
| 2673 | content, newline = "", "\n" |
| 2674 | new_content = _always_on("claude-md") |
| 2675 | |
| 2676 | if target.exists() and new_content == content: |
| 2677 | print(f"graphify already configured in {target.resolve()} (no change)") |
| 2678 | else: |
| 2679 | _write_keep_newline(target, new_content, newline) |
| 2680 | print(f"graphify section written to {target.resolve()}") |
| 2681 | |
| 2682 | # Also write CodeBuddy PreToolUse hook to .codebuddy/settings.json |
| 2683 | _install_codebuddy_hook(project_dir or Path(".")) |
| 2684 | |
| 2685 | print() |
| 2686 | print("CodeBuddy will now check the knowledge graph before answering") |
| 2687 | print("codebase questions and rebuild it after code changes.") |
| 2688 | def _install_codebuddy_hook(project_dir: Path) -> None: |
| 2689 | """Add graphify PreToolUse hook to .codebuddy/settings.json.""" |
| 2690 | settings_path = project_dir / ".codebuddy" / "settings.json" |