diff --git a/.github/actions/minimize-comments/action.yml b/.github/actions/minimize-comments/action.yml new file mode 100644 index 000000000..47fba729a --- /dev/null +++ b/.github/actions/minimize-comments/action.yml @@ -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}" diff --git a/.github/workflows/comment-to-ai.yml b/.github/workflows/comment-to-ai.yml index a5a8c20f1..7e606d527 100644 --- a/.github/workflows/comment-to-ai.yml +++ b/.github/workflows/comment-to-ai.yml @@ -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: | @@ -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: | diff --git a/.serena/project.yml b/.serena/project.yml index e046a9b51..4cdacb18d 100644 --- a/.serena/project.yml +++ b/.serena/project.yml @@ -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: []