brainiac-github 0.2.0 → 0.2.2
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 +48 -1
- 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: c5ae816a199e6894108759603b7d806d34000a3da5c44637456cbeb270ed4e8c
|
|
4
|
+
data.tar.gz: 06c7c6bb1bf211992d40ba6cf7f50df203300319dea3d34bc4f3630990311edf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7491a2210feb364892a300ea122f07694d08a82a8f46563e45a36e425346480779ebe82bbb6c1269dbc3ea8bb2805a6fe505b6fa8ee4d957177318c63daece08
|
|
7
|
+
data.tar.gz: b99ada00a52071cda049b98e4baa6f68358827dba5dced00bfb2cf1421e9ca2095d756d2364b1c176f54e68209b038ee9922502b6bd6ecb866bea126b200cd04
|
|
@@ -52,6 +52,27 @@ module Brainiac
|
|
|
52
52
|
|
|
53
53
|
def handle_pr_opened(payload)
|
|
54
54
|
track_pr_in_work_items(payload)
|
|
55
|
+
|
|
56
|
+
# Emit :pr_opened hook so plugins (e.g., brainiac-basecamp) can trigger review gates.
|
|
57
|
+
pr = payload["pull_request"]
|
|
58
|
+
branch = pr.dig("head", "ref")
|
|
59
|
+
|
|
60
|
+
result = find_work_item_by_branch(branch)
|
|
61
|
+
if result
|
|
62
|
+
_internal_id, card_info = result
|
|
63
|
+
card_number = extract_card_number(card_info)
|
|
64
|
+
pr_number = pr["number"]
|
|
65
|
+
repo_name = payload.dig("repository", "full_name")
|
|
66
|
+
repo_path = card_info["worktree"] || find_repo_path_for(payload)
|
|
67
|
+
base_branch = pr.dig("base", "ref")
|
|
68
|
+
|
|
69
|
+
Brainiac.emit(:pr_opened,
|
|
70
|
+
card_number: card_number, card_info: card_info,
|
|
71
|
+
pr_number: pr_number, repo_name: repo_name,
|
|
72
|
+
repo_path: repo_path, branch: branch,
|
|
73
|
+
base_branch: base_branch, pull_request: pr)
|
|
74
|
+
end
|
|
75
|
+
|
|
55
76
|
[200, { status: "processed", action: "pr_tracked" }.to_json]
|
|
56
77
|
end
|
|
57
78
|
|
|
@@ -177,6 +198,20 @@ module Brainiac
|
|
|
177
198
|
branch = fetch_pr_branch(repo_name, pr_number, agent_name, project_config)
|
|
178
199
|
result = find_work_item_by_branch(branch)
|
|
179
200
|
|
|
201
|
+
# If a work item exists and has an assigned agent, use that agent
|
|
202
|
+
# instead of the project default. This ensures comments on a PR
|
|
203
|
+
# route to whoever is actually working it (e.g. GLaDOS opened the PR,
|
|
204
|
+
# so GLaDOS should handle follow-up comments — not the project's default agent).
|
|
205
|
+
# Explicit mentions still take priority (already resolved above).
|
|
206
|
+
if result && !mentioned
|
|
207
|
+
_, card_info = result
|
|
208
|
+
work_item_agent = card_info["agent"]
|
|
209
|
+
if work_item_agent && work_item_agent.downcase != agent_name.downcase && local_agent_names.include?(work_item_agent)
|
|
210
|
+
LOG.info "[GitHub] Work item agent override: #{work_item_agent} (project default: #{agent_name})"
|
|
211
|
+
agent_name = work_item_agent
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
180
215
|
card_number, worktree = resolve_comment_worktree(result, mentioned, agent_name, pr_number, project_config)
|
|
181
216
|
return worktree if worktree.is_a?(Array)
|
|
182
217
|
|
|
@@ -283,6 +318,18 @@ module Brainiac
|
|
|
283
318
|
card_info["number"] || card_info.dig("sources", "fizzy", "card_number")
|
|
284
319
|
end
|
|
285
320
|
|
|
321
|
+
# Resolve the agent name from a work item, falling back to the project default.
|
|
322
|
+
# Work items track which agent is assigned (e.g. GLaDOS opened the PR), so
|
|
323
|
+
# comments/reviews should route to that agent rather than the project default.
|
|
324
|
+
def resolve_work_item_agent(card_info, project_config)
|
|
325
|
+
work_item_agent = card_info["agent"] if card_info
|
|
326
|
+
if work_item_agent && local_agent_names.include?(work_item_agent)
|
|
327
|
+
work_item_agent
|
|
328
|
+
else
|
|
329
|
+
agent_name_for(project_config)
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
|
|
286
333
|
# Fetch the head branch name of a PR using the GitHub App or `gh` CLI.
|
|
287
334
|
def fetch_pr_branch(repo_name, pr_number, agent_name, project_config)
|
|
288
335
|
if AppClient.configured?(agent_name)
|
|
@@ -460,7 +507,7 @@ module Brainiac
|
|
|
460
507
|
def dispatch_pr_review(card_number, card_key, card_info, pr_number, review, reviewer,
|
|
461
508
|
repo_name, project_key, project_config, repo_path)
|
|
462
509
|
review_id = review["id"]
|
|
463
|
-
agent_name =
|
|
510
|
+
agent_name = resolve_work_item_agent(card_info, project_config)
|
|
464
511
|
|
|
465
512
|
Thread.new do
|
|
466
513
|
if AppClient.configured?(agent_name)
|