Class: ClaudeHooks::PreCompact
- Inherits:
-
Base
- Object
- Base
- ClaudeHooks::PreCompact
show all
- Defined in:
- lib/claude_hooks/pre_compact.rb
Constant Summary
Constants inherited
from Base
Base::COMMON_INPUT_FIELDS
Instance Attribute Summary
Attributes inherited from Base
#config, #input_data, #logger, #output, #output_data
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#agent_id, #agent_type, #allow_continue!, #base_dir, #call, #clear_specifics!, #clear_system_message!, #cwd, #effort, #home_claude_dir, #home_path_for, #hook_event_name, #hook_type, #initialize, #log, #output_and_exit, #path_for, #permission_mode, #prevent_continue!, #project_claude_dir, #project_path_for, #prompt_id, #read_transcript, #session_id, #show_output!, #stringify_output, #suppress_output!, #system_message!, #terminal_sequence, #terminal_sequence!, #transcript_path
Class Method Details
.hook_type ⇒ Object
8
9
10
|
# File 'lib/claude_hooks/pre_compact.rb', line 8
def self.hook_type
'PreCompact'
end
|
12
13
14
|
# File 'lib/claude_hooks/pre_compact.rb', line 12
def self.input_fields
%w[trigger custom_instructions]
end
|
Instance Method Details
#backup_transcript!(backup_file_path) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/claude_hooks/pre_compact.rb', line 39
def backup_transcript!(backup_file_path)
unless Dir.exist?(File.dirname(backup_file_path))
FileUtils.mkdir_p(File.dirname(backup_file_path))
end
transcript_content = read_transcript
File.write(backup_file_path, transcript_content)
log "Transcript backed up to: #{backup_file_path}"
end
|
#block!(reason = '') ⇒ Object
32
33
34
35
|
# File 'lib/claude_hooks/pre_compact.rb', line 32
def block!(reason = '')
@output_data['decision'] = 'block'
@output_data['reason'] = reason
end
|
#custom_instructions ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/claude_hooks/pre_compact.rb', line 22
def custom_instructions
if trigger == 'manual'
@input_data['custom_instructions']
else
''
end
end
|
#trigger ⇒ Object
18
19
20
|
# File 'lib/claude_hooks/pre_compact.rb', line 18
def trigger
@input_data['trigger']
end
|