mirror of
https://github.com/anthropics/claude-code.git
synced 2026-04-19 10:02:42 +00:00
Compare commits
35 Commits
boris/eyda
...
boris/iuni
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20ba9a34a5 | ||
|
|
fc8c10995f | ||
|
|
01fb7af5b3 | ||
|
|
afb0fc9156 | ||
|
|
370a97d939 | ||
|
|
f54569efd2 | ||
|
|
d8cf5a874c | ||
|
|
e499db6e9e | ||
|
|
5300e12135 | ||
|
|
4a04589002 | ||
|
|
04cace9ec0 | ||
|
|
2dbf1e97a0 | ||
|
|
0662600e93 | ||
|
|
27d2c6fdcf | ||
|
|
dd53f86325 | ||
|
|
c40c658e1f | ||
|
|
e05411140d | ||
|
|
ce5b9164fa | ||
|
|
5af0b38a92 | ||
|
|
22946869b2 | ||
|
|
1579216fc7 | ||
|
|
f0042afb3b | ||
|
|
6059607354 | ||
|
|
478f63be73 | ||
|
|
a7edbdc9e7 | ||
|
|
399a7dcf2f | ||
|
|
9ced2a3470 | ||
|
|
d7aa61e6f1 | ||
|
|
072856dd5b | ||
|
|
1cc90e9b78 | ||
|
|
483e0e892f | ||
|
|
5248fa06bc | ||
|
|
eb48a37a48 | ||
|
|
fdb7efe6f1 | ||
|
|
3fd750e3cb |
@@ -28,9 +28,10 @@ Found 3 possible duplicate issues:
|
|||||||
2. <link to issue>
|
2. <link to issue>
|
||||||
3. <link to issue>
|
3. <link to issue>
|
||||||
|
|
||||||
If your issue is a duplicate, please close it and 👍 the existing issue instead.
|
This issue will be automatically closed as a duplicate in 3 days.
|
||||||
|
|
||||||
<sub>This issue will be automatically closed as a duplicate in 3 days if there are no additional comments. To prevent auto-closure, please 👎 this comment.</sub>
|
- If your issue is a duplicate, please close it and 👍 the existing issue instead
|
||||||
|
- To prevent auto-closure, add a comment or 👎 this comment
|
||||||
|
|
||||||
🤖 Generated with [Claude Code](https://claude.ai/code)
|
🤖 Generated with [Claude Code](https://claude.ai/code)
|
||||||
|
|
||||||
|
|||||||
11
.github/workflows/auto-close-duplicates.yml
vendored
11
.github/workflows/auto-close-duplicates.yml
vendored
@@ -1,5 +1,5 @@
|
|||||||
name: Auto-close duplicate issues (DRY RUN)
|
name: Auto-close duplicate issues
|
||||||
description: Dry run - logs issues that would be auto-closed as duplicates after 3 days if no response
|
description: Auto-closes issues that are duplicates of existing issues
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 9 * * *"
|
- cron: "0 9 * * *"
|
||||||
@@ -11,20 +11,21 @@ jobs:
|
|||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
issues: read
|
issues: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Bun
|
- name: Setup Bun
|
||||||
uses: oven-sh/setup-bun@v2
|
uses: oven-sh/setup-bun@v2
|
||||||
with:
|
with:
|
||||||
bun-version: latest
|
bun-version: latest
|
||||||
|
|
||||||
- name: Auto-close duplicate issues
|
- name: Auto-close duplicate issues
|
||||||
run: bun run scripts/auto-close-duplicates.ts
|
run: bun run scripts/auto-close-duplicates.ts
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
|
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
|
||||||
GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }}
|
GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }}
|
||||||
|
STATSIG_API_KEY: ${{ secrets.STATSIG_API_KEY }}
|
||||||
|
|||||||
44
.github/workflows/backfill-duplicate-comments.yml
vendored
Normal file
44
.github/workflows/backfill-duplicate-comments.yml
vendored
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
name: Backfill Duplicate Comments
|
||||||
|
description: Triggers duplicate detection for old issues that don't have duplicate comments
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
days_back:
|
||||||
|
description: 'How many days back to look for old issues'
|
||||||
|
required: false
|
||||||
|
default: '90'
|
||||||
|
type: string
|
||||||
|
dry_run:
|
||||||
|
description: 'Dry run mode (true to only log what would be done)'
|
||||||
|
required: false
|
||||||
|
default: 'true'
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- 'true'
|
||||||
|
- 'false'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
backfill-duplicate-comments:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 30
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
issues: read
|
||||||
|
actions: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Bun
|
||||||
|
uses: oven-sh/setup-bun@v2
|
||||||
|
with:
|
||||||
|
bun-version: latest
|
||||||
|
|
||||||
|
- name: Backfill duplicate comments
|
||||||
|
run: bun run scripts/backfill-duplicate-comments.ts
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
DAYS_BACK: ${{ inputs.days_back }}
|
||||||
|
DRY_RUN: ${{ inputs.dry_run }}
|
||||||
57
.github/workflows/claude-dedupe-issues.yml
vendored
57
.github/workflows/claude-dedupe-issues.yml
vendored
@@ -3,6 +3,12 @@ description: Automatically dedupe GitHub issues using Claude Code
|
|||||||
on:
|
on:
|
||||||
issues:
|
issues:
|
||||||
types: [opened]
|
types: [opened]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
issue_number:
|
||||||
|
description: 'Issue number to process for duplicate detection'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
claude-dedupe-issues:
|
claude-dedupe-issues:
|
||||||
@@ -19,7 +25,56 @@ jobs:
|
|||||||
- name: Run Claude Code slash command
|
- name: Run Claude Code slash command
|
||||||
uses: anthropics/claude-code-base-action@beta
|
uses: anthropics/claude-code-base-action@beta
|
||||||
with:
|
with:
|
||||||
prompt: "/dedupe ${{ github.repository }}/issues/${{ github.event.issue.number }}"
|
prompt: "/dedupe ${{ github.repository }}/issues/${{ github.event.issue.number || inputs.issue_number }}"
|
||||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
claude_env: |
|
claude_env: |
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Log duplicate comment event to Statsig
|
||||||
|
if: always()
|
||||||
|
env:
|
||||||
|
STATSIG_API_KEY: ${{ secrets.STATSIG_API_KEY }}
|
||||||
|
run: |
|
||||||
|
ISSUE_NUMBER=${{ github.event.issue.number || inputs.issue_number }}
|
||||||
|
REPO=${{ github.repository }}
|
||||||
|
|
||||||
|
if [ -z "$STATSIG_API_KEY" ]; then
|
||||||
|
echo "STATSIG_API_KEY not found, skipping Statsig logging"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prepare the event payload
|
||||||
|
EVENT_PAYLOAD=$(jq -n \
|
||||||
|
--arg issue_number "$ISSUE_NUMBER" \
|
||||||
|
--arg repo "$REPO" \
|
||||||
|
--arg triggered_by "${{ github.event_name }}" \
|
||||||
|
'{
|
||||||
|
events: [{
|
||||||
|
eventName: "github_duplicate_comment_added",
|
||||||
|
value: 1,
|
||||||
|
metadata: {
|
||||||
|
repository: $repo,
|
||||||
|
issue_number: ($issue_number | tonumber),
|
||||||
|
triggered_by: $triggered_by,
|
||||||
|
workflow_run_id: "${{ github.run_id }}"
|
||||||
|
},
|
||||||
|
time: (now | floor | tostring)
|
||||||
|
}]
|
||||||
|
}')
|
||||||
|
|
||||||
|
# Send to Statsig API
|
||||||
|
echo "Logging duplicate comment event to Statsig for issue #${ISSUE_NUMBER}"
|
||||||
|
|
||||||
|
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST https://events.statsigapi.net/v1/log_event \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "STATSIG-API-KEY: ${STATSIG_API_KEY}" \
|
||||||
|
-d "$EVENT_PAYLOAD")
|
||||||
|
|
||||||
|
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
|
||||||
|
BODY=$(echo "$RESPONSE" | head -n-1)
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" -eq 200 ] || [ "$HTTP_CODE" -eq 202 ]; then
|
||||||
|
echo "Successfully logged duplicate comment event for issue #${ISSUE_NUMBER}"
|
||||||
|
else
|
||||||
|
echo "Failed to log duplicate comment event for issue #${ISSUE_NUMBER}. HTTP ${HTTP_CODE}: ${BODY}"
|
||||||
|
fi
|
||||||
|
|||||||
84
.github/workflows/lock-closed-issues.yml
vendored
84
.github/workflows/lock-closed-issues.yml
vendored
@@ -13,16 +13,80 @@ concurrency:
|
|||||||
group: lock-threads
|
group: lock-threads
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lock-threads:
|
lock-closed-issues:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 # v5.0.1
|
- name: Lock closed issues after 7 days of inactivity
|
||||||
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
issue-inactive-days: "7"
|
script: |
|
||||||
process-only: "issues"
|
const sevenDaysAgo = new Date();
|
||||||
log-output: true
|
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
|
||||||
issue-comment: >
|
|
||||||
This issue has been automatically locked since it was
|
const lockComment = `This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.`;
|
||||||
closed and has not had any activity for 7 days.
|
|
||||||
If you're experiencing a similar issue, please file a new issue
|
let page = 1;
|
||||||
and reference this one if it's relevant.
|
let hasMore = true;
|
||||||
|
let totalLocked = 0;
|
||||||
|
|
||||||
|
while (hasMore) {
|
||||||
|
// Get closed issues (pagination)
|
||||||
|
const { data: issues } = await github.rest.issues.listForRepo({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
state: 'closed',
|
||||||
|
sort: 'updated',
|
||||||
|
direction: 'asc',
|
||||||
|
per_page: 100,
|
||||||
|
page: page
|
||||||
|
});
|
||||||
|
|
||||||
|
if (issues.length === 0) {
|
||||||
|
hasMore = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const issue of issues) {
|
||||||
|
// Skip if already locked
|
||||||
|
if (issue.locked) continue;
|
||||||
|
|
||||||
|
// Skip pull requests
|
||||||
|
if (issue.pull_request) continue;
|
||||||
|
|
||||||
|
// Check if updated more than 7 days ago
|
||||||
|
const updatedAt = new Date(issue.updated_at);
|
||||||
|
if (updatedAt > sevenDaysAgo) {
|
||||||
|
// Since issues are sorted by updated_at ascending,
|
||||||
|
// once we hit a recent issue, all remaining will be recent too
|
||||||
|
hasMore = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Add comment before locking
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: issue.number,
|
||||||
|
body: lockComment
|
||||||
|
});
|
||||||
|
|
||||||
|
// Lock the issue
|
||||||
|
await github.rest.issues.lock({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: issue.number,
|
||||||
|
lock_reason: 'resolved'
|
||||||
|
});
|
||||||
|
|
||||||
|
totalLocked++;
|
||||||
|
console.log(`Locked issue #${issue.number}: ${issue.title}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Failed to lock issue #${issue.number}: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
page++;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Total issues locked: ${totalLocked}`);
|
||||||
|
|||||||
176
.github/workflows/log-issue-events.yml
vendored
Normal file
176
.github/workflows/log-issue-events.yml
vendored
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
name: Log GitHub Issue Events
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened, closed]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
log-issue-created:
|
||||||
|
if: github.event.action == 'opened'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 5
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
issues: read
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Log issue creation to Statsig
|
||||||
|
env:
|
||||||
|
STATSIG_API_KEY: ${{ secrets.STATSIG_API_KEY }}
|
||||||
|
run: |
|
||||||
|
ISSUE_NUMBER=${{ github.event.issue.number }}
|
||||||
|
REPO=${{ github.repository }}
|
||||||
|
ISSUE_TITLE=$(echo '${{ github.event.issue.title }}' | sed "s/'/'\\\\''/g")
|
||||||
|
AUTHOR="${{ github.event.issue.user.login }}"
|
||||||
|
CREATED_AT="${{ github.event.issue.created_at }}"
|
||||||
|
|
||||||
|
if [ -z "$STATSIG_API_KEY" ]; then
|
||||||
|
echo "STATSIG_API_KEY not found, skipping Statsig logging"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prepare the event payload
|
||||||
|
EVENT_PAYLOAD=$(jq -n \
|
||||||
|
--arg issue_number "$ISSUE_NUMBER" \
|
||||||
|
--arg repo "$REPO" \
|
||||||
|
--arg title "$ISSUE_TITLE" \
|
||||||
|
--arg author "$AUTHOR" \
|
||||||
|
--arg created_at "$CREATED_AT" \
|
||||||
|
'{
|
||||||
|
events: [{
|
||||||
|
eventName: "github_issue_created",
|
||||||
|
value: 1,
|
||||||
|
metadata: {
|
||||||
|
repository: $repo,
|
||||||
|
issue_number: ($issue_number | tonumber),
|
||||||
|
issue_title: $title,
|
||||||
|
issue_author: $author,
|
||||||
|
created_at: $created_at
|
||||||
|
},
|
||||||
|
time: (now | floor | tostring)
|
||||||
|
}]
|
||||||
|
}')
|
||||||
|
|
||||||
|
# Send to Statsig API
|
||||||
|
echo "Logging issue creation to Statsig for issue #${ISSUE_NUMBER}"
|
||||||
|
|
||||||
|
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST https://events.statsigapi.net/v1/log_event \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "STATSIG-API-KEY: ${STATSIG_API_KEY}" \
|
||||||
|
-d "$EVENT_PAYLOAD")
|
||||||
|
|
||||||
|
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
|
||||||
|
BODY=$(echo "$RESPONSE" | head -n-1)
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" -eq 200 ] || [ "$HTTP_CODE" -eq 202 ]; then
|
||||||
|
echo "Successfully logged issue creation for issue #${ISSUE_NUMBER}"
|
||||||
|
else
|
||||||
|
echo "Failed to log issue creation for issue #${ISSUE_NUMBER}. HTTP ${HTTP_CODE}: ${BODY}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log-issue-closed:
|
||||||
|
if: github.event.action == 'closed'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 5
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
issues: read
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Log issue closure to Statsig
|
||||||
|
env:
|
||||||
|
STATSIG_API_KEY: ${{ secrets.STATSIG_API_KEY }}
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
ISSUE_NUMBER=${{ github.event.issue.number }}
|
||||||
|
REPO=${{ github.repository }}
|
||||||
|
ISSUE_TITLE=$(echo '${{ github.event.issue.title }}' | sed "s/'/'\\\\''/g")
|
||||||
|
CLOSED_BY="${{ github.event.issue.closed_by.login }}"
|
||||||
|
CLOSED_AT="${{ github.event.issue.closed_at }}"
|
||||||
|
STATE_REASON="${{ github.event.issue.state_reason }}"
|
||||||
|
|
||||||
|
if [ -z "$STATSIG_API_KEY" ]; then
|
||||||
|
echo "STATSIG_API_KEY not found, skipping Statsig logging"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get additional issue data via GitHub API
|
||||||
|
echo "Fetching additional issue data for #${ISSUE_NUMBER}"
|
||||||
|
ISSUE_DATA=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H "Accept: application/vnd.github.v3+json" \
|
||||||
|
"https://api.github.com/repos/${REPO}/issues/${ISSUE_NUMBER}")
|
||||||
|
|
||||||
|
COMMENTS_COUNT=$(echo "$ISSUE_DATA" | jq -r '.comments')
|
||||||
|
|
||||||
|
# Get reactions data
|
||||||
|
REACTIONS_DATA=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H "Accept: application/vnd.github.v3+json" \
|
||||||
|
"https://api.github.com/repos/${REPO}/issues/${ISSUE_NUMBER}/reactions")
|
||||||
|
|
||||||
|
REACTIONS_COUNT=$(echo "$REACTIONS_DATA" | jq '. | length')
|
||||||
|
|
||||||
|
# Check if issue was closed automatically (by checking if closed_by is a bot)
|
||||||
|
CLOSED_AUTOMATICALLY="false"
|
||||||
|
if [[ "$CLOSED_BY" == *"[bot]"* ]]; then
|
||||||
|
CLOSED_AUTOMATICALLY="true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if closed as duplicate by state_reason
|
||||||
|
CLOSED_AS_DUPLICATE="false"
|
||||||
|
if [ "$STATE_REASON" = "duplicate" ]; then
|
||||||
|
CLOSED_AS_DUPLICATE="true"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prepare the event payload
|
||||||
|
EVENT_PAYLOAD=$(jq -n \
|
||||||
|
--arg issue_number "$ISSUE_NUMBER" \
|
||||||
|
--arg repo "$REPO" \
|
||||||
|
--arg title "$ISSUE_TITLE" \
|
||||||
|
--arg closed_by "$CLOSED_BY" \
|
||||||
|
--arg closed_at "$CLOSED_AT" \
|
||||||
|
--arg state_reason "$STATE_REASON" \
|
||||||
|
--arg comments_count "$COMMENTS_COUNT" \
|
||||||
|
--arg reactions_count "$REACTIONS_COUNT" \
|
||||||
|
--arg closed_automatically "$CLOSED_AUTOMATICALLY" \
|
||||||
|
--arg closed_as_duplicate "$CLOSED_AS_DUPLICATE" \
|
||||||
|
'{
|
||||||
|
events: [{
|
||||||
|
eventName: "github_issue_closed",
|
||||||
|
value: 1,
|
||||||
|
metadata: {
|
||||||
|
repository: $repo,
|
||||||
|
issue_number: ($issue_number | tonumber),
|
||||||
|
issue_title: $title,
|
||||||
|
closed_by: $closed_by,
|
||||||
|
closed_at: $closed_at,
|
||||||
|
state_reason: $state_reason,
|
||||||
|
comments_count: ($comments_count | tonumber),
|
||||||
|
reactions_count: ($reactions_count | tonumber),
|
||||||
|
closed_automatically: ($closed_automatically | test("true")),
|
||||||
|
closed_as_duplicate: ($closed_as_duplicate | test("true"))
|
||||||
|
},
|
||||||
|
time: (now | floor | tostring)
|
||||||
|
}]
|
||||||
|
}')
|
||||||
|
|
||||||
|
# Send to Statsig API
|
||||||
|
echo "Logging issue closure to Statsig for issue #${ISSUE_NUMBER}"
|
||||||
|
|
||||||
|
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST https://events.statsigapi.net/v1/log_event \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "STATSIG-API-KEY: ${STATSIG_API_KEY}" \
|
||||||
|
-d "$EVENT_PAYLOAD")
|
||||||
|
|
||||||
|
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
|
||||||
|
BODY=$(echo "$RESPONSE" | head -n-1)
|
||||||
|
|
||||||
|
if [ "$HTTP_CODE" -eq 200 ] || [ "$HTTP_CODE" -eq 202 ]; then
|
||||||
|
echo "Successfully logged issue closure for issue #${ISSUE_NUMBER}"
|
||||||
|
echo "Closed by: $CLOSED_BY"
|
||||||
|
echo "Comments: $COMMENTS_COUNT"
|
||||||
|
echo "Reactions: $REACTIONS_COUNT"
|
||||||
|
echo "Closed automatically: $CLOSED_AUTOMATICALLY"
|
||||||
|
echo "Closed as duplicate: $CLOSED_AS_DUPLICATE"
|
||||||
|
else
|
||||||
|
echo "Failed to log issue closure for issue #${ISSUE_NUMBER}. HTTP ${HTTP_CODE}: ${BODY}"
|
||||||
|
fi
|
||||||
33
CHANGELOG.md
33
CHANGELOG.md
@@ -1,5 +1,38 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 1.0.81
|
||||||
|
|
||||||
|
- Released output styles, including new built-in educational output styles "Explanatory" and "Learning". Docs: https://docs.anthropic.com/en/docs/claude-code/output-styles
|
||||||
|
- Agents: Fix custom agent loading when agent files are unparsable
|
||||||
|
|
||||||
|
## 1.0.80
|
||||||
|
|
||||||
|
- UI improvements: Fix text contrast for custom subagent colors and spinner rendering issues
|
||||||
|
|
||||||
|
## 1.0.77
|
||||||
|
|
||||||
|
- Bash tool: Fix heredoc and multiline string escaping, improve stderr redirection handling
|
||||||
|
- SDK: Add session support and permission denial tracking
|
||||||
|
- Fix token limit errors in conversation summarization
|
||||||
|
- Opus Plan Mode: New setting in `/model` to run Opus only in plan mode, Sonnet otherwise
|
||||||
|
|
||||||
|
## 1.0.73
|
||||||
|
|
||||||
|
- MCP: Support multiple config files with `--mcp-config file1.json file2.json`
|
||||||
|
- MCP: Press Esc to cancel OAuth authentication flows
|
||||||
|
- Bash: Improved command validation and reduced false security warnings
|
||||||
|
- UI: Enhanced spinner animations and status line visual hierarchy
|
||||||
|
- Linux: Added support for Alpine and musl-based distributions (requires separate ripgrep installation)
|
||||||
|
|
||||||
|
## 1.0.72
|
||||||
|
|
||||||
|
- Ask permissions: have Claude Code always ask for confirmation to use specific tools with /permissions
|
||||||
|
|
||||||
|
## 1.0.71
|
||||||
|
|
||||||
|
- Background commands: (Ctrl-b) to run any Bash command in the background so Claude can keep working (great for dev servers, tailing logs, etc.)
|
||||||
|
- Customizable status line: add your terminal prompt to Claude Code with /statusline
|
||||||
|
|
||||||
## 1.0.70
|
## 1.0.70
|
||||||
|
|
||||||
- Performance: Optimized message rendering for better performance with large contexts
|
- Performance: Optimized message rendering for better performance with large contexts
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ interface GitHubIssue {
|
|||||||
number: number;
|
number: number;
|
||||||
title: string;
|
title: string;
|
||||||
user: { id: number };
|
user: { id: number };
|
||||||
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GitHubComment {
|
interface GitHubComment {
|
||||||
@@ -24,13 +25,16 @@ interface GitHubReaction {
|
|||||||
content: string;
|
content: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function githubRequest<T>(endpoint: string, token: string): Promise<T> {
|
async function githubRequest<T>(endpoint: string, token: string, method: string = 'GET', body?: any): Promise<T> {
|
||||||
const response = await fetch(`https://api.github.com${endpoint}`, {
|
const response = await fetch(`https://api.github.com${endpoint}`, {
|
||||||
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
Accept: "application/vnd.github.v3+json",
|
Accept: "application/vnd.github.v3+json",
|
||||||
"User-Agent": "auto-close-duplicates-script",
|
"User-Agent": "auto-close-duplicates-script",
|
||||||
|
...(body && { "Content-Type": "application/json" }),
|
||||||
},
|
},
|
||||||
|
...(body && { body: JSON.stringify(body) }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -42,6 +46,56 @@ async function githubRequest<T>(endpoint: string, token: string): Promise<T> {
|
|||||||
return response.json();
|
return response.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extractDuplicateIssueNumber(commentBody: string): number | null {
|
||||||
|
// Try to match #123 format first
|
||||||
|
let match = commentBody.match(/#(\d+)/);
|
||||||
|
if (match) {
|
||||||
|
return parseInt(match[1], 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to match GitHub issue URL format: https://github.com/owner/repo/issues/123
|
||||||
|
match = commentBody.match(/github\.com\/[^\/]+\/[^\/]+\/issues\/(\d+)/);
|
||||||
|
if (match) {
|
||||||
|
return parseInt(match[1], 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function closeIssueAsDuplicate(
|
||||||
|
owner: string,
|
||||||
|
repo: string,
|
||||||
|
issueNumber: number,
|
||||||
|
duplicateOfNumber: number,
|
||||||
|
token: string
|
||||||
|
): Promise<void> {
|
||||||
|
await githubRequest(
|
||||||
|
`/repos/${owner}/${repo}/issues/${issueNumber}`,
|
||||||
|
token,
|
||||||
|
'PATCH',
|
||||||
|
{
|
||||||
|
state: 'closed',
|
||||||
|
state_reason: 'duplicate',
|
||||||
|
labels: ['duplicate']
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await githubRequest(
|
||||||
|
`/repos/${owner}/${repo}/issues/${issueNumber}/comments`,
|
||||||
|
token,
|
||||||
|
'POST',
|
||||||
|
{
|
||||||
|
body: `This issue has been automatically closed as a duplicate of #${duplicateOfNumber}.
|
||||||
|
|
||||||
|
If this is incorrect, please re-open this issue or create a new one.
|
||||||
|
|
||||||
|
🤖 Generated with [Claude Code](https://claude.ai/code)`
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
async function autoCloseDuplicates(): Promise<void> {
|
async function autoCloseDuplicates(): Promise<void> {
|
||||||
console.log("[DEBUG] Starting auto-close duplicates script");
|
console.log("[DEBUG] Starting auto-close duplicates script");
|
||||||
|
|
||||||
@@ -61,11 +115,32 @@ async function autoCloseDuplicates(): Promise<void> {
|
|||||||
`[DEBUG] Checking for duplicate comments older than: ${threeDaysAgo.toISOString()}`
|
`[DEBUG] Checking for duplicate comments older than: ${threeDaysAgo.toISOString()}`
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("[DEBUG] Fetching open issues...");
|
console.log("[DEBUG] Fetching open issues created more than 3 days ago...");
|
||||||
const issues: GitHubIssue[] = await githubRequest(
|
const allIssues: GitHubIssue[] = [];
|
||||||
`/repos/${owner}/${repo}/issues?state=open&per_page=100`,
|
let page = 1;
|
||||||
token
|
const perPage = 100;
|
||||||
);
|
|
||||||
|
while (true) {
|
||||||
|
const pageIssues: GitHubIssue[] = await githubRequest(
|
||||||
|
`/repos/${owner}/${repo}/issues?state=open&per_page=${perPage}&page=${page}`,
|
||||||
|
token
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pageIssues.length === 0) break;
|
||||||
|
|
||||||
|
// Filter for issues created more than 3 days ago
|
||||||
|
const oldEnoughIssues = pageIssues.filter(issue =>
|
||||||
|
new Date(issue.created_at) <= threeDaysAgo
|
||||||
|
);
|
||||||
|
|
||||||
|
allIssues.push(...oldEnoughIssues);
|
||||||
|
page++;
|
||||||
|
|
||||||
|
// Safety limit to avoid infinite loops
|
||||||
|
if (page > 20) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const issues = allIssues;
|
||||||
console.log(`[DEBUG] Found ${issues.length} open issues`);
|
console.log(`[DEBUG] Found ${issues.length} open issues`);
|
||||||
|
|
||||||
let processedCount = 0;
|
let processedCount = 0;
|
||||||
@@ -165,11 +240,30 @@ async function autoCloseDuplicates(): Promise<void> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const duplicateIssueNumber = extractDuplicateIssueNumber(lastDupeComment.body);
|
||||||
|
if (!duplicateIssueNumber) {
|
||||||
|
console.log(
|
||||||
|
`[DEBUG] Issue #${issue.number} - could not extract duplicate issue number from comment, skipping`
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
candidateCount++;
|
candidateCount++;
|
||||||
const issueUrl = `https://github.com/${owner}/${repo}/issues/${issue.number}`;
|
const issueUrl = `https://github.com/${owner}/${repo}/issues/${issue.number}`;
|
||||||
console.log(
|
|
||||||
`[DRY RUN] Would auto-close issue #${issue.number} as duplicate: ${issueUrl}`
|
try {
|
||||||
);
|
console.log(
|
||||||
|
`[INFO] Auto-closing issue #${issue.number} as duplicate of #${duplicateIssueNumber}: ${issueUrl}`
|
||||||
|
);
|
||||||
|
await closeIssueAsDuplicate(owner, repo, issue.number, duplicateIssueNumber, token);
|
||||||
|
console.log(
|
||||||
|
`[SUCCESS] Successfully closed issue #${issue.number} as duplicate of #${duplicateIssueNumber}`
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(
|
||||||
|
`[ERROR] Failed to close issue #${issue.number} as duplicate: ${error}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
|
|||||||
213
scripts/backfill-duplicate-comments.ts
Normal file
213
scripts/backfill-duplicate-comments.ts
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
#!/usr/bin/env bun
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
var process: {
|
||||||
|
env: Record<string, string | undefined>;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GitHubIssue {
|
||||||
|
number: number;
|
||||||
|
title: string;
|
||||||
|
state: string;
|
||||||
|
state_reason?: string;
|
||||||
|
user: { id: number };
|
||||||
|
created_at: string;
|
||||||
|
closed_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GitHubComment {
|
||||||
|
id: number;
|
||||||
|
body: string;
|
||||||
|
created_at: string;
|
||||||
|
user: { type: string; id: number };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function githubRequest<T>(endpoint: string, token: string, method: string = 'GET', body?: any): Promise<T> {
|
||||||
|
const response = await fetch(`https://api.github.com${endpoint}`, {
|
||||||
|
method,
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
Accept: "application/vnd.github.v3+json",
|
||||||
|
"User-Agent": "backfill-duplicate-comments-script",
|
||||||
|
...(body && { "Content-Type": "application/json" }),
|
||||||
|
},
|
||||||
|
...(body && { body: JSON.stringify(body) }),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(
|
||||||
|
`GitHub API request failed: ${response.status} ${response.statusText}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function triggerDedupeWorkflow(
|
||||||
|
owner: string,
|
||||||
|
repo: string,
|
||||||
|
issueNumber: number,
|
||||||
|
token: string,
|
||||||
|
dryRun: boolean = true
|
||||||
|
): Promise<void> {
|
||||||
|
if (dryRun) {
|
||||||
|
console.log(`[DRY RUN] Would trigger dedupe workflow for issue #${issueNumber}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await githubRequest(
|
||||||
|
`/repos/${owner}/${repo}/actions/workflows/claude-dedupe-issues.yml/dispatches`,
|
||||||
|
token,
|
||||||
|
'POST',
|
||||||
|
{
|
||||||
|
ref: 'main',
|
||||||
|
inputs: {
|
||||||
|
issue_number: issueNumber.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function backfillDuplicateComments(): Promise<void> {
|
||||||
|
console.log("[DEBUG] Starting backfill duplicate comments script");
|
||||||
|
|
||||||
|
const token = process.env.GITHUB_TOKEN;
|
||||||
|
if (!token) {
|
||||||
|
throw new Error(`GITHUB_TOKEN environment variable is required
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
GITHUB_TOKEN=your_token bun run scripts/backfill-duplicate-comments.ts
|
||||||
|
|
||||||
|
Environment Variables:
|
||||||
|
GITHUB_TOKEN - GitHub personal access token with repo and actions permissions (required)
|
||||||
|
DRY_RUN - Set to "false" to actually trigger workflows (default: true for safety)
|
||||||
|
MAX_ISSUE_NUMBER - Only process issues with numbers less than this value (default: 4050)`);
|
||||||
|
}
|
||||||
|
console.log("[DEBUG] GitHub token found");
|
||||||
|
|
||||||
|
const owner = "anthropics";
|
||||||
|
const repo = "claude-code";
|
||||||
|
const dryRun = process.env.DRY_RUN !== "false";
|
||||||
|
const maxIssueNumber = parseInt(process.env.MAX_ISSUE_NUMBER || "4050", 10);
|
||||||
|
const minIssueNumber = parseInt(process.env.MIN_ISSUE_NUMBER || "1", 10);
|
||||||
|
|
||||||
|
console.log(`[DEBUG] Repository: ${owner}/${repo}`);
|
||||||
|
console.log(`[DEBUG] Dry run mode: ${dryRun}`);
|
||||||
|
console.log(`[DEBUG] Looking at issues between #${minIssueNumber} and #${maxIssueNumber}`);
|
||||||
|
|
||||||
|
console.log(`[DEBUG] Fetching issues between #${minIssueNumber} and #${maxIssueNumber}...`);
|
||||||
|
const allIssues: GitHubIssue[] = [];
|
||||||
|
let page = 1;
|
||||||
|
const perPage = 100;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const pageIssues: GitHubIssue[] = await githubRequest(
|
||||||
|
`/repos/${owner}/${repo}/issues?state=all&per_page=${perPage}&page=${page}&sort=created&direction=desc`,
|
||||||
|
token
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pageIssues.length === 0) break;
|
||||||
|
|
||||||
|
// Filter to only include issues within the specified range
|
||||||
|
const filteredIssues = pageIssues.filter(issue =>
|
||||||
|
issue.number >= minIssueNumber && issue.number < maxIssueNumber
|
||||||
|
);
|
||||||
|
allIssues.push(...filteredIssues);
|
||||||
|
|
||||||
|
// If the oldest issue in this page is still above our minimum, we need to continue
|
||||||
|
// but if the oldest issue is below our minimum, we can stop
|
||||||
|
const oldestIssueInPage = pageIssues[pageIssues.length - 1];
|
||||||
|
if (oldestIssueInPage && oldestIssueInPage.number >= maxIssueNumber) {
|
||||||
|
console.log(`[DEBUG] Oldest issue in page #${page} is #${oldestIssueInPage.number}, continuing...`);
|
||||||
|
} else if (oldestIssueInPage && oldestIssueInPage.number < minIssueNumber) {
|
||||||
|
console.log(`[DEBUG] Oldest issue in page #${page} is #${oldestIssueInPage.number}, below minimum, stopping`);
|
||||||
|
break;
|
||||||
|
} else if (filteredIssues.length === 0 && pageIssues.length > 0) {
|
||||||
|
console.log(`[DEBUG] No issues in page #${page} are in range #${minIssueNumber}-#${maxIssueNumber}, continuing...`);
|
||||||
|
}
|
||||||
|
|
||||||
|
page++;
|
||||||
|
|
||||||
|
// Safety limit to avoid infinite loops
|
||||||
|
if (page > 200) {
|
||||||
|
console.log("[DEBUG] Reached page limit, stopping pagination");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[DEBUG] Found ${allIssues.length} issues between #${minIssueNumber} and #${maxIssueNumber}`);
|
||||||
|
|
||||||
|
let processedCount = 0;
|
||||||
|
let candidateCount = 0;
|
||||||
|
let triggeredCount = 0;
|
||||||
|
|
||||||
|
for (const issue of allIssues) {
|
||||||
|
processedCount++;
|
||||||
|
console.log(
|
||||||
|
`[DEBUG] Processing issue #${issue.number} (${processedCount}/${allIssues.length}): ${issue.title}`
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(`[DEBUG] Fetching comments for issue #${issue.number}...`);
|
||||||
|
const comments: GitHubComment[] = await githubRequest(
|
||||||
|
`/repos/${owner}/${repo}/issues/${issue.number}/comments`,
|
||||||
|
token
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`[DEBUG] Issue #${issue.number} has ${comments.length} comments`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Look for existing duplicate detection comments (from the dedupe bot)
|
||||||
|
const dupeDetectionComments = comments.filter(
|
||||||
|
(comment) =>
|
||||||
|
comment.body.includes("Found") &&
|
||||||
|
comment.body.includes("possible duplicate") &&
|
||||||
|
comment.user.type === "Bot"
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`[DEBUG] Issue #${issue.number} has ${dupeDetectionComments.length} duplicate detection comments`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Skip if there's already a duplicate detection comment
|
||||||
|
if (dupeDetectionComments.length > 0) {
|
||||||
|
console.log(
|
||||||
|
`[DEBUG] Issue #${issue.number} already has duplicate detection comment, skipping`
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
candidateCount++;
|
||||||
|
const issueUrl = `https://github.com/${owner}/${repo}/issues/${issue.number}`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
console.log(
|
||||||
|
`[INFO] ${dryRun ? '[DRY RUN] ' : ''}Triggering dedupe workflow for issue #${issue.number}: ${issueUrl}`
|
||||||
|
);
|
||||||
|
await triggerDedupeWorkflow(owner, repo, issue.number, token, dryRun);
|
||||||
|
|
||||||
|
if (!dryRun) {
|
||||||
|
console.log(
|
||||||
|
`[SUCCESS] Successfully triggered dedupe workflow for issue #${issue.number}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
triggeredCount++;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(
|
||||||
|
`[ERROR] Failed to trigger workflow for issue #${issue.number}: ${error}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a delay between workflow triggers to avoid overwhelming the system
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`[DEBUG] Script completed. Processed ${processedCount} issues, found ${candidateCount} candidates without duplicate comments, ${dryRun ? 'would trigger' : 'triggered'} ${triggeredCount} workflows`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
backfillDuplicateComments().catch(console.error);
|
||||||
|
|
||||||
|
// Make it a module
|
||||||
|
export {};
|
||||||
Reference in New Issue
Block a user