Skip to content

ci: resolve issue creation, tighten functional /oc body gate, and add concurrency for OC agent#256

Merged
RussellSB merged 2 commits into
mainfrom
ci/oc-agent-gh-auth-and-conventions
Jul 21, 2026
Merged

ci: resolve issue creation, tighten functional /oc body gate, and add concurrency for OC agent#256
RussellSB merged 2 commits into
mainfrom
ci/oc-agent-gh-auth-and-conventions

Conversation

@RussellSB

@RussellSB RussellSB commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Changes

opencode.yml

GH_TOKEN for gh CLI auth (#251): Added GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} to the opencode workflow env. The action uses Octokit for its own GitHub operations, but when the agent shells out to gh CLI via the bash tool, it needs GH_TOKEN in the environment. The workflow's permissions: block already grants issues: write.

Remove unsupported pull_request_review trigger (#252): The opencode action runtime (github.handler.ts:148) only supports issue_comment, pull_request_review_comment, issues, pull_request, schedule, workflow_dispatch. /oc in a review body (pull_request_review) throws Unsupported event type. Removed the trigger and added a comment block documenting the supported events. Conversation comments and line comments still work.

Restore /oc body gate: The if condition now checks github.event.comment.body for /oc or /opencode, so ordinary discussion comments don't reach the agent.

Concurrency group: Added concurrency keyed by issue/PR number with cancel-in-progress: false to serialise agent runs per discussion and avoid race conditions on rapid comments.

AGENTS.md

Conventional Commits enforcement (#253): Expanded the Critical rules section with explicit commit conventions so the agent applies them without needing to load the maintenance skill first. Narrowed the lint-pr-title.yml claim to what it actually enforces: the type: description prefix and allowed types on PR titles.

Supported events

Event Trigger Notes
issue_comment /oc or /opencode in PR/issue conversation Works
pull_request_review_comment /oc or /opencode on a code line (Files tab) Works
pull_request_review /oc or /opencode in review body (Submit review) Not supportedupstream issue

Closes #251
Closes #252
Closes #253

- Add GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} to opencode workflow env so
  agent can use gh CLI (e.g. gh issue create) with proper auth (#251)
- Remove pull_request_review trigger: /oc in review bodies is not supported
  by the opencode action; conversation and line comments still work (#252)
- Expand AGENTS.md commit conventions with explicit Conventional Commits
  rules so agent applies them without loading the maintenance skill (#253)

Closes #251
Closes #253
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@RussellSB

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot added automated documentation Improvements or additions to documentation labels Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The OpenCode workflow now handles created issue and review comments, uses author-association checks, and provides GH_TOKEN. AGENTS.md documents required Conventional Commit prefixes and formatting rules.

Changes

OpenCode maintenance

Layer / File(s) Summary
Workflow triggers and authentication
.github/workflows/opencode.yml
The workflow limits triggers to created issue and review comments, simplifies job eligibility checks, and adds GH_TOKEN from secrets.GITHUB_TOKEN.
Conventional Commit guidance
AGENTS.md
Commit and generated-summary rules now specify allowed prefixes, lowercase imperative wording, a 72-character limit, and no trailing full stop.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: documentation, automated

Poem

Comments arrive, the workflow wakes,
A token unlocks the GitHub gates.
Commits march in a proper line,
Lowercase, crisp, and well-defined.
OpenCode keeps its house in rhyme.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR satisfies #251, #252, and #253 by adding GH_TOKEN, enabling review-comment triggers, and documenting Conventional Commits.
Out of Scope Changes check ✅ Passed The changes stay within the stated OC workflow and agent-instruction scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title uses Conventional Commits and matches the workflow and AGENTS changes described in the patch.
Description check ✅ Passed The description directly covers the GH token, trigger gating, concurrency, and commit-rule updates in this changeset.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch ci/oc-agent-gh-auth-and-conventions

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.

@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: 4

🤖 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.yml:
- Around line 3-18: Add the documented issues, pull_request, schedule, and
workflow_dispatch event declarations to the workflow’s on block alongside
issue_comment and pull_request_review_comment, preserving the required event
types and schedule/manual configuration expected by the existing workflow.
- Around line 20-24: Add a concurrency configuration to the opencode job, using
a group key based on the current issue or pull-request number so runs for the
same discussion are serialized. Set an explicit cancellation policy that
preserves an active run rather than canceling it when a newer comment triggers
another run.
- Around line 22-24: Update the workflow job’s if condition to require the
comment body to contain the supported /oc or /opencode command, in addition to
the existing OWNER or COLLABORATOR author association checks. Ensure ordinary
comments cannot reach anomalyco/opencode/github@latest.

In `@AGENTS.md`:
- Around line 18-21: Update the commit-message guidance in AGENTS.md to match
what lint-pr-title.yml actually validates: narrow the documented scope to PR
titles and remove claims about lowercase wording, imperative mood, length,
trailing periods, and all generated commits unless corresponding enforcement is
added.
🪄 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: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ae06abd1-e2bb-44ed-ab0a-17660caf4999

📥 Commits

Reviewing files that changed from the base of the PR and between 03cd5eb and 53963af.

📒 Files selected for processing (2)
  • .github/workflows/opencode.yml
  • AGENTS.md
📜 Review details
⚠️ CI failures not shown inline (2)

GitHub Actions: Check Base Branch / 0_Validate Base Branch.txt: ci: add GH_TOKEN and enforce commit conventions for OC agent

Conclusion: failure

View job details

##[group]Run BASE="main"
 �[36;1mBASE="main"�[0m
 �[36;1mHEAD="ci/oc-agent-gh-auth-and-conventions"�[0m
 �[36;1m�[0m
 �[36;1m# Allow temp-to-temp branch flows (neither base nor head are main/develop)�[0m
 �[36;1mif [ "$BASE" != "main" ] && [ "$BASE" != "develop" ] && [ "$HEAD" != "main" ] && [ "$HEAD" != "develop" ]; then�[0m
 �[36;1m  echo "Base branch check passed: allowing temporary branch flow from '$HEAD' to '$BASE'."�[0m
 �[36;1m  exit 0�[0m
 �[36;1mfi�[0m
 �[36;1m�[0m
 �[36;1mif [ "$BASE" = "develop" ]; then�[0m
 �[36;1m  echo "Base branch check passed: targeting 'develop'."�[0m
 �[36;1m  exit 0�[0m
 �[36;1mfi�[0m
 �[36;1m�[0m
 �[36;1mif [ "$BASE" = "main" ] && [ "$HEAD" = "develop" ]; then�[0m
 �[36;1m  echo "Base branch check passed: allowing release PR from 'develop' to 'main'."�[0m
 �[36;1m  exit 0�[0m
 �[36;1mfi�[0m
 �[36;1m�[0m
 �[36;1mif [ "$BASE" = "main" ] && [[ "$HEAD" == docs/whats-new-* ]]; then�[0m
 �[36;1m  echo "Base branch check passed: allowing automated What's New PR from '$HEAD' to 'main'."�[0m
 �[36;1m  exit 0�[0m
 �[36;1mfi�[0m
 �[36;1m�[0m
 �[36;1mif [ "$BASE" = "main" ]; then�[0m
 �[36;1m  echo "Error: Pull requests targeting 'main' must come from the 'develop' branch, not '$HEAD'."�[0m
 �[36;1m  exit 1�[0m
 �[36;1mfi�[0m
 �[36;1m�[0m
 �[36;1mecho "Error: Pull requests must target 'develop' (or target 'main' only from 'develop'), not '$BASE'."�[0m
 �[36;1mexit 1�[0m
 shell: /usr/bin/bash -e {0}
 ##[endgroup]
 Error: Pull requests targeting 'main' must come from the 'develop' branch, not 'ci/oc-agent-gh-auth-and-conventions'.
 ##[error]Process completed with exit code 1.

GitHub Actions: Check Base Branch / Validate Base Branch: ci: add GH_TOKEN and enforce commit conventions for OC agent

Conclusion: failure

View job details

##[group]Run BASE="main"
 �[36;1mBASE="main"�[0m
 �[36;1mHEAD="ci/oc-agent-gh-auth-and-conventions"�[0m
 �[36;1m�[0m
 �[36;1m# Allow temp-to-temp branch flows (neither base nor head are main/develop)�[0m
 �[36;1mif [ "$BASE" != "main" ] && [ "$BASE" != "develop" ] && [ "$HEAD" != "main" ] && [ "$HEAD" != "develop" ]; then�[0m
 �[36;1m  echo "Base branch check passed: allowing temporary branch flow from '$HEAD' to '$BASE'."�[0m
 �[36;1m  exit 0�[0m
 �[36;1mfi�[0m
 �[36;1m�[0m
 �[36;1mif [ "$BASE" = "develop" ]; then�[0m
 �[36;1m  echo "Base branch check passed: targeting 'develop'."�[0m
 �[36;1m  exit 0�[0m
 �[36;1mfi�[0m
 �[36;1m�[0m
 �[36;1mif [ "$BASE" = "main" ] && [ "$HEAD" = "develop" ]; then�[0m
 �[36;1m  echo "Base branch check passed: allowing release PR from 'develop' to 'main'."�[0m
 �[36;1m  exit 0�[0m
 �[36;1mfi�[0m
 �[36;1m�[0m
 �[36;1mif [ "$BASE" = "main" ] && [[ "$HEAD" == docs/whats-new-* ]]; then�[0m
 �[36;1m  echo "Base branch check passed: allowing automated What's New PR from '$HEAD' to 'main'."�[0m
 �[36;1m  exit 0�[0m
 �[36;1mfi�[0m
 �[36;1m�[0m
 �[36;1mif [ "$BASE" = "main" ]; then�[0m
 �[36;1m  echo "Error: Pull requests targeting 'main' must come from the 'develop' branch, not '$HEAD'."�[0m
 �[36;1m  exit 1�[0m
 �[36;1mfi�[0m
 �[36;1m�[0m
 �[36;1mecho "Error: Pull requests must target 'develop' (or target 'main' only from 'develop'), not '$BASE'."�[0m
 �[36;1mexit 1�[0m
 shell: /usr/bin/bash -e {0}
 ##[endgroup]
 Error: Pull requests targeting 'main' must come from the 'develop' branch, not 'ci/oc-agent-gh-auth-and-conventions'.
 ##[error]Process completed with exit code 1.
🧰 Additional context used
📓 Path-based instructions (2)
**/*

📄 CodeRabbit inference engine (AGENTS.md)

**/*: Before making code changes, commits, or pull requests, load the maintenance and pytrendy skills; load test, cicd, debug, or pr-plots only when relevant.
Pull requests must target the develop branch, not main.
Use Conventional Commits with lowercase, imperative, under-72-character messages and no trailing period, using permitted prefixes such as fix:, feat:, chore:, ci:, docs:, refactor:, perf:, test:, build:, or revert:.
Deprecating a public parameter must use a feat: commit because it is a minor API change, not refactor:.

Files:

  • AGENTS.md
**/AGENTS.md

⚙️ CodeRabbit configuration file

General overview about pytrendy

Files:

  • AGENTS.md
🪛 zizmor (1.26.1)
.github/workflows/opencode.yml

[info] 21-21: workflow or action definition without a name (anonymous-definition): this job

(anonymous-definition)


[warning] 14-18: insufficient job-level concurrency limits (concurrency-limits): workflow is missing concurrency setting

(concurrency-limits)

🔇 Additional comments (1)
.github/workflows/opencode.yml (1)

82-82: LGTM!

Comment thread .github/workflows/opencode.yml
Comment thread .github/workflows/opencode.yml Outdated
Comment thread .github/workflows/opencode.yml Outdated
Comment thread AGENTS.md Outdated
@RussellSB RussellSB changed the title ci: add GH_TOKEN and enforce commit conventions for OC agent ci: add GH_TOKEN, restore /oc body gate, add concurrency for OC agent Jul 21, 2026

@RussellSB RussellSB left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Addressed all 4 CodeRabbit findings: (1) issues/pull_request/schedule/workflow_dispatch are action-level supported events, not triggers for this /oc user-interaction workflow — documented in comment block; (2) added concurrency group serialised per issue/PR; (3) restored /oc + /opencode body gate in if condition; (4) narrowed lint-pr-title.yml claim to PR title prefix + allowed types only.

Comment thread .github/workflows/opencode.yml
Comment thread .github/workflows/opencode.yml
Comment thread .github/workflows/opencode.yml
Comment thread AGENTS.md
@opencode-agent

Copy link
Copy Markdown
Contributor

All 4 CodeRabbit findings are addressed in the current code. Let me verify each:

Finding 1 — "Restore documented workflow triggers" (line 18):
Wrong. The comment block (lines 3-13) documents events the opencode action runtime supports, not triggers for this workflow. issues, pull_request, schedule, workflow_dispatch require a prompt input and are for separate auto-triggered workflows. Adding them here would fire the agent on every issue/PR open without /oc — not the intent. ✅ Correct as-is.

Finding 2 — Concurrency group:
Already present at lines 22-24: group: opencode-${{ github.event.issue.number || ... }}, cancel-in-progress: false. ✅ Resolved.

Finding 3 — Body gate:
Already present at lines 25-32: if checks contains(github.event.comment.body, '/oc') || contains(...). ✅ Resolved.

Finding 4 — AGENTS.md alignment with lint-pr-title.yml:
Line 21 now correctly reads lint-pr-title.yml enforces the type: description prefix and allowed types on PR titles — accurate. Lines 18-20 are aspirational guidance for the agent's own commit messages, not CI-enforced. ✅ Resolved.

The PR looks clean. One issue: check-base-branch.yml is failing because this targets main instead of develop.

New%20session%20-%202026-07-21T07%3A19%3A50.609Z
opencode session  |  github run

@RussellSB RussellSB changed the title ci: add GH_TOKEN, restore /oc body gate, add concurrency for OC agent ci: resolve issue creation, tighten functional /oc body gate, and add concurrency for OC agent Jul 21, 2026
Repository owner deleted a comment from opencode-agent Bot Jul 21, 2026
@RussellSB
RussellSB force-pushed the ci/oc-agent-gh-auth-and-conventions branch from 5979673 to 410c27f Compare July 21, 2026 07:24
@RussellSB
RussellSB merged commit f608849 into main Jul 21, 2026
5 of 6 checks passed
@RussellSB
RussellSB deleted the ci/oc-agent-gh-auth-and-conventions branch July 21, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated documentation Improvements or additions to documentation

Projects

None yet

1 participant