Module: SwarmMemory::Tools::TitleLookup
- Included in:
- MemoryGrep, MemoryRead
- Defined in:
- lib/swarm_memory/tools/title_lookup.rb
Overview
Shared module for looking up memory entry titles
Provides a consistent way to look up titles for memory entries across different tools (MemoryRead, MemoryGrep, etc.)
Instance Method Summary collapse
-
#format_memory_path_with_title(path) ⇒ String
Format a memory path with its title.
-
#lookup_title(path) ⇒ String?
Look up the title of a memory entry.
Instance Method Details
#format_memory_path_with_title(path) ⇒ String
Format a memory path with its title
Normalizes the path (removes memory:// prefix if present) and formats it with the title in quotes if available.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/swarm_memory/tools/title_lookup.rb', line 53 def format_memory_path_with_title(path) normalized_path = path.sub(%r{^memory://}, "") title = lookup_title(normalized_path) if title "memory://#{normalized_path} \"#{title}\"" else "memory://#{normalized_path}" end end |
#lookup_title(path) ⇒ String?
Look up the title of a memory entry
27 28 29 30 31 32 |
# File 'lib/swarm_memory/tools/title_lookup.rb', line 27 def lookup_title(path) entry = @storage.read_entry(file_path: path) entry.title rescue StandardError nil end |