brainiac-basecamp 0.0.18 → 0.0.19

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: c082cb39df24b56239de1b12de0772b25088854641d633afa7352a035e63b721
4
- data.tar.gz: 2139e2c80a63636e2f3e427b9b784a4237d5f5abf2e52e8018407081d3b6ad23
3
+ metadata.gz: e7d5fd8ee1c180d8083b77c3324d138678276d8bbc471dfa48c51d43ae0cca06
4
+ data.tar.gz: ec08e6a76392e28d5ef6b6a88adac7712bb60887eca9643d02227f556c7d472a
5
5
  SHA512:
6
- metadata.gz: 16b4848a37f1d4a0b0e0a93940540cace70f020dd11c4cbad84410310f442cb6377a1bf7a8de0204326bf36c894a345aee88278908fffc5c2cd38ba0456b81d9
7
- data.tar.gz: 2f2caa6a328819e0c27eb5f3b1da73b26e411b5a38f40d1bea2078ad4c3c9dfa1f381d25f83838675941a2cc06b599f50df99f75aec30bc024f891741d892d35
6
+ metadata.gz: c82d88fd5a6cc8cf77330773b7eff552a3bfb7db291627ab0aef5dc3e8e178cee829389a0f72abd1938e4610c04878f3688e0963091a5361f6ae9dcea9f63b4c
7
+ data.tar.gz: 7ecb2081edefc0da28093bb5eb2b3cd26da316926349093bf51a36c7308073b5387279d3723a0a814c05f3a79dd7a4b17df07c7f479cc132f0fbeb75d5b64f88
@@ -522,7 +522,7 @@ module Brainiac
522
522
  def resolve_project_from_fizzy_card(card_number)
523
523
  return nil unless card_number
524
524
 
525
- # Query the Fizzy card for its tags
525
+ # Query the Fizzy card for its tags and board
526
526
  stdout, _, status = Open3.capture3("fizzy", "card", "show", card_number.to_s, "--json")
527
527
  return nil unless status.success?
528
528
 
@@ -531,20 +531,43 @@ module Brainiac
531
531
  card = card_data.is_a?(Hash) && card_data["data"] ? card_data["data"] : card_data
532
532
  tags = card["tags"] || []
533
533
 
534
- # Extract tag names (tags can be strings or hashes with "name" key)
535
- tag_names = tags.map { |t| t.is_a?(Hash) ? t["name"] : t.to_s }.map(&:downcase)
536
- return nil if tag_names.empty?
537
-
538
- # Load projects and match tags
534
+ # Load projects for matching
539
535
  projects_file = File.join(BRAINIAC_DIR, "projects.json")
540
536
  return nil unless File.exist?(projects_file)
541
537
 
542
538
  all_projects = JSON.parse(File.read(projects_file))
543
539
 
544
- # Find the first project whose fizzy_tags intersect with the card's tags
545
- all_projects.each do |key, config|
546
- project_tags = (config["tags"] || config["fizzy_tags"] || []).map(&:downcase)
547
- return key if tag_names.intersect?(project_tags)
540
+ # Priority 1: Match by card tags (same as fizzy handler)
541
+ tag_names = tags.map { |t| t.is_a?(Hash) ? t["name"] : t.to_s }.map(&:downcase)
542
+ unless tag_names.empty?
543
+ all_projects.each do |key, config|
544
+ project_tags = (config["tags"] || config["fizzy_tags"] || []).map(&:downcase)
545
+ return key if tag_names.intersect?(project_tags)
546
+ end
547
+ end
548
+
549
+ # Priority 2: Match by card's board → board_key → project with fizzy_board
550
+ # This mirrors the fizzy handler's fallback logic to prevent project mismatch
551
+ board_id = card.dig("board", "id")
552
+ if board_id
553
+ board_key = resolve_board_key_for_id(board_id)
554
+ if board_key
555
+ # Check for board's default_project in fizzy config
556
+ fizzy_config_file = File.join(BRAINIAC_DIR, "fizzy.json")
557
+ if File.exist?(fizzy_config_file)
558
+ fizzy_config = JSON.parse(File.read(fizzy_config_file))
559
+ board_config = fizzy_config.dig("boards", board_key)
560
+ if board_config && board_config["default_project"]
561
+ project_key = board_config["default_project"]
562
+ return project_key if all_projects.key?(project_key)
563
+ end
564
+ end
565
+
566
+ # Fall back to any project whose fizzy_board matches this board_key
567
+ all_projects.each do |key, config|
568
+ return key if config["fizzy_board"] == board_key
569
+ end
570
+ end
548
571
  end
549
572
 
550
573
  nil
@@ -553,6 +576,23 @@ module Brainiac
553
576
  nil
554
577
  end
555
578
 
579
+ # Resolve a fizzy board_key from a board_id by checking fizzy.json boards config.
580
+ def resolve_board_key_for_id(board_id)
581
+ fizzy_config_file = File.join(BRAINIAC_DIR, "fizzy.json")
582
+ return nil unless File.exist?(fizzy_config_file)
583
+
584
+ fizzy_config = JSON.parse(File.read(fizzy_config_file))
585
+ boards = fizzy_config["boards"] || {}
586
+
587
+ boards.each do |key, config|
588
+ return key if config["board_id"] == board_id
589
+ end
590
+
591
+ nil
592
+ rescue StandardError
593
+ nil
594
+ end
595
+
556
596
  # Dispatch an agent to review the epic state after a task completes.
557
597
  # This ensures the remaining plan still makes sense given implementation decisions.
558
598
  # The callback is called after the review completes.
@@ -3,7 +3,7 @@
3
3
  module Brainiac
4
4
  module Plugins
5
5
  module Basecamp
6
- VERSION = "0.0.18"
6
+ VERSION = "0.0.19"
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-basecamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Davis