Class: KairosMcp::Tools::SkillsAudit

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/kairos_mcp/tools/skills_audit.rb

Overview

SkillsAudit: Tool for auditing knowledge health across L0/L1/L2 layers

Provides:

  • Health checks (conflicts, staleness, dangerous patterns)

  • Promotion/archive recommendations

  • Archive management (with human approval)

  • Optional Persona Assembly for deeper analysis

Constant Summary collapse

STALENESS_RULES =

Layer-specific staleness rules L0: No date-based staleness (stability is valued) L1: 180 days threshold L2: 14 days threshold

{
  'L0' => {
    check_date: false,
    checks: %i[external_refs internal_consistency deprecated_patterns]
  },
  'L1' => {
    check_date: true,
    threshold_days: 180,
    checks: %i[version_refs usage_frequency]
  },
  'L2' => {
    check_date: true,
    threshold_days: 14,
    checks: %i[session_validity orphaned]
  }
}.freeze
READONLY_COMMANDS =
%w[check conflicts stale dangerous recommend gaps export_needs].freeze
WRITE_COMMANDS =
%w[archive unarchive].freeze

Instance Method Summary collapse

Methods inherited from BaseTool

#initialize, #invoke_tool, #to_full_schema, #to_schema

Constructor Details

This class inherits a constructor from KairosMcp::Tools::BaseTool

Instance Method Details

#call(arguments) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
# File 'lib/kairos_mcp/tools/skills_audit.rb', line 170

def call(arguments)
  command = arguments['command']

  if READONLY_COMMANDS.include?(command)
    handle_readonly_command(command, arguments)
  elsif WRITE_COMMANDS.include?(command)
    handle_write_command(command, arguments)
  else
    text_content("Unknown command: #{command}")
  end
end

#categoryObject



56
57
58
# File 'lib/kairos_mcp/tools/skills_audit.rb', line 56

def category
  :skills
end

#descriptionObject



49
50
51
52
53
54
# File 'lib/kairos_mcp/tools/skills_audit.rb', line 49

def description
  'Audit knowledge health across L0/L1/L2 layers. Check for conflicts, staleness, ' \
  'dangerous patterns, get promotion/archive recommendations, and detect knowledge gaps ' \
  'defined by custom instruction mode policies. ' \
  'Archive operations require human approval (approved: true).'
end

#examplesObject



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
94
95
# File 'lib/kairos_mcp/tools/skills_audit.rb', line 64

def examples
  [
    {
      title: 'Full health check',
      code: 'skills_audit(command: "check")'
    },
    {
      title: 'Check for dangerous patterns',
      code: 'skills_audit(command: "dangerous")'
    },
    {
      title: 'Get promotion recommendations',
      code: 'skills_audit(command: "recommend")'
    },
    {
      title: 'Archive stale knowledge',
      code: 'skills_audit(command: "archive", target: "old_guide", reason: "No longer relevant", approved: true)'
    },
    {
      title: 'Check knowledge gaps for current mode',
      code: 'skills_audit(command: "gaps")'
    },
    {
      title: 'Check knowledge gaps for specific mode',
      code: 'skills_audit(command: "gaps", mode_name: "genomics_expert")'
    },
    {
      title: 'Export knowledge needs for Meeting Place sharing',
      code: 'skills_audit(command: "export_needs")'
    }
  ]
end

#input_schemaObject



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/kairos_mcp/tools/skills_audit.rb', line 101

def input_schema
  {
    type: 'object',
    properties: {
      command: {
        type: 'string',
        description: 'Command to execute',
        enum: READONLY_COMMANDS + WRITE_COMMANDS
      },
      layer: {
        type: 'string',
        description: 'Target layer (default: "all")',
        enum: %w[L0 L1 L2 all]
      },
      session_id: {
        type: 'string',
        description: 'Session ID (required for L2 operations)'
      },
      with_assembly: {
        type: 'boolean',
        description: 'Use Persona Assembly for deeper analysis (default: false). Warning: increases token usage.'
      },
      assembly_mode: {
        type: 'string',
        description: 'Assembly mode: "oneshot" (default, single evaluation) or "discussion" (multi-round with facilitator)',
        enum: %w[oneshot discussion]
      },
      personas: {
        type: 'array',
        items: { type: 'string' },
        description: 'Personas for assembly (default: ["archivist", "guardian", "promoter"]). Pre-defined: archivist, guardian, promoter. Custom persona names are also accepted — the LLM will infer the role from the name and context.'
      },
      facilitator: {
        type: 'string',
        description: 'Facilitator persona for discussion mode (default: "kairos")'
      },
      max_rounds: {
        type: 'integer',
        description: 'Maximum discussion rounds for discussion mode (default: 3)'
      },
      consensus_threshold: {
        type: 'number',
        description: 'Consensus threshold for early termination in discussion mode (default: 0.6 = 60%)'
      },
      target: {
        type: 'string',
        description: 'Target knowledge name (for archive/unarchive commands)'
      },
      reason: {
        type: 'string',
        description: 'Reason for archive/unarchive operation'
      },
      approved: {
        type: 'boolean',
        description: 'Human approval flag (required for archive/unarchive)'
      },
      include_archived: {
        type: 'boolean',
        description: 'Include archived items in results (default: false)'
      },
      mode_name: {
        type: 'string',
        description: 'Instruction mode name (for gaps command). Defaults to current active mode.'
      }
    },
    required: ['command']
  }
end

#nameObject



45
46
47
# File 'lib/kairos_mcp/tools/skills_audit.rb', line 45

def name
  'skills_audit'
end


97
98
99
# File 'lib/kairos_mcp/tools/skills_audit.rb', line 97

def related_tools
  %w[skills_promote knowledge_update chain_verify state_status]
end

#usecase_tagsObject



60
61
62
# File 'lib/kairos_mcp/tools/skills_audit.rb', line 60

def usecase_tags
  %w[audit health check recommend archive stale dangerous gaps needs meeting knowledge-policy L0 L1 L2]
end