brainiac-fizzy 0.0.5 → 0.0.7

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: 52b33b796dafe9d47fe9db8f881537d2d66bda2f54f51f1bafb9dd4a4b188a4c
4
- data.tar.gz: '0260149a3b2daa8439049b9369980f1edf73f65226cb07785f7f0c954e74dc66'
3
+ metadata.gz: 217c9ec16a0eb73260514086be2a7b686e8471cfd0c81c11e95d240a0a5eafa9
4
+ data.tar.gz: 713ae82ad6dd28c9abc7c8e7cb588e32722d1dced7d6de39f9b30b0cea72003f
5
5
  SHA512:
6
- metadata.gz: 2fc7f43f8c505d94fc7f4364cb24d33d9aee11d23e6a73033df82e5fd6ad4b4aa496348df42fcac455ba71d75d7d66b3cea76b458f3cb5b0f544682427e5f4a5
7
- data.tar.gz: 6bb9c239037adde4e1f371eb7087501ee9233ac32177ca2997aad0a4926b4e9db217d0b06dd49e2384fab3cb4a27de01b7491af32afcf121a536e68e7ab5a773
6
+ metadata.gz: a0fb9fc74bb8b6ee408ffcb5f65c6123cf5b4b3e50a761bde58bc7a6aafb4b64496c3cb00f98580fe248afd261b3822aae4d064d44452909f3f2ac011d378f29
7
+ data.tar.gz: 93307161001d597b62991ffbd6850bf76883227d93a1844740ade3b55168aafbed71a1e9d5a4918e5673c1ab456dcbe903c41a5209bab53b588726f018c3cdee
@@ -137,6 +137,56 @@ module Brainiac
137
137
  def self.completions
138
138
  %w[config status setup]
139
139
  end
140
+
141
+ # Called by brainiac CLI after `agent create` — prompts for Fizzy user ID.
142
+ def self.on_agent_created(agent_key, entry)
143
+ return unless $stdin.tty?
144
+
145
+ config_file = File.join(ENV.fetch("BRAINIAC_DIR", File.join(Dir.home, ".brainiac")), "fizzy.json")
146
+ return unless File.exist?(config_file)
147
+
148
+ display_name = entry["display_name"] || agent_key.capitalize
149
+ puts ""
150
+ puts " [Fizzy] Configure Fizzy for #{display_name}?"
151
+ print " Fizzy user ID (or blank to skip): "
152
+ user_id = $stdin.gets&.chomp
153
+ return if user_id.nil? || user_id.empty?
154
+
155
+ config = JSON.parse(File.read(config_file))
156
+ config["authorized_users"] ||= []
157
+
158
+ # Don't add if already present
159
+ existing = config["authorized_users"].find { |u| u["id"] == user_id || u["name"]&.downcase == display_name.downcase }
160
+ if existing
161
+ puts " ✓ #{display_name} already in authorized_users (id: #{existing["id"]})"
162
+ return
163
+ end
164
+
165
+ config["authorized_users"] << { "id" => user_id, "name" => display_name, "human" => false }
166
+ File.write(config_file, JSON.pretty_generate(config))
167
+ puts " ✓ Added #{display_name} (#{user_id}) to fizzy.json authorized_users"
168
+ rescue JSON::ParserError => e
169
+ puts " ⚠ Could not update fizzy.json: #{e.message}"
170
+ end
171
+
172
+ # Called by brainiac CLI after `agent remove` — removes from Fizzy authorized_users.
173
+ def self.on_agent_removed(agent_key, display_name)
174
+ config_file = File.join(ENV.fetch("BRAINIAC_DIR", File.join(Dir.home, ".brainiac")), "fizzy.json")
175
+ return unless File.exist?(config_file)
176
+
177
+ config = JSON.parse(File.read(config_file))
178
+ users = config["authorized_users"]
179
+ return unless users
180
+
181
+ original_size = users.size
182
+ users.reject! { |u| u["name"]&.downcase == display_name.downcase || u["name"]&.downcase == agent_key }
183
+ return if users.size == original_size
184
+
185
+ File.write(config_file, JSON.pretty_generate(config))
186
+ puts " [Fizzy] Removed #{display_name} from fizzy.json authorized_users"
187
+ rescue JSON::ParserError
188
+ nil
189
+ end
140
190
  end
141
191
  end
142
192
  end
@@ -370,7 +370,10 @@ def dispatch_cross_agent_review(ctx, card_key:, card_number:, card_assigned_agen
370
370
  model: ctx.model, effort: ctx.effort, agent_name: ctx.agent_name,
371
371
  card_number: card_number, comment_id: ctx.comment_id,
372
372
  source: :fizzy, source_context: { card_number: card_number },
373
- cli_provider: ctx.cli_provider_override)
373
+ cli_provider: ctx.cli_provider_override,
374
+ message: ctx.plain_text, channel: "Fizzy comment")
375
+ return [200, { status: "intent_skip", agent: ctx.agent_name, card: card_number }.to_json] unless pid
376
+
374
377
  register_session(card_key, pid, log_file: log_file, supersede_key: card_key, agent_name: ctx.agent_name)
375
378
 
376
379
  [200, { status: "cross_agent_review", agent: ctx.agent_name, card_agent: card_assigned_agent,
@@ -475,7 +478,10 @@ def dispatch_new_mention(ctx, card_key:, card_number:, card_title:, branch:, wor
475
478
  model: ctx.model, effort: ctx.effort, agent_name: ctx.agent_name,
476
479
  card_number: card_number, comment_id: ctx.comment_id,
477
480
  source: :fizzy, cli_provider: ctx.cli_provider_override,
478
- source_context: { card_number: card_number })
481
+ source_context: { card_number: card_number },
482
+ message: ctx.plain_text, channel: "Fizzy comment")
483
+ return [200, { status: "intent_skip", agent: ctx.agent_name, card: card_number }.to_json] unless pid
484
+
479
485
  register_session(card_key, pid, log_file: log_file, supersede_key: card_key, agent_name: ctx.agent_name)
480
486
 
481
487
  [200, { status: "responded", card_internal_id: ctx.card_internal_id, card_number: card_number,
@@ -512,7 +518,10 @@ def dispatch_followup_comment(ctx, card_key:, card_number:, work_dir:)
512
518
  source_context: {
513
519
  card_number: card_number, card_internal_id: ctx.card_internal_id,
514
520
  deploy_intent: ctx.deploy_intent
515
- })
521
+ },
522
+ message: ctx.plain_text, channel: "Fizzy comment")
523
+ return [200, { status: "intent_skip", agent: ctx.agent_name, card: card_number }.to_json] unless pid
524
+
516
525
  register_session(card_key, pid, log_file: log_file, supersede_key: card_key, agent_name: ctx.agent_name)
517
526
 
518
527
  Thread.new { move_card_to_column(card_number, "right_now", project_config: ctx.project_config, agent_name: ctx.agent_name) }
@@ -9,6 +9,7 @@ module Brainiac
9
9
  def register_all!
10
10
  register_agent_completed
11
11
  register_agent_crashed
12
+ register_agent_lifecycle
12
13
  register_pre_dispatch
13
14
  register_brain_context
14
15
  register_pr_merged
@@ -76,6 +77,19 @@ module Brainiac
76
77
  end
77
78
  end
78
79
 
80
+ # Agent lifecycle — reload config when agents are added/removed
81
+ def register_agent_lifecycle
82
+ Brainiac.on(:agent_added) do |ctx|
83
+ Config.reload!
84
+ LOG.info "[Fizzy] Agent added: #{ctx[:display_name]} — config reloaded" if defined?(LOG)
85
+ end
86
+
87
+ Brainiac.on(:agent_removed) do |ctx|
88
+ Config.reload!
89
+ LOG.info "[Fizzy] Agent removed: #{ctx[:agent_key]} — config reloaded" if defined?(LOG)
90
+ end
91
+ end
92
+
79
93
  # Before agent dispatch — copy .fizzy.yaml and clean attachments
80
94
  def register_pre_dispatch
81
95
  Brainiac.on(:pre_dispatch) do |ctx|
@@ -3,7 +3,7 @@
3
3
  module Brainiac
4
4
  module Plugins
5
5
  module Fizzy
6
- VERSION = "0.0.5"
6
+ VERSION = "0.0.7"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brainiac-fizzy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Davis
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.0.8
18
+ version: 0.0.14
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 0.0.8
25
+ version: 0.0.14
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: minitest
28
28
  requirement: !ruby/object:Gem::Requirement