Skip to content

🔄 synced file(s) with dianlight/opencode-actions - #11

Closed
dianlight wants to merge 11 commits into
mainfrom
repo-sync/opencode-actions/default
Closed

🔄 synced file(s) with dianlight/opencode-actions#11
dianlight wants to merge 11 commits into
mainfrom
repo-sync/opencode-actions/default

Conversation

@dianlight

@dianlight dianlight commented Jul 7, 2026

Copy link
Copy Markdown
Owner

synced local file(s) with dianlight/opencode-actions.

Changed files
  • created local .github/workflows/opencode-pr-review.yml from remote .github/workflows/opencode-pr-review.yml
  • created local .github/workflows/opencode-pr-comment.yml from remote .github/workflows/opencode-pr-comment.yml
  • created local .github/workflows/opencode-issue-handler.yml from remote .github/workflows/opencode-issue-handler.yml
  • created local .github/scripts/auth.sh from remote .github/scripts/auth.sh
  • created local .github/scripts/resolve-model.sh from remote .github/scripts/resolve-model.sh
  • synced local .github/workflows/opencode.yml with remote .github/workflows/opencode.yml
  • synced local .github/workflows/opencode-triage.yaml with remote .github/workflows/opencode-triage.yaml
  • created local .github/workflows/opencode-triage-pr.yaml from remote .github/workflows/opencode-triage-pr.yaml
  • created local .github/workflows/opencode-triage-issue.yaml from remote .github/workflows/opencode-triage-issue.yaml
  • synced local .github/workflows/opencode-implement.yaml with remote .github/workflows/opencode-implement.yaml
  • synced local .github/workflows/opencode-review.yaml with remote .github/workflows/opencode-review.yaml

This PR was created automatically by the repo-file-sync-action workflow run #31084509917

@dianlight dianlight added the sync label Jul 7, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 3 · 🛠️ 1

✅ No existing threads resolved.

The || contains(..., 'opencode:awaiting-response') suffix in both new triage workflows (3 occurrences) short-circuits all preceding guard clauses (bot exclusion, author association, state check), allowing any comment — including from bots — to potentially trigger the implementation workflow without human verification.

) &&
github.event.comment.body.length > 10
) ||
contains(github.event.issue.labels.*.name, 'opencode:awaiting-response')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 [CRITICAL] Bot bypass via unguarded label check

The || at line 27 has lower precedence than &&, so the label check on line 28 bypasses ALL preceding guards (bot exclusion, author association, state check). Any comment on an issue with opencode:awaiting-response triggers the workflow, and if the comment body matches 'approved', 'lgtm', etc., implementation is dispatched without human review.

Fix: Wrap the label check with the same guard clauses.

Suggested change
contains(github.event.issue.labels.*.name, 'opencode:awaiting-response')
contains(github.event.issue.labels.*.name, 'opencode:awaiting-response') &&
github.event.issue.state == 'open' &&
github.event.comment.user.login != 'github-actions[bot]' &&
github.event.comment.user.login != 'opencode-agent[bot]' &&
github.event.comment.user.login != 'coderabbitai[bot]'

) &&
github.event.comment.body.length > 10
) ||
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 [CRITICAL] Same bypass in triage-pr (review-comment branch)

Identical guard-clause bypass in the pull_request_review_comment branch.

Suggested change
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response')
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response') &&
github.event.pull_request.state == 'open' &&
github.event.comment.user.login != 'github-actions[bot]' &&
github.event.comment.user.login != 'opencode-agent[bot]' &&
github.event.comment.user.login != 'coderabbitai[bot]'

) &&
github.event.review.body.length > 10
) ||
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 [CRITICAL] Same bypass in triage-pr (review branch)

Identical guard-clause bypass in the pull_request_review branch.

Suggested change
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response')
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response') &&
github.event.pull_request.state == 'open' &&
github.event.review.user.login != 'github-actions[bot]' &&
github.event.review.user.login != 'opencode-agent[bot]' &&
github.event.review.user.login != 'coderabbitai[bot]'

Comment thread .github/workflows/opencode-review.yaml Outdated
Comment on lines +34 to +38
changed_files=$(git diff --name-only "$base"...HEAD 2>/dev/null || echo "")
if [ -z "$changed_files" ]; then
# Fallback: just check if any file changed at all
changed_files=$(git diff --name-only HEAD~1...HEAD 2>/dev/null || echo "")
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ [QUALITY] Fallback diff logic misses intermediate commits

When git diff --name-only "$base"...HEAD returns empty (edge case — e.g. invalid base SHA), the fallback HEAD~1...HEAD only captures the most recent commit's changes. For multi-commit PRs, intermediate changes are invisible. Since fetch-depth: 0 provides full history, compute the merge base explicitly and avoid the fallback entirely:

Suggested change
changed_files=$(git diff --name-only "$base"...HEAD 2>/dev/null || echo "")
if [ -z "$changed_files" ]; then
# Fallback: just check if any file changed at all
changed_files=$(git diff --name-only HEAD~1...HEAD 2>/dev/null || echo "")
fi
merge_base=$(git merge-base "$base" HEAD 2>/dev/null) || merge_base="$base"
changed_files=$(git diff --name-only "$merge_base" HEAD 2>/dev/null || echo "")

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review submitted. Verdict: REQUEST_CHANGES — 3 🚨 CRITICAL, 1 🛠️ QUALITY.

Most critical finding: All three || contains(..., 'opencode:awaiting-response') guard-clause bypasses in the new triage workflows (triage-issue.yaml:28, triage-pr.yaml:32,50). Due to &&-over-|| precedence, the label check short-circuits bot exclusion, author association, and state-open checks, allowing any comment (including from bots) to potentially dispatch the implementation workflow.

New%20session%20-%202026-07-07T07%3A33%3A26.205Z
opencode session  |  github run

@dianlight
dianlight force-pushed the repo-sync/opencode-actions/default branch from 4c9ccd9 to dd540f3 Compare July 7, 2026 08:27
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds /oc command parsing and new issue/PR automation workflows for refinement, implementation, task execution, and review. Several existing Opencode workflows are replaced with manual no-op deprecation workflows.

Changes

Opencode automation

Layer / File(s) Summary
Command parsing contract
.github/scripts/auth.sh
Parses /oc comments and exports command status, subcommands, and task arguments through GITHUB_OUTPUT.
Issue command processing
.github/workflows/opencode-issue-handler.yml
Routes authorized issue commands to refinement or implementation jobs, then posts reactions and propagates agent failures.
PR comment routing and task execution
.github/workflows/opencode-pr-comment.yml
Routes bot-thread replies, user-thread takeovers, and /oc task requests to dedicated Opencode jobs.
PR review workflow
.github/workflows/opencode-pr-review.yml
Filters eligible comments, skips draft PRs, runs read-only reviews, submits feedback, and reports outcomes.
Deprecated workflow replacements
.github/workflows/opencode-implement.yaml, .github/workflows/opencode-review.yaml, .github/workflows/opencode-triage*.yaml, .github/workflows/opencode.yml
Replaces legacy automated workflows with manual no-op workflows and simplified deprecation notices.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Comment
  participant auth.sh
  participant Workflow
  participant Opencode
  Comment->>auth.sh: Parse /oc command
  auth.sh->>Workflow: Return subcommand and arguments
  Workflow->>Opencode: Run selected automation path
  Opencode->>Workflow: Return outcome
  Workflow->>Comment: Post reaction or result
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately identifies the primary change as synchronizing repository files with dianlight/opencode-actions.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch repo-sync/opencode-actions/default

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dianlight
dianlight force-pushed the repo-sync/opencode-actions/default branch from dd540f3 to 8ead145 Compare July 7, 2026 08:28

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 4 · 🛠️ 1

✅ 0 threads resolved — all 4 previously flagged issues remain unaddressed in the current diff. A new 🚨 YAML indentation error is also found in the new opencode-triage-issue.yaml.

Most critical finding: opencode-triage-issue.yaml:12debug: at column 0 (same indent as jobs:) makes it a top-level key, not a child of jobs:. This invalid YAML structure will cause a GitHub Actions workflow validation error, preventing the triage job from ever running.

Comment on lines +12 to +22
debug: # ← NUOVO JOB
runs-on: ubuntu-latest
steps:
- name: Debug auth info
run: |
echo "Comment user: ${{ github.event.comment.user.login }}"
echo "Author association: ${{ github.event.comment.author_association }}"
echo "Issue state: ${{ github.event.issue.state }}"
echo "Comment body: ${{ github.event.comment.body }}"
echo "Trigger contains /oc: $(echo '${{ github.event.comment.body }}' | grep -c '/oc' || echo '0')"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 [CRITICAL] debug: job YAML indentation breaks workflow validation

The debug: key is at column 0 (same indent as jobs:), making it a top-level key instead of a child of jobs:. This will cause a GitHub Actions workflow validation error — neither debug nor triage will run.

This is also leftover development scaffolding that should not be in production. Remove it:

Suggested change
debug: # ← NUOVO JOB
runs-on: ubuntu-latest
steps:
- name: Debug auth info
run: |
echo "Comment user: ${{ github.event.comment.user.login }}"
echo "Author association: ${{ github.event.comment.author_association }}"
echo "Issue state: ${{ github.event.issue.state }}"
echo "Comment body: ${{ github.event.comment.body }}"
echo "Trigger contains /oc: $(echo '${{ github.event.comment.body }}' | grep -c '/oc' || echo '0')"

) &&
github.event.comment.body.length > 10
) ||
contains(github.event.issue.labels.*.name, 'opencode:awaiting-response')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 [CRITICAL] Bot bypass via unguarded || label check (previously flagged, still open)

|| contains(github.event.issue.labels.*.name, 'opencode:awaiting-response') has lower precedence than all preceding && operators, so the label check bypasses ALL guards (bot exclusion, author association, state check). Any comment (including from bots) on an issue with this label triggers the workflow.

Suggested change
contains(github.event.issue.labels.*.name, 'opencode:awaiting-response')
contains(github.event.issue.labels.*.name, 'opencode:awaiting-response') &&
github.event.issue.state == 'open' &&
github.event.comment.user.login != 'github-actions[bot]' &&
github.event.comment.user.login != 'opencode-agent[bot]' &&
github.event.comment.user.login != 'coderabbitai[bot]'

) &&
github.event.comment.body.length > 10
) ||
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 [CRITICAL] Bot bypass in pull_request_review_comment branch (previously flagged, still open)

Same ||-over-&& precedence issue — the label check on this line bypasses all preceding guard clauses.

Suggested change
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response')
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response') &&
github.event.pull_request.state == 'open' &&
github.event.comment.user.login != 'github-actions[bot]' &&
github.event.comment.user.login != 'opencode-agent[bot]' &&
github.event.comment.user.login != 'coderabbitai[bot]'

) &&
github.event.review.body.length > 10
) ||
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 [CRITICAL] Bot bypass in pull_request_review branch (previously flagged, still open)

Same ||-over-&& precedence issue for review events.

Suggested change
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response')
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response') &&
github.event.pull_request.state == 'open' &&
github.event.review.user.login != 'github-actions[bot]' &&
github.event.review.user.login != 'opencode-agent[bot]' &&
github.event.review.user.login != 'coderabbitai[bot]'

Comment thread .github/workflows/opencode-review.yaml Outdated
run: |
base="${{ github.event.pull_request.base.sha }}"
# Get list of changed files against the base
changed_files=$(git diff --name-only "$base"...HEAD 2>/dev/null || echo "")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ [QUALITY] Fallback diff logic misses intermediate commits (previously flagged, still open)

When git diff --name-only "$base"...HEAD returns empty, the fallback HEAD~1...HEAD only covers the most recent commit. For multi-commit PRs, intermediate changes are invisible. Since fetch-depth: 0 provides full history, compute the merge base explicitly:

Suggested change
changed_files=$(git diff --name-only "$base"...HEAD 2>/dev/null || echo "")
merge_base=$(git merge-base "$base" HEAD 2>/dev/null) || merge_base="$base"
changed_files=$(git diff --name-only "$merge_base" HEAD 2>/dev/null || echo "")

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review submitted — REQUEST_CHANGES.

Step 1: No threads resolved — all 4 previously flagged issues persist in the current diff (3 🚨 bypass in triage-issue.yaml:39, triage-pr.yaml:32, triage-pr.yaml:50; 1 🛠️ fallback in review.yaml:34).

Step 2: Submitted with 5 inline comments:

  • 🚨 triage-issue.yaml:12 — New: debug: YAML indentation error (column 0, same as jobs:) breaks workflow validation
  • 🚨 triage-issue.yaml:39 — Previously flagged: || contains(...) bypasses all guard clauses
  • 🚨 triage-pr.yaml:32 — Previously flagged: same bypass in review-comment branch
  • 🚨 triage-pr.yaml:50 — Previously flagged: same bypass in review branch
  • 🛠️ review.yaml:34 — Previously flagged: fallback HEAD~1 misses intermediate commits

New%20session%20-%202026-07-07T08%3A28%3A10.743Z
opencode session  |  github run

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 3 · 🛠️ 2

✅ 0 threads resolved — all previously flagged issues remain unaddressed in the current diff.

Most critical finding: All three || contains(..., 'opencode:awaiting-response') guard-clause bypasses persist (triage-issue.yaml:39, triage-pr.yaml:32, triage-pr.yaml:50). Due to &&-over-|| operator precedence, the label check short-circuits all preceding guards (bot exclusion, author association, state check), allowing any comment — including from bots — to trigger the implementation workflow without human verification.

cancel-in-progress: false

jobs:
debug: # ← NUOVO JOB

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ [QUALITY] Debug job is leftover development scaffolding

The debug job (lines 12–21) prints variable values and serves no purpose in production. It runs on every issue_comment event, consuming CI minutes and cluttering logs. Remove it before shipping.

Suggested change
debug: # ← NUOVO JOB
triage:

) &&
github.event.comment.body.length > 10
) ||
contains(github.event.issue.labels.*.name, 'opencode:awaiting-response')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 [CRITICAL] Guard-clause bypass via || operator precedence (previously flagged, still open)

|| has lower precedence than &&, so || contains(..., 'opencode:awaiting-response') on line 39 is evaluated as an alternative to ALL preceding &&-chained guards (bot exclusion at 25–27, author association at 28, state check at 29). Any commenter — including github-actions[bot], opencode-agent[bot], or coderabbitai[bot] — can bypass all checks simply by commenting on an issue with the opencode:awaiting-response label. If the comment body matches 'approved'/'lgtm', the implementation workflow is dispatched without human review.

Fix: Move the label check inside the guarded parentheses so it is subject to the same bot/author/state filters.

Suggested change
contains(github.event.issue.labels.*.name, 'opencode:awaiting-response')
(
contains(github.event.issue.labels.*.name, 'opencode:awaiting-response') ||
(
(
contains(github.event.comment.body, ' /oc') ||
startsWith(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, ' /opencode') ||
startsWith(github.event.comment.body, '/opencode')
) &&
github.event.comment.body.length > 10
)
)

) &&
github.event.comment.body.length > 10
) ||
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 [CRITICAL] Guard-clause bypass via || in pull_request_review_comment branch (previously flagged, still open)

Same ||-over-&& precedence issue. The label check on line 32 bypasses bot exclusion (lines 18–20), author association (line 21), and state check (line 22).

Suggested change
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response')
(
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response') ||
(
(
contains(github.event.comment.body, ' /oc') ||
startsWith(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, ' /opencode') ||
startsWith(github.event.comment.body, '/opencode')
) &&
github.event.comment.body.length > 10
)
)

) &&
github.event.review.body.length > 10
) ||
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 [CRITICAL] Guard-clause bypass via || in pull_request_review branch (previously flagged, still open)

Same ||-over-&& precedence issue. The label check on line 50 bypasses bot exclusion (lines 36–38), author association (line 39), and state check (line 40).

Suggested change
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response')
(
contains(github.event.pull_request.labels.*.name, 'opencode:awaiting-response') ||
(
(
contains(github.event.review.body, ' /oc') ||
startsWith(github.event.review.body, '/oc') ||
contains(github.event.review.body, ' /opencode') ||
startsWith(github.event.review.body, '/opencode')
) &&
github.event.review.body.length > 10
)
)

Comment thread .github/workflows/opencode-review.yaml Outdated
run: |
base="${{ github.event.pull_request.base.sha }}"
# Get list of changed files against the base
changed_files=$(git diff --name-only "$base"...HEAD 2>/dev/null || echo "")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ [QUALITY] Fallback diff logic misses intermediate commits (previously flagged, still open)

When git diff --name-only "$base"...HEAD returns empty (edge case such as an invalid base SHA), the fallback HEAD~1...HEAD only captures the most recent commit's changes. For multi-commit PRs, intermediate changes are invisible. Since fetch-depth: 0 provides full history, compute the merge base explicitly and avoid the fallback entirely:

Suggested change
changed_files=$(git diff --name-only "$base"...HEAD 2>/dev/null || echo "")
merge_base=$(git merge-base "$base" HEAD 2>/dev/null) || merge_base="$base"
changed_files=$(git diff --name-only "$merge_base" HEAD 2>/dev/null || echo "")

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review submitted successfully — REQUEST_CHANGES with 5 inline comments:

  • opencode-triage-issue.yaml:12 — 🛠️ Debug job is leftover scaffolding
  • opencode-triage-issue.yaml:39 — 🚨 Guard-clause bypass via || precedence (previously flagged)
  • opencode-triage-pr.yaml:32 — 🚨 Same bypass in pull_request_review_comment branch (previously flagged)
  • opencode-triage-pr.yaml:50 — 🚨 Same bypass in pull_request_review branch (previously flagged)
  • opencode-review.yaml:34 — 🛠️ Fallback diff logic misses intermediate commits (previously flagged)

New%20session%20-%202026-07-07T08%3A31%3A42.668Z
opencode session  |  github run

@dianlight
dianlight force-pushed the repo-sync/opencode-actions/default branch from 8ead145 to 0e8cd54 Compare July 11, 2026 17:46

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/scripts/auth.sh:
- Around line 50-59: Replace the fixed OCAUTH_EOF delimiter in the TASK_ARGS
output block with a cryptographically unpredictable, per-invocation delimiter,
and use that same generated value for both the opening and closing markers.
Preserve the existing empty TASK_ARGS behavior and GitHub output format while
ensuring comment content cannot terminate the heredoc early.
- Line 26: Update the /oc pattern in the TRIMMED matcher to require whitespace
or end-of-line immediately after the token, preventing prefixes such as /october
from matching while preserving valid /oc comments.

In @.github/workflows/opencode-pr-comment.yml:
- Around line 100-102: Update the workflow step containing the PARENT_AUTHOR and
in_reply_to_id lookups so GitHub event fields are passed through step-level env
variables rather than interpolated directly in run commands. Define env values
for the pull request review URL and in_reply_to_id, then reference them as
quoted shell variables in the gh api and related commands.
- Around line 354-397: Update the workflow instructions for
issue_comment-triggered steps to use github.event.issue.number instead of
github.event.pull_request.number when invoking gh pr checkout, gh pr edit, and
gh pr comment; preserve the existing task execution and checklist behavior.
- Around line 119-127: Update the LAST_COMMENT_AUTHOR lookup in the bot-thread
detection block to fetch the latest comments page explicitly before selecting
the comment immediately preceding the trigger. Preserve the existing
previous-author selection and bot comparisons, ensuring threads with more than
30 comments inspect the correct latest-page entry.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 94d2ca7b-3963-4318-a340-a71efea176f6

📥 Commits

Reviewing files that changed from the base of the PR and between 08b5b38 and 0e8cd54.

📒 Files selected for processing (10)
  • .github/scripts/auth.sh
  • .github/workflows/opencode-implement.yaml
  • .github/workflows/opencode-issue-handler.yml
  • .github/workflows/opencode-pr-comment.yml
  • .github/workflows/opencode-pr-review.yml
  • .github/workflows/opencode-review.yaml
  • .github/workflows/opencode-triage-issue.yaml
  • .github/workflows/opencode-triage-pr.yaml
  • .github/workflows/opencode-triage.yaml
  • .github/workflows/opencode.yml

Comment thread .github/scripts/auth.sh Outdated
SUBCOMMAND="none"
TASK_ARGS=""

if [[ "$TRIMMED" =~ ^/oc ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Tighten the /oc matcher.
^/oc also matches prefixes like /october, so those comments can be routed as /oc. Anchor the token to whitespace or end-of-line.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/scripts/auth.sh at line 26, Update the /oc pattern in the TRIMMED
matcher to require whitespace or end-of-line immediately after the token,
preventing prefixes such as /october from matching while preserving valid /oc
comments.

Comment thread .github/scripts/auth.sh
Comment thread .github/workflows/opencode-pr-comment.yml
Comment on lines +119 to +127
LAST_COMMENT_AUTHOR=$(gh api \
"/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \
--jq '.[-2].user.login' 2>/dev/null || echo "")

if [[ "$LAST_COMMENT_AUTHOR" == "opencode-agent[bot]" ]] || \
[[ "$LAST_COMMENT_AUTHOR" == "github-actions[bot]" ]]; then
IS_BOT_THREAD="true"
fi
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the workflow around the referenced lines
file=".github/workflows/opencode-pr-comment.yml"
wc -l "$file"
sed -n '90,150p' "$file"

# Check for any pagination / per_page handling in this workflow
rg -n --no-heading 'per_page|paginate|issues/.*/comments|LAST_COMMENT_AUTHOR|IS_BOT_THREAD' "$file"

# Gather the relevant gh api / jq behavior from local help if available
gh api --help 2>/dev/null | sed -n '1,220p' || true
gh help api 2>/dev/null | sed -n '1,220p' || true

Repository: dianlight/smartmontools-sdk

Length of output: 18761


🌐 Web query:

GitHub REST API list issue comments default order per_page 30 docs comments endpoint oldest first

💡 Result:

For the GitHub REST API "List issue comments" endpoints, the default behavior regarding pagination and ordering is as follows: Pagination: The default value for the per_page parameter is 30, with a maximum allowed value of 100 per page [1][2]. Ordering: By default, issue comments are ordered by ascending ID [3][4][5]. The API documentation explicitly states this default ordering [3][4], which typically results in the oldest comments appearing first. Some discussions within the community have noted that while ID-based ordering often corresponds to chronological creation order, the API behavior is officially documented as being based on the ID [3][4].

Citations:


Bot-thread detection only inspects the first comments page .github/workflows/opencode-pr-comment.yml:119-127

/repos/{owner}/{repo}/issues/{n}/comments returns comments oldest-first with 30 per page, so .[-2] reads from page 1 instead of the comment immediately before the trigger. On threads with more than 30 comments, IS_BOT_THREAD can be computed from the wrong comment. Fetch the latest page explicitly before selecting the previous author.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 119 - 127, Update the
LAST_COMMENT_AUTHOR lookup in the bot-thread detection block to fetch the latest
comments page explicitly before selecting the comment immediately preceding the
trigger. Preserve the existing previous-author selection and bot comparisons,
ensuring threads with more than 30 comments inspect the correct latest-page
entry.

Comment thread .github/workflows/opencode-pr-comment.yml Outdated
@dianlight
dianlight force-pushed the repo-sync/opencode-actions/default branch from 0e8cd54 to 01484a8 Compare July 12, 2026 14:23

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/opencode-issue-handler.yml:
- Around line 64-83: Update the Process 4 job permissions and opencode step:
remove id-token: write from permissions and set use_github_token: true in the
opencode action’s with configuration. Keep the existing read-only contents
permission and issue-writing behavior unchanged.
- Around line 118-124: Remove the manual gh issue comment instructions and
execution steps from the issue-handling workflow, including the corresponding
block around the later response section. Configure the workflow to return the
formatted response to the pinned anomalyco/opencode/github action instead,
relying on that action to create the issue comment once.

In @.github/workflows/opencode-pr-comment.yml:
- Around line 81-89: Add a repository checkout step at the beginning of the
process-2 job’s steps, before any Opencode execution, so the job has a local git
worktree available. Use the workflow’s existing checkout action configuration
and leave the job conditions and permissions unchanged.
- Around line 215-229: Update the process-3 workflow job around the opencode
step to grant contents: write permission and enable persisted checkout
credentials instead of setting persist-credentials to false. Apply the same
contents: write permission to the process-6 job while preserving its existing
checkout authentication configuration, so both jobs can push changes.
- Around line 175-181: Remove the gh api reply instructions and shell code
blocks from the prompt blocks in the workflow, including the ## Output section
shown and all equivalent prompt sections. Have each prompt request and return
only the Markdown reply content directly, without instructing the model to post
via GitHub API or reference github.event.comment.id.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a5c51317-6d71-4180-aa44-6245b6846b8f

📥 Commits

Reviewing files that changed from the base of the PR and between 0e8cd54 and 01484a8.

📒 Files selected for processing (10)
  • .github/scripts/auth.sh
  • .github/workflows/opencode-implement.yaml
  • .github/workflows/opencode-issue-handler.yml
  • .github/workflows/opencode-pr-comment.yml
  • .github/workflows/opencode-pr-review.yml
  • .github/workflows/opencode-review.yaml
  • .github/workflows/opencode-triage-issue.yaml
  • .github/workflows/opencode-triage-pr.yaml
  • .github/workflows/opencode-triage.yaml
  • .github/workflows/opencode.yml
🚧 Files skipped from review as they are similar to previous changes (8)
  • .github/workflows/opencode-triage-issue.yaml
  • .github/workflows/opencode.yml
  • .github/workflows/opencode-triage-pr.yaml
  • .github/workflows/opencode-triage.yaml
  • .github/workflows/opencode-review.yaml
  • .github/workflows/opencode-implement.yaml
  • .github/scripts/auth.sh
  • .github/workflows/opencode-pr-review.yml

Comment on lines +64 to +83
permissions:
id-token: write
contents: read
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false

- name: Run opencode (Process 4 — Issue Review & Refinement)
id: opencode
continue-on-error: true
uses: anomalyco/opencode/github@77fc88c8ade8e5a620ebbe1197f3a572d29ae91a # latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
OPENCODE_TRIGGER_BODY: ${{ github.event.comment.body }}
with:
model: opencode/deepseek-v4-flash-free

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
curl -fsSL \
  https://raw.githubusercontent.com/anomalyco/opencode/77fc88c8ade8e5a620ebbe1197f3a572d29ae91a/github/action.yml |
  grep -n -A8 'use_github_token'

Repository: dianlight/smartmontools-sdk

Length of output: 739


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- workflow ---'
cat -n .github/workflows/opencode-issue-handler.yml | sed -n '55,90p'

echo
echo '--- local references to use_github_token ---'
rg -n "use_github_token|USE_GITHUB_TOKEN|OIDC_BASE_URL|GITHUB_TOKEN" .github/workflows . -g '!**/node_modules/**' -g '!**/dist/**' -g '!**/build/**'

Repository: dianlight/smartmontools-sdk

Length of output: 4704


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- opencode-issue-handler around the other use_github_token occurrence ---'
cat -n .github/workflows/opencode-issue-handler.yml | sed -n '188,210p'

echo
echo '--- opencode-pr-review usage ---'
cat -n .github/workflows/opencode-pr-review.yml | sed -n '60,80p'

echo
echo '--- opencode-pr-comment usage ---'
cat -n .github/workflows/opencode-pr-comment.yml | sed -n '138,152p'

Repository: dianlight/smartmontools-sdk

Length of output: 3373


Enforce Process 4’s read-only boundary with the job token. use_github_token is still at its default false, so this step uses the OIDC/App-token path instead of the job-scoped GITHUB_TOKEN. Set use_github_token: true here and remove id-token: write.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-issue-handler.yml around lines 64 - 83, Update
the Process 4 job permissions and opencode step: remove id-token: write from
permissions and set use_github_token: true in the opencode action’s with
configuration. Keep the existing read-only contents permission and issue-writing
behavior unchanged.

Comment thread .github/workflows/opencode-issue-handler.yml Outdated
Comment on lines +81 to +89
process-2:
if: needs.route.outputs.process == 'process-2'
needs: route
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
steps:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '81,145p' .github/workflows/opencode-pr-comment.yml

Repository: dianlight/smartmontools-sdk

Length of output: 2902


Checkout the repository before Process 2. Opencode runs from the local git worktree here, but this job never checks the repo out first, so the step can fail before it processes the prompt.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 81 - 89, Add a
repository checkout step at the beginning of the process-2 job’s steps, before
any Opencode execution, so the job has a local git worktree available. Use the
workflow’s existing checkout action configuration and leave the job conditions
and permissions unchanged.

Comment on lines +175 to +181
## Output
Reply to the thread via `gh api`:
```bash
gh api --method POST \
/repos/${{ github.repository }}/pulls/comments/${{ github.event.comment.id }}/replies \
-f body="Your response here"
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
curl -fsSL \
  https://raw.githubusercontent.com/anomalyco/opencode/77fc88c8ade8e5a620ebbe1197f3a572d29ae91a/packages/opencode/src/cli/cmd/github.ts |
  grep -n 'createComment'

Repository: dianlight/smartmontools-sdk

Length of output: 823


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== workflow outline ==\n'
ast-grep outline .github/workflows/opencode-pr-comment.yml || true

printf '\n== workflow snippets ==\n'
sed -n '150,210p' .github/workflows/opencode-pr-comment.yml
printf '\n---\n'
sed -n '250,290p' .github/workflows/opencode-pr-comment.yml
printf '\n---\n'
sed -n '380,410p' .github/workflows/opencode-pr-comment.yml

printf '\n== github.ts around createComment ==\n'
tmp=$(mktemp)
curl -fsSL \
  https://raw.githubusercontent.com/anomalyco/opencode/77fc88c8ade8e5a620ebbe1197f3a572d29ae91a/packages/opencode/src/cli/cmd/github.ts \
  -o "$tmp"
sed -n '1280,1335p' "$tmp"
rm -f "$tmp"

Repository: dianlight/smartmontools-sdk

Length of output: 7764


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '150,210p' .github/workflows/opencode-pr-comment.yml
printf '\n---\n'
sed -n '250,290p' .github/workflows/opencode-pr-comment.yml
printf '\n---\n'
sed -n '380,410p' .github/workflows/opencode-pr-comment.yml

Repository: dianlight/smartmontools-sdk

Length of output: 5789


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "opencode|final response|createComment|gh api|pulls/comments|issue_comment|review comment" .github/workflows/opencode-pr-comment.yml

Repository: dianlight/smartmontools-sdk

Length of output: 3780


🌐 Web query:

GitHub REST API reply to pull request review comment requires pull request review comment ID issue_comment payload comment.id review comment id

💡 Result:

To reply to a pull request review comment using the GitHub REST API, you should use the dedicated endpoint for pull request review comment replies rather than the generic issue comment endpoint [1][2][3][4]. The correct endpoint is: POST /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies In this path, the {comment_id} must be the unique identifier of an existing top-level pull request review comment [1][5]. The API does not support replies to replies; you cannot nest replies further than the initial response to a top-level comment [1][2][6]. Key requirements for the request: 1. Path Parameters: You must provide the correct owner, repository name, pull request number, and the ID of the top-level comment you are replying to [5][7]. 2. Body Payload: The request body must include a body field containing the text of your reply [1][6][7]. Example: {"body": "Your reply text here"}. 3. Distinction: Do not confuse this with the "issue comments" API, which manages comments on the pull request as a whole rather than specific review comments within the diff [3][4]. If you are programmatically identifying the comment to reply to, ensure you are referencing the id field of the pull request review comment object, not an issue_comment ID [1][5].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,85p' .github/workflows/opencode-pr-comment.yml
printf '\n---\n'
sed -n '220,310p' .github/workflows/opencode-pr-comment.yml
printf '\n---\n'
sed -n '330,440p' .github/workflows/opencode-pr-comment.yml

Repository: dianlight/smartmontools-sdk

Length of output: 11007


🌐 Web query:

anomalyco/opencode github action posts final response automatically gh api reply prompt

💡 Result:

The anomalyco/opencode GitHub Action is designed to integrate the OpenCode AI agent into your GitHub workflow [1][2]. It does not require you to manually use the GitHub API (gh api) to post responses, as the action handles this process automatically [1][3]. Key features and mechanisms: 1. Automatic Replying: When triggered by events like issue comments or pull request reviews, the OpenCode GitHub Action automatically processes the context (including existing comments) and posts its response as a comment on the corresponding GitHub issue or pull request [1][2][4]. 2. Triggering: You typically configure the action in a workflow file (e.g.,.github/workflows/opencode.yml) [1][4]. It can be configured to trigger on events such as issue_comment, pull_request_review_comment, issues, and pull_request [1][2][5]. 3. No Manual API Calls Needed: The action manages the interaction with the GitHub API internally [1][3]. It uses the provided GITHUB_TOKEN (typically supplied via secrets) to perform operations such as posting comments, creating branches, or opening pull requests [2][4][5]. 4. Advanced Automation: Recent updates have expanded the action's capabilities, allowing it to automatically extract prompts from issue titles, bodies, and labels (for example, on 'assigned' or 'opened' events), further reducing the need for manual prompt configuration or manual API interaction [3]. If you are looking to build a custom solution or need to interact with the GitHub API manually for other purposes, you can use the GitHub CLI (gh api) [6] or the actions/github-script action [7], but for standard OpenCode functionality, the anomalyco/opencode action handles these tasks for you [1][3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

tmp=$(mktemp)
curl -fsSL https://raw.githubusercontent.com/anomalyco/opencode/main/README.md -o "$tmp" || curl -fsSL https://raw.githubusercontent.com/anomalyco/opencode/master/README.md -o "$tmp"

printf '\n== README mentions GitHub action/comment behavior ==\n'
rg -n "GitHub Action|comment|reply|final response|post.*response|createComment|gh api" "$tmp" || true

printf '\n== nearby sections ==\n'
sed -n '1,260p' "$tmp" | rg -n -C 3 "GitHub Action|comment|reply|final response|post.*response|createComment|gh api" || true

rm -f "$tmp"

Repository: dianlight/smartmontools-sdk

Length of output: 291


Remove the gh api reply instruction from these prompts
The action posts the model output itself, so the prompt should return the Markdown reply directly. github.event.comment.id is also wrong on issue_comment runs, where GitHub expects the top-level review-comment ID for /pulls/comments/{comment_id}/replies. Apply the same change to the other prompt blocks.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 175 - 181, Remove the
gh api reply instructions and shell code blocks from the prompt blocks in the
workflow, including the ## Output section shown and all equivalent prompt
sections. Have each prompt request and return only the Markdown reply content
directly, without instructing the model to post via GitHub API or reference
github.event.comment.id.

Comment thread .github/workflows/opencode-pr-comment.yml
@dianlight
dianlight force-pushed the repo-sync/opencode-actions/default branch 2 times, most recently from 603e384 to e25d4f6 Compare July 14, 2026 20:48
@dianlight
dianlight force-pushed the repo-sync/opencode-actions/default branch 4 times, most recently from c2a2488 to 7effd20 Compare July 22, 2026 08:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (6)
.github/workflows/opencode-pr-comment.yml (6)

90-110: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Template injection persists — unquoted github.event.comment.* fields expanded directly into run.

This is the exact pattern flagged previously (and reportedly "addressed" in a prior commit), but it's back in this version — likely reintroduced by the upstream sync. zizmor still flags Line 101 as template-injection; the same risk applies to the in_reply_to_id expansions on Lines 105-108. Pass these through env: and reference as shell variables.

Proposed fix
       - name: Check if this is a reply to an Opencode thread
         id: thread-check
         env:
           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           EVENT_NAME: ${{ github.event_name }}
+          PR_REVIEW_URL: ${{ github.event.comment.pull_request_review_url }}
+          IN_REPLY_TO_ID: ${{ github.event.comment.in_reply_to_id }}
         run: |
           IS_BOT_THREAD="false"

           if [[ "$EVENT_NAME" == "pull_request_review_comment" ]]; then
             PARENT_AUTHOR=$(gh api \
-              "${{ github.event.comment.pull_request_review_url }}" \
+              "$PR_REVIEW_URL" \
               --jq '.user.login' 2>/dev/null || echo "")

-            if [[ "${{ github.event.comment.in_reply_to_id }}" != "null" ]] && \
-               [[ -n "${{ github.event.comment.in_reply_to_id }}" ]]; then
+            if [[ "$IN_REPLY_TO_ID" != "null" ]] && [[ -n "$IN_REPLY_TO_ID" ]]; then
               PARENT_AUTHOR=$(gh api \
-                "/repos/${{ github.repository }}/pulls/comments/${{ github.event.comment.in_reply_to_id }}" \
+                "/repos/${{ github.repository }}/pulls/comments/${IN_REPLY_TO_ID}" \
                 --jq '.user.login' 2>/dev/null || echo "$PARENT_AUTHOR")
             fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 90 - 110, Remove
direct github.event.comment.* interpolations from the run script in the
thread-check step. Expose pull_request_review_url and in_reply_to_id through the
step’s env block, then reference the corresponding shell variables in the gh api
calls and conditional checks while preserving the existing fallback behavior.

Source: Linters/SAST tools


175-181: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Drop the gh api reply instructions from the Process 2/3 prompts.

The anomalyco/opencode/github action posts the model's output as the reply itself; instructing it to call gh api .../pulls/comments/${{ github.event.comment.id }}/replies is redundant and wrong for issue_comment-sourced runs into Process 2 (top-level comment IDs aren't valid review-comment IDs for that endpoint). Same issue flagged previously on both blocks, still present.

Proposed fix
             ## Output
-            Reply to the thread via `gh api`:
-            ```bash
-            gh api --method POST \
-              /repos/${{ github.repository }}/pulls/comments/${{ github.event.comment.id }}/replies \
-              -f body="Your response here"
-            ```
+            Return your reply as Markdown directly — the action posts it to the thread automatically.

Apply the equivalent change to the Process 3 block (Lines 268-274).

Also applies to: 268-274

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 175 - 181, Remove the
`gh api` reply instructions from both the Process 2 and Process 3 prompt blocks
in the workflow. Replace each output section with guidance to return the
response as Markdown directly, relying on the `anomalyco/opencode/github` action
to post it automatically; do not reference the pull-request comment reply
endpoint or comment ID.

215-224: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Process 3 & 6 can't push — contents: read plus use_github_token: true, and Process 3 also drops persisted checkout creds.

Both jobs set use_github_token: true (Lines 236, 341), which per Opencode's docs skips its own git-credential setup and relies on the job's GITHUB_TOKEN. With contents: read (Lines 217, 310) that token can't push, and Process 3 additionally sets persist-credentials: false (Line 223), removing the only other credential source. Still unresolved from the prior review.

Proposed fix
   process-3:
     ...
     permissions:
       id-token: write
-      contents: read
+      contents: write
       pull-requests: write
     steps:
       - name: Checkout repository
         uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
         with:
-          persist-credentials: false
+          persist-credentials: true
           fetch-depth: 0
   process-6:
     ...
     permissions:
       id-token: write
-      contents: read
+      contents: write
       pull-requests: write

Note: keeping persist-credentials at its implicit default true on Process 6's checkout (Lines 313-316) also triggers zizmor's artipacked warning; that's an accepted trade-off here since a git credential is required to push, but worth a comment noting it's intentional.

Also applies to: 304-316

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 215 - 224, Update the
Process 3 and Process 6 workflow jobs to grant contents: write because their
use_github_token configuration requires GITHUB_TOKEN push access. In Process 3,
remove persist-credentials: false so checkout retains credentials; keep Process
6’s implicit persisted credentials and add a comment documenting that this is
intentional for pushing despite the zizmor warning.

Source: Linters/SAST tools


352-397: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Process 6 uses github.event.pull_request.number, which is empty on issue_comment events.

Process 6 is only reachable via the issue_comment route (Lines 66-69), whose payload has no pull_request object — only issue.number. gh pr checkout, gh pr edit, and gh pr comment will all run with a blank PR number. Same critical finding as the prior review, still present.

Proposed fix
            ## Context
            - Repository: ${{ github.repository }}
-           - Pull request: #${{ github.event.pull_request.number }}
+           - Pull request: #${{ github.event.issue.number }}
            - Task arguments from the user: env var `OPENCODE_TASK_ARGS`
            ...
            ### 2. Checkout the PR branch
            ```bash
-           gh pr checkout ${{ github.event.pull_request.number }}
+           gh pr checkout ${{ github.event.issue.number }}
            ```
            ...
            ```bash
-           gh pr edit ${{ github.event.pull_request.number }} \
+           gh pr edit ${{ github.event.issue.number }} \
              --body "<updated PR body with checked checkbox>"
            ```

            ### 6. Post summary comment
            ```bash
-           gh pr comment ${{ github.event.pull_request.number }} \
+           gh pr comment ${{ github.event.issue.number }} \
              --body "✅ Task completed: <description>\nCommit: <sha>"
            ```
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 352 - 397, Update the
issue_comment workflow instructions in the Workflow steps to use
github.event.issue.number instead of github.event.pull_request.number for gh pr
checkout, gh pr edit, and gh pr comment, so all operations target the pull
request associated with the issue_comment event.

116-127: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Bot-thread detection still only inspects the first comments page.

/repos/{owner}/{repo}/issues/{n}/comments returns comments oldest-first, 30 per page by default; .[-2] reads page 1, not the comment immediately preceding the trigger. On threads with >30 comments, IS_BOT_THREAD is computed from the wrong comment, silently skipping Process 2 for legitimate bot-thread replies. Unresolved from the prior review.

Proposed fix
-            LAST_COMMENT_AUTHOR=$(gh api \
-              "/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \
-              --jq '.[-2].user.login' 2>/dev/null || echo "")
+            LAST_COMMENT_AUTHOR=$(gh api --paginate \
+              "/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \
+              --jq '.[].user.login' 2>/dev/null | tail -n 2 | head -n 1 || echo "")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 116 - 127, Update the
issue_comment branch’s LAST_COMMENT_AUTHOR lookup to retrieve the full/latest
comments page or otherwise identify the comment immediately preceding the
triggering comment, rather than assuming page 1 contains it. Preserve the
existing bot-author checks for opencode-agent[bot] and github-actions[bot] so
IS_BOT_THREAD reflects the actual preceding comment even when the thread exceeds
30 comments.

81-90: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Process 2 still has no checkout step.

Opencode operates on a local git worktree (see Process 3/6, which both checkout before invoking anomalyco/opencode/github), but Process 2 goes straight from job setup to the thread-check step with no actions/checkout. Any fix/commit path in this prompt (Lines 156-158, 170-172) will fail before it starts. Also unaddressed from the prior review.

Proposed fix
     steps:
+      - name: Checkout repository
+        uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
+        with:
+          persist-credentials: true
+          fetch-depth: 0
+
       - name: Check if this is a reply to an Opencode thread
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 81 - 90, Add an
actions/checkout step at the start of process-2, before “Check if this is a
reply to an Opencode thread” and any Opencode invocation, so the job has a local
git worktree for fix and commit operations. Match the checkout configuration
already used by Process 3/6.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/opencode-issue-handler.yml:
- Around line 177-204: Remove the unused id-token: write entry from the
permissions block for the “Run opencode (Process 5 — Issue Work & PR Creation)”
job, while preserving the contents, pull-requests, and issues permissions
required by the workflow.

In @.github/workflows/opencode-pr-comment.yml:
- Around line 66-77: Avoid duplicate handling of /oc review issue comments in
the issue_comment routing logic: update the branch around SUBCOMMAND and PROCESS
in the workflow so review subcommands are excluded or otherwise prevented from
reaching this workflow, while preserving existing handling for task, bare /oc,
and non-/oc comments.
- Around line 85-88: Add issues: write to the permissions for the process-2 and
process-6 jobs in the workflow. Keep the existing id-token, contents, and
pull-requests permissions unchanged so their reaction fallback can write
reactions to top-level PR comments.

---

Duplicate comments:
In @.github/workflows/opencode-pr-comment.yml:
- Around line 90-110: Remove direct github.event.comment.* interpolations from
the run script in the thread-check step. Expose pull_request_review_url and
in_reply_to_id through the step’s env block, then reference the corresponding
shell variables in the gh api calls and conditional checks while preserving the
existing fallback behavior.
- Around line 175-181: Remove the `gh api` reply instructions from both the
Process 2 and Process 3 prompt blocks in the workflow. Replace each output
section with guidance to return the response as Markdown directly, relying on
the `anomalyco/opencode/github` action to post it automatically; do not
reference the pull-request comment reply endpoint or comment ID.
- Around line 215-224: Update the Process 3 and Process 6 workflow jobs to grant
contents: write because their use_github_token configuration requires
GITHUB_TOKEN push access. In Process 3, remove persist-credentials: false so
checkout retains credentials; keep Process 6’s implicit persisted credentials
and add a comment documenting that this is intentional for pushing despite the
zizmor warning.
- Around line 352-397: Update the issue_comment workflow instructions in the
Workflow steps to use github.event.issue.number instead of
github.event.pull_request.number for gh pr checkout, gh pr edit, and gh pr
comment, so all operations target the pull request associated with the
issue_comment event.
- Around line 116-127: Update the issue_comment branch’s LAST_COMMENT_AUTHOR
lookup to retrieve the full/latest comments page or otherwise identify the
comment immediately preceding the triggering comment, rather than assuming page
1 contains it. Preserve the existing bot-author checks for opencode-agent[bot]
and github-actions[bot] so IS_BOT_THREAD reflects the actual preceding comment
even when the thread exceeds 30 comments.
- Around line 81-90: Add an actions/checkout step at the start of process-2,
before “Check if this is a reply to an Opencode thread” and any Opencode
invocation, so the job has a local git worktree for fix and commit operations.
Match the checkout configuration already used by Process 3/6.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b359bda9-7026-4391-94eb-6343b77411c2

📥 Commits

Reviewing files that changed from the base of the PR and between 1a4edf2 and 7effd20.

📒 Files selected for processing (10)
  • .github/scripts/auth.sh
  • .github/workflows/opencode-implement.yaml
  • .github/workflows/opencode-issue-handler.yml
  • .github/workflows/opencode-pr-comment.yml
  • .github/workflows/opencode-pr-review.yml
  • .github/workflows/opencode-review.yaml
  • .github/workflows/opencode-triage-issue.yaml
  • .github/workflows/opencode-triage-pr.yaml
  • .github/workflows/opencode-triage.yaml
  • .github/workflows/opencode.yml
🚧 Files skipped from review as they are similar to previous changes (8)
  • .github/workflows/opencode.yml
  • .github/workflows/opencode-triage-issue.yaml
  • .github/workflows/opencode-triage-pr.yaml
  • .github/workflows/opencode-triage.yaml
  • .github/workflows/opencode-review.yaml
  • .github/workflows/opencode-implement.yaml
  • .github/scripts/auth.sh
  • .github/workflows/opencode-pr-review.yml

Comment on lines +177 to +204
permissions:
id-token: write
contents: write
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7

- name: Configure git identity
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Run opencode (Process 5 — Issue Work & PR Creation)
id: opencode
continue-on-error: true
uses: anomalyco/opencode/github@77fc88c8ade8e5a620ebbe1197f3a572d29ae91a # latest
env:
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENCODE_TRIGGER_BODY: ${{ github.event.comment.body }}
OPENCODE_IMPLEMENT_ARGS: ${{ needs.route.outputs.task_args }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
with:
model: opencode/deepseek-v4-flash-free
use_github_token: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the relevant workflow section with line numbers
sed -n '160,220p' .github/workflows/opencode-issue-handler.yml | cat -n

# Locate any direct references to id-token or use_github_token in the repo
rg -n "id-token: write|use_github_token|OPENCODE_API_KEY|GITHUB_TOKEN|anomalyco/opencode/github" .github/workflows .github -S

# Check whether the repo vendors any documentation or scripts that explain the action behavior
git ls-files | rg '(^|/)(README|CHANGELOG|docs?)/|opencode|github\.ya?ml$' -n

Repository: dianlight/smartmontools-sdk

Length of output: 13227


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the full process-5 job and nearby jobs for context
sed -n '160,260p' .github/workflows/opencode-issue-handler.yml | cat -n

# Show any job-level uses of id-token in this workflow to compare patterns
rg -n "id-token: write|use_github_token: true|uses: anomalyco/opencode/github" .github/workflows/opencode-issue-handler.yml -n -A4 -B4

# Look for any workflow steps in process-5 that invoke cloud/OIDC-related tools
rg -n "aws-actions|azure/login|google-github-actions|oidc|id-token|assume-role|workload identity|jwt" .github/workflows/opencode-issue-handler.yml -S

Repository: dianlight/smartmontools-sdk

Length of output: 6666


Remove the unused id-token permission.
process-5 only uses GITHUB_TOKEN via use_github_token: true, so id-token: write just broadens the job’s privileges without a matching need.

🧰 Tools
🪛 zizmor (1.26.1)

[warning] 183-184: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-issue-handler.yml around lines 177 - 204, Remove
the unused id-token: write entry from the permissions block for the “Run
opencode (Process 5 — Issue Work & PR Creation)” job, while preserving the
contents, pull-requests, and issues permissions required by the workflow.

Comment on lines +66 to +77
elif [[ "$EVENT_NAME" == "issue_comment" ]]; then
# Top-level PR comment
if [[ "$SUBCOMMAND" == "task" ]]; then
PROCESS="process-6"
elif [[ "$IS_OC" == "true" ]]; then
# Bare /oc on PR without subcommand — Process 2 if in bot thread
PROCESS="process-2"
else
# Non-/oc comment — only Process 2 if replying to bot thread
PROCESS="process-2"
fi
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
fd -e yml -e yaml . .github/workflows | xargs rg -n "issue_comment|SUBCOMMAND|review" 2>/dev/null
cat .github/workflows/opencode-pr-review.yml 2>/dev/null | head -80

Repository: dianlight/smartmontools-sdk

Length of output: 7102


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- opencode-pr-comment.yml (relevant sections) ---'
sed -n '1,220p' .github/workflows/opencode-pr-comment.yml

echo
echo '--- opencode-pr-review.yml (job gate and parse section) ---'
sed -n '1,140p' .github/workflows/opencode-pr-review.yml

echo
echo '--- auth.sh ---'
sed -n '1,220p' .github/scripts/auth.sh

Repository: dianlight/smartmontools-sdk

Length of output: 15704


🏁 Script executed:

#!/bin/bash
set -euo pipefail

nl -ba .github/workflows/opencode-pr-comment.yml | sed -n '1,220p'
echo
nl -ba .github/workflows/opencode-pr-review.yml | sed -n '1,120p'
echo
nl -ba .github/scripts/auth.sh | sed -n '1,220p'

Repository: dianlight/smartmontools-sdk

Length of output: 205


Avoid double-processing /oc review comments. Both opencode-pr-review.yml and .github/workflows/opencode-pr-comment.yml:66-77 handle issue_comment /oc review events, so the same comment can run twice. Exclude /oc review here or narrow the review workflow trigger.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 66 - 77, Avoid
duplicate handling of /oc review issue comments in the issue_comment routing
logic: update the branch around SUBCOMMAND and PROCESS in the workflow so review
subcommands are excluded or otherwise prevented from reaching this workflow,
while preserving existing handling for task, bare /oc, and non-/oc comments.

Comment on lines +85 to +88
permissions:
id-token: write
contents: write
pull-requests: write

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the workflow file and inspect the relevant region.
wc -l .github/workflows/opencode-pr-comment.yml
sed -n '1,220p' .github/workflows/opencode-pr-comment.yml

# Find the job names and any reaction-related calls.
rg -n "process-2|process-6|reactions|issue_comment|pull_request|permissions" .github/workflows/opencode-pr-comment.yml

Repository: dianlight/smartmontools-sdk

Length of output: 11755


🌐 Web query:

GitHub REST API reactions endpoint permissions issues comments pull request review comments

💡 Result:

The GitHub REST API provides dedicated endpoints to manage reactions on pull request review comments [1][2]. These endpoints allow you to list, create, and delete reactions [1][3]. Endpoints for Pull Request Review Comment Reactions: List reactions: GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions [1][2] Create a reaction: POST /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions [1][2] Delete a reaction: DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id} [1] Permissions and Troubleshooting: Access to these endpoints depends on the repository's visibility and the authentication method used (e.g., Personal Access Tokens or GitHub Apps) [4][5]. If you encounter permission issues when interacting with these endpoints, you can determine the exact required permissions by checking the X-Accepted-GitHub-Permissions header in the API response [4][6]. This header is returned by the GitHub API to indicate which permissions are necessary for a given request, serving as an authoritative guide for troubleshooting authorization errors [4][5]. For private repositories, appropriate repository-level permissions (typically read for listing and write for creating/deleting) are generally required [4][5]. Always verify that your token or app has the necessary scope to interact with the specific repository [4][5].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the workflow context around the referenced jobs and any reaction handling.
python3 - <<'PY'
from pathlib import Path
p = Path('.github/workflows/opencode-pr-comment.yml')
text = p.read_text()
lines = text.splitlines()
for start in [1, 70, 280, 300]:
    end = min(len(lines), start + 40)
    print(f"\n--- lines {start}-{end} ---")
    for i in range(start-1, end):
        print(f"{i+1:4d}: {lines[i]}")
PY

# Locate comments/reactions usage in the workflow.
rg -n "issues/comments/.*/reactions|pulls/comments/.*/reactions|issue_comment|process-2|process-6|permissions:" .github/workflows/opencode-pr-comment.yml

Repository: dianlight/smartmontools-sdk

Length of output: 9015


🌐 Web query:

GitHub REST API create reaction issue comment requires issues write fine-grained token pull request review comment requires pull-requests write

💡 Result:

When using fine-grained personal access tokens (PATs) with the GitHub REST API, the required permissions for creating reactions can be nuanced. For creating a reaction to an issue comment (POST /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions), the official documentation and API references indicate that the Issues repository permission (write) is required [1][2]. However, some users have reported that the Pull requests repository permission (write) also functions for this endpoint [1]. For creating a reaction to a pull request review comment (POST /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions), while the endpoint is often categorized under Pull requests, users have reported issues where standard write permissions do not always behave as documented, leading to "Insufficient scopes" errors (HTTP 403) [3]. To troubleshoot or verify the exact permissions required for your specific repository or fine-grained token configuration, you should check the X-Accepted-GitHub-Permissions header returned in the response when you make a request to the endpoint [4][5]. This header explicitly lists the permissions needed for that specific request [4]. If you encounter unexpected access errors, it is recommended to ensure your token has the necessary repository permissions (typically Issues or Pull requests set to Write) and to rely on the X-Accepted-GitHub-Permissions header for confirmation [4].

Citations:


Add issues: write to process-2 and process-6. Their reaction fallback posts to /issues/comments/{id}/reactions for top-level PR comments, so pull-requests: write alone leaves the emoji step skipped behind || true.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 85 - 88, Add issues:
write to the permissions for the process-2 and process-6 jobs in the workflow.
Keep the existing id-token, contents, and pull-requests permissions unchanged so
their reaction fallback can write reactions to top-level PR comments.

@dianlight
dianlight force-pushed the repo-sync/opencode-actions/default branch from 7effd20 to 8d38dab Compare July 22, 2026 10:42

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (10)
.github/workflows/opencode-pr-comment.yml (8)

81-96: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Process 2 never checks out the repository before running opencode.

Unlike Process 3 and Process 6, this job has no checkout step; the opencode step (Line 136) executes against whatever ambient working directory the runner has, which can fail before the prompt is even processed if the action or agent expects a local git worktree.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 81 - 96, Update the
process-2 job to add a repository checkout step before the opencode execution
step, matching the checkout behavior used by process-3 and process-6. Ensure the
checkout runs before any steps that require a local git worktree.

175-181: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Prompts instruct a manual gh api ... /replies post, duplicating the action's own reply and using a wrong comment ID on issue_comment runs.

The action already posts the model's response; the ## Output block telling the agent to gh api --method POST /repos/.../pulls/comments/${{ github.event.comment.id }}/replies causes a duplicate reply, and github.event.comment.id is not a valid top-level review-comment ID when the trigger came from issue_comment. Remove these instructions from both Process 2's and Process 3's prompts and let the action return the Markdown reply directly.

Also applies to: 268-274

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 175 - 181, Remove the
manual gh api reply instructions from the ## Output sections of both Process 2
and Process 3 prompts. Have each prompt instruct the model to return the
Markdown response directly, without posting it, while leaving the action
responsible for submitting the reply.

98-110: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Direct github.event.comment.* expansion in run: — template-injection risk (zizmor flags Line 101).

pull_request_review_url and in_reply_to_id are interpolated straight into the shell command instead of via env:. A crafted value in these fields could inject shell code. This exact fix was proposed previously and marked addressed, but the vulnerable pattern is back in this synced file.

🔒 Proposed fix
       - name: Check if this is a reply to an Opencode thread
         id: thread-check
         env:
           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           EVENT_NAME: ${{ github.event_name }}
+          PR_REVIEW_URL: ${{ github.event.comment.pull_request_review_url }}
+          IN_REPLY_TO_ID: ${{ github.event.comment.in_reply_to_id }}
         run: |
           IS_BOT_THREAD="false"
           if [[ "$EVENT_NAME" == "pull_request_review_comment" ]]; then
             PARENT_AUTHOR=$(gh api \
-              "${{ github.event.comment.pull_request_review_url }}" \
+              "$PR_REVIEW_URL" \
               --jq '.user.login' 2>/dev/null || echo "")
-            if [[ "${{ github.event.comment.in_reply_to_id }}" != "null" ]] && \
-               [[ -n "${{ github.event.comment.in_reply_to_id }}" ]]; then
+            if [[ "$IN_REPLY_TO_ID" != "null" ]] && [[ -n "$IN_REPLY_TO_ID" ]]; then
               PARENT_AUTHOR=$(gh api \
-                "/repos/${{ github.repository }}/pulls/comments/${{ github.event.comment.in_reply_to_id }}" \
+                "/repos/${{ github.repository }}/pulls/comments/${IN_REPLY_TO_ID}" \
                 --jq '.user.login' 2>/dev/null || echo "$PARENT_AUTHOR")
             fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 98 - 110, Remove
direct github.event.comment.* expressions from the run shell commands in the
pull_request_review_comment branch. Pass pull_request_review_url and
in_reply_to_id through the step’s env mapping, then reference those environment
variables in the gh api URL and conditional checks while preserving the existing
parent-author fallback behavior.

Source: Linters/SAST tools


85-88: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Process 2 and Process 6 are missing issues: write, so the reaction fallback for top-level PR comments silently no-ops.

The reaction steps (e.g. Lines 188-193, 410-415) try /repos/.../issues/comments/{id}/reactions first, which needs issues: write; both jobs only grant pull-requests: write, so that call 403s and falls through to the || true on every top-level comment.

Also applies to: 304-311

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 85 - 88, Add issues:
write to the permissions blocks for Process 2 and Process 6 in the workflow,
preserving the existing id-token, contents, and pull-requests permissions.
Ensure the reaction steps in those jobs can access the issue-comment reactions
endpoint without changing their fallback behavior.

66-77: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

/oc review comments can be double-processed by this workflow and the dedicated PR-review workflow.

For issue_comment events, a bare /oc review falls through to the IS_OC == true branch (Lines 70-72) and routes to Process 2, while opencode-pr-review.yml also listens for /oc review on issue_comment. The same comment can trigger both workflows unless the subcommand is excluded here or the review workflow's trigger is narrowed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 66 - 77, Exclude the
review subcommand from the issue_comment routing in the workflow’s conditional
block so `/oc review` is not assigned to Process 2 by this workflow. Preserve
the existing routing for `/oc task`, bare `/oc`, and non-/oc comments, while
leaving review handling to the dedicated PR-review workflow.

352-397: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Process 6's prompt uses github.event.pull_request.number, which is empty on the issue_comment event that triggers this job.

Process 6 is only reached via the issue_comment branch of the route job (Line 68-69: SUBCOMMAND == "task"), where GitHub populates github.event.issue, not github.event.pull_request. gh pr checkout ${{ github.event.pull_request.number }} (Line 368), gh pr edit ${{ github.event.pull_request.number }} (Line 389), and gh pr comment ${{ github.event.pull_request.number }} (Line 395) will all receive a blank/invalid number and fail. Use github.event.issue.number throughout this job's context and commands.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 352 - 397, The
workflow instructions for the task process use the unavailable pull_request
event context. Replace github.event.pull_request.number with
github.event.issue.number in the checkout, PR body update, and summary comment
commands, and in the surrounding context text, while preserving the existing
task workflow.

116-127: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Bot-thread detection only inspects the first comments page.

/repos/{owner}/{repo}/issues/{n}/comments returns comments ordered ascending by ID with a default page size of 30 — confirmed by GitHub's docs, which state comments are ordered by ascending ID. .jq '.[-2]' therefore reads the wrong element on any thread exceeding 30 comments, computing IS_BOT_THREAD from a stale comment rather than the one immediately preceding the trigger.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 116 - 127, Update the
issue_comment branch’s LAST_COMMENT_AUTHOR lookup to retrieve the complete or
appropriately paginated comment history before selecting the comment immediately
preceding the trigger. Preserve the existing author checks for
opencode-agent[bot] and github-actions[bot], ensuring IS_BOT_THREAD reflects the
actual preceding comment even when the thread exceeds the default API page size.

215-224: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Process 3 and Process 6 lack write access to push commits.

Both set use_github_token: true (Lines 236, 341) so the action relies on the job's own GITHUB_TOKEN, but permissions.contents is still read for both jobs (Lines 217, 310). git push in the agent's workflow (Line 380 for Process 6; commit/push in Process 3's prompt) will fail with a 403. Process 3 additionally disables persist-credentials (Line 223) while Process 6's checkout (Lines 313-317) omits it entirely (also flagged by zizmor as artipacked) — align both to contents: write and restore/keep checkout credentials consistent with which auth path the action actually uses.

🔒 Proposed fix
   process-3:
     permissions:
       id-token: write
-      contents: read
+      contents: write
       pull-requests: write
@@
   process-6:
     permissions:
       id-token: write
-      contents: read
+      contents: write
       pull-requests: write

Also applies to: 304-317

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-pr-comment.yml around lines 215 - 224, Update the
Process 3 and Process 6 job permission blocks to grant contents: write because
both use use_github_token: true and must push commits. Align their
actions/checkout configurations so credential persistence matches that
token-based authentication path, removing the inconsistent persist-credentials:
false in Process 3 and explicitly setting the same behavior for Process 6.
.github/workflows/opencode-issue-handler.yml (2)

118-124: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Manual gh issue comment steps duplicate the action's own auto-posted response.

The pinned anomalyco/opencode/github action already posts the model's final reply as an issue comment; instructing the agent to additionally run gh issue comment ... --body-file /tmp/response.md (Lines 121-124) and gh issue comment "$ISSUE_NUMBER" --body "..." (Lines 313-315) causes duplicate comments on the issue timeline. This was raised on a prior commit and marked addressed, but the pattern is present again in this synced version.

Also applies to: 310-315

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-issue-handler.yml around lines 118 - 124, Remove
the manual gh issue comment commands from the workflow instructions, including
the command in the “Post your response” section and the corresponding command
near the later response-posting steps. Rely on the pinned
anomalyco/opencode/github action to publish the model’s final reply once, while
preserving the surrounding response-generation guidance.

172-204: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

id-token: write is unused, and the checkout step lacks persist-credentials: false (zizmor: artipacked).

Process 5 sets use_github_token: true (Line 204), so it only relies on GITHUB_TOKEN; id-token: write (Line 178) grants unused OIDC privilege. Separately, the checkout at Lines 183-185 omits persist-credentials: false, unlike the other checkout steps in this file — though note that with use_github_token: true, the checked-out credential may be the mechanism the agent's later git push relies on, so verify before blindly disabling persistence.

🔒 Proposed fix (id-token only; verify push behavior before removing persisted credentials)
     permissions:
-      id-token: write
       contents: write
       pull-requests: write
       issues: write
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-issue-handler.yml around lines 172 - 204, Remove
the unused id-token write permission from the process-5 job permissions. Review
the Checkout repository step and determine whether the later git push depends on
persisted checkout credentials when use_github_token is enabled; disable
credential persistence if push remains functional through the configured GitHub
token, otherwise preserve it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/opencode-issue-handler.yml:
- Around line 64-84: Update the opencode step identified by id "opencode" to set
use_github_token to true in its with configuration, ensuring it uses the
job-scoped GITHUB_TOKEN. Remove the unnecessary id-token: write permission from
the workflow permissions while preserving the existing contents: read and
issues: write permissions.

In @.github/workflows/opencode-triage.yaml:
- Around line 19-22: Update the “Deprecation notice” step in the workflow to
also direct pull-request users to opencode-pr-comment.yml, while retaining the
existing opencode-issue-handler.yml guidance for issue events.

---

Duplicate comments:
In @.github/workflows/opencode-issue-handler.yml:
- Around line 118-124: Remove the manual gh issue comment commands from the
workflow instructions, including the command in the “Post your response” section
and the corresponding command near the later response-posting steps. Rely on the
pinned anomalyco/opencode/github action to publish the model’s final reply once,
while preserving the surrounding response-generation guidance.
- Around line 172-204: Remove the unused id-token write permission from the
process-5 job permissions. Review the Checkout repository step and determine
whether the later git push depends on persisted checkout credentials when
use_github_token is enabled; disable credential persistence if push remains
functional through the configured GitHub token, otherwise preserve it.

In @.github/workflows/opencode-pr-comment.yml:
- Around line 81-96: Update the process-2 job to add a repository checkout step
before the opencode execution step, matching the checkout behavior used by
process-3 and process-6. Ensure the checkout runs before any steps that require
a local git worktree.
- Around line 175-181: Remove the manual gh api reply instructions from the ##
Output sections of both Process 2 and Process 3 prompts. Have each prompt
instruct the model to return the Markdown response directly, without posting it,
while leaving the action responsible for submitting the reply.
- Around line 98-110: Remove direct github.event.comment.* expressions from the
run shell commands in the pull_request_review_comment branch. Pass
pull_request_review_url and in_reply_to_id through the step’s env mapping, then
reference those environment variables in the gh api URL and conditional checks
while preserving the existing parent-author fallback behavior.
- Around line 85-88: Add issues: write to the permissions blocks for Process 2
and Process 6 in the workflow, preserving the existing id-token, contents, and
pull-requests permissions. Ensure the reaction steps in those jobs can access
the issue-comment reactions endpoint without changing their fallback behavior.
- Around line 66-77: Exclude the review subcommand from the issue_comment
routing in the workflow’s conditional block so `/oc review` is not assigned to
Process 2 by this workflow. Preserve the existing routing for `/oc task`, bare
`/oc`, and non-/oc comments, while leaving review handling to the dedicated
PR-review workflow.
- Around line 352-397: The workflow instructions for the task process use the
unavailable pull_request event context. Replace github.event.pull_request.number
with github.event.issue.number in the checkout, PR body update, and summary
comment commands, and in the surrounding context text, while preserving the
existing task workflow.
- Around line 116-127: Update the issue_comment branch’s LAST_COMMENT_AUTHOR
lookup to retrieve the complete or appropriately paginated comment history
before selecting the comment immediately preceding the trigger. Preserve the
existing author checks for opencode-agent[bot] and github-actions[bot], ensuring
IS_BOT_THREAD reflects the actual preceding comment even when the thread exceeds
the default API page size.
- Around line 215-224: Update the Process 3 and Process 6 job permission blocks
to grant contents: write because both use use_github_token: true and must push
commits. Align their actions/checkout configurations so credential persistence
matches that token-based authentication path, removing the inconsistent
persist-credentials: false in Process 3 and explicitly setting the same behavior
for Process 6.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8105ab74-c785-4d40-9744-d8b13deabca9

📥 Commits

Reviewing files that changed from the base of the PR and between 7effd20 and 8d38dab.

📒 Files selected for processing (10)
  • .github/scripts/auth.sh
  • .github/workflows/opencode-implement.yaml
  • .github/workflows/opencode-issue-handler.yml
  • .github/workflows/opencode-pr-comment.yml
  • .github/workflows/opencode-pr-review.yml
  • .github/workflows/opencode-review.yaml
  • .github/workflows/opencode-triage-issue.yaml
  • .github/workflows/opencode-triage-pr.yaml
  • .github/workflows/opencode-triage.yaml
  • .github/workflows/opencode.yml
🚧 Files skipped from review as they are similar to previous changes (5)
  • .github/workflows/opencode-triage-pr.yaml
  • .github/workflows/opencode-triage-issue.yaml
  • .github/workflows/opencode-implement.yaml
  • .github/workflows/opencode-pr-review.yml
  • .github/scripts/auth.sh

Comment on lines +64 to +84
permissions:
id-token: write
contents: read
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false

- name: Run opencode (Process 4 — Issue Review & Refinement)
id: opencode
continue-on-error: true
uses: anomalyco/opencode/github@77fc88c8ade8e5a620ebbe1197f3a572d29ae91a # latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
OPENCODE_TRIGGER_BODY: ${{ github.event.comment.body }}
with:
model: opencode/qwen3.7-plus
prompt: |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

use_github_token still defaults to false; Process 4's "read-only" boundary isn't enforced by the job token.

Permissions still grant id-token: write (Line 65) and the with: block for the opencode step has no use_github_token: true, so the action authenticates via its own OIDC-issued App token rather than this job's scoped GITHUB_TOKEN. The prompt's "read-only" instructions are then only a soft constraint — the actual credential used may have broader repo write access than the job declares.

🔒 Proposed fix
     permissions:
-      id-token: write
       contents: read
       issues: write
     steps:
@@
         with:
           model: opencode/qwen3.7-plus
+          use_github_token: true
           prompt: |

This mirrors a still-open comment from a prior review round on this exact block.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-issue-handler.yml around lines 64 - 84, Update
the opencode step identified by id "opencode" to set use_github_token to true in
its with configuration, ensuring it uses the job-scoped GITHUB_TOKEN. Remove the
unnecessary id-token: write permission from the workflow permissions while
preserving the existing contents: read and issues: write permissions.

Comment on lines +19 to +22
- name: Deprecation notice
run: |
echo "This workflow is deprecated and performs no operations."
echo "Use opencode-issue-handler.yml instead."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Point PR users to the PR replacement too.

opencode-issue-handler.yml explicitly excludes pull requests, while the retired workflow also handled PR comment/review events. Include opencode-pr-comment.yml in this notice so the migration path is not misleading.

Proposed fix
-          echo "Use opencode-issue-handler.yml instead."
+          echo "Use opencode-issue-handler.yml for issues or opencode-pr-comment.yml for pull requests instead."
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Deprecation notice
run: |
echo "This workflow is deprecated and performs no operations."
echo "Use opencode-issue-handler.yml instead."
- name: Deprecation notice
run: |
echo "This workflow is deprecated and performs no operations."
echo "Use opencode-issue-handler.yml for issues or opencode-pr-comment.yml for pull requests instead."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/opencode-triage.yaml around lines 19 - 22, Update the
“Deprecation notice” step in the workflow to also direct pull-request users to
opencode-pr-comment.yml, while retaining the existing opencode-issue-handler.yml
guidance for issue events.

@dianlight
dianlight force-pushed the repo-sync/opencode-actions/default branch 7 times, most recently from 968f90f to bcda533 Compare July 29, 2026 07:20
@dianlight
dianlight force-pushed the repo-sync/opencode-actions/default branch 3 times, most recently from f2743d7 to f881054 Compare August 4, 2026 21:51
@dianlight
dianlight force-pushed the repo-sync/opencode-actions/default branch from f881054 to dacf6de Compare August 6, 2026 08:20
@dianlight dianlight closed this Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant