Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions .github/actions/minimize-comments/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Minimize Comments
description: Minimize triggering and bot comments
inputs:
trigger_comment_node_id:
description: Triggering comment node ID
required: false
owner:
description: Repository owner
required: false
repo:
description: Repository name
required: false
pr_number:
description: Pull request number
required: false
bot_logins:
description: Comma-separated bot logins to minimize
required: false
default: opencode-agent,opencode-agent[bot],github-actions,github-actions[bot]
runs:
using: composite
steps:
- name: Minimize triggering comment
if: inputs.trigger_comment_node_id != ''
shell: bash
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
COMMENT_NODE_ID: ${{ inputs.trigger_comment_node_id }}
run: |
set -euo pipefail
if ! gh api graphql \
-f query='mutation($id:ID!){ minimizeComment(input:{subjectId:$id,classifier:OUTDATED}) { minimizedComment { isMinimized minimizedReason } } }' \
-f id="${COMMENT_NODE_ID}" >/dev/null 2>&1; then
echo "::warning::Failed to minimize triggering comment, continuing..."
fi

- name: Minimize old bot comments
if: inputs.owner != '' && inputs.repo != '' && inputs.pr_number != ''
shell: bash
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
OWNER: ${{ inputs.owner }}
REPO: ${{ inputs.repo }}
PR_NUMBER: ${{ inputs.pr_number }}
BOT_LOGINS: ${{ inputs.bot_logins }}
run: |
set -euo pipefail
minimized=0

normalize_logins() {
echo "$1" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | awk 'NF'
}

mapfile -t BOT_LOGIN_LIST < <(normalize_logins "${BOT_LOGINS}")

# Early exit if no bot logins specified
if [ ${#BOT_LOGIN_LIST[@]} -eq 0 ]; then
echo "No bot logins specified, skipping minimization"
exit 0
fi

should_minimize() {
local login="$1"
for allowed in "${BOT_LOGIN_LIST[@]}"; do
if [ "${login}" = "${allowed}" ]; then
return 0
fi
done
return 1
}

minimize_node_ids() {
while IFS=$'\t' read -r login node_id; do
[ -z "${node_id}" ] && continue
if should_minimize "${login}"; then
if gh api graphql \
-f query='mutation($id:ID!){ minimizeComment(input:{subjectId:$id,classifier:OUTDATED}) { minimizedComment { isMinimized minimizedReason } } }' \
-f id="${node_id}" >/dev/null 2>&1; then
minimized=$((minimized + 1))
else
echo "::warning::Failed to minimize comment with node_id=${node_id}, continuing..."
fi
fi
done
}

gh api --paginate "repos/${OWNER}/${REPO}/pulls/${PR_NUMBER}/comments" \
-H "Accept: application/vnd.github+json" \
--jq '.[] | [.user.login, .node_id] | @tsv' | minimize_node_ids

gh api --paginate "repos/${OWNER}/${REPO}/issues/${PR_NUMBER}/comments" \
-H "Accept: application/vnd.github+json" \
--jq '.[] | [.user.login, .node_id] | @tsv' | minimize_node_ids

echo "Minimized old bot comments: ${minimized}"
52 changes: 10 additions & 42 deletions .github/workflows/comment-to-ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ jobs:
fetch-depth: 0

- name: Minimize triggering comment
uses: ./.github/actions/minimize-comments
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMENT_NODE_ID: ${{ github.event.comment.node_id }}
run: |
set -euo pipefail
gh api graphql \
-f query='mutation($id:ID!){ minimizeComment(input:{subjectId:$id,classifier:OUTDATED}) { minimizedComment { isMinimized minimizedReason } } }' \
-f id="${COMMENT_NODE_ID}" >/dev/null
with:
trigger_comment_node_id: ${{ github.event.comment.node_id }}

- name: Configure git
run: |
Expand Down Expand Up @@ -112,44 +109,15 @@ jobs:
with:
fetch-depth: 0

- name: Minimize triggering comment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMENT_NODE_ID: ${{ github.event.comment.node_id }}
run: |
set -euo pipefail
gh api graphql \
-f query='mutation($id:ID!){ minimizeComment(input:{subjectId:$id,classifier:OUTDATED}) { minimizedComment { isMinimized minimizedReason } } }' \
-f id="${COMMENT_NODE_ID}" >/dev/null

- name: Minimize old bot comments on PR
- name: Minimize comments
uses: ./.github/actions/minimize-comments
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
run: |
set -euo pipefail
minimized=0

minimize_node_ids() {
while IFS= read -r node_id; do
[ -z "${node_id}" ] && continue
gh api graphql \
-f query='mutation($id:ID!){ minimizeComment(input:{subjectId:$id,classifier:OUTDATED}) { minimizedComment { isMinimized minimizedReason } } }' \
-f id="${node_id}" >/dev/null && minimized=$((minimized + 1))
done
}

gh api --paginate "repos/${OWNER}/${REPO}/pulls/${PR_NUMBER}/comments" \
-H "Accept: application/vnd.github+json" \
--jq '.[] | select(.user.login == "opencode-agent" or .user.login == "opencode-agent[bot]" or .user.login == "github-actions" or .user.login == "github-actions[bot]") | .node_id' | minimize_node_ids

gh api --paginate "repos/${OWNER}/${REPO}/issues/${PR_NUMBER}/comments" \
-H "Accept: application/vnd.github+json" \
--jq '.[] | select(.user.login == "opencode-agent" or .user.login == "opencode-agent[bot]" or .user.login == "github-actions" or .user.login == "github-actions[bot]") | .node_id' | minimize_node_ids

echo "Minimized old bot comments: ${minimized}"
with:
trigger_comment_node_id: ${{ github.event.comment.node_id }}
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
pr_number: ${{ github.event.issue.number }}

- name: Configure git
run: |
Expand Down
4 changes: 4 additions & 0 deletions .serena/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,7 @@ symbol_info_budget:
# Note: the backend is fixed at startup. If a project with a different backend
# is activated post-init, an error will be returned.
language_backend:

# list of regex patterns which, when matched, mark a memory entry as read‑only.
# Extends the list from the global configuration, merging the two lists.
read_only_memory_patterns: []