Class: KairosMcp::Tools::KnowledgeUpdate

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

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



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/kairos_mcp/tools/knowledge_update.rb', line 77

def call(arguments)
  command = arguments['command']
  name = arguments['name']
  content = arguments['content']
  reason = arguments['reason']
  create_subdirs = arguments['create_subdirs'] || false

  return text_content("Error: name is required") unless name && !name.empty?

  # Check if L1 layer is enabled
  unless SkillsConfig.layer_enabled?(:L1)
    return text_content("Error: L1 (knowledge) layer is disabled")
  end

  provider = KnowledgeProvider.new(nil, user_context: @safety&.current_user)

  case command
  when 'create'
    handle_create(provider, name, content, reason, create_subdirs)
  when 'update'
    handle_update(provider, name, content, reason)
  when 'delete'
    handle_delete(provider, name, reason)
  else
    text_content("Unknown command: #{command}")
  end
end

#categoryObject



18
19
20
# File 'lib/kairos_mcp/tools/knowledge_update.rb', line 18

def category
  :knowledge
end

#descriptionObject



14
15
16
# File 'lib/kairos_mcp/tools/knowledge_update.rb', line 14

def description
  'Create, update, or delete L1 knowledge skills. Changes are recorded with hash references to the blockchain.'
end

#examplesObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kairos_mcp/tools/knowledge_update.rb', line 26

def examples
  [
    {
      title: 'Create new knowledge',
      code: 'knowledge_update(command: "create", name: "api_guidelines", content: "---\nname: api_guidelines\ndescription: API design rules\n---\n# API Guidelines\n...")'
    },
    {
      title: 'Update existing knowledge',
      code: 'knowledge_update(command: "update", name: "api_guidelines", content: "...", reason: "Added auth section")'
    },
    {
      title: 'Delete knowledge',
      code: 'knowledge_update(command: "delete", name: "old_rule", reason: "No longer applicable")'
    }
  ]
end

#input_schemaObject



47
48
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
# File 'lib/kairos_mcp/tools/knowledge_update.rb', line 47

def input_schema
  {
    type: 'object',
    properties: {
      command: {
        type: 'string',
        description: 'Command: "create", "update", or "delete"',
        enum: %w[create update delete]
      },
      name: {
        type: 'string',
        description: 'Knowledge skill name'
      },
      content: {
        type: 'string',
        description: 'Full content including YAML frontmatter (for create/update)'
      },
      reason: {
        type: 'string',
        description: 'Reason for the change (recorded in blockchain)'
      },
      create_subdirs: {
        type: 'boolean',
        description: 'Create scripts/assets/references subdirectories (for create, default: false)'
      }
    },
    required: %w[command name]
  }
end

#nameObject



10
11
12
# File 'lib/kairos_mcp/tools/knowledge_update.rb', line 10

def name
  'knowledge_update'
end


43
44
45
# File 'lib/kairos_mcp/tools/knowledge_update.rb', line 43

def related_tools
  %w[knowledge_list knowledge_get context_save skills_promote]
end

#usecase_tagsObject



22
23
24
# File 'lib/kairos_mcp/tools/knowledge_update.rb', line 22

def usecase_tags
  %w[save update delete L1 knowledge project permanent]
end