Skip to content

Add PR comment, reaction and user permission commands - #16

Merged
Andrey Hura (andrey-hura) merged 2 commits into
mainfrom
andrey-hura/add-pr-comment-commands
Nov 2, 2026
Merged

Andrey Hura (andrey-hura) merged 2 commits into
mainfrom
andrey-hura/add-pr-comment-commands

Conversation

@andrey-hura

@andrey-hura Andrey Hura (andrey-hura) commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds three commands that let a pipeline started from a pull request comment respond on that pull request:

Command Inputs Outputs
upsertPrComment PR_NUMBER, COMMENT_BODY or COMMENT_BODY_FILE, optional COMMENT_MARKER COMMENT_ID, COMMENT_URL, COMMENT_ACTION
addReaction COMMENT_ID, REACTION —
getUserPermission USERNAME PERMISSION, HAS_WRITE_ACCESS
  • upsertPrComment: without COMMENT_MARKER, it adds a new comment. With a marker, it appends a hidden <!-- harness-github-api-plugin:<marker> --> tag and on later runs edits the most recent comment carrying it. That keeps one up-to-date status comment per pull request. Only comments written by the token owner are matched. COMMENT_BODY_FILE takes the body from a file in the workspace, for long or multiline content.
  • addReaction: reacts to an issue or pull request comment, for example to acknowledge the comment that started a pipeline. The reaction is checked against the values GitHub accepts.
  • getUserPermission: returns admin, write, read or none, plus HAS_WRITE_ACCESS, so a pipeline can check who is allowed to start it. A user GitHub doesn't know is reported as none instead of failing the step.

The README now documents every command with its outputs, including the previously undocumented AddPullRequestLabels, waitForStatus and getRef. It also adds an example Harness step and a note on the fixed order commands run in.

Existing commands are unchanged.

Testing

  • gofmt -l . is clean and go vet ./... passes with Go 1.22.5.
  • docker build . succeeds, and the image starts as before.

🤖 Generated with Claude Code

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 93e5866. Configure here.

Comment thread comments.go
func resolveCommentBody(body string, bodyFile string) string {
if bodyFile == "" {
return body
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Null optional settings are not ignored

Medium Severity

When COMMENT_BODY_FILE or COMMENT_MARKER is omitted, Harness can still pass the literal string null, which this plugin already treats as unset for PR_LABELS. resolveCommentBody then tries to open a file named null and fails the step, and a null marker is treated as a real upsert key instead of always creating a comment.

suggestion
if bodyFile == "" || bodyFile == "null" {
return body
}

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 93e5866. Configure here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in the latest commit: a new optionalEnv helper treats null as unset for COMMENT_BODY, COMMENT_BODY_FILE and COMMENT_MARKER. Covering COMMENT_BODY too means a null body now fails with the "needs COMMENT_BODY or COMMENT_BODY_FILE" error instead of posting null as a comment.

Add three commands so a pipeline triggered by a pull request comment can
talk back to the PR:

- upsertPrComment: create a PR comment, or with COMMENT_MARKER update the
  latest comment the token owner posted with the same hidden marker.
  The body can come from COMMENT_BODY or COMMENT_BODY_FILE.
- addReaction: add an emoji reaction to a PR/issue comment.
- getUserPermission: report a user's repository permission and whether
  it includes write access (unknown users are reported as none).

Document every command in the README, including the previously
undocumented AddPullRequestLabels, waitForStatus and getRef.
@andrey-hura
Andrey Hura (andrey-hura) force-pushed the andrey-hura/add-pr-comment-commands branch from f099e8c to 6325220 Compare November 2, 2026 15:15
@andrey-hura
Andrey Hura (andrey-hura) deleted the andrey-hura/add-pr-comment-commands branch November 2, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant