Module: Legion::MCP::ColdStart

Extended by:
Logging::Helper
Defined in:
lib/legion/mcp/cold_start.rb

Class Method Summary collapse

Class Method Details

.configured_pathObject



27
28
29
30
31
32
33
34
35
# File 'lib/legion/mcp/cold_start.rb', line 27

def configured_path
  return nil unless defined?(Legion::Settings)

  Legion::Settings.dig(:mcp, :cold_start, :patterns_path)
rescue StandardError => e
  handle_exception(e, level: :warn, operation: 'legion.mcp.cold_start.configured_path')
  log.warn("ColdStart#configured_path failed: #{e.message}")
  nil
end

.load_community_patterns(path: nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/legion/mcp/cold_start.rb', line 13

def load_community_patterns(path: nil)
  log.info('Starting legion.mcp.cold_start.load_community_patterns')
  return { skipped: true, reason: 'store not empty' } unless PatternStore.empty?

  path ||= configured_path
  return { skipped: true, reason: 'no path configured' } unless path

  PatternExchange.import_from_file(path, trust_level: :community)
rescue StandardError => e
  handle_exception(e, level: :error, operation: 'legion.mcp.cold_start.load_community_patterns')
  log.error("ColdStart#load_community_patterns failed: #{e.message}")
  { error: e.message, imported: 0 }
end