mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 05:42:54 -07:00
Issue fixer.
This commit is contained in:
@@ -2,7 +2,8 @@ name: '🧠 Gemini CLI Bot: Brain'
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *' # Every 24 hours
|
||||
- cron: '0 0 * * *' # Nightly (Strategic Metrics)
|
||||
- cron: '0 */4 * * *' # Every 4 hours (Issue Fixing)
|
||||
issue_comment:
|
||||
types: ['created']
|
||||
workflow_dispatch:
|
||||
@@ -26,7 +27,7 @@ on:
|
||||
enable_prs:
|
||||
description: 'Enable PRs (automatically promote changes to PRs)'
|
||||
type: 'boolean'
|
||||
default: false
|
||||
default: true
|
||||
|
||||
concurrency:
|
||||
group: '${{ github.workflow }}-${{ github.event.issue.number || github.event.inputs.issue_number || github.ref }}'
|
||||
@@ -39,8 +40,7 @@ jobs:
|
||||
if: |
|
||||
github.repository == 'google-gemini/gemini-cli' && (
|
||||
github.event_name == 'schedule' ||
|
||||
(github.event_name == 'workflow_dispatch' && github.event.inputs.run_interactive != 'true') ||
|
||||
(github.event_name == 'workflow_dispatch' && github.event.inputs.run_interactive == 'true') ||
|
||||
(github.event_name == 'workflow_dispatch') ||
|
||||
(github.event_name == 'issue_comment' && github.event.comment.user.login != 'gemini-cli[bot]' && contains(github.event.comment.body, '@gemini-cli') && contains(fromJSON('["COLLABORATOR", "MEMBER", "OWNER"]'), github.event.comment.author_association))
|
||||
)
|
||||
# The reasoning phase is strictly readonly.
|
||||
@@ -124,16 +124,22 @@ jobs:
|
||||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
||||
GEMINI_MODEL: 'gemini-3-flash-preview'
|
||||
GEMINI_CLI_HOME: 'tools/gemini-cli-bot'
|
||||
ENABLE_PRS: "${{ github.event.inputs.enable_prs || 'false' }}"
|
||||
ENABLE_PRS: "${{ github.event.inputs.enable_prs || 'true' }}"
|
||||
TRIGGER_ISSUE_NUMBER: '${{ github.event.issue.number || github.event.inputs.issue_number }}'
|
||||
TRIGGER_COMMENT_ID: '${{ github.event.comment.id || github.event.inputs.comment_id }}'
|
||||
run: |
|
||||
PROMPT_PATH="tools/gemini-cli-bot/brain/scheduled.md"
|
||||
# Determine trigger and intent
|
||||
PROMPT_FILE="tools/gemini-cli-bot/brain/scheduled.md"
|
||||
MANDATE="Your specific mandate for this run: Implement surgical fixes for repository issues (issue-fixer skill)."
|
||||
|
||||
if [ "${{ github.event_name }}" = "issue_comment" ] || [ "${{ github.event.inputs.run_interactive }}" = "true" ]; then
|
||||
PROMPT_PATH="tools/gemini-cli-bot/brain/interactive.md"
|
||||
export ENABLE_PRS="true"
|
||||
PROMPT_FILE="tools/gemini-cli-bot/brain/interactive.md"
|
||||
MANDATE="Your specific mandate for this run: Respond to the user request in <untrusted_context>."
|
||||
elif [ "${{ github.event.schedule }}" = "0 0 * * *" ]; then
|
||||
MANDATE="Your specific mandate for this run: Analyze repository metrics to identify bottlenecks and self-evolve (metrics skill)."
|
||||
fi
|
||||
|
||||
# Prepare Context if available
|
||||
touch trigger_context.md
|
||||
if [ -n "$TRIGGER_ISSUE_NUMBER" ]; then
|
||||
echo "<untrusted_context>" > trigger_context.md
|
||||
@@ -151,15 +157,17 @@ jobs:
|
||||
echo "</untrusted_context>" >> trigger_context.md
|
||||
fi
|
||||
|
||||
if [ "$ENABLE_PRS" = "true" ]; then
|
||||
echo "**System Directive**: PR creation is ENABLED for this run. You MUST activate the **'prs' skill** to stage your changes and generate a \`pr-description.md\` file if you are proposing fixes." >> trigger_context.md
|
||||
echo "**CRITICAL System Directive**: You MUST ONLY propose and implement a **SINGLE** improvement or fix per run. Bundling unrelated changes (e.g., a documentation update and a script fix, or a metrics update and a logic fix) into a single PR is STRICTLY FORBIDDEN and will result in immediate rejection during the critique phase. If you identify multiple issues, pick the most impactful one and ignore the others for now." >> trigger_context.md
|
||||
else
|
||||
echo "**System Directive**: PR creation is DISABLED for this run. You MUST NOT stage files or attempt to create a PR description." >> trigger_context.md
|
||||
# Pass PR Enablement Directive
|
||||
PR_DIRECTIVE="PR creation is DISABLED. You MUST NOT stage files."
|
||||
if [ "${{ github.event.inputs.enable_prs || 'true' }}" = "true" ] || [ "${{ github.event_name }}" = "issue_comment" ]; then
|
||||
PR_DIRECTIVE="PR creation is ENABLED. You MUST activate the 'prs' skill to stage changes if proposing fixes."
|
||||
fi
|
||||
echo "" >> trigger_context.md
|
||||
|
||||
cat trigger_context.md "$PROMPT_PATH" > combined_prompt.md
|
||||
# Assemble final prompt: Context + Base Brain + Specific Mandate
|
||||
echo "System: $PR_DIRECTIVE" > combined_prompt.md
|
||||
cat trigger_context.md "$PROMPT_FILE" >> combined_prompt.md
|
||||
echo -e "\n\n# MANDATE FOR THIS RUN\n$MANDATE" >> combined_prompt.md
|
||||
|
||||
node bundle/gemini.js --policy tools/gemini-cli-bot/ci-policy.toml --prompt="$(cat combined_prompt.md)"
|
||||
|
||||
if [ -n "$TRIGGER_ISSUE_NUMBER" ] && [ ! -s "issue-comment.md" ] && [ ! -s "pr-comment.md" ]; then
|
||||
@@ -294,15 +302,12 @@ jobs:
|
||||
git apply "${{ runner.temp }}/brain-data/bot-changes.patch"
|
||||
git add .
|
||||
|
||||
PR_TITLE="🤖 Gemini Bot Maintenance Update"
|
||||
if [ -s "${{ runner.temp }}/brain-data/pr-description.md" ]; then
|
||||
git commit -F "${{ runner.temp }}/brain-data/pr-description.md"
|
||||
else
|
||||
git commit -m "🤖 Gemini Bot Productivity Optimizations"
|
||||
fi
|
||||
|
||||
PR_TITLE="🤖 Gemini Bot Productivity Optimizations"
|
||||
if [ -s "${{ runner.temp }}/brain-data/pr-description.md" ]; then
|
||||
PR_TITLE=$(head -n 1 "${{ runner.temp }}/brain-data/pr-description.md")
|
||||
else
|
||||
git commit -m "$PR_TITLE"
|
||||
fi
|
||||
|
||||
if ! git push origin "$BRANCH_NAME" --force; then
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Skill: issue-fixer
|
||||
|
||||
## Objective
|
||||
Proactively identify and implement surgical fixes for "small effort" issues and maintain existing PRs to reduce the repository backlog.
|
||||
|
||||
## High-Level Expectations
|
||||
1. **Maintenance**: Prioritize driving existing `bot-fix` PRs to completion. Check for CI failures, merge conflicts, or requested changes.
|
||||
2. **Discovery**: Find open issues labeled `effort/small`. Prioritize those with clear reproduction steps.
|
||||
3. **Autonomous Implementation**: You are responsible for the entire fix: research, code changes, and test verification.
|
||||
4. **Surgical Precision**: Changes must be minimal and strictly focused on the identified issue. Avoid "drive-by" refactoring.
|
||||
5. **Local Verification**: You MUST run `npm run preflight` locally and iterate on any failures before finalizing your PR.
|
||||
6. **Expert Mentions**: Identify the domain expert for the affected files and CC them in the PR description.
|
||||
7. **Focused contributions**: limit your active PRs to ~10 at a time. Try to complete existing PRs before opening new ones. If a maintainer closes a PR, that may be an indication that they are rejecting the fix.
|
||||
|
||||
## Workflow
|
||||
1. **Inventory & Drive PRs**: Use the `prs` skill to list all open PRs labeled `bot-fix`.
|
||||
- If any require attention (CI failure, requested changes), focus your entire run on resolving ONE of them.
|
||||
- Do NOT start a new issue fix if an existing PR needs work.
|
||||
2. **Search for candidates**: If no PRs need attention, search for `effort/small` issues: `gh issue list --label "effort/small" --limit 10`.
|
||||
3. **Select ONE issue** and implement a fix on a new branch.
|
||||
4. **Verify** via `npm run preflight`.
|
||||
5. **Use the `prs` skill** to stage changes and prepare the draft PR (label: `bot-fix`).
|
||||
@@ -21,6 +21,7 @@ maintainability.
|
||||
`tools/gemini-cli-bot/history/metrics-before-prev.csv` and the current run's
|
||||
metrics.
|
||||
- **Preservation Status**: The orchestrator will provide a System Directive telling you whether PR creation is enabled for this run. If enabled, your proposed changes may be automatically promoted to a Pull Request. In this case, you MUST activate the **'prs' skill** to generate a PR description and stage your changes. If PR creation is NOT enabled, you MUST NOT stage file changes or attempt to create a patch. Instead, simply report your findings.
|
||||
- **Ownership Mandate**: Any PR generated by this skill MUST use the `bot-fix` label.
|
||||
|
||||
## Repo Policy Priorities
|
||||
|
||||
|
||||
@@ -10,6 +10,12 @@ description: Expertise in managing the Git and GitHub Pull Request lifecycle, in
|
||||
Standardize how the Gemini CLI Bot stages its changes, generates Pull Request
|
||||
descriptions, and manages the lifecycle of both new and existing PRs.
|
||||
|
||||
## Mandatory PR Driver (Ownership)
|
||||
|
||||
You are the "owner" of all PRs labeled `bot-fix`. You MUST proactively drive them to completion:
|
||||
1. **Inventory**: Use `gh pr list --label "bot-fix" --json number,title,headRefName,statusCheckRollup,comments` to find your active PRs.
|
||||
2. **Proactive Maintenance**: If a `bot-fix` PR has failing status checks or new maintainer comments, you MUST prioritize fixing the CI or responding to the feedback before starting new work.
|
||||
|
||||
## Staging & Patch Preparation (MANDATORY)
|
||||
|
||||
If you are proposing fixes and PR creation is enabled (per the System Directive):
|
||||
@@ -23,8 +29,8 @@ If you are proposing fixes and PR creation is enabled (per the System Directive)
|
||||
2. **Generate PR Description**: Use the `write_file` tool to create
|
||||
`pr-description.md`.
|
||||
- **Title**: The very first line MUST be a concise, conventional title.
|
||||
- **Body**: The rest should be the markdown body explaining the change, why
|
||||
it is recommended, and the expected impact.
|
||||
- **Body**: Explain the change and expected impact. You MUST identify the domain expert for the affected files and mention them (cc @<user>).
|
||||
- **Labels**: Always apply the `bot-fix` label.
|
||||
3. **Stage Fixes**: You MUST explicitly stage your fixes using the
|
||||
`git add <files>` command.
|
||||
4. **Internal File Protection (CRITICAL)**: You are STRICTLY FORBIDDEN from
|
||||
|
||||
Reference in New Issue
Block a user