Class: KairosMcp::SkillsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/kairos_mcp/skills_parser.rb

Defined Under Namespace

Classes: Section

Instance Method Summary collapse

Constructor Details

#initialize(skills_path = nil) ⇒ SkillsParser

Returns a new instance of SkillsParser.



7
8
9
10
11
# File 'lib/kairos_mcp/skills_parser.rb', line 7

def initialize(skills_path = nil)
  skills_path ||= KairosMcp.md_path
  @skills_path = skills_path
  @sections = nil
end

Instance Method Details

#get_section(section_id) ⇒ Object



27
28
29
# File 'lib/kairos_mcp/skills_parser.rb', line 27

def get_section(section_id)
  sections.find { |s| s.id == section_id }
end

#list_sectionsObject



17
18
19
20
21
22
23
24
25
# File 'lib/kairos_mcp/skills_parser.rb', line 17

def list_sections
  sections.map do |section|
    {
      id: section.id,
      title: section.title,
      use_when: section.use_when
    }
  end
end

#search_sections(query, max_results = 3) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kairos_mcp/skills_parser.rb', line 31

def search_sections(query, max_results = 3)
  pattern = Regexp.new(query, Regexp::IGNORECASE)
  
  matches = sections.select do |section|
    section.title.match?(pattern) ||
      section.content.match?(pattern) ||
      (section.use_when && section.use_when.match?(pattern))
  end

  matches.first(max_results)
end

#sectionsObject



13
14
15
# File 'lib/kairos_mcp/skills_parser.rb', line 13

def sections
  @sections ||= parse_sections
end