Class: ClaudeMemory::Commands::Registry

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

Overview

Registry for CLI command lookup and dispatch Maps command names to command classes and short descriptions. Descriptions are authoritative for shell completion and help output; keep them current when adding commands.

Constant Summary collapse

COMMANDS =

Map of command names to description: entries. As more commands are extracted, add them here.

{
  "help" => {class: HelpCommand, description: "Show help message"},
  "version" => {class: VersionCommand, description: "Show version"},
  "doctor" => {class: DoctorCommand, description: "Check system health"},
  "stats" => {class: StatsCommand, description: "Show statistics"},
  "promote" => {class: PromoteCommand, description: "Promote fact to global"},
  "search" => {class: SearchCommand, description: "Search indexed content"},
  "explain" => {class: ExplainCommand, description: "Explain a fact with receipts"},
  "conflicts" => {class: ConflictsCommand, description: "Show open conflicts"},
  "changes" => {class: ChangesCommand, description: "Show recent fact changes"},
  "recall" => {class: RecallCommand, description: "Recall facts matching query"},
  "sweep" => {class: SweepCommand, description: "Run maintenance"},
  "ingest" => {class: IngestCommand, description: "Ingest transcript delta"},
  "publish" => {class: PublishCommand, description: "Publish snapshot"},
  "db:init" => {class: DbInitCommand, description: "Initialize database"},
  "init" => {class: InitCommand, description: "Initialize ClaudeMemory"},
  "uninstall" => {class: UninstallCommand, description: "Remove configuration"},
  "serve-mcp" => {class: ServeMcpCommand, description: "Start MCP server"},
  "hook" => {class: HookCommand, description: "Run hook entrypoints"},
  "index" => {class: IndexCommand, description: "Index content"},
  "recover" => {class: RecoverCommand, description: "Recover database"},
  "compact" => {class: CompactCommand, description: "Compact databases"},
  "export" => {class: ExportCommand, description: "Export facts to JSON"},
  "git-lfs" => {class: GitLfsCommand, description: "Git LFS integration"},
  "install-skill" => {class: InstallSkillCommand, description: "Install agent skills"},
  "completion" => {class: CompletionCommand, description: "Generate shell completions"},
  "embeddings" => {class: EmbeddingsCommand, description: "Inspect embedding backend"},
  "reject" => {class: RejectCommand, description: "Mark a fact as rejected"},
  "restore" => {class: RestoreCommand, description: "Restore superseded facts from obsolete single-value classification"}
}.freeze

Class Method Summary collapse

Class Method Details

.all_commandsArray<String>

Get all registered command names

Returns:

  • (Array<String>)

    list of command names



52
53
54
# File 'lib/claude_memory/commands/registry.rb', line 52

def self.all_commands
  COMMANDS.keys
end

.description(command_name) ⇒ String?

Get the short description for a command

Parameters:

  • command_name (String)

    the command name

Returns:

  • (String, nil)

    the description, or nil if not registered



66
67
68
# File 'lib/claude_memory/commands/registry.rb', line 66

def self.description(command_name)
  COMMANDS.dig(command_name, :description)
end

.descriptionsHash{String => String}

Get all command descriptions as a hash

Returns:

  • (Hash{String => String})

    command name → description



72
73
74
# File 'lib/claude_memory/commands/registry.rb', line 72

def self.descriptions
  COMMANDS.transform_values { |entry| entry[:description] }
end

.find(command_name) ⇒ Class?

Find a command class by name

Parameters:

  • command_name (String)

    the command name (e.g., “help”, “version”)

Returns:

  • (Class, nil)

    the command class, or nil if not found



46
47
48
# File 'lib/claude_memory/commands/registry.rb', line 46

def self.find(command_name)
  COMMANDS.dig(command_name, :class)
end

.registered?(command_name) ⇒ Boolean

Check if a command is registered

Parameters:

  • command_name (String)

    the command name

Returns:

  • (Boolean)

    true if registered



59
60
61
# File 'lib/claude_memory/commands/registry.rb', line 59

def self.registered?(command_name)
  COMMANDS.key?(command_name)
end