Class: Rixie::CLI::Commands::Compress

Inherits:
Base
  • Object
show all
Defined in:
lib/rixie/cli/commands/compress.rb

Instance Method Summary collapse

Methods inherited from Base

#complete, #initialize

Constructor Details

This class inherits a constructor from Rixie::CLI::Commands::Base

Instance Method Details

#call(arg, cli:) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rixie/cli/commands/compress.rb', line 11

def call(arg, cli:)
  keep_recent = parse_keep_recent(arg)
  return renderer.error("Invalid argument: expected a non-negative integer") if keep_recent.nil?

  if cli.current_context_length.zero?
    renderer.info("Context", "Already empty, nothing to compress")
    return
  end

  before_size = cli.current_context_size
  renderer.start_spinner
  cli.compress!(keep_recent: keep_recent)
  renderer.stop_spinner

  after_size = cli.current_context_size
  if after_size >= before_size
    renderer.info("Notice", "Compression did not reduce context size (~#{before_size} → ~#{after_size} tokens). Context may be too small to benefit from compression.")
  else
    renderer.success("Compressed ~#{before_size} → ~#{after_size} tokens")
  end
rescue => e
  renderer.stop_spinner
  renderer.error(e.message)
end

#descriptionObject



9
# File 'lib/rixie/cli/commands/compress.rb', line 9

def description = "Compress conversation context into a summary (optionally keep N recent entries)"

#nameObject



7
# File 'lib/rixie/cli/commands/compress.rb', line 7

def name = "compress"