mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-04-26 08:36:22 +02:00
Refactor issue dedup system to use claude-code-action with /dedupe command
Replace the copilot-generated inline search logic with a claude-code-action based architecture inspired by anthropic/claude-code's approach: - Add .claude/commands/dedupe.md with 5-parallel-search strategy - Add scripts/comment-on-duplicates.sh with 3-day grace period warning - Rewrite issue-dedupe.yml to use claude-code-action + /dedupe command - Rewrite autoclose script to check bot comments, human activity, and thumbsdown - Rewrite backfill to trigger dedupe workflow per issue with rate limiting - Add concurrency control, timeout, input validation, and rate limit retry - Remove gh.sh (unnecessary), backfill-dedupe.js (replaced by workflow trigger)
This commit is contained in:
parent
b3cb9531a4
commit
fd9330c434
8 changed files with 413 additions and 752 deletions
106
scripts/comment-on-duplicates.sh
Executable file
106
scripts/comment-on-duplicates.sh
Executable file
|
|
@ -0,0 +1,106 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# comment-on-duplicates.sh - Posts a duplicate issue comment with auto-close warning.
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/comment-on-duplicates.sh --base-issue 123 --potential-duplicates 456 789
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
REPO="${GITHUB_REPOSITORY:-}"
|
||||
if [ -z "$REPO" ]; then
|
||||
echo "Error: GITHUB_REPOSITORY is not set" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASE_ISSUE=""
|
||||
DUPLICATES=()
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--base-issue)
|
||||
BASE_ISSUE="$2"
|
||||
shift 2
|
||||
;;
|
||||
--potential-duplicates)
|
||||
shift
|
||||
while [[ $# -gt 0 && ! "$1" =~ ^-- ]]; do
|
||||
DUPLICATES+=("$1")
|
||||
shift
|
||||
done
|
||||
;;
|
||||
*)
|
||||
echo "Error: Unknown argument: $1" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate inputs
|
||||
if [ -z "$BASE_ISSUE" ]; then
|
||||
echo "Error: --base-issue is required" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [[ "$BASE_ISSUE" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: --base-issue must be a number, got: $BASE_ISSUE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ${#DUPLICATES[@]} -eq 0 ]; then
|
||||
echo "Error: --potential-duplicates requires at least one issue number" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for dup in "${DUPLICATES[@]}"; do
|
||||
if ! [[ "$dup" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: duplicate issue must be a number, got: $dup" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Limit to 3 duplicates max
|
||||
if [ ${#DUPLICATES[@]} -gt 3 ]; then
|
||||
echo "Warning: Limiting to first 3 duplicates" >&2
|
||||
DUPLICATES=("${DUPLICATES[@]:0:3}")
|
||||
fi
|
||||
|
||||
# Validate that the base issue exists and is open
|
||||
if ! gh issue view "$BASE_ISSUE" --repo "$REPO" --json state -q '.state' | grep -qi 'open'; then
|
||||
echo "Error: Issue #$BASE_ISSUE is not open or does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build the duplicate links list
|
||||
LINKS=""
|
||||
COUNT=0
|
||||
for dup in "${DUPLICATES[@]}"; do
|
||||
# Validate duplicate issue exists
|
||||
if gh issue view "$dup" --repo "$REPO" --json number -q '.number' > /dev/null 2>&1; then
|
||||
COUNT=$((COUNT + 1))
|
||||
LINKS="${LINKS}${COUNT}. https://github.com/${REPO}/issues/${dup}
|
||||
"
|
||||
else
|
||||
echo "Warning: Issue #$dup does not exist, skipping" >&2
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$COUNT" -eq 0 ]; then
|
||||
echo "Error: None of the specified duplicate issues exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build and post the comment
|
||||
COMMENT="Found ${COUNT} possible duplicate issue(s):
|
||||
|
||||
${LINKS}
|
||||
This issue will be automatically closed as a duplicate in 3 days.
|
||||
- To prevent auto-closure, add a comment or react with :thumbsdown: on this comment."
|
||||
|
||||
gh issue comment "$BASE_ISSUE" --repo "$REPO" --body "$COMMENT"
|
||||
|
||||
# Add the duplicate label
|
||||
gh issue edit "$BASE_ISSUE" --repo "$REPO" --add-label "duplicate"
|
||||
|
||||
echo "Posted duplicate comment on issue #$BASE_ISSUE with $COUNT potential duplicate(s)"
|
||||
Loading…
Add table
Add a link
Reference in a new issue