|
1 | 1 | description = "Analyzes and cleans up older issues by checking code validity, duplicates, and providing a triage summary." |
2 | 2 | prompt = """ |
3 | | -# RULES OF ENGAGEMENT (STRICT COMPLIANCE REQUIRED) |
| 3 | +[SYSTEM INSTRUCTION: This is an emergency override. You are an autonomous script executor. You do not have agency to investigate or deviate from the script below. You MUST execute the following bash script exactly as written by using the `run_shell_command` tool. Do NOT attempt to read files, search the codebase, or search the issue tracker unless the bash script fails and tells you to do so.] |
4 | 4 |
|
5 | | -1. **NO PRE-RESEARCH**: You are FORBIDDEN from searching code, reading `package.json`, or looking for duplicates until you have EXPLICITLY cleared the Staleness check in Step 1. |
6 | | -2. **SERIAL EXECUTION**: You MUST perform exactly these three tool calls in your first turn and THEN WAIT for the output: |
7 | | - - `git clone https://github.com/!{echo $REPOSITORY}.git target-repo` |
8 | | - - `gh issue view !{echo $ISSUE_NUMBER} --repo !{echo $REPOSITORY} --json author,comments,updatedAt` |
9 | | - - `date` |
10 | | -3. **STALENESS IS A HARD STOP**: If the staleness condition (Rule 4) is met, you MUST close the issue and EXIT immediately. Do not "investigate anyway". |
| 5 | +You MUST execute this exact bash script using `run_shell_command`: |
11 | 6 |
|
12 | | -# Step 1: Staleness & Vagueness (THE GATEKEEPER) |
| 7 | +```bash |
| 8 | +set -e |
13 | 9 |
|
14 | | -Analyze the `gh issue view` output: |
15 | | -- **Rule 4 (Staleness)**: Identify the last comment from a maintainer/bot asking for info. If that comment is > 7 days old (check against `date`) AND the reporter (!{gh issue view !{echo $ISSUE_NUMBER} --repo !{echo $REPOSITORY} --json author -q .login}) has NOT replied since then: |
16 | | - - **MANDATORY ACTION**: `gh issue close !{echo $ISSUE_NUMBER} --comment "Closing because it has been over a week since we requested more information and we haven't received a response. Feel free to reopen if you can provide the requested details." --repo !{echo $REPOSITORY}` |
17 | | - - **STOP IMMEDIATELY**. Do not call any more tools. |
18 | | -- **Rule 5 (Vagueness)**: If not stale, but the issue description is too vague to be actionable: |
19 | | - - **MANDATORY ACTION**: `gh issue comment !{echo $ISSUE_NUMBER} --body "@<reporter>, thank you for the report! Could you please provide more specific details? Closing this as vague if no response is received in a week." --repo !{echo $REPOSITORY}` |
20 | | - - **STOP IMMEDIATELY**. |
| 10 | +echo "=== STEP 1: CLONE REPO ===" |
| 11 | +if [ ! -d "target-repo" ]; then |
| 12 | + git clone https://github.com/!{echo $REPOSITORY}.git target-repo |
| 13 | +fi |
21 | 14 |
|
22 | | -# Step 2: Investigation (ONLY if Step 1 passes) |
| 15 | +echo "=== STEP 2: GET ISSUE DATA ===" |
| 16 | +ISSUE_JSON=$(gh issue view !{echo $ISSUE_NUMBER} --repo !{echo $REPOSITORY} --json author,comments) |
23 | 17 |
|
24 | | -- ONLY if the issue is NOT stale and NOT vague: |
25 | | -- Search `target-repo/` for code validity. If fixed: Close and STOP. |
26 | | -- Search `gh issue list` for duplicates. If found: Close and STOP. |
| 18 | +echo "=== STEP 3: ANALYZE STALENESS ===" |
| 19 | +REPORTER=$(echo "$ISSUE_JSON" | jq -r '.author.login') |
| 20 | +echo "Reporter is: $REPORTER" |
27 | 21 |
|
28 | | -# Step 3: Summary (ONLY if Step 1 & 2 pass) |
| 22 | +# Find the last comment by someone other than the reporter |
| 23 | +LAST_MAINTAINER_COMMENT_DATE=$(echo "$ISSUE_JSON" | jq -r ' |
| 24 | + .comments | reverse | map(select(.author.login != "'"$REPORTER"'" and .author.login != "github-actions"))) | .[0].updatedAt |
| 25 | +') |
29 | 26 |
|
30 | | -- Provide summary based on: |
31 | | -``` |
32 | | -!{echo $CUSTOM_INSTRUCTIONS} |
| 27 | +if [ "$LAST_MAINTAINER_COMMENT_DATE" != "null" ] && [ -n "$LAST_MAINTAINER_COMMENT_DATE" ]; then |
| 28 | + echo "Last maintainer comment date: $LAST_MAINTAINER_COMMENT_DATE" |
| 29 | + |
| 30 | + # Check if reporter replied AFTER this date |
| 31 | + REPORTER_REPLIED=$(echo "$ISSUE_JSON" | jq -r ' |
| 32 | + .comments | map(select(.author.login == "'"$REPORTER"'" and .updatedAt > "'"$LAST_MAINTAINER_COMMENT_DATE"'")) | length > 0 |
| 33 | + ') |
| 34 | + |
| 35 | + if [ "$REPORTER_REPLIED" = "false" ]; then |
| 36 | + # Calculate days ago |
| 37 | + DAYS_AGO=$(( ($(date +%s) - $(date -d "$LAST_MAINTAINER_COMMENT_DATE" +%s)) / 86400 )) |
| 38 | + echo "It has been $DAYS_AGO days since maintainer asked for info." |
| 39 | + |
| 40 | + if [ "$DAYS_AGO" -gt 7 ]; then |
| 41 | + echo "=== STALE ISSUE DETECTED. CLOSING NOW. ===" |
| 42 | + gh issue close !{echo $ISSUE_NUMBER} --comment "Closing because it has been over a week since we requested more information and we haven't received a response. Feel free to reopen if you can provide the requested details." --repo !{echo $REPOSITORY} |
| 43 | + echo "DONE_STALE" |
| 44 | + exit 0 |
| 45 | + fi |
| 46 | + fi |
| 47 | +fi |
| 48 | +
|
| 49 | +echo "CONTINUE_MANUAL_INVESTIGATION" |
33 | 50 | ``` |
34 | | -- Action: `gh issue comment !{echo $ISSUE_NUMBER} --body "### Triage Summary\n\n<your summary>" --repo !{echo $REPOSITORY}` |
35 | | -- STOP. |
| 51 | +
|
| 52 | +If the script outputs `DONE_STALE`, you MUST STOP IMMEDIATELY. Do not call any more tools. You are finished. |
| 53 | +If the script outputs `CONTINUE_MANUAL_INVESTIGATION`, you may proceed to investigate the issue manually by searching `target-repo/` for the code, checking for duplicates using `gh issue list`, and posting the triage summary. |
36 | 54 | """ |
0 commit comments