Class: RosettAi::Behaviour::Manager
- Inherits:
-
Object
- Object
- RosettAi::Behaviour::Manager
- Defined in:
- lib/rosett_ai/behaviour/manager.rb
Overview
MCP-facing facade for behaviour file management.
Provides add/modify/delete operations for behaviour YAML files, matching the interface expected by Mcp::Tools::BehaviourManageTool.
Instance Method Summary collapse
-
#add(name, description: nil) ⇒ Pathname
Creates a new behaviour file.
-
#delete(name, options: {}) ⇒ Boolean
Deletes a behaviour file.
-
#initialize(behaviour_dir: nil) ⇒ Manager
constructor
A new instance of Manager.
-
#modify(name, description: nil) ⇒ Pathname
Modifies an existing behaviour file.
Constructor Details
#initialize(behaviour_dir: nil) ⇒ Manager
Returns a new instance of Manager.
24 25 26 |
# File 'lib/rosett_ai/behaviour/manager.rb', line 24 def initialize(behaviour_dir: nil) @behaviour_dir = Pathname.new(behaviour_dir || RosettAi.paths.rai_conf_dir.join('behaviour')) end |
Instance Method Details
#add(name, description: nil) ⇒ Pathname
Creates a new behaviour file.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rosett_ai/behaviour/manager.rb', line 33 def add(name, description: nil) path = behaviour_path(name) raise RosettAi::BehaviourError, "Behaviour '#{name}' already exists" if path.exist? data = build_template(name, description || "#{name} behaviour") FileUtils.mkdir_p(path.dirname) path.write(YAML.dump(data)) validate_behaviour!(path) path end |
#delete(name, options: {}) ⇒ Boolean
Deletes a behaviour file.
63 64 65 66 67 68 69 70 71 |
# File 'lib/rosett_ai/behaviour/manager.rb', line 63 def delete(name, options: {}) path = behaviour_path(name) force_delete = .fetch(:force_delete, false) raise RosettAi::BehaviourError, "Behaviour '#{name}' not found" unless force_delete || path.exist? path.delete if path.exist? cleanup_compiled_rules(name) path end |
#modify(name, description: nil) ⇒ Pathname
Modifies an existing behaviour file.
49 50 51 52 53 54 55 56 |
# File 'lib/rosett_ai/behaviour/manager.rb', line 49 def modify(name, description: nil) path = behaviour_path(name) raise RosettAi::BehaviourError, "Behaviour '#{name}' not found" unless path.exist? update_behaviour_file(path, description) validate_behaviour!(path) path end |