mirror of
https://github.com/anthropics/claude-code.git
synced 2026-04-25 22:42:41 +00:00
Compare commits
11 Commits
boris/bktr
...
ashwin/upd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ead501a4a9 | ||
|
|
ce5b9164fa | ||
|
|
5af0b38a92 | ||
|
|
22946869b2 | ||
|
|
1579216fc7 | ||
|
|
f0042afb3b | ||
|
|
6059607354 | ||
|
|
478f63be73 | ||
|
|
a7edbdc9e7 | ||
|
|
399a7dcf2f | ||
|
|
9ced2a3470 |
9
.github/workflows/auto-close-duplicates.yml
vendored
9
.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 * * *"
|
||||||
@@ -16,15 +16,16 @@ jobs:
|
|||||||
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}`);
|
||||||
|
|||||||
68
.github/workflows/log-issue-events.yml
vendored
Normal file
68
.github/workflows/log-issue-events.yml
vendored
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
name: Log GitHub Issue Events
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
log-issue-created:
|
||||||
|
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="${{ github.event.issue.title }}"
|
||||||
|
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
|
||||||
@@ -51,6 +51,42 @@ function extractDuplicateIssueNumber(commentBody: string): number | null {
|
|||||||
return match ? parseInt(match[1], 10) : null;
|
return match ? parseInt(match[1], 10) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function logStatsigEvent(eventName: string, value: number, metadata: Record<string, any>): Promise<void> {
|
||||||
|
const statsigApiKey = process.env.STATSIG_API_KEY;
|
||||||
|
if (!statsigApiKey) {
|
||||||
|
console.log("[DEBUG] STATSIG_API_KEY not found, skipping Statsig logging");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const eventPayload = {
|
||||||
|
events: [{
|
||||||
|
eventName,
|
||||||
|
value,
|
||||||
|
metadata,
|
||||||
|
time: Math.floor(Date.now()).toString()
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('https://events.statsigapi.net/v1/log_event', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'STATSIG-API-KEY': statsigApiKey
|
||||||
|
},
|
||||||
|
body: JSON.stringify(eventPayload)
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
console.log(`[DEBUG] Successfully logged Statsig event: ${eventName}`);
|
||||||
|
} else {
|
||||||
|
console.log(`[DEBUG] Failed to log Statsig event: ${response.status} ${response.statusText}`);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(`[DEBUG] Error logging to Statsig: ${error}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function closeIssueAsDuplicate(
|
async function closeIssueAsDuplicate(
|
||||||
owner: string,
|
owner: string,
|
||||||
repo: string,
|
repo: string,
|
||||||
@@ -80,6 +116,14 @@ If this is incorrect, please re-open this issue or create a new one.
|
|||||||
🤖 Generated with [Claude Code](https://claude.ai/code)`
|
🤖 Generated with [Claude Code](https://claude.ai/code)`
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Log to Statsig
|
||||||
|
await logStatsigEvent('github_issue_closed_as_duplicate', 1, {
|
||||||
|
repository: `${owner}/${repo}`,
|
||||||
|
issue_number: issueNumber,
|
||||||
|
duplicate_of_issue: duplicateOfNumber,
|
||||||
|
closed_by: 'auto-close-script'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function autoCloseDuplicates(): Promise<void> {
|
async function autoCloseDuplicates(): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user