Class: RubynCode::Checkpoint::Hook
- Inherits:
-
Object
- Object
- RubynCode::Checkpoint::Hook
- Defined in:
- lib/rubyn_code/checkpoint/hook.rb
Overview
A :pre_tool_use hook that snapshots a file’s original contents into the current checkpoint just before a mutating tool changes it. Only the file-mutating tools are watched; everything else is ignored.
Constant Summary collapse
- MUTATING_TOOLS =
%w[write_file edit_file].freeze
Instance Method Summary collapse
-
#call(tool_name:, tool_input: {}, **_kwargs) ⇒ nil
Never blocks the tool (returns no deny decision).
-
#initialize(manager:) ⇒ Hook
constructor
A new instance of Hook.
Constructor Details
#initialize(manager:) ⇒ Hook
Returns a new instance of Hook.
12 13 14 |
# File 'lib/rubyn_code/checkpoint/hook.rb', line 12 def initialize(manager:) @manager = manager end |
Instance Method Details
#call(tool_name:, tool_input: {}, **_kwargs) ⇒ nil
Returns never blocks the tool (returns no deny decision).
17 18 19 20 21 22 23 |
# File 'lib/rubyn_code/checkpoint/hook.rb', line 17 def call(tool_name:, tool_input: {}, **_kwargs) return nil unless MUTATING_TOOLS.include?(tool_name.to_s) path = tool_input[:path] || tool_input['path'] @manager.record_file(path) if path nil end |