Class: ClaudeMemory::Commands::Checks::HooksCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_memory/commands/checks/hooks_check.rb

Overview

Checks hooks configuration in settings files

Constant Summary collapse

SETTINGS_PATHS =
[".claude/settings.json", ".claude/settings.local.json"].freeze
EXPECTED_HOOKS =
%w[Stop StopFailure SessionStart PreCompact SessionEnd].freeze

Instance Method Summary collapse

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/claude_memory/commands/checks/hooks_check.rb', line 13

def call
  hooks_found = false
  warnings = []
  paths_checked = []

  SETTINGS_PATHS.each do |path|
    next unless File.exist?(path)

    paths_checked << path
    result = check_settings_file(path)

    if result[:has_hooks]
      hooks_found = true
      warnings.concat(result[:warnings])
    end
  end

  # Check for orphaned hooks
  if hooks_found && !mcp_configured?
    warnings << "Orphaned hooks detected: claude-memory hooks are configured but MCP server is not"
    warnings << "Run 'claude-memory uninstall' to remove hooks, or 'claude-memory init' to reconfigure"
  end

  if hooks_found
    {
      status: warnings.any? ? :warning : :ok,
      label: "hooks",
      message: "Hooks configured in #{paths_checked.join(", ")}",
      details: {
        paths: paths_checked,
        fallback_available: false
      },
      warnings: warnings
    }
  else
    {
      status: :warning,
      label: "hooks",
      message: "No hooks configured. Run 'claude-memory init' or configure manually.",
      details: {
        paths: SETTINGS_PATHS,
        fallback_available: true,
        fallback_commands: [
          "claude-memory ingest --session-id <id> --transcript-path <path>",
          "claude-memory sweep --budget 5",
          "claude-memory publish"
        ]
      },
      warnings: []
    }
  end
end