Class: Ace::Compressor::Organisms::AgentCompressor

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/compressor/organisms/agent_compressor.rb

Overview

Agent mode keeps exact ContextPack structure and asks the LLM to rewrite only compressible payloads. The model never emits headers, file markers, or section markers.

Constant Summary collapse

PAYLOAD_PREFIXES =
["SUMMARY|", "FACT|"].freeze
PROTECTED_PREFIXES =
[
  "RULE|", "CONSTRAINT|", "CMD|", "TABLE|", "U|", "CODE|", "PROBLEMS|",
  "EXAMPLE|", "EXAMPLE_REF|", "FILES|", "TREE|", "LOSS|"
].freeze
LIST_REWRITE_MIN_ITEMS =
5
LIST_REWRITE_MIN_BYTES =
140
LIST_STOPWORDS =
%w[
  a an and as at by for from in into is of on or that the this to via with within
].freeze
LIST_TOKEN_MAP =
{
  "architecture" => "arch",
  "architectural" => "arch",
  "configuration" => "config",
  "documentation" => "docs",
  "generation" => "gen",
  "management" => "mgmt",
  "repository" => "repo",
  "repositories" => "repos",
  "development" => "dev",
  "integration" => "integr",
  "execution" => "exec",
  "reporting" => "reports",
  "organization" => "org",
  "organizations" => "orgs",
  "capabilities" => "caps",
  "capability" => "cap",
  "foundation" => "base",
  "tracking" => "track",
  "powered" => "pwr",
  "detected" => "detect",
  "matching" => "match"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths, verbose: false, shell_runner: nil) ⇒ AgentCompressor

Returns a new instance of AgentCompressor.



49
50
51
52
# File 'lib/ace/compressor/organisms/agent_compressor.rb', line 49

def initialize(paths, verbose: false, shell_runner: nil)
  @exact = ExactCompressor.new(paths, verbose: verbose, mode_label: "agent")
  @shell_runner = shell_runner || method(:default_shell_runner)
end

Instance Attribute Details

#ignored_pathsObject (readonly)

Returns the value of attribute ignored_paths.



47
48
49
# File 'lib/ace/compressor/organisms/agent_compressor.rb', line 47

def ignored_paths
  @ignored_paths
end

Instance Method Details

#callObject



54
55
56
# File 'lib/ace/compressor/organisms/agent_compressor.rb', line 54

def call
  compress_sources(resolve_sources)
end

#compress_sources(sources, source_paths: nil) ⇒ Object



66
67
68
69
70
71
72
73
74
# File 'lib/ace/compressor/organisms/agent_compressor.rb', line 66

def compress_sources(sources, source_paths: nil)
  exact_output = @exact.compress_sources(sources, source_paths: source_paths)
  exact_lines = normalize_output_lines(exact_output)
  return exact_output if exact_lines.empty?

  job = build_rewrite_job(exact_lines)
  rewrites = rewrite_payloads(job[:records])
  rebuild_output(job[:entries], rewrites)
end

#resolve_sourcesObject



58
59
60
# File 'lib/ace/compressor/organisms/agent_compressor.rb', line 58

def resolve_sources
  @exact.resolve_sources
end