Remove the graphify skill tree (SKILL.md + references/) and the CODEBUDDY.md section. Scope rules (#2215): a bare call removes the user-global skill; passing ``project_dir`` (or ``project=True``) scopes skill removal to that project and leaves the global tree untouched, unless ``remove_
(project_dir: Path | None = None, *, project: bool = False, remove_user_skill: bool | None = None)
| 2722 | _write_settings_with_backup(settings_path, settings) |
| 2723 | print(f" .codebuddy/settings.json -> PreToolUse hook removed") |
| 2724 | def codebuddy_uninstall(project_dir: Path | None = None, *, project: bool = False, remove_user_skill: bool | None = None) -> None: |
| 2725 | """Remove the graphify skill tree (SKILL.md + references/) and the CODEBUDDY.md section. |
| 2726 | |
| 2727 | Scope rules (#2215): a bare call removes the user-global skill; passing |
| 2728 | ``project_dir`` (or ``project=True``) scopes skill removal to that project |
| 2729 | and leaves the global tree untouched, unless ``remove_user_skill=True`` |
| 2730 | explicitly opts back into the global delete (as ``uninstall_all`` does). |
| 2731 | """ |
| 2732 | explicit_dir = project_dir is not None |
| 2733 | project_dir = project_dir or Path(".") |
| 2734 | if remove_user_skill is None: |
| 2735 | remove_user_skill = not project and not explicit_dir |
| 2736 | if project or (explicit_dir and not remove_user_skill): |
| 2737 | _remove_skill_file("codebuddy", project=True, project_dir=project_dir) |
| 2738 | if remove_user_skill: |
| 2739 | _remove_skill_file("codebuddy", project=False) |
| 2740 | # Before the project-file checks below, which return early. |
| 2741 | _remove_skill_registration( |
| 2742 | _codebuddy_global_registration(), " CODEBUDDY.md -> ", only_graphify_written=True |
| 2743 | ) |
| 2744 | target = project_dir / "CODEBUDDY.md" |
| 2745 | |
| 2746 | if not target.exists(): |
| 2747 | print("No CODEBUDDY.md found in current directory - nothing to do") |
| 2748 | return |
| 2749 | |
| 2750 | content, newline = _read_keep_newline(target) |
| 2751 | cleaned = _remove_marker_section(content, _CODEBUDDY_MD_MARKER) |
| 2752 | if cleaned is None: |
| 2753 | print("graphify section not found in CODEBUDDY.md - nothing to do") |
| 2754 | return |
| 2755 | |
| 2756 | # A symlink stays: writing through it cleans the file it points to. |
| 2757 | if cleaned or target.is_symlink(): |
| 2758 | _write_keep_newline(target, cleaned + "\n", newline) |
| 2759 | print(f"graphify section removed from {target.resolve()}") |
| 2760 | else: |
| 2761 | target.unlink() |
| 2762 | print(f"CODEBUDDY.md was empty after removal - deleted {target.resolve()}") |
| 2763 | |
| 2764 | _uninstall_codebuddy_hook(project_dir or Path(".")) |
| 2765 | |
| 2766 | |
| 2767 | _CLI_INSTALL_COMMANDS = frozenset({ |