Class: KairosMcp::Tools::InstructionsUpdate

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

Constant Summary collapse

PROTECTED_FILES =

Protected built-in files that cannot be deleted

%w[kairos.md kairos_quickguide.md kairos_tutorial.md researcher.md].freeze
RESERVED_MODES =

Reserved mode names that map to built-in behavior

%w[developer user tutorial none].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



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/kairos_mcp/tools/instructions_update.rb', line 90

def call(arguments)
  command = arguments['command']
  mode_name = arguments['mode_name']
  content = arguments['content']
  reason = arguments['reason']
  approved = arguments['approved'] || false

  # Path traversal protection
  if mode_name && mode_name.match?(%r{[/\\]|\.\.})
    return text_content("Error: mode_name must not contain path separators or '..'")
  end

  case command
  when 'status'
    handle_status
  when 'create'
    handle_create(mode_name, content, reason, approved)
  when 'update'
    handle_update(mode_name, content, reason, approved)
  when 'delete'
    handle_delete(mode_name, reason, approved)
  when 'set_mode'
    handle_set_mode(mode_name, reason, approved)
  else
    text_content("Unknown command: #{command}")
  end
end

#categoryObject



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

def category
  :skills
end

#descriptionObject



21
22
23
24
25
# File 'lib/kairos_mcp/tools/instructions_update.rb', line 21

def description
  'Create, update, or delete custom instruction files and switch instructions_mode. ' \
  'Instructions control the AI system prompt (L0-level). ' \
  'All changes require human approval and are recorded to blockchain.'
end

#examplesObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/kairos_mcp/tools/instructions_update.rb', line 35

def examples
  [
    {
      title: 'Check current instructions status',
      code: 'instructions_update(command: "status")'
    },
    {
      title: 'Create custom instructions',
      code: 'instructions_update(command: "create", mode_name: "researcher", ' \
            'content: "# Researcher Constitution\n...", ' \
            'reason: "Create researcher identity", approved: true)'
    },
    {
      title: 'Switch to custom mode',
      code: 'instructions_update(command: "set_mode", mode_name: "researcher", ' \
            'reason: "Activate researcher identity", approved: true)'
    }
  ]
end

#input_schemaObject



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
# File 'lib/kairos_mcp/tools/instructions_update.rb', line 59

def input_schema
  {
    type: 'object',
    properties: {
      command: {
        type: 'string',
        description: 'Command: "status", "create", "update", "delete", or "set_mode"',
        enum: %w[status create update delete set_mode]
      },
      mode_name: {
        type: 'string',
        description: 'Mode name (resolves to skills/{mode_name}.md). ' \
                     'Cannot be "developer", "user", or "none".'
      },
      content: {
        type: 'string',
        description: 'Full markdown content for the instructions file (for create/update)'
      },
      reason: {
        type: 'string',
        description: 'Reason for the change (recorded in blockchain). Required for create/update/delete/set_mode.'
      },
      approved: {
        type: 'boolean',
        description: 'Human approval flag. Must be true to execute L0-level changes.'
      }
    },
    required: %w[command]
  }
end

#nameObject



17
18
19
# File 'lib/kairos_mcp/tools/instructions_update.rb', line 17

def name
  'instructions_update'
end


55
56
57
# File 'lib/kairos_mcp/tools/instructions_update.rb', line 55

def related_tools
  %w[skills_list skills_get chain_history]
end

#usecase_tagsObject



31
32
33
# File 'lib/kairos_mcp/tools/instructions_update.rb', line 31

def usecase_tags
  %w[instructions mode L0 system-prompt identity philosophy customize]
end