lex-autofix 0.1.9 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8189f823a1a5fafeb00ba07cdfaaec5600f44c0d70179f10d25df3bf3d154d9
4
- data.tar.gz: f43e171678b083d3eb7e7c28d05b3bec33e73eb3f3d585275d3f2ee3aa0f4f81
3
+ metadata.gz: 51c3000a6c2f89d70171eba91c7b1abee9b5c232bad8c2f810f18925ea85eb3e
4
+ data.tar.gz: '0325354485126a1cf21da112f6a56fc5a5f8901e970456d85c000ccff0c1d5db'
5
5
  SHA512:
6
- metadata.gz: def74ac1ef435404387c9ccd15d8e32be795cefe492dc2afde1dfdcc9e35b36285bc20eee5425890e9f81d31ce6e3ec34d7712c61de366f3d94b869f8f4a33d3
7
- data.tar.gz: 971162e7ed81f50dec244683dfa3e95a8847b889ab882d29b650d971b22780cc6af0669634d2b222794b6715e55ab87739effe9e5c3b6464a8feb6d9b57e8e87
6
+ metadata.gz: d3323d8e4dcf8f7eae82e93b69f48038b699abd29742842dde1339c0abb746355c73582b072fcb1460ed9b1f55ea00947ee87594598eb5ed4f0a38eb23dc4524
7
+ data.tar.gz: 92c83963a9d2ae13f2f51bf0288b2beac93d3952efddfeb3adc0eeb3f31047c56745242ef6df96c5328815b7021614426addc879d18b2f0c924c56f532778b71
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.2.1] - 2026-03-30
6
+
7
+ ### Changed
8
+ - update to rubocop-legion 0.1.7, resolve all offenses
9
+
10
+ ## [0.2.0] - 2026-03-29
11
+
12
+ ### Changed
13
+ - All 4 pipeline runners (`batch_triage`, `check_github`, `attempt_fix`, `ship`) accept `**` for task system compatibility
14
+ - `check_github` and `attempt_fix` pass through upstream data in results for downstream consumers
15
+ - `attempt_fix` constructs `repo_url` and `branch` from payload keys when not provided directly
16
+ - `ship` accepts `org:` as alternative to `owner:`
17
+ - `LogConsumer` actor enables `check_subtask?` for workflow chain dispatch
18
+
5
19
  ## [0.1.9] - 2026-03-28
6
20
 
7
21
  ### Changed
@@ -7,10 +7,10 @@ module Legion
7
7
  class LogConsumer < Legion::Extensions::Actors::Subscription
8
8
  def runner_class = Legion::Extensions::Autofix::Runners::Pipeline
9
9
  def runner_function = 'handle_log_event'
10
- def check_subtask? = false
10
+ def check_subtask? = true
11
11
  def generate_task? = false
12
12
 
13
- def enabled?
13
+ def enabled? # rubocop:disable Legion/Extension/ActorEnabledSideEffects
14
14
  !!(defined?(Legion::LLM) && Legion::LLM.respond_to?(:started?) && Legion::LLM.started?)
15
15
  end
16
16
  end
@@ -4,8 +4,10 @@ module Legion
4
4
  module Extensions
5
5
  module Autofix
6
6
  module Runners
7
- module Diagnose
8
- def check_github(cluster:, events:, token:, org: 'LegionIO')
7
+ module Diagnose # rubocop:disable Legion/Extension/RunnerIncludeHelpers
8
+ def check_github(cluster:, events:, token: nil, org: nil, **)
9
+ token ||= resolve_token
10
+ org ||= resolve_org
9
11
  repo = cluster[:suggested_repo]
10
12
  exception_class = events.first[:exception_class] || 'unknown'
11
13
  client = Legion::Extensions::Github::Client.new(token: token)
@@ -14,12 +16,14 @@ module Legion
14
16
  )
15
17
  items = search_result.dig(:result, :items) || []
16
18
 
17
- if items.any?
18
- update_existing_issue(client: client, issue: items.first, events: events, org: org, repo: repo)
19
- else
20
- ctx = build_issue_context(cluster: cluster, events: events, exception_class: exception_class)
21
- open_new_issue(client: client, cluster: cluster, org: org, repo: repo, ctx: ctx)
22
- end
19
+ result = if items.any?
20
+ update_existing_issue(client: client, issue: items.first, events: events, org: org, repo: repo)
21
+ else
22
+ ctx = build_issue_context(cluster: cluster, events: events, exception_class: exception_class)
23
+ open_new_issue(client: client, cluster: cluster, org: org, repo: repo, ctx: ctx)
24
+ end
25
+
26
+ result.merge(org: org, repo: cluster[:suggested_repo], cluster: cluster, events: events)
23
27
  rescue StandardError => e
24
28
  { success: false, reason: e.message }
25
29
  end
@@ -7,13 +7,21 @@ module Legion
7
7
  module Extensions
8
8
  module Autofix
9
9
  module Runners
10
- module Fix
11
- def attempt_fix(repo_url:, branch:, error_details:, max_retries: 3, checkout_dir: nil)
10
+ module Fix # rubocop:disable Legion/Extension/RunnerIncludeHelpers
11
+ def attempt_fix(repo_url: nil, branch: nil, error_details: nil, issue_number: nil, # rubocop:disable Metrics/ParameterLists
12
+ org: nil, repo: nil, summary: nil, max_retries: 3, checkout_dir: nil, **)
13
+ repo_url ||= "https://github.com/#{org}/#{repo}.git" if org && repo
14
+ branch ||= "autofix/#{issue_number}-#{slug(summary || 'fix')}" if issue_number
15
+ error_details ||= {}
16
+
12
17
  tc_opts = checkout_dir ? { base_dir: checkout_dir } : {}
13
18
  tc = Helpers::TempCheckout.new(**tc_opts)
14
19
 
15
20
  clone_result = tc.clone(repo_url: repo_url, branch: branch)
16
- return clone_result unless clone_result[:success]
21
+ unless clone_result[:success]
22
+ return clone_result.merge(issue_number: issue_number, org: org, repo: repo,
23
+ branch: branch, summary: summary)
24
+ end
17
25
 
18
26
  checkout_path = clone_result[:path]
19
27
  file_paths = extract_file_paths(error_details)
@@ -40,7 +48,11 @@ module Legion
40
48
  test_result = run_tests(checkout_path: checkout_path)
41
49
  if test_result[:success]
42
50
  lint_result = run_lint(checkout_path: checkout_path)
43
- return { success: true, checkout_path: checkout_path } if lint_result[:success]
51
+ if lint_result[:success]
52
+ return { success: true, checkout_path: checkout_path,
53
+ issue_number: issue_number, org: org, repo: repo,
54
+ branch: branch, summary: summary }
55
+ end
44
56
 
45
57
  test_output = lint_result[:output]
46
58
  else
@@ -98,6 +110,10 @@ module Legion
98
110
  path.delete_prefix("#{gem_base}/")
99
111
  end
100
112
 
113
+ def slug(text)
114
+ text.to_s.downcase.gsub(/[^a-z0-9]+/, '-').gsub(/^-+|-+$/, '')[0, 40]
115
+ end
116
+
101
117
  def build_messages(attempt:, error_details:, files:, test_output:)
102
118
  prompt = if attempt.zero?
103
119
  Helpers::Prompts.fix(error_details: error_details, files: files)
@@ -6,7 +6,7 @@ module Legion
6
6
  module Extensions
7
7
  module Autofix
8
8
  module Runners
9
- module Ship
9
+ module Ship # rubocop:disable Legion/Extension/RunnerIncludeHelpers
10
10
  def commit_and_push(checkout_path:, branch:, message:)
11
11
  Dir.chdir(checkout_path) do
12
12
  return { success: false, reason: 'git add failed' } unless system('git', 'add', '-A')
@@ -17,7 +17,7 @@ module Legion
17
17
  { success: true }
18
18
  end
19
19
 
20
- def open_pr(owner:, repo:, branch:, title:, body:, token:) # rubocop:disable Metrics/ParameterLists
20
+ def open_pr(owner:, repo:, branch:, title:, body:, token:)
21
21
  client = Legion::Extensions::Github::Client.new(token: token)
22
22
  result = client.create_pull_request(
23
23
  owner: owner,
@@ -33,7 +33,10 @@ module Legion
33
33
  { success: false, reason: e.message }
34
34
  end
35
35
 
36
- def ship(checkout_path:, owner:, repo:, branch:, issue_number:, summary:, token:, checkout_dir: nil) # rubocop:disable Metrics/ParameterLists
36
+ def ship(checkout_path:, branch:, issue_number:, summary:, owner: nil, repo: nil, # rubocop:disable Metrics/ParameterLists
37
+ token: nil, org: nil, checkout_dir: nil, **)
38
+ owner ||= org
39
+ token ||= resolve_token
37
40
  commit_result = commit_and_push(
38
41
  checkout_path: checkout_path,
39
42
  branch: branch,
@@ -6,8 +6,8 @@ module Legion
6
6
  module Extensions
7
7
  module Autofix
8
8
  module Runners
9
- module Triage
10
- def batch_triage(events:)
9
+ module Triage # rubocop:disable Legion/Extension/RunnerIncludeHelpers
10
+ def batch_triage(events:, **)
11
11
  return { success: false, reason: 'no events to triage' } if events.empty?
12
12
 
13
13
  prompt = Helpers::Prompts.triage(events)
@@ -3,7 +3,7 @@
3
3
  module Legion
4
4
  module Extensions
5
5
  module Autofix
6
- VERSION = '0.1.9'
6
+ VERSION = '0.2.1'
7
7
  end
8
8
  end
9
9
  end
@@ -30,6 +30,6 @@ if defined?(Legion::Extensions::Core)
30
30
  require_relative 'autofix/runners/ship'
31
31
  require_relative 'autofix/runners/pipeline'
32
32
  require_relative 'autofix/client'
33
- require_relative 'autofix/transport' if defined?(Legion::Extensions::Transport)
34
- require_relative 'autofix/actors/log_consumer' if defined?(Legion::Extensions::Actors::Subscription)
33
+ require_relative 'autofix/transport'
34
+ require_relative 'autofix/actors/log_consumer'
35
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-autofix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - LegionIO