Class: KairosMcp::SkillsAst

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

Class Method Summary collapse

Class Method Details

.diff(old_ast, new_ast) ⇒ Object



40
41
42
# File 'lib/kairos_mcp/skills_ast.rb', line 40

def self.diff(old_ast, new_ast)
  "AST diffing not yet fully implemented."
end

.extract_skill_nodes(ast) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/kairos_mcp/skills_ast.rb', line 12

def self.extract_skill_nodes(ast)
  return [] unless ast
  nodes = []
  
  if ast.type == :SCOPE
    body = ast.children[2] 
    if body && body.type == :BLOCK
       body.children.each do |node|
         if is_skill_call?(node)
           nodes << node
         end
       end
    elsif body && is_skill_call?(body)
       nodes << body
    end
  end
  
  nodes
end

.is_skill_call?(node) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
# File 'lib/kairos_mcp/skills_ast.rb', line 46

def self.is_skill_call?(node)
  return false unless node.is_a?(RubyVM::AbstractSyntaxTree::Node)
  
  return true if node.type == :FCALL && node.children[0] == :skill
  return true if node.type == :VCALL && node.children[0] == :skill
  
  false
end

.parse(path) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/kairos_mcp/skills_ast.rb', line 3

def self.parse(path)
  if defined?(RubyVM::AbstractSyntaxTree)
    return nil unless File.exist?(path)
    RubyVM::AbstractSyntaxTree.parse_file(path)
  else
    raise "RubyVM::AbstractSyntaxTree is not available in this Ruby version."
  end
end

.validate(skill_nodes) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/kairos_mcp/skills_ast.rb', line 32

def self.validate(skill_nodes)
  errors = []
  skill_nodes.each do |node|
    # Validation logic placeholder
  end
  errors
end