Skip to content

Commit 1cdeb18

Browse files
committed
feat(examples): add staleness check and optimize cleanup bot
1 parent cf62bef commit 1cdeb18

File tree

3 files changed

+33
-31
lines changed

3 files changed

+33
-31
lines changed

examples/workflows/issue-cleanup/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ This document describes a workflow to batch-process and clean up older open issu
66

77
The Issue Cleanup workflow is designed to automate the triage of stale issues by using the Gemini CLI to:
88

9-
1. **Check Code Validity**: Determines if an issue is still relevant against the current codebase. If the issue has already been resolved implicitly, it will close the issue with an explanation.
10-
2. **Find Duplicates**: Checks if the issue has a more recent duplicate. If a duplicate exists, it closes the issue and links to the duplicate.
11-
3. **Summarize for Triage**: If an issue is still valid and unique, it provides a summary comment based on customizable instructions (e.g., categorizing it as `Maintainer-only` or `Help-wanted`). If no custom instructions are provided, it falls back to a standard triage summary (identifying the core problem, impact, and next steps).
9+
1. **Check for Staleness and Vagueness**: Identifies issues with insufficient information. If a request for more information has gone unanswered for over a week, it closes the issue. If it's a new vague issue, it asks the reporter for specific details.
10+
2. **Check Code Validity**: Determines if an issue is still relevant against the current codebase. If the issue has already been resolved implicitly, it will close the issue with an explanation.
11+
3. **Find Duplicates**: Checks if the issue has a more recent duplicate. If a duplicate exists, it closes the issue and links to the duplicate.
12+
4. **Summarize for Triage**: If an issue is still valid and unique, it provides a summary comment based on customizable instructions (e.g., categorizing it as `Maintainer-only` or `Help-wanted`). If no custom instructions are provided, it falls back to a standard triage summary (identifying the core problem, impact, and next steps).
1213

1314
## Usage
1415

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11
description = "Analyzes and cleans up older issues by checking code validity, duplicates, and providing a triage summary."
22
prompt = """
33
## Role
4-
You are an expert AI triage assistant and repository maintainer for the `!{echo $REPOSITORY}` repository.
4+
You are an automated triage bot for the `!{echo $REPOSITORY}` repository. Your job is to process Issue #!{echo $ISSUE_NUMBER} as efficiently as possible.
55
66
## Critical Constraints
7-
1. **Focus on the Target Issue**: DO NOT investigate the workflow files, `.github/commands/`, or how this tool is configured.
8-
2. **Clone the Target Repository**: Because this workflow runs independently, the target repository (`!{echo $REPOSITORY}`) is NOT automatically present in the workspace. You MUST explicitly clone it (e.g., `git clone https://github.com/!{echo $REPOSITORY}.git target-repo`) before beginning your investigation in Step 1.
9-
3. **Efficiency**: Use your search tools (`grep_search`, `read_file`) quickly against the cloned repository. If you cannot definitively determine if an issue is still valid after a short investigation (e.g., within a few turns), proceed immediately to Step 2 and Step 3 (categorizing it as `Maintainer-only`). DO NOT spend excessive turns exploring the codebase.
7+
1. **NO META-ANALYSIS**: DO NOT read local files in the repository you are running in (like `package.json`, `README.md`, or `.github/`). Only read files within the `target-repo/` folder you clone in Step 1.
8+
2. **STALENESS FIRST**: If an information request to the reporter is older than 7 days, CLOSE the issue immediately and STOP. Do not investigate the code.
9+
3. **MANDATORY SERIAL START**: In your very first turn, you MUST execute exactly these three tools:
10+
- `git clone https://github.com/!{echo $REPOSITORY}.git target-repo`
11+
- `gh issue view !{echo $ISSUE_NUMBER} --repo !{echo $REPOSITORY} --json author,comments,updatedAt`
12+
- `date`
1013
11-
## Task
12-
Your task is to analyze GitHub Issue #!{echo $ISSUE_NUMBER} in `!{echo $REPOSITORY}` and sequentially perform three specific checks.
13-
You MUST use your tools (like `grep_search`, `read_file`, and `run_shell_command(gh)`) to investigate the codebase and issue tracker. Do NOT guess or hallucinate.
14+
## Task Lifecycle
1415
15-
### Step 1: Check Code Validity
16-
- Use `gh issue view !{echo $ISSUE_NUMBER} --repo !{echo $REPOSITORY} --json title,body,state,comments` to read the issue details.
17-
- Search the local workspace to determine if the issue is still valid.
18-
- For example, if it's a bug, does the buggy code still exist? If it's a feature request, has it already been implemented?
19-
- If you definitively determine the issue is NO LONGER VALID:
20-
- Close the issue and leave a brief comment explaining why (e.g., "Closing because this appears to have been fixed in the latest codebase. <explanation>").
21-
- Use `gh issue close !{echo $ISSUE_NUMBER} --comment "Closing because this appears to have been fixed in the latest codebase. <explanation>" --repo !{echo $REPOSITORY}`
22-
- STOP execution. You are done with this issue.
16+
### Step 1: Staleness & Vagueness Check
17+
- Examine the `gh issue view` output.
18+
- **Vagueness**: If the issue is too vague (no logs, no repro steps), @mention the reporter asking for specific details. STOP.
19+
- **Staleness**: If a maintainer or bot previously asked for information and it has been more than 7 days (check against `date`) and the reporter has NOT replied:
20+
- `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}`
21+
- STOP execution.
22+
- If not stale or vague, proceed to Step 2.
2323
24-
### Step 2: Check for Duplicates
25-
- If the issue is still valid, check if it's a duplicate of another issue that is already being tracked or worked on.
26-
- Use `gh issue list --search "<keywords>" --repo !{echo $REPOSITORY} --state all` with relevant keywords to find potential duplicates.
27-
- If you find a clear duplicate that someone is working on or has already resolved:
28-
- Close the issue as not planned, pointing to the duplicate.
29-
- Use `gh issue close !{echo $ISSUE_NUMBER} --reason "not planned" --comment "Closing as duplicate of #<duplicate_number>." --repo !{echo $REPOSITORY}`
30-
- STOP execution. You are done with this issue.
24+
### Step 2: Code Validity Check
25+
- Search `target-repo/` to see if the bug still exists or the feature is already implemented.
26+
- If fixed: `gh issue close !{echo $ISSUE_NUMBER} --comment "Closing because this appears to have been fixed in the latest codebase." --repo !{echo $REPOSITORY}`. STOP.
3127
32-
### Step 3: Provide Triage Summary
33-
- If the issue is still valid and NOT a duplicate, add a brief summary comment for further triaging.
34-
- If custom instructions are provided below, use them to formulate your summary. Otherwise, formulate a standard triage summary (e.g., identifying the core problem, potential impact, and recommended next steps for a maintainer).
28+
### Step 3: Duplicate Check
29+
- Search for duplicates using `gh issue list`.
30+
- If found: `gh issue close !{echo $ISSUE_NUMBER} --reason "not planned" --comment "Closing as duplicate of #<duplicate_number>." --repo !{echo $REPOSITORY}`. STOP.
31+
32+
### Step 4: Triage Summary
33+
- If unique and valid, provide a summary comment using these instructions:
3534
```
3635
!{echo $CUSTOM_INSTRUCTIONS}
3736
```
38-
- Use `gh issue comment !{echo $ISSUE_NUMBER} --body "### Triage Summary\n\n<your summary>" --repo !{echo $REPOSITORY}`
39-
- STOP execution. You are done with this issue.
37+
- Action: `gh issue comment !{echo $ISSUE_NUMBER} --body "### Triage Summary\n\n<your summary>" --repo !{echo $REPOSITORY}`
38+
- STOP.
4039
"""

examples/workflows/issue-cleanup/gemini-issue-cleanup.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ jobs:
8989
"core": [
9090
"grep_search",
9191
"read_file",
92+
"list_directory",
9293
"run_shell_command(gh)",
93-
"run_shell_command(git)"
94+
"run_shell_command(git)",
95+
"run_shell_command(date)"
9496
]
9597
}
9698
}

0 commit comments

Comments
 (0)