Commit Graph
10 Commits
Author SHA1 Message Date
Rishav NaskarandGitHub b49813d0e7 feat(context): include diffHunk in PR review comment context (#1584)
* feat(context): include diffHunk in PR review comment context

Review comments arrived with only path and line, so the code they were
written against was missing from the prompt. Fetch diffHunk in the PR
GraphQL query and render it under the comment as a diff block.

The hunk is PR-authored content, so it goes through sanitizeContent like
the comment body. Comments without a hunk are unchanged.

Fixes #855

* test(formatter): cover outdated review comments with an empty diff hunk

GitHub returns diffHunk: "" (not null) for comments whose line no longer
exists in the diff, so the render guard has to reject empty strings too.
Found running the real query against anthropics/claude-code-action#1025.
2026-08-14 16:32:44 -07:00
leepokaiandGitHub 0a5f191964 fix: handle null files field from GraphQL on very large PRs (#1593)
GitHub's GraphQL API returns files: null (with no errors entry, and
changedFiles misreported as 0) when a PR's diff is too large to compute.
The unguarded pullRequest.files.nodes dereference in the fetcher crashed
the action with 'TypeError: null is not an object', and the formatter had
the same latent crash on prData.files.nodes.length.

Widen the GitHubPullRequest type to files | null so the compiler enforces
guards, degrade gracefully in the fetcher with a warning, and render the
file count as unavailable (not '0 files') in the formatter.

Fixes #1587
2026-08-07 07:55:10 -07:00
PaarthandGitHub 3e807ec379 fix: handle null comment/review author from deleted accounts (#1490)
GitHub's GraphQL author field is null when the account behind a
comment, review, PR, or issue has been deleted (the ghost user). The
action typed author as non-null and read author.login directly, so a
single comment from a deleted account threw and was swallowed into a
generic 'Failed to fetch PR/issue data', failing the entire run.

Make author nullable on the four affected types and fall back to
'ghost' at each login read. With the type nullable, tsc flags every
dereference, so all sites are covered.
2026-07-15 21:00:22 -07:00
24b915648e Include labels in formatContext() output for issues and PRs (#1298)
The formatted_context block sent to the agent omitted labels for both
issues and pull requests, even though the GraphQL queries already
fetched them. This caused agents to incorrectly report "no labels"
when labels existed, breaking any workflow that routes on label state
(e.g., drift-fix routing on drift:* labels in a Drift Watcher pattern).

Changes:
- Add 'PR Labels:' line to PR context output
- Add 'Issue Labels:' line to issue context output
- Both emit 'none' when no labels are present (explicit > omitted)
- Bump labels(first: 1) → labels(first: 100) in both queries; the
  previous cap meant only one label would appear even after the
  formatter fix
- Update existing tests + add 'with labels' tests for both PR and
  issue branches

Discovered while building a GitHub Actions workflow that uses this
action for drift-watcher routing in an internal seed framework
(joshpayne-joby/slim-routines#6). The agent self-diagnosed the gap
by inspecting this action's source — a satisfying full-loop.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-11 21:19:15 -07:00
c3bf66dbc2 fix: handle fork PRs by fetching via refs/pull/N/head (#962) (#963)
When a PR originates from a fork, `git fetch origin <branch>` fails
because the branch only exists on the fork's remote.

Fix: detect cross-repository PRs via the `isCrossRepository` GraphQL
field and fetch using `pull/<number>/head:<branch>` refspec instead,
which is the standard GitHub mechanism for accessing fork PR branches.

Changes:
- Add `isCrossRepository` and `headRepository` to PR GraphQL query
- Add corresponding fields to GitHubPullRequest type
- Branch checkout uses pull ref for fork PRs
- Update test fixtures with new fields

Co-authored-by: User <user@example.com>
2026-04-14 20:33:04 -07:00
Cole DandGitHub c247cb152d feat: custom branch name templates (#571)
* Add branch-name-template config option

* Logging

* Use branch name template

* Add label to template variables

* Add description template variable

* More concise description for branch_name_template

* Remove more granular time template variables

* Only fetch first label

* Add check for empty template-generated name

* Clean up comments, docstrings

* Merge createBranchTemplateVariables into generateBranchName

* Still replace undefined values

* Fall back to default on duplicate branch

* Parameterize description wordcount

* Remove some over-explanatory comments

* NUM_DESCRIPTION_WORDS: 3 -> 5
2026-01-08 06:47:26 +05:30
atsushi-ishibashiandGitHub fd012347a2 feat: exclude hidden (minimized) comments from GitHub Issues and PRs (#368)
* feat: ignore minimized comments

* fix tests
2025-07-30 07:18:34 -07:00
Lina TawfikandGitHub 35ad5fc467 Add enhanced text sanitization (#83)
* Add enhanced text sanitization

* Format code with prettier

* Refactor tests to remove redundancy and improve structure

- Remove redundant 'mixed input patterns' test from sanitizer.test.ts
- Consolidate integration tests into 2 focused real-world scenarios
- Add HTML comment stripping to sanitizeContent function
- Update test expectations to match sanitization behavior
- Maintain full coverage with fewer, more focused tests

* Fix prettier formatting

* Remove rendered.html from repository

* Remove test-markdown.json and update .gitignore

* Revert .gitignore changes
2025-05-29 16:35:50 -07:00
Lina Tawfik dd5e8c974a feat: strip HTML comments from GitHub content
- Add stripHtmlComments function to remove HTML comments from text
- Apply to all GitHub content (bodies, comments, reviews, triggers)
- Add comprehensive tests for comment stripping functionality
2025-05-21 13:23:32 -07:00
Lina Tawfik f66f337f4e Initial commit 2025-05-19 08:32:32 -07:00