Class: KairosMcp::Tools::DefinitionDrift
- Inherits:
-
BaseTool
- Object
- BaseTool
- KairosMcp::Tools::DefinitionDrift
show all
- Defined in:
- lib/kairos_mcp/tools/definition_drift.rb
Instance Method Summary
collapse
Methods inherited from BaseTool
#initialize, #invoke_tool, #to_full_schema, #to_schema
Instance Method Details
#call(arguments) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/kairos_mcp/tools/definition_drift.rb', line 49
def call(arguments)
skill_id = arguments['skill_id']
return text_content("Error: skill_id is required") unless skill_id && !skill_id.empty?
provider = DslSkillsProvider.new
skill = provider.get_skill(skill_id)
unless skill
available = provider.list_skills.map { |s| s[:id] }.join(', ')
return text_content("Skill '#{skill_id}' not found. Available: #{available}")
end
unless skill.definition
return text_content("## Drift Report: #{skill_id}\n\nThis skill has no definition block. Drift detection requires both content and definition layers.")
end
require_relative '../dsl_ast/drift_detector'
report = DslAst::DriftDetector.detect(skill)
output = "## Drift Report: #{skill_id}\n\n"
s = report.summary
output += "**Coverage Ratio**: #{(report.coverage_ratio * 100).round(0)}% of definition nodes reflected in content\n"
output += "**Issues**: #{s[:errors]} errors, #{s[:warnings]} warnings, #{s[:info]} info (#{s[:total]} total)\n\n"
if report.drifted?
report.items.each do |item|
icon = case item.severity
when :error then "\u{274c}"
when :warning then "\u{26a0}\u{fe0f}"
when :info then "\u{2139}\u{fe0f}"
end
direction_label = case item.direction
when :content_uncovered then "Content > Definition"
when :definition_orphaned then "Definition > Content"
when :value_mismatch then "Value Mismatch"
end
output += "#{icon} [#{direction_label}] #{item.description}\n"
end
else
output += "No drift detected. Content and definition layers are aligned."
end
text_content(output)
end
|
#category ⇒ Object
15
16
17
|
# File 'lib/kairos_mcp/tools/definition_drift.rb', line 15
def category
:skills
end
|
#description ⇒ Object
11
12
13
|
# File 'lib/kairos_mcp/tools/definition_drift.rb', line 11
def description
'Detect drift between a skill\'s content (natural language) and definition (structural AST). Identifies uncovered assertions and orphaned nodes.'
end
|
#examples ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/kairos_mcp/tools/definition_drift.rb', line 23
def examples
[
{
title: 'Check drift for core_safety',
code: 'definition_drift(skill_id: "core_safety")'
}
]
end
|
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/kairos_mcp/tools/definition_drift.rb', line 36
def input_schema
{
type: 'object',
properties: {
skill_id: {
type: 'string',
description: 'The skill ID to check for drift'
}
},
required: ['skill_id']
}
end
|
#name ⇒ Object
7
8
9
|
# File 'lib/kairos_mcp/tools/definition_drift.rb', line 7
def name
'definition_drift'
end
|
32
33
34
|
# File 'lib/kairos_mcp/tools/definition_drift.rb', line 32
def related_tools
%w[definition_verify definition_decompile skills_dsl_get]
end
|
19
20
21
|
# File 'lib/kairos_mcp/tools/definition_drift.rb', line 19
def usecase_tags
%w[drift detection content definition consistency analysis]
end
|