uninstall

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: MIT Imports: 11 Imported by: 0

README

Uninstall Package

This package provides functionality for cleanly removing SageOx from repositories and user environments.

Components

Repository-Level Uninstall
  • sageox_dir.go - Handles removal of .sageox/ directory and its contents
  • hooks.go - Manages removal of SageOx git hooks from .git/hooks/
User-Level Uninstall
  • user_integrations.go - Handles removal of user-level SageOx integrations

User Integration Removal

The user integrations removal system finds and removes SageOx hooks and plugins from user-level configuration, affecting only the current user's agent setup.

Supported Integrations

The system detects and removes SageOx integrations from:

  1. Claude Code

    • Hooks in ~/.claude/settings.json (SessionStart, PreCompact)
    • User-level config in ~/.claude/CLAUDE.md
  2. OpenCode

    • Plugin at ~/.config/opencode/plugin/ox-prime.ts
  3. Gemini CLI

    • Hooks in ~/.gemini/settings.json
  4. User Git Hooks

    • SageOx hooks in ~/.config/git/hooks/ (XDG-compliant)
Usage
import "github.com/sageox/ox/internal/uninstall"

// Create finder
finder, err := uninstall.NewUserIntegrationsFinder()
if err != nil {
    return err
}

// Find all user-level integrations
items, err := finder.FindAll()
if err != nil {
    return err
}

// Remove integrations (dryRun=false for actual removal)
err = uninstall.RemoveUserIntegrations(items, false)
Platform Support

The implementation follows XDG Base Directory specification and works across:

  • macOS (using ~/.config/ for consistency)
  • Linux (XDG-compliant paths)
  • Windows (respects XDG_CONFIG_HOME if set)
Hook Removal Behavior

For settings files (Claude, Gemini):

  • Edits the JSON file to remove only SageOx hooks
  • Preserves other hooks and user content
  • Removes empty hook event sections after cleanup

For plugin files (OpenCode):

  • Removes the entire plugin file/directory
  • Only removes if it matches SageOx plugin signature
Safety Features
  1. Detection: Only removes items confirmed to contain SageOx references
  2. Dry Run: Preview mode to show what would be removed
  3. Confirmation: Separate confirmation required for user integrations
  4. Scope Warning: Clearly indicates this only affects current user
  5. Granular: Edits settings files rather than deleting them
  6. Logging: Comprehensive slog logging for troubleshooting
Command Integration

The ox uninstall --user-integrations flag enables user integration removal:

# Preview user integrations that would be removed
ox uninstall --user-integrations --dry-run

# Remove user integrations (with confirmation)
ox uninstall --user-integrations

# Non-interactive removal
ox uninstall --user-integrations --force
User Config Directory

The system intentionally does NOT remove ~/.config/sageox/ by default. This directory contains:

  • User preferences (tips enabled/disabled)
  • Telemetry settings
  • Attribution data

Users are shown a message suggesting manual removal if desired.

Testing

All components have comprehensive test coverage:

# Run all uninstall tests
go test ./internal/uninstall/

# Run user integrations tests only
go test ./internal/uninstall/ -run "TestIsOxPrimeCommand|TestContainsOxPrime|TestFind.*|TestRemoveUserIntegrations"

Design Principles

  1. Conservative: Never delete more than necessary
  2. Transparent: Show exactly what will be removed
  3. Reversible: Allow dry-run previews
  4. Safe: Multiple confirmation layers
  5. Informative: Clear messaging about scope and impact
  6. Cross-platform: XDG-compliant with platform awareness

Documentation

Overview

Package uninstall provides functionality for removing SageOx from repositories.

The package handles the complete uninstall process including:

  • Finding and removing the .sageox directory
  • Cleaning up git hooks installed by SageOx
  • Removing agent integration files (AGENTS.md, CLAUDE.md, etc.)
  • Optionally removing user-level integrations

The uninstall process uses git commands to properly handle tracked files and ensures user content is preserved when cleaning up shared files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPlatformInfo

func GetPlatformInfo() string

GetPlatformInfo returns platform-specific information for display

func RemoveRepoHooks

func RemoveRepoHooks(repoRoot string, dryRun bool) error

RemoveRepoHooks removes SageOx hooks from .git/hooks/ If dryRun is true, only reports what would be removed without making changes Returns error if any removal fails

func RemoveSageoxDir

func RemoveSageoxDir(repoRoot string, dryRun bool) error

RemoveSageoxDir removes the .sageox directory from the repository Uses 'git rm -r' for tracked files and os.RemoveAll for untracked files If dryRun is true, only logs what would be done without making changes

func RemoveUserIntegrations

func RemoveUserIntegrations(items []UserIntegrationItem, dryRun bool) error

RemoveUserIntegrations removes user-level SageOx integrations dryRun: if true, only shows what would be removed without actually removing

func ShouldRemoveUserConfig

func ShouldRemoveUserConfig() bool

ShouldRemoveUserConfig determines if user config should be removed This is intentionally conservative - we only suggest it, never do it automatically

Types

type GitHookItem

type GitHookItem struct {
	Path        string // full path to hook file
	Name        string // hook name (e.g., "pre-commit")
	HasMixed    bool   // true if hook contains both SageOx and non-SageOx content
	IsEntireSox bool   // true if entire file is SageOx content
}

GitHookItem represents a git hook that can be removed

func FindSageoxHooks

func FindSageoxHooks(repoRoot string) ([]GitHookItem, error)

FindSageoxHooks scans .git/hooks/ directory for SageOx-installed hooks Returns list of hooks that contain SageOx markers

type SageoxFileItem

type SageoxFileItem struct {
	Path      string // absolute path to the item
	RelPath   string // path relative to git root
	Size      int64  // size in bytes (0 for directories)
	IsTracked bool   // whether the item is tracked by git
	IsDir     bool   // whether the item is a directory
}

RemovalItem represents a file or directory that will be removed during uninstall

func FindSageoxFiles

func FindSageoxFiles(repoRoot string) ([]SageoxFileItem, error)

FindSageoxFiles finds all files in the .sageox/ directory Returns a list of RemovalItem entries for preview and processing

type UserIntegrationItem

type UserIntegrationItem struct {
	Path        string // full path to the item
	Type        string // type of item: "hook", "config", "plugin"
	Agent       string // which agent it belongs to: "claude", "opencode", "gemini", etc.
	Description string // human-readable description
}

RemovalItem represents a user-level item that can be removed

type UserIntegrationsFinder

type UserIntegrationsFinder struct {
	// contains filtered or unexported fields
}

UserIntegrationsFinder finds all user-level SageOx integrations

func NewUserIntegrationsFinder

func NewUserIntegrationsFinder() (*UserIntegrationsFinder, error)

NewUserIntegrationsFinder creates a new finder

func (*UserIntegrationsFinder) FindAll

FindAll finds all user-level SageOx integrations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL