brainiac-fizzy 0.0.6 → 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 +4 -4
- data/lib/brainiac/plugins/fizzy/cli.rb +50 -0
- data/lib/brainiac/plugins/fizzy/hooks.rb +14 -0
- data/lib/brainiac/plugins/fizzy/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: 217c9ec16a0eb73260514086be2a7b686e8471cfd0c81c11e95d240a0a5eafa9
|
|
4
|
+
data.tar.gz: 713ae82ad6dd28c9abc7c8e7cb588e32722d1dced7d6de39f9b30b0cea72003f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
@@ -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|
|