brainiac-fizzy 0.0.6 → 0.0.8
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/delegators.rb +4 -0
- data/lib/brainiac/plugins/fizzy/handlers/comments.rb +9 -3
- data/lib/brainiac/plugins/fizzy/helpers.rb +19 -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: 98a0dcf9fc45aff45ad0dd467090b4f7ef96e426ce2862fcf5b9251baf4fc519
|
|
4
|
+
data.tar.gz: eb2b8ec913902f3365efefa1424ae271f3e63f94161c0bbaddc116f9c0ec1bcb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 065dd360d8c26815dc3122e652003c40296edd8fcd582ac9d23a8446b3e29bbcff7d2983b468ad4c395b5729d1ee309a26756af663291ea5385ba4325d7d885d
|
|
7
|
+
data.tar.gz: 969d24c897c660ef777576c258df0b26d9f86d478525306f53e5836bcb36716ad6b9b9d6133a465efce89a14c4fab51f5b46b3f44e2f563fdbf885d7caaccaad
|
|
@@ -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
|
|
@@ -25,6 +25,10 @@ def prefetch_card_context(card_number, repo_path:, agent_name: nil)
|
|
|
25
25
|
Brainiac::Plugins::Fizzy::Helpers.prefetch_card_context(card_number, repo_path: repo_path, agent_name: agent_name)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
def fetch_intent_context(card_number, repo_path:, agent_name: nil)
|
|
29
|
+
Brainiac::Plugins::Fizzy::Helpers.fetch_intent_context(card_number, repo_path: repo_path, agent_name: agent_name)
|
|
30
|
+
end
|
|
31
|
+
|
|
28
32
|
def move_card_to_column(card_number, column_name, project_config:, agent_name: nil)
|
|
29
33
|
Brainiac::Plugins::Fizzy::Helpers.move_card_to_column(card_number, column_name, project_config: project_config, agent_name: agent_name)
|
|
30
34
|
end
|
|
@@ -364,6 +364,7 @@ def dispatch_cross_agent_review(ctx, card_key:, card_number:, card_assigned_agen
|
|
|
364
364
|
review_worktree_path, review_branch = setup_cross_agent_worktree(ctx, card_number)
|
|
365
365
|
prompt = build_cross_agent_prompt(ctx, card_number, card_assigned_agent, review_worktree_path, review_branch)
|
|
366
366
|
|
|
367
|
+
intent_ctx = fetch_intent_context(card_number, repo_path: ctx.project_config["repo_path"], agent_name: ctx.agent_name)
|
|
367
368
|
pid, log_file = run_agent(prompt,
|
|
368
369
|
project_config: ctx.project_config, chdir: review_worktree_path,
|
|
369
370
|
log_name: "review-#{ctx.agent_name.downcase}-#{card_number || ctx.card_internal_id}",
|
|
@@ -371,7 +372,8 @@ def dispatch_cross_agent_review(ctx, card_key:, card_number:, card_assigned_agen
|
|
|
371
372
|
card_number: card_number, comment_id: ctx.comment_id,
|
|
372
373
|
source: :fizzy, source_context: { card_number: card_number },
|
|
373
374
|
cli_provider: ctx.cli_provider_override,
|
|
374
|
-
message: ctx.plain_text, channel: "Fizzy comment"
|
|
375
|
+
message: ctx.plain_text, channel: "Fizzy comment",
|
|
376
|
+
context: intent_ctx)
|
|
375
377
|
return [200, { status: "intent_skip", agent: ctx.agent_name, card: card_number }.to_json] unless pid
|
|
376
378
|
|
|
377
379
|
register_session(card_key, pid, log_file: log_file, supersede_key: card_key, agent_name: ctx.agent_name)
|
|
@@ -472,6 +474,7 @@ end
|
|
|
472
474
|
def dispatch_new_mention(ctx, card_key:, card_number:, card_title:, branch:, worktree_path:)
|
|
473
475
|
prompt = build_mention_prompt(ctx, card_number, card_title, branch, worktree_path)
|
|
474
476
|
|
|
477
|
+
intent_ctx = fetch_intent_context(card_number, repo_path: ctx.project_config["repo_path"], agent_name: ctx.agent_name)
|
|
475
478
|
pid, log_file = run_agent(prompt,
|
|
476
479
|
project_config: ctx.project_config, chdir: worktree_path,
|
|
477
480
|
log_name: "mention-#{card_number || ctx.card_internal_id}",
|
|
@@ -479,7 +482,8 @@ def dispatch_new_mention(ctx, card_key:, card_number:, card_title:, branch:, wor
|
|
|
479
482
|
card_number: card_number, comment_id: ctx.comment_id,
|
|
480
483
|
source: :fizzy, cli_provider: ctx.cli_provider_override,
|
|
481
484
|
source_context: { card_number: card_number },
|
|
482
|
-
message: ctx.plain_text, channel: "Fizzy comment"
|
|
485
|
+
message: ctx.plain_text, channel: "Fizzy comment",
|
|
486
|
+
context: intent_ctx)
|
|
483
487
|
return [200, { status: "intent_skip", agent: ctx.agent_name, card: card_number }.to_json] unless pid
|
|
484
488
|
|
|
485
489
|
register_session(card_key, pid, log_file: log_file, supersede_key: card_key, agent_name: ctx.agent_name)
|
|
@@ -509,6 +513,7 @@ def dispatch_followup_comment(ctx, card_key:, card_number:, work_dir:)
|
|
|
509
513
|
build_followup_prompt(ctx, card_number, card_tags, work_dir)
|
|
510
514
|
end
|
|
511
515
|
|
|
516
|
+
intent_ctx = fetch_intent_context(card_number, repo_path: ctx.project_config["repo_path"], agent_name: ctx.agent_name)
|
|
512
517
|
pid, log_file = run_agent(prompt,
|
|
513
518
|
project_config: ctx.project_config, chdir: work_dir,
|
|
514
519
|
log_name: "followup-#{card_number || ctx.card_internal_id}",
|
|
@@ -519,7 +524,8 @@ def dispatch_followup_comment(ctx, card_key:, card_number:, work_dir:)
|
|
|
519
524
|
card_number: card_number, card_internal_id: ctx.card_internal_id,
|
|
520
525
|
deploy_intent: ctx.deploy_intent
|
|
521
526
|
},
|
|
522
|
-
message: ctx.plain_text, channel: "Fizzy comment"
|
|
527
|
+
message: ctx.plain_text, channel: "Fizzy comment",
|
|
528
|
+
context: intent_ctx)
|
|
523
529
|
return [200, { status: "intent_skip", agent: ctx.agent_name, card: card_number }.to_json] unless pid
|
|
524
530
|
|
|
525
531
|
register_session(card_key, pid, log_file: log_file, supersede_key: card_key, agent_name: ctx.agent_name)
|
|
@@ -73,6 +73,25 @@ module Brainiac
|
|
|
73
73
|
""
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
+
# Lightweight recent comment context for intent classification.
|
|
77
|
+
# Returns a simple "author: message" format (last 5 comments).
|
|
78
|
+
def fetch_intent_context(card_number, repo_path:, agent_name: nil)
|
|
79
|
+
env = fizzy_env_for(agent_name || AI_AGENT_NAME)
|
|
80
|
+
output = run_cmd("fizzy", "comment", "list", "--card", card_number.to_s, chdir: repo_path, env: env)
|
|
81
|
+
comments = JSON.parse(output)["data"] || []
|
|
82
|
+
return nil if comments.empty?
|
|
83
|
+
|
|
84
|
+
comments.last(5).map do |c|
|
|
85
|
+
creator = c["creator_name"] || "unknown"
|
|
86
|
+
body = (c.dig("body", "plain_text") || "").lines.first(3).join.strip
|
|
87
|
+
body = "#{body[0..200]}..." if body.length > 200
|
|
88
|
+
"#{creator}: #{body}"
|
|
89
|
+
end.join("\n")
|
|
90
|
+
rescue StandardError => e
|
|
91
|
+
LOG.warn "[Fizzy] Could not fetch intent context for card ##{card_number}: #{e.message}" if defined?(LOG)
|
|
92
|
+
nil
|
|
93
|
+
end
|
|
94
|
+
|
|
76
95
|
def move_card_to_column(card_number, column_name, project_config:, agent_name: nil)
|
|
77
96
|
board_key = Config.board_key_for_project(project_config)
|
|
78
97
|
column_id = Config.board_column_id(board_key, column_name) if board_key
|
|
@@ -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|
|