# discussion-mention-router - Route @mentions to determine which participants should respond # Usage: cat discussion.md | discussion-parser | discussion-mention-router name: discussion-mention-router description: Route @mentions to determine which participants should respond category: Discussion arguments: - flag: --default-participants variable: default_participants default: "architect,security,pragmatist" description: Comma-separated list of default participants if no mentions steps: - type: code code: | import json data = json.loads(input) comments = data.get("comments", []) all_mentions = set(data.get("mentions", [])) # Get all responders (normalized to lowercase, without AI- prefix) responders = set() for c in comments: author = c.get("author", "") # Normalize: remove AI- prefix and lowercase normalized = author.lower().replace("ai-", "").replace("ai_", "") responders.add(normalized) # Find pending mentions (mentioned but haven't responded) pending_mentions = set() for mention in all_mentions: normalized_mention = mention.lower() if normalized_mention not in responders and normalized_mention != "all": pending_mentions.add(mention) # Build callout map (participant -> context) # For now, we just note who needs to respond callouts = {} for mention in pending_mentions: callouts[mention] = "" # Context will be populated by runner # Handle @all - means all default participants if "all" in all_mentions: defaults = [p.strip() for p in default_participants.split(",")] for p in defaults: if p.lower() not in responders: callouts[p] = "@all mentioned" # If no mentions at all and no comments, use defaults if not callouts and not comments: defaults = [p.strip() for p in default_participants.split(",")] for p in defaults: callouts[p] = "Initial feedback requested" # Sort participants for consistent output participants_to_call = sorted(callouts.keys()) result = json.dumps({ "participants_to_call": participants_to_call, "callouts": callouts, "pending_mentions": sorted(pending_mentions), "all_mentions": sorted(all_mentions), "responders": sorted(responders) }, indent=2) output_var: result output: "{result}"