Class: RubynCode::CLI::Commands::Compact

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyn_code/cli/commands/compact.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

aliases, all_names, hidden?

Class Method Details

.command_nameObject



7
# File 'lib/rubyn_code/cli/commands/compact.rb', line 7

def self.command_name = '/compact'

.descriptionObject



8
# File 'lib/rubyn_code/cli/commands/compact.rb', line 8

def self.description = 'Compress conversation context'

Instance Method Details

#execute(args, ctx) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/rubyn_code/cli/commands/compact.rb', line 10

def execute(args, ctx)
  focus = args.first

  compactor = ::RubynCode::Context::Compactor.new(llm_client: ctx.llm_client)
  new_messages = compactor.manual_compact!(ctx.conversation.messages, focus: focus)
  ctx.conversation.replace!(new_messages)
  ctx.renderer.info("Context compacted. #{ctx.conversation.length} messages remaining.")
end