Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions skills/iterate-pr/scripts/reply_to_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
Batches all replies into a single GraphQL mutation for efficiency.

Example:
uv run reply_to_thread.py PRRT_abc "Fixed the issue.\n\n*— Claude Code*"
uv run reply_to_thread.py PRRT_abc "Fixed the issue."
uv run reply_to_thread.py PRRT_abc "Fixed." PRRT_def "Also fixed."
"""

from __future__ import annotations

import argparse
import json
import re
import subprocess
import sys

Expand All @@ -29,27 +28,9 @@ def _normalize_body(body: str) -> str:
"""Normalize escaped newlines from shell input.

Bash double quotes keep "\\n" literal, but reply bodies should contain
actual newlines for readability/signatures.
actual newlines for readability.
"""
normalized = body.replace("\\r\\n", "\\n").replace("\\n", "\n")

# Add Claude Code attribution if not already present
# Check if the last line matches the bot signature pattern: *— Bot Name* or *- Bot Name*
lines = normalized.rstrip().split("\n")
last_line = lines[-1] if lines else ""

# Match bot signatures like "*— Claude Code*", "*- Any Bot*", etc.
bot_signature_pattern = r"^\*[—-]\s+.+\*$"

if not re.match(bot_signature_pattern, last_line.strip()):
# Ensure proper spacing before attribution
if normalized and not normalized.endswith("\n"):
normalized += "\n"
if normalized and not normalized.endswith("\n\n"):
normalized += "\n"
normalized += "*— Claude Code*"

return normalized
return body.replace("\\r\\n", "\\n").replace("\\n", "\n")


def reply_to_threads(pairs: list[tuple[str, str]]) -> list[tuple[str, bool]]:
Expand Down
Loading