brainiac-fizzy 0.0.22 → 0.0.24

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: 55c60df15ffb87640dfbfce7a3dd64033bdf14a6c551e2269fb252468a96e4bb
4
- data.tar.gz: cc1eb7dad2215000df5fd608f12a54ee0246e5474f19b03dcc3a98716d3d76f8
3
+ metadata.gz: 5458df6821434350e3814c4002b36bf7c24449fec0375304004d96f34381c413
4
+ data.tar.gz: 6fe4ea5f51574cca99f6e90cada9480d6ff7a2c69008837f1e98259e1249abeb
5
5
  SHA512:
6
- metadata.gz: 1fa2208a211311ce53f677da3ff14786f154b506c457659ee026afc08f9495d78737282361f737d2fabc3a4474d3f11bc9f8c0e2e8a06aae90b8e8a1b63a9256
7
- data.tar.gz: fb6d51f31357250bd28c0f3d58d6115fc379afafa117316b17095e6576068a45e5a0524232acc997c9eaef5a56c2d762d42b04e57dede7b19e6c813642720ae6
6
+ metadata.gz: 6c9657c7470c20a0d288917a92d15d10823dd4ec3d113c7acf48f1b1263291106947ff0e8ecdbc675c49db1f928affc1050e9405820d11cd00e21aae329e4747
7
+ data.tar.gz: 0c03004274a798059eaa5f46025fba1e69e4b084ee99acf4a3185802a0eb6af58fed9ee23a87b7de74635c3080426a9a2aa226ae48646d9247b4afcdb8d3bec2
@@ -30,7 +30,8 @@ def fetch_intent_context(card_number, repo_path:, agent_name: nil)
30
30
  end
31
31
 
32
32
  def move_card_to_column(card_number, column_name, project_config:, agent_name: nil, board_key: nil)
33
- Brainiac::Plugins::Fizzy::Helpers.move_card_to_column(card_number, column_name, project_config: project_config, agent_name: agent_name, board_key: board_key)
33
+ Brainiac::Plugins::Fizzy::Helpers.move_card_to_column(card_number, column_name, project_config: project_config, agent_name: agent_name,
34
+ board_key: board_key)
34
35
  end
35
36
 
36
37
  def append_fizzy_comment_footer(card_number, project_config:, agent_name: nil, since: nil)
@@ -113,7 +113,13 @@ end
113
113
  def setup_assigned_worktree(repo_path, branch, card_internal_id, card_number, project_key, agent_name, board_key: nil)
114
114
  debounced_repo_fetch(repo_path)
115
115
  worktree_path = File.join(File.dirname(repo_path), "#{File.basename(repo_path)}--#{branch}")
116
- worktree_path = create_or_reuse_worktree(repo_path: repo_path, branch: branch, worktree_path: worktree_path)
116
+
117
+ # Allow plugins (e.g., brainiac-basecamp) to override the base branch for epic workflows.
118
+ base_ref = if defined?(resolve_base_branch)
119
+ resolve_base_branch(repo_path: repo_path, card_number: card_number, project_key: project_key)
120
+ end
121
+
122
+ worktree_path = create_or_reuse_worktree(repo_path: repo_path, branch: branch, base_ref: base_ref, worktree_path: worktree_path)
117
123
 
118
124
  source_data = { "card_internal_id" => card_internal_id, "card_number" => card_number }
119
125
  source_data["board_key"] = board_key if board_key
@@ -134,6 +140,17 @@ def dispatch_assigned_card(card_number:, card_internal_id:, title:, tags:, branc
134
140
  "CARD_NUMBER" => card_number, "CARD_TITLE" => title,
135
141
  "BRANCH" => branch, "COMMENT_CREATOR" => agent_name
136
142
  }
143
+
144
+ # Resolve custom PR target (for epic branch workflows)
145
+ pr_target = if defined?(resolve_pr_target)
146
+ resolve_pr_target(repo_path: project_config["repo_path"], card_number: card_number, project_key: project_key)
147
+ end
148
+ template_vars["PR_TARGET_INSTRUCTION"] = if pr_target
149
+ "**IMPORTANT: Open the PR targeting the `#{pr_target}` branch " \
150
+ "(not main).** Use: `gh pr create --base #{pr_target}`"
151
+ else
152
+ ""
153
+ end
137
154
  brain_ctx = build_brain_context(
138
155
  agent_name: agent_name, card_title: title,
139
156
  card_number: card_number, project_key: project_key, source: :fizzy
@@ -565,7 +565,9 @@ def dispatch_followup_comment(ctx, card_key:, card_number:, work_dir:)
565
565
 
566
566
  register_session(card_key, pid, log_file: log_file, supersede_key: card_key, agent_name: ctx.agent_name)
567
567
 
568
- Thread.new { move_card_to_column(card_number, "right_now", project_config: ctx.project_config, agent_name: ctx.agent_name, board_key: ctx.board_key) }
568
+ Thread.new do
569
+ move_card_to_column(card_number, "right_now", project_config: ctx.project_config, agent_name: ctx.agent_name, board_key: ctx.board_key)
570
+ end
569
571
 
570
572
  { status: "follow_up", card: card_number, card_internal_id: ctx.card_internal_id,
571
573
  worktree: work_dir, project: ctx.project_key }
@@ -33,6 +33,22 @@ end
33
33
  DEPLOYMENTS_CONFIG = load_deployments_config
34
34
  DEPLOYMENT_STATE = load_deployment_state
35
35
 
36
+ # Load work items as a card-map-compatible structure for deployment lookups.
37
+ def load_card_map
38
+ map = load_work_item_map
39
+ map.transform_values do |entry|
40
+ {
41
+ "worktree" => entry["worktree"],
42
+ "branch" => entry["branch"],
43
+ "number" => entry.dig("sources", "fizzy", "card_number"),
44
+ "title" => entry.dig("sources", "fizzy", "card_title"),
45
+ "prs" => entry.dig("sources", "github", "prs") || []
46
+ }
47
+ end
48
+ rescue StandardError
49
+ {}
50
+ end
51
+
36
52
  def reload_deployments_config!(force: false)
37
53
  return unless file_changed?(DEPLOYMENTS_CONFIG_FILE, force: force)
38
54
 
@@ -50,7 +50,7 @@ module Brainiac
50
50
 
51
51
  def agent_commented_on_card?(card_number, agent_name, repo_path:, since: nil)
52
52
  env = Helpers.fizzy_env_for(agent_name)
53
- output = run_cmd("fizzy", "comment", "list", "--card", card_number.to_s, chdir: repo_path, env: env)
53
+ output = run_cmd("fizzy", "comment", "list", "--card", card_number.to_s, "--all", chdir: repo_path, env: env)
54
54
  comments = JSON.parse(output)["data"] || []
55
55
  agent_display = agent_display_name(agent_name)
56
56
 
@@ -59,7 +59,7 @@ module Brainiac
59
59
  end
60
60
 
61
61
  def fetch_card_comments(card_number, repo_path:, env:)
62
- output = run_cmd("fizzy", "comment", "list", "--card", card_number.to_s, chdir: repo_path, env: env)
62
+ output = run_cmd("fizzy", "comment", "list", "--card", card_number.to_s, "--all", chdir: repo_path, env: env)
63
63
  comments = JSON.parse(output)["data"] || []
64
64
  return "" if comments.empty?
65
65
 
@@ -77,7 +77,7 @@ module Brainiac
77
77
  # Returns a simple "author: message" format (last 5 comments).
78
78
  def fetch_intent_context(card_number, repo_path:, agent_name: nil)
79
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)
80
+ output = run_cmd("fizzy", "comment", "list", "--card", card_number.to_s, "--all", chdir: repo_path, env: env)
81
81
  comments = JSON.parse(output)["data"] || []
82
82
  return nil if comments.empty?
83
83
 
@@ -106,7 +106,7 @@ module Brainiac
106
106
  repo_path = project_config["repo_path"]
107
107
  env = fizzy_env_for(agent_name || AI_AGENT_NAME)
108
108
 
109
- output = run_cmd("fizzy", "comment", "list", "--card", card_number.to_s, chdir: repo_path, env: env)
109
+ output = run_cmd("fizzy", "comment", "list", "--card", card_number.to_s, "--all", chdir: repo_path, env: env)
110
110
  comments = JSON.parse(output)["data"] || []
111
111
  agent_display = agent_display_name(agent_name || AI_AGENT_NAME)
112
112
 
@@ -51,7 +51,7 @@ module Brainiac
51
51
  # Retry once after a short delay to account for Fizzy API propagation.
52
52
  # The agent may have posted its comment just before exiting, and the API
53
53
  # might not return it immediately in a list call.
54
- if !found_comment
54
+ unless found_comment
55
55
  sleep 5
56
56
  found_comment = Helpers.append_fizzy_comment_footer(card_number,
57
57
  project_config: ctx[:project_config],
@@ -360,20 +360,42 @@ module Brainiac
360
360
  boards = Config.boards
361
361
  return if boards.empty?
362
362
 
363
- env = Helpers.default_fizzy_env
363
+ admin_token = Config.current["admin_token"]
364
+ unless admin_token
365
+ LOG.debug "[Fizzy] Webhook reactivation check skipped (no admin_token in fizzy.json)"
366
+ return
367
+ end
368
+
369
+ env = { "FIZZY_TOKEN" => admin_token }
364
370
  boards.each do |board_key, board_config|
365
371
  board_id = board_config["board_id"]
366
372
  next unless board_id
367
373
 
368
- output = run_cmd("fizzy", "webhook", "list", "--board", board_id, "--all", "--json", env: env)
369
- webhooks = JSON.parse(output)["data"] || []
374
+ stdout, _stderr, status = Open3.capture3(env, "fizzy", "webhook", "list",
375
+ "--board", board_id, "--all", "--json",
376
+ chdir: Dir.home)
377
+ unless status.success?
378
+ parsed = begin
379
+ JSON.parse(stdout)
380
+ rescue StandardError
381
+ nil
382
+ end
383
+ if parsed&.dig("code") == "forbidden"
384
+ LOG.warn "[Fizzy] Webhook check failed for board '#{board_key}' (admin_token lacks permission)"
385
+ else
386
+ LOG.warn "[Fizzy] Could not check webhooks for board '#{board_key}': exit #{status.exitstatus}"
387
+ end
388
+ next
389
+ end
370
390
 
391
+ webhooks = JSON.parse(stdout)["data"] || []
371
392
  webhooks.each do |webhook|
372
393
  next unless webhook["name"]&.start_with?("brainiac")
373
394
  next if webhook["active"]
374
395
 
375
396
  LOG.info "[Fizzy] Reactivating webhook '#{webhook["name"]}' on board '#{board_key}' (was inactive)"
376
- run_cmd("fizzy", "webhook", "reactivate", webhook["id"], "--board", board_id, env: env)
397
+ run_cmd("fizzy", "webhook", "reactivate", webhook["id"], "--board", board_id,
398
+ chdir: Dir.home, env: env)
377
399
  end
378
400
  rescue StandardError => e
379
401
  LOG.warn "[Fizzy] Could not check webhooks for board '#{board_key}': #{e.message}"
@@ -59,6 +59,7 @@ module Brainiac
59
59
  You have been assigned Fizzy card #{{CARD_NUMBER}}: "{{CARD_TITLE}}".
60
60
  You are on branch "{{BRANCH}}" in a fresh worktree.
61
61
  Implement the task, commit, push, and open a PR (link back to Fizzy).
62
+ {{PR_TARGET_INSTRUCTION}}
62
63
 
63
64
  **Response destination: Post your response as a comment on Fizzy card #{{CARD_NUMBER}}.**
64
65
  Your comment MUST include a concise summary of what you did, a PR link, and the branch name.
@@ -3,7 +3,7 @@
3
3
  module Brainiac
4
4
  module Plugins
5
5
  module Fizzy
6
- VERSION = "0.0.22"
6
+ VERSION = "0.0.24"
7
7
  end
8
8
  end
9
9
  end
@@ -178,7 +178,7 @@ module Brainiac
178
178
  config = DEPLOYMENTS_CONFIG["environments"] || {}
179
179
  halt 404, { error: "Unknown environment: #{env_key}" }.to_json unless config.key?(env_key)
180
180
  request.body.rewind
181
- payload = begin
181
+ begin
182
182
  JSON.parse(request.body.read)
183
183
  rescue StandardError
184
184
  {}
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.22
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Davis