brainiac-fizzy 0.0.1 → 0.0.2

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: 900a770925d9d311e242d2262ba1d55488f1f1d99b706940412c90354fbecbe7
4
- data.tar.gz: 10745520e457d223051f8b02451b6648b2fbd63b541a595da7430ef5a22a2580
3
+ metadata.gz: 4d61ec1e2e7dda1f0d37c5d584064da809d8314a97e9ad937c1ccc15ac8b7622
4
+ data.tar.gz: 794c745cb261a297a27c2b26bc7e0d831acf4eb86b56f74244f8f0f35c8b88fd
5
5
  SHA512:
6
- metadata.gz: b5da5cb4db94444d25292a4521b73229c2e0115eaa14a4f29e1ddc0de47d87cb7bf54294d16ae59615ba0691be76ebf25040895c78a460fa7492b1f12729ff23
7
- data.tar.gz: 9d16fc1d6792ddfbd2a0ba983a9bf66b4dc46cf3d2ead4bc3c77a4b6222679d5835cb30161722224cae7578a2ddd2531075090bc1829072f7c343b7bdb30abab
6
+ metadata.gz: 5a00fdc220e52bfdc4e27fc44472af3c7036f5f60bcaaa49e33239e217a48474d50fbfea3bf36b214d592260d3c06022dd8d7b5c1f1f531b694c1add5267ab4a
7
+ data.tar.gz: 181d3be9008ff6bea89223d6caed6d76503d3c1aac8517fa26c785f3f99ae9467f0acb2e7b103d1f646b3482f5ec1c0a1013bdb2498a6247010fcdd36cfcb41a
@@ -89,7 +89,7 @@ module Brainiac
89
89
  tag_names = tags.map { |t| t.is_a?(Hash) ? t["name"] : t.to_s }.map(&:downcase)
90
90
 
91
91
  PROJECTS.each do |key, config|
92
- project_tags = (config["fizzy_tags"] || []).map(&:downcase)
92
+ project_tags = (config["tags"] || config["fizzy_tags"] || []).map(&:downcase)
93
93
  return [key, config] if tag_names.intersect?(project_tags)
94
94
  end
95
95
 
@@ -41,6 +41,11 @@ def scrub_invalid_attachments!(dir)
41
41
  Brainiac::Plugins::Fizzy::Helpers.scrub_invalid_attachments!(dir)
42
42
  end
43
43
 
44
+ def detect_planning_mode(text:, tags:, card_internal_id:, card_number:)
45
+ Brainiac::Plugins::Fizzy::Helpers.detect_planning_mode(text: text, tags: tags,
46
+ card_internal_id: card_internal_id, card_number: card_number)
47
+ end
48
+
44
49
  def verify_fizzy_signature!(request, payload_body, board_key: nil)
45
50
  Brainiac::Plugins::Fizzy::Helpers.verify_signature!(request, payload_body, board_key: board_key)
46
51
  end
@@ -83,6 +88,30 @@ def human_mentioned?(user_id)
83
88
  Brainiac::Plugins::Fizzy::Config.human_mentioned?(user_id)
84
89
  end
85
90
 
91
+ # Extracts user IDs from Fizzy mention markup in plain text.
92
+ # Fizzy represents mentions as @[Display Name](user-id) in plain text.
93
+ def detect_mentioned_user_ids(text)
94
+ return [] unless text
95
+
96
+ text.scan(/@\[[^\]]*\]\(([^)]+)\)/).flatten
97
+ end
98
+
99
+ # Webhook dispatch — routes incoming actions to the appropriate handler.
100
+ # Called from within the Sinatra route block, so it must be a top-level method.
101
+ def dispatch_webhook_action(action, payload)
102
+ case action
103
+ when "card_assigned"
104
+ handle_card_assigned(payload)
105
+ when "comment_created"
106
+ handle_comment(payload)
107
+ when "card_published", "card_triaged"
108
+ Brainiac::Plugins::Fizzy.handle_publish_or_triage(action, payload)
109
+ else
110
+ LOG.info "[Fizzy] Ignoring unknown action: #{action}"
111
+ [200, { status: "ignored", action: action }.to_json]
112
+ end
113
+ end
114
+
86
115
  # Top-level prompt constants — handler files reference these directly
87
116
  PROMPT_CARD_ASSIGNED = Brainiac::Plugins::Fizzy::Prompts::CARD_ASSIGNED
88
117
  PROMPT_FOLLOWUP_WORKTREE = Brainiac::Plugins::Fizzy::Prompts::FOLLOWUP_WORKTREE
@@ -67,6 +67,24 @@ end
67
67
 
68
68
  def react_to_assignment(card_number, repo_path, agent_name)
69
69
  Thread.new do
70
+ # Delete existing reactions from this agent before re-reacting
71
+ result = run_cmd("fizzy", "reaction", "list", "--card", card_number.to_s,
72
+ "--jq", '[.data[] | {id, reacter_id: .reacter.id}]',
73
+ chdir: repo_path, env: fizzy_env_for(agent_name))
74
+ reactions = JSON.parse(result)
75
+
76
+ identity = run_cmd("fizzy", "identity", "show", "--jq", '.data.accounts[0].user.id',
77
+ chdir: repo_path, env: fizzy_env_for(agent_name))
78
+ current_user_id = identity.strip.tr('"', '')
79
+
80
+ reactions.each do |reaction|
81
+ if reaction["reacter_id"] == current_user_id
82
+ run_cmd("fizzy", "reaction", "delete", reaction["id"], "--card", card_number.to_s,
83
+ chdir: repo_path, env: fizzy_env_for(agent_name))
84
+ end
85
+ end
86
+
87
+ # Add fresh reaction
70
88
  run_cmd("fizzy", "reaction", "create", "--card", card_number.to_s,
71
89
  "--content", "👍", chdir: repo_path, env: fizzy_env_for(agent_name))
72
90
  rescue StandardError => e
@@ -139,6 +139,16 @@ module Brainiac
139
139
  end
140
140
  end
141
141
 
142
+ # Determines whether a card should run in planning mode.
143
+ # Returns nil if planning is not active, or { card_id: <id> } if it is.
144
+ # Planning mode is triggered by a "plan" or "planning" tag on the card.
145
+ def detect_planning_mode(text:, tags:, card_internal_id:, card_number:)
146
+ tag_names = (tags || []).map { |t| t.is_a?(Hash) ? t["name"] : t.to_s }.map(&:downcase)
147
+ return nil unless tag_names.include?("plan") || tag_names.include?("planning")
148
+
149
+ { card_id: card_number || card_internal_id }
150
+ end
151
+
142
152
  private
143
153
 
144
154
  def detect_branch_from_comment(body, card_number)
@@ -3,7 +3,7 @@
3
3
  module Brainiac
4
4
  module Plugins
5
5
  module Fizzy
6
- VERSION = "0.0.1"
6
+ VERSION = "0.0.2"
7
7
  end
8
8
  end
9
9
  end
@@ -171,20 +171,6 @@ module Brainiac
171
171
  end
172
172
  end
173
173
 
174
- def dispatch_webhook_action(action, payload)
175
- case action
176
- when "card_assigned"
177
- handle_card_assigned(payload)
178
- when "comment_created"
179
- handle_comment(payload)
180
- when "card_published", "card_triaged"
181
- Brainiac::Plugins::Fizzy.handle_publish_or_triage(action, payload)
182
- else
183
- LOG.info "[Fizzy] Ignoring unknown action: #{action}"
184
- [200, { status: "ignored", action: action }.to_json]
185
- end
186
- end
187
-
188
174
  public
189
175
 
190
176
  def handle_publish_or_triage(action, payload)
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Davis