Class: RubynCode::Tools::Bash

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyn_code/tools/bash.rb

Constant Summary collapse

TOOL_NAME =
'bash'
DESCRIPTION =
'Runs a shell command in the project directory. Blocks dangerous patterns ' \
'and scrubs sensitive environment variables.'
PARAMETERS =
{
  command: { type: :string, required: true, description: 'The shell command to execute' },
  timeout: { type: :integer, required: false, default: 120, description: 'Timeout in seconds (default: 120)' }
}.freeze
RISK_LEVEL =
:execute
REQUIRES_CONFIRMATION =
true

Instance Attribute Summary

Attributes inherited from Base

#project_root

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

description, #initialize, parameters, requires_confirmation?, risk_level, #safe_path, to_schema, tool_name, #truncate

Constructor Details

This class inherits a constructor from RubynCode::Tools::Base

Class Method Details

.summarize(_output, args) ⇒ Object



21
22
23
24
# File 'lib/rubyn_code/tools/bash.rb', line 21

def self.summarize(_output, args)
  cmd = args['command'] || args[:command] || ''
  "$ #{cmd[0, 180]}"
end

Instance Method Details

#execute(command:, timeout: 120) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/rubyn_code/tools/bash.rb', line 26

def execute(command:, timeout: 120)
  validate_command!(command)

  stdout, stderr, status = safe_capture3(scrubbed_env, command, chdir: project_root, timeout: timeout)

  build_output(stdout, stderr, status)
end