Class: RosettAi::Mcp::Tools::HookPreviewTool
- Inherits:
-
Object
- Object
- RosettAi::Mcp::Tools::HookPreviewTool
- Defined in:
- lib/rosett_ai/mcp/tools/hook_preview_tool.rb
Overview
MCP tool: preview a generated enforcement hook script.
Generates a Ruby hook script from behaviour rules without writing anything to disk. Allows inspection before installing via HookInstallTool. Strictly read-only.
Delegates generation to Enforcement::HookGenerator and validation to Enforcement::Validator.
Constant Summary collapse
- TOOL_NAME =
'rai_hook_preview'- DESCRIPTION =
'Preview generated enforcement hook script (read-only, no side effects)'- ANNOTATIONS =
{ 'readOnlyHint' => true, 'destructiveHint' => false, 'idempotentHint' => true, 'openWorldHint' => false }.freeze
Instance Method Summary collapse
-
#call(behaviour_name: nil, rule_id: nil, scope: nil) ⇒ Hash
Generates a preview of the enforcement hook script.
Instance Method Details
#call(behaviour_name: nil, rule_id: nil, scope: nil) ⇒ Hash
Generates a preview of the enforcement hook script.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rosett_ai/mcp/tools/hook_preview_tool.rb', line 40 def call(behaviour_name: nil, rule_id: nil, scope: nil) behaviours = load_behaviours(behaviour_name, scope) validated = validate_and_collect(behaviours, rule_id) return ResponseHelper.error('No enforceable rules found') if validated[:rules].empty? script = generate_script(validated) build_response(script, validated, scope) rescue StandardError => e ResponseHelper.error("Hook preview failed: #{e.}") end |