brainiac-github 0.3.2 → 0.3.3
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 +4 -4
- data/lib/brainiac/plugins/github/handler.rb +37 -13
- data/lib/brainiac/plugins/github/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 675324c048d76415c0f4cd440ff81ed8eea72aa2806451882ea2bbe24e26303a
|
|
4
|
+
data.tar.gz: 5d30ef4b03cfdf213331c70b17ad0d275a07e3b8e7f1b869cde62665852cf0c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bef506b5391c0344d6b7f3cb25edc9c0cb4843b708fc3ddf7f2ec3fa37426855ed54d201872f41901e9e2773928ddf34527f25dbd7075b8575f7f3ed5b6538ec
|
|
7
|
+
data.tar.gz: 6e5f83d6f1598ce872505ae9eb1bad25296868846f1e93cdfea77aa9012fe956e479577b0adaa90d43a4525f6961da9ec5d3fbb3fb0fe1673a1aa16b2b78cee6
|
|
@@ -181,13 +181,14 @@ module Brainiac
|
|
|
181
181
|
result = find_work_item_by_branch(branch)
|
|
182
182
|
|
|
183
183
|
if result
|
|
184
|
-
|
|
184
|
+
work_item_id, card_info = result
|
|
185
185
|
card_number = extract_card_number(card_info)
|
|
186
186
|
unless card_number
|
|
187
187
|
LOG.warn "Card has no number — can't dispatch review"
|
|
188
188
|
return [200, { status: "ignored", reason: "card has no number" }.to_json]
|
|
189
189
|
end
|
|
190
190
|
else
|
|
191
|
+
work_item_id = nil
|
|
191
192
|
card_info = {}
|
|
192
193
|
card_number = nil
|
|
193
194
|
end
|
|
@@ -236,7 +237,7 @@ module Brainiac
|
|
|
236
237
|
card_context = card_number ? " for card ##{card_number}" : ""
|
|
237
238
|
LOG.info "PR review submitted by #{reviewer} on PR ##{pr_number}#{card_context} (project: #{project_key})"
|
|
238
239
|
dispatch_pr_review(card_number, card_key, card_info, pr_number, review, reviewer,
|
|
239
|
-
repo_name, project_key, project_config, repo_path)
|
|
240
|
+
repo_name, project_key, project_config, repo_path, work_item_id: work_item_id)
|
|
240
241
|
|
|
241
242
|
[200, { status: "processed", card: card_number, pr: pr_number, reviewer: reviewer, project: project_key }.to_json]
|
|
242
243
|
rescue StandardError => e
|
|
@@ -742,23 +743,15 @@ module Brainiac
|
|
|
742
743
|
|
|
743
744
|
intent_ctx = fetch_pr_intent_context(pr_number, repo_name, agent_name)
|
|
744
745
|
agent_env = github_agent_env(agent_name, repo_name)
|
|
745
|
-
# detect_model_explicit is newer core; fall back to detect_model on older builds.
|
|
746
|
-
if respond_to?(:detect_model_explicit)
|
|
747
|
-
comment_model, comment_model_explicit = detect_model_explicit(project_config, text: comment_body)
|
|
748
|
-
else
|
|
749
|
-
comment_model = detect_model(project_config, text: comment_body)
|
|
750
|
-
comment_model_explicit = nil
|
|
751
|
-
end
|
|
752
746
|
run_agent_opts = { project_config: project_config, chdir: worktree,
|
|
753
747
|
log_name: "pr-comment-#{pr_number}",
|
|
754
|
-
model: comment_model,
|
|
755
|
-
effort: detect_effort(project_config, text: comment_body),
|
|
756
748
|
agent_name: agent_name, source: :github,
|
|
757
749
|
source_context: { pr_number: pr_number, repo_name: repo_name, work_dir: worktree },
|
|
758
750
|
message: comment_body, channel: "GitHub PR comment",
|
|
759
751
|
context: intent_ctx }
|
|
752
|
+
work_item_id = find_work_item_by_worktree(worktree)&.first if respond_to?(:find_work_item_by_worktree, true)
|
|
753
|
+
run_agent_opts.merge!(dispatch_override_opts(project_config, comment_body, agent_name, work_item_id))
|
|
760
754
|
run_agent_opts[:env] = agent_env if method(:run_agent).parameters.flatten.include?(:env)
|
|
761
|
-
run_agent_opts[:explicit_model] = comment_model_explicit if method(:run_agent).parameters.flatten.include?(:explicit_model)
|
|
762
755
|
pid, log_file = run_agent(prompt, **run_agent_opts)
|
|
763
756
|
return unless pid
|
|
764
757
|
|
|
@@ -766,7 +759,7 @@ module Brainiac
|
|
|
766
759
|
end
|
|
767
760
|
|
|
768
761
|
def dispatch_pr_review(card_number, card_key, card_info, pr_number, review, reviewer,
|
|
769
|
-
repo_name, project_key, project_config, repo_path)
|
|
762
|
+
repo_name, project_key, project_config, repo_path, work_item_id: nil)
|
|
770
763
|
review_id = review["id"]
|
|
771
764
|
agent_name = resolve_work_item_agent(card_info, project_config)
|
|
772
765
|
|
|
@@ -809,6 +802,7 @@ module Brainiac
|
|
|
809
802
|
source_context: { pr_number: pr_number, repo_name: repo_name, work_dir: work_dir },
|
|
810
803
|
message: review["body"], channel: "GitHub PR review",
|
|
811
804
|
context: fetch_pr_intent_context(pr_number, repo_name, agent_name) }
|
|
805
|
+
run_agent_opts.merge!(dispatch_override_opts(project_config, review["body"].to_s, agent_name, work_item_id))
|
|
812
806
|
run_agent_opts[:env] = agent_env if method(:run_agent).parameters.flatten.include?(:env)
|
|
813
807
|
pid, log_file = run_agent(prompt, **run_agent_opts)
|
|
814
808
|
return unless pid
|
|
@@ -816,6 +810,36 @@ module Brainiac
|
|
|
816
810
|
register_session(card_key, pid, log_file: log_file, agent_name: agent_name)
|
|
817
811
|
end
|
|
818
812
|
|
|
813
|
+
# run_agent options for the CLI provider, model, effort and profile of a dispatch.
|
|
814
|
+
# Core's resolve_dispatch_overrides parses the [cli:X]/[model]/[effort:X]/[p:X] tags,
|
|
815
|
+
# falls back to the work item's stored overrides (so a card switched to claude in
|
|
816
|
+
# Fizzy stays on claude for PR comments), resolves the model through the provider
|
|
817
|
+
# that will actually run, and persists new tags. Older core builds lack it, so fall
|
|
818
|
+
# back to the per-tag detectors there.
|
|
819
|
+
def dispatch_override_opts(project_config, text, agent_name, work_item_id)
|
|
820
|
+
supported = method(:run_agent).parameters.flatten
|
|
821
|
+
opts = if respond_to?(:resolve_dispatch_overrides, true)
|
|
822
|
+
overrides = resolve_dispatch_overrides(project_config, text: text, agent_name: agent_name,
|
|
823
|
+
work_item_id: work_item_id)
|
|
824
|
+
{ cli_provider: overrides[:cli_provider], model: overrides[:model], effort: overrides[:effort],
|
|
825
|
+
profile: overrides[:profile], explicit_model: overrides[:explicit_model] }
|
|
826
|
+
else
|
|
827
|
+
legacy_override_opts(project_config, text)
|
|
828
|
+
end
|
|
829
|
+
opts.compact.slice(*supported)
|
|
830
|
+
end
|
|
831
|
+
|
|
832
|
+
def legacy_override_opts(project_config, text)
|
|
833
|
+
cli_provider = respond_to?(:detect_cli_provider, true) ? detect_cli_provider(text: text) : nil
|
|
834
|
+
if respond_to?(:detect_model_explicit, true)
|
|
835
|
+
model, explicit = detect_model_explicit(project_config, text: text, cli_provider_override: cli_provider)
|
|
836
|
+
else
|
|
837
|
+
model = detect_model(project_config, text: text)
|
|
838
|
+
end
|
|
839
|
+
{ cli_provider: cli_provider, model: model, explicit_model: explicit,
|
|
840
|
+
effort: detect_effort(project_config, text: text) }
|
|
841
|
+
end
|
|
842
|
+
|
|
819
843
|
def build_review_context(reviewer, review, pr_number, repo_name, agent_key = nil)
|
|
820
844
|
context = "GitHub PR Review from @#{reviewer}:\n\n"
|
|
821
845
|
context += "Review body:\n#{review["body"]}\n\n" if review["body"] && !review["body"].empty?
|