brainiac-github 0.0.4 → 0.0.6

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: 2b4b7765436395524bb60085fcbc02da2c081ad9317936158e0e1b35b55d84c6
4
- data.tar.gz: 7d1ee30b16258e253fe89330a9c4d8a59452e87f94f939bc4146aa0170d81ed6
3
+ metadata.gz: b4606ec0c07107e122e51570364e05d20db3d0717e7a6679cdff85471f38e0b5
4
+ data.tar.gz: 73ad18ee4563e0e55d56a1cab2f8f8714484d3fee3bbc1c3763ec1e2886221eb
5
5
  SHA512:
6
- metadata.gz: 7e9da9afda1cabacd1aaf6c6ec6705b77f515b0ec161b109fe8b08a466ebf8a129fae26705538d131e01ef60419c61505cb3386fe0aaee1b90d99f80e09d7871
7
- data.tar.gz: a8584862b22c4efe2627d9174d0b52062e079c0853f344e13f22c4ec13b9ded05adf1aff741e347e8c9ec3d3f223fbfacf5909717c503409a9d1513a90babe81
6
+ metadata.gz: 9c7240c8f7a3a1b57e72bc6245a50d7089c82736e6e0259c2944ca623fbb6839f564064b75788c3b8fc60489393b0fdc65ff932410da878b2bb19bc16327c801
7
+ data.tar.gz: 05405f8388fe9c817d4c2b59edde95f5ac6819112fa1f30f24d486a35a37c2dd417aad3f0c17f760e237f1d54681508e436cd1820f6b56eea5a1fc6ec77d1e96
@@ -301,13 +301,15 @@ module Brainiac
301
301
  project_key: project_key, comment_body: comment_body),
302
302
  agent_name: agent_name, channel: :github)
303
303
 
304
+ intent_ctx = fetch_pr_intent_context(pr_number, repo_name)
304
305
  pid, log_file = run_agent(prompt, project_config: project_config, chdir: worktree,
305
306
  log_name: "pr-comment-#{pr_number}",
306
307
  model: detect_model(project_config, text: comment_body),
307
308
  effort: detect_effort(project_config, text: comment_body),
308
309
  agent_name: agent_name, source: :github,
309
310
  source_context: { pr_number: pr_number, repo_name: repo_name, work_dir: worktree },
310
- message: comment_body, channel: "GitHub PR comment")
311
+ message: comment_body, channel: "GitHub PR comment",
312
+ context: intent_ctx)
311
313
  return unless pid
312
314
 
313
315
  register_session(card_key, pid, log_file: log_file, agent_name: agent_name)
@@ -345,7 +347,8 @@ module Brainiac
345
347
  agent_name: agent_name,
346
348
  source: :github,
347
349
  source_context: { pr_number: pr_number, repo_name: repo_name, work_dir: work_dir },
348
- message: review["body"], channel: "GitHub PR review")
350
+ message: review["body"], channel: "GitHub PR review",
351
+ context: fetch_pr_intent_context(pr_number, repo_name))
349
352
  return unless pid
350
353
 
351
354
  register_session(card_key, pid, log_file: log_file, agent_name: agent_name)
@@ -375,6 +378,20 @@ module Brainiac
375
378
  []
376
379
  end
377
380
 
381
+ # Lightweight recent PR comment context for intent classification.
382
+ # Returns "author: message" format (last 5 issue comments on the PR).
383
+ def fetch_pr_intent_context(pr_number, repo_name)
384
+ output = run_cmd("gh", "api", "/repos/#{repo_name}/issues/#{pr_number}/comments",
385
+ "--jq", ".[-5:] | .[] | \"\\(.user.login): \\(.body[0:200])\"",
386
+ chdir: PROJECTS.values.first&.dig("repo_path") || Dir.pwd)
387
+ return nil if output.strip.empty?
388
+
389
+ output.strip
390
+ rescue StandardError => e
391
+ LOG.warn "[GitHub] Could not fetch intent context for PR ##{pr_number}: #{e.message}" if defined?(LOG)
392
+ nil
393
+ end
394
+
378
395
  def close_uat_cards_after_deploy(project_key, project_config)
379
396
  results = Brainiac.emit(:production_deployed, project_key: project_key, project_config: project_config)
380
397
  closed_cards = results.flatten.compact
@@ -3,7 +3,7 @@
3
3
  module Brainiac
4
4
  module Plugins
5
5
  module Github
6
- VERSION = "0.0.4"
6
+ VERSION = "0.0.6"
7
7
  end
8
8
  end
9
9
  end
@@ -19,6 +19,7 @@ module Brainiac
19
19
  Config.load!
20
20
  Brainiac.register_channel_prompt(:github, Prompts::CHANNEL, pre_post_check: Prompts::PRE_POST_CHECK)
21
21
  register_crash_handler!
22
+ register_agent_lifecycle_hooks!
22
23
  setup_routes(app)
23
24
  LOG.info "[GitHub] Plugin registered (webhook: /github)"
24
25
  end
@@ -39,6 +40,18 @@ module Brainiac
39
40
 
40
41
  private
41
42
 
43
+ def register_agent_lifecycle_hooks!
44
+ Brainiac.on(:agent_added) do |ctx|
45
+ Config.reload!
46
+ LOG.info "[GitHub] Agent added: #{ctx[:display_name]} — config reloaded" if defined?(LOG)
47
+ end
48
+
49
+ Brainiac.on(:agent_removed) do |ctx|
50
+ Config.reload!
51
+ LOG.info "[GitHub] Agent removed: #{ctx[:agent_key]} — config reloaded" if defined?(LOG)
52
+ end
53
+ end
54
+
42
55
  def register_crash_handler!
43
56
  Brainiac.on(:agent_crashed) do |ctx|
44
57
  next unless ctx[:source] == :github
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brainiac-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Davis