Class: Ace::Lint::Organisms::AutoFixOrchestrator

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/lint/organisms/auto_fix_orchestrator.rb

Overview

Coordinates deterministic and agent-assisted auto-fix flows.

Constant Summary collapse

FIX_CAPABLE_TYPES =
[:markdown, :skill, :workflow, :agent, :ruby].freeze
DEFAULT_PROVIDER_MODEL =
"gemini:flash-latest@yolo".freeze

Instance Method Summary collapse

Constructor Details

#initialize(orchestrator:, lint_options:, with_agent:, model:, file_block_start:, file_block_end:, no_changes_marker:, max_file_bytes:, max_total_bytes:) ⇒ AutoFixOrchestrator

Returns a new instance of AutoFixOrchestrator.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ace/lint/organisms/auto_fix_orchestrator.rb', line 15

def initialize(
  orchestrator:,
  lint_options:,
  with_agent:,
  model:,
  file_block_start:,
  file_block_end:,
  no_changes_marker:,
  max_file_bytes:,
  max_total_bytes:
)
  @orchestrator = orchestrator
  @lint_options = lint_options
  @with_agent = with_agent
  @model = model
  @file_block_start = file_block_start
  @file_block_end = file_block_end
  @no_changes_marker = no_changes_marker
  @max_file_bytes = max_file_bytes
  @max_total_bytes = max_total_bytes
end

Instance Method Details

#run(paths) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ace/lint/organisms/auto_fix_orchestrator.rb', line 37

def run(paths)
  fix_options = @lint_options.merge(fix: true)
  fix_options.delete(:format)

  fixable_paths, lint_only_paths = partition_fixable_paths(paths)
  fixed_results = if fixable_paths.empty?
    []
  else
    @orchestrator.lint_files(fixable_paths, options: fix_options)
  end

  paths_for_final_lint = if lint_only_paths.empty?
    paths
  else
    fixable_paths + lint_only_paths
  end
  lint_results = @orchestrator.lint_files(paths_for_final_lint, options: lint_only_options(@lint_options))
  merged_results = merge_fix_and_lint_results(fixed_results, lint_results)

  return merged_results unless @with_agent

  run_agent_fix(paths, initial_results: merged_results)
end

#run_dry_run(paths) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/ace/lint/organisms/auto_fix_orchestrator.rb', line 61

def run_dry_run(paths)
  lint_results = @orchestrator.lint_files(paths, options: lint_only_options(@lint_options))

  issues = collect_issues(lint_results)
  if issues.empty?
    puts "No violations found."
  else
    issues.each do |issue|
      puts "Would attempt to fix: #{issue}"
    end

    file_count = lint_results.select { |result| result.has_errors? || result.has_warnings? }.map(&:file_path).uniq.count
    puts "#{issues.count} issue(s) detected in #{file_count} file(s) during dry-run."
  end

  return unless @with_agent
  return puts "\nNo remaining issues for agent prompt." if lint_results.none? { |result| result.has_errors? || result.has_warnings? }

  prompt = build_agent_prompt(lint_results)
  puts "\nAgent prompt (dry-run):"
  puts prompt
end