Commit Graph
543 Commits
Author SHA1 Message Date
Vlad MocanuandClaude Opus 4.6 d9c22ffe50 docs(prd-6): mark M2 complete — PR review comment trigger validated
E2E test confirmed: Claude correctly responds to @claude mentions in
PR review comments on Forgejo (run #12075, PR #15). Three bugs were
found and fixed during validation:
1. Missing comment object in Forgejo webhook payload
2. Event name mismatch (pull_request_comment vs pull_request_review_comment)
3. MCP server routing updates to wrong API (critical — silently dropped responses)

Progress: 3/8 milestones complete (37.5%)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:45:09 +02:00
Vlad MocanuandClaude Opus 4.6 84cf34ff1f fix: route Forgejo review comment updates to issue comment API
On Forgejo, the tracking comment for pull_request_review_comment events
is always created as a regular issue comment (because Forgejo's webhook
payload lacks the top-level comment object). The MCP server was
incorrectly setting isPullRequestReviewComment=true based on the event
name, causing every update to try pulls.updateReviewComment first —
which 404'd and silently swallowed Claude's responses.

Three fixes:
- MCP server: detect Forgejo and always use issue comment path
- update-comment-link: skip pulls.getReviewComment on Forgejo (saves
  one wasted 404 API call)
- update-claude-comment: expand fallback to also catch 422 (defense
  in depth for Forgejo edge cases)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:45:09 +02:00
Vlad MocanuandClaude Opus 4.6 821cc86c6e docs(prd-6): mark M1.5 resolved — CI confirmed green
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:45:09 +02:00
Vlad MocanuandClaude Opus 4.6 2f44e40942 fix: remove all image-downloader mocking from forgejo-data-fetcher test
Both mock.module and spyOn cause cross-file test pollution in Bun's
single-process runner — mock.module poisons the module registry permanently,
and spyOn doesn't correctly restore ESM live bindings across files on Linux.

The real downloadCommentImages is safe to call because test comment bodies
contain no GitHub image URLs, so the function finds zero images and returns
an empty Map naturally. The only side effect is mkdir("/tmp/github-images")
which is harmless on CI runners.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:45:09 +02:00
Vlad MocanuandClaude Opus 4.6 ede18897b0 docs(prd-6): mark M1.5 resolved, document root cause and fix
Root cause was mock.module cross-file pollution in Bun's test runner,
not Linux-specific mock tracking bugs as previously theorized.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:45:09 +02:00
Vlad MocanuandClaude Opus 4.6 ac9e9cddff fix: replace mock.module with spyOn to stop cross-file test pollution
mock.module("image-downloader") in forgejo-data-fetcher.test.ts replaced
the module in Bun's registry globally for the entire process. When Bun's
non-deterministic file ordering ran this file BEFORE image-downloader.test.ts,
the image-downloader tests imported a stubbed module instead of the real one,
breaking all 18 tests. This was the root cause of the CI failures that
persisted through 5 previous fix attempts.

spyOn patches the live module export per-test and is auto-restored by Bun
after each test — no cross-file pollution regardless of execution order.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:45:09 +02:00
Vlad MocanuandClaude Opus 4.6 a544d710e5 test: remove diagnostic file that broke typecheck
The DI fix for image-downloader tests passed on CI (all 18 tests
green). Removing the temporary mock tracking diagnostic file whose
type errors caused the typecheck job to fail.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:45:09 +02:00
Vlad MocanuandClaude Opus 4.6 7011b0f71a test: add mock tracking diagnostics for Forgejo CI debugging
DI fix passes locally in grunt-runner Docker but still fails on
actual Forgejo runner. Adding diagnostic tests to isolate whether
mock() tracking itself is broken, or something else in the runner
environment causes it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:45:09 +02:00
Vlad MocanuandClaude Opus 4.6 a6b3c94004 fix: use dependency injection for image-downloader fs mocks
mock.module("fs/promises") on Linux Bun poisons the entire mock
tracking system — not just fs mocks, but ALL mock/spy assertions
(octokit mocks, spyOn(global, "fetch"), etc.) stop recording calls.

Replace with dependency injection: downloadCommentImages() now accepts
an optional fsDeps parameter. Tests pass mock mkdir/writeFile directly.
Production callers omit it and get real fs. No mock.module anywhere.

Fixes 18 test failures blocking CI on Forgejo Linux runners.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:45:08 +02:00
Vlad Mocanu 6113a4ef2d test: add M2 E2E test marker for PR review comment trigger 2026-02-26 10:45:08 +02:00
Vlad MocanuandClaude Opus 4.6 3cd73bccde revert: remove label check from opened events to prevent duplicates
Forgejo fires both issues/opened AND issues/label_updated when an
issue is created with a label. Having the label check on opened
caused duplicate Claude runs. Remove it — the label_updated event
handles label triggers correctly now that the workflow gate and
action normalization are fixed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:30:47 +02:00
Vlad MocanuandClaude Opus 4.6 1feec26c2e feat: check trigger label on issue opened events
When an issue is created with the trigger label already applied,
Forgejo only fires issues/opened (not a separate labeled event).
Check payload.issue.labels for the trigger label during opened
events so creating an issue with the claude label works in one step.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:29:05 +02:00
Vlad MocanuandClaude Opus 4.6 b37009b766 cleanup: remove M4 debug logging from run.ts
Debug logging confirmed Forgejo sends 'label_updated' as eventAction
for issues/labeled events. Normalization fix in context.ts handles it.
Remove temporary debug lines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:27:59 +02:00
Vlad MocanuandClaude Opus 4.6 baa007a3ec fix: normalize Forgejo 'label_updated' to 'labeled' in context
Forgejo sends eventAction 'label_updated' instead of 'labeled' for
issue label events. Add FORGEJO_EVENT_ACTION_MAP in context.ts to
normalize at parse time (same pattern as event name normalization),
so all downstream code (trigger.ts, create-prompt) works unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:25:58 +02:00
Vlad MocanuandClaude Opus 4.6 fa0070ddcc fix: accept Forgejo 'label_updated' action for label triggers
Forgejo sends eventAction 'label_updated' instead of 'labeled'
for issue label events (discovered via debug logging, run 52786).
Accept both values in trigger.ts label check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:24:01 +02:00
Vlad MocanuandClaude Opus 4.6 b020426956 debug: add issues event payload logging for M4 label trigger
Temporary debug logging to inspect eventAction and payload.label
on Forgejo for issues/labeled events.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:22:57 +02:00
Vlad MocanuandClaude Opus 4.6 a864b1636f fix: move comments out of workflow if: expression block
Forgejo runner's expression parser rejects '#' characters inside
if: | blocks (run 52778: "unexpected character '#' while lexing
expression"). Move all comments above the if: key and switch from
block scalar (|) to folded scalar (>-) to avoid multiline issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:21:23 +02:00
Vlad MocanuandClaude Opus 4.6 414c7053eb fix: let all issues events through workflow gate on Forgejo
Forgejo does not populate github.event.action in the workflow if:
context for issues events (run 12061 was skipped despite action
being 'labeled'). Same pattern as pull_request_comment (M3).

Remove the action/body/title gating from the workflow condition
and let trigger.ts handle all validation (label, assignee, mention).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 10:19:39 +02:00
Vlad MocanuandClaude Opus 4.6 dab92ef0eb fix: use mock.module for image-downloader tests
Replace the _fsForTest/DI patterns with Bun's native mock.module() API.
This mocks fs/promises at the module loader level, which works reliably
on Linux where jest.fn() call tracking fails cross-module. The source
code is now clean with no testing artifacts.

Also switches from jest.fn() to mock() (Bun's native API) for Octokit
mocks in these tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 09:05:39 +02:00
Vlad MocanuandClaude Opus 4.6 cff360d00a fix: use dependency injection for image-downloader fs mocks
The _fsForTest mutable object pattern fails on Linux Bun because
test and source files get different module instances. Switch to
passing fs operations as an optional parameter with defaults.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 08:54:58 +02:00
Vlad MocanuandClaude Opus 4.6 ac8e22e2f8 fix: fall through to issue comment when PR review comment fetch 404s
On Forgejo, pull_request_review_comment events create the tracking
comment as a regular issue comment (because the payload lacks
comment.id for reply-to-review). The update-comment-link step then
tried pulls.getReviewComment() first, which 404'd and threw before
reaching the issues.getComment() fallback.

Wrap the PR review comment fetch in its own try/catch so it falls
through to the issue comment fetch on failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 08:49:26 +02:00
Vlad MocanuandClaude Opus 4.6 910c843122 chore: remove debug-event job, merge into failure step
The separate debug-event job ran on every event, wasting a runner.
Merged the event payload dump into the existing "Debug on failure"
step so it only runs when the claude job actually fails.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 08:43:57 +02:00
Vlad MocanuandClaude Opus 4.6 e73c881c64 fix: skip commentBody validation for Forgejo review comment events
Forgejo's pull_request_review_comment payload doesn't include the
comment body. The Forgejo data fetcher retrieves it via REST instead.
Skip the COMMENT_BODY required check on Forgejo to avoid crashing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 08:42:22 +02:00
Vlad MocanuandClaude Opus 4.6 9d8c96f01e fix: handle missing comment payload in Forgejo pull_request_review_comment
Forgejo's pull_request_review_comment event does NOT include a top-level
`comment` object in the webhook payload. This caused crashes at:
- create-initial.ts: context.payload.comment.id (for reply-to-review)
- fetcher.ts: context.payload.comment.created_at (for trigger timestamp)

Fix: use optional chaining and fall back gracefully — reply-to-review
becomes a regular issue comment, trigger timestamp returns undefined.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 08:39:48 +02:00
Vlad MocanuandClaude Opus 4.6 a10b0475c0 fix: handle missing comment payload in Forgejo review comment events
Forgejo's pull_request_review_comment event does not include a
top-level `comment` object in the payload (it's undefined), causing
a crash: "undefined is not an object (evaluating 'context.payload.comment.body')".

- trigger.ts: On Forgejo, always trigger for pull_request_review_comment
  events since the workflow already gates on event name alone
- create-prompt/index.ts: Use optional chaining for comment fields,
  fall back to actor/empty values (data fetcher provides full data)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 23:53:19 +02:00
Vlad MocanuandClaude Opus 4.6 b4bc36810d fix: let pull_request_review_comment events through unconditionally
Forgejo's pull_request_review_comment event does not populate
github.event.comment.body in the workflow context (it's always
empty), so the contains() check never matches. The action code
does its own trigger phrase validation, so it's safe to let these
events through based on event name alone.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 23:49:19 +02:00
Vlad Mocanu 2ff7e35b48 chore: trigger workflow cache refresh for debug job 2026-02-25 23:48:10 +02:00
Vlad Mocanu 97dd0863c7 chore: improve debug-event job payload dump [skip ci] 2026-02-25 23:47:04 +02:00
Vlad Mocanu a129a15f61 feat(prd-6): verify workflow triggers and add assignee_trigger (#13) 2026-02-25 21:43:37 +00:00
Vlad Mocanu 095c2c2429 Merge pull request 'docs: rename bot from claude-bot to claude in CI and docs' (#12) from claude/issue-11-20260225-2020 into main
Reviewed-on: https://git.wxs.ro/actions/claude-code-action/pulls/12
2026-02-25 20:37:35 +00:00
claude-botandvtmocanu 2d8753c3db docs: rename bot from claude-bot to claude in CI and docs
Update all runtime-relevant references to the Forgejo bot username
from 'claude-bot' to 'claude' following the bot account rename.

- .forgejo/workflows/claude.yml: bot_name input
- docs/forgejo.md: setup guide, examples, and inline references
- CLAUDE.md: bot identity description

Test fixtures and historical PRD files are left unchanged as they
use 'claude-bot' as arbitrary mock data or historical record.

Co-authored-by: vtmocanu <vtmocanu@users.noreply.github.com>
2026-02-25 20:22:38 +00:00
Vlad Mocanu 3bab2edc41 fix: build image URL regexes at call time, not module load time 2026-02-25 19:26:18 +00:00
Vlad MocanuandClaude Opus 4.6 2f7d0a7fb2 docs(prd-5): mark complete and archive to prds/done/ [skip ci]
- All milestones delivered, E2E validated on PR #8
- Deferred: commit authorship E2E, cross-repo test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 21:11:20 +02:00
Vlad Mocanu 40731a0f5d Merge pull request 'feat: add dedicated claude-bot user for Forgejo (PRD #5)' (#8) from feature/prd-5-dedicated-forgejo-user into main 2026-02-25 19:07:49 +00:00
Vlad MocanuandClaude Opus 4.6 23f15aecb9 fix: use GITHUB_RUN_NUMBER for Forgejo job URLs and pin Bun version in CI
Forgejo uses the per-repo sequential run index (GITHUB_RUN_NUMBER) in
action URLs, not the internal DB run ID (GITHUB_RUN_ID). This caused
"View job" links to return 404. Fixed in all 4 URL construction sites:
create-initial comment, update-comment-link, and both prompt generators.

Also pins Bun to 1.2.21 in CI — Bun 1.3.9 broke spyOn(fs, ...) which
failed 18 upstream image-downloader tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 21:07:40 +02:00
Vlad MocanuandClaude Opus 4.6 6ebfb4914f docs: replace instance-specific values with placeholders in forgejo.md
Replace hardcoded bot_id "48" and bot_email "claude@wxs.ro" with
generic placeholders in Quick Start and setup examples so readers
don't copy instance-specific values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 20:56:55 +02:00
Vlad MocanuandClaude Opus 4.6 b03ccb518c feat(prd-5): add dedicated claude-bot user for Forgejo
- Add bot_email action input for custom git commit email on Forgejo
- Update claude.yml to use CLAUDE_BOT_TOKEN with bot_id/bot_name/bot_email
- Update git-config.ts to use provided email over noreply format
- Add "Dedicated Bot User" setup guide to docs/forgejo.md
- Update CLAUDE.md with bot identity documentation

Infrastructure (done outside code):
- claude-bot user created (ID 48, non-admin, with avatar)
- Claude team with write access in all 12 orgs
- CLAUDE_BOT_TOKEN org-level secret in all 12 orgs

Progress: ~85% complete - pending E2E validation after merge

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 20:56:55 +02:00
Vlad MocanuandClaude Opus 4.6 07e0384538 docs: replace instance-specific values with placeholders in forgejo.md
Replace hardcoded bot_id "48" and bot_email "claude@wxs.ro" with
generic placeholders in Quick Start and setup examples so readers
don't copy instance-specific values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 20:56:37 +02:00
Vlad MocanuandClaude Opus 4.6 b4a6c34853 fix: use per-review comment fetching for Forgejo compatibility
Forgejo doesn't have the flat GET /pulls/{number}/comments endpoint
(returns 404). Replace pulls.listReviewComments() with a 2-phase
approach: fetch reviews first, then pulls.listCommentsForReview()
per-review in parallel. Updates tests to mock the new per-review API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 20:52:25 +02:00
Vlad MocanuandClaude Opus 4.6 efe30422e7 ci: switch claude.yml to use claude-bot token [skip ci]
Use CLAUDE_BOT_TOKEN (dedicated bot user) instead of FORGEJO_CLAUDE_TOKEN
(personal token). Comments and commits will now appear as claude-bot.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 20:45:11 +02:00
Vlad MocanuandClaude Opus 4.6 34c259f189 docs(prd): create PRDs #5, #6, #7 for Forgejo hardening [skip ci]
- PRD #5: Dedicated Forgejo user for Claude bot (dedicated identity, scoped token)
- PRD #6: E2E test all 5 untested Forgejo trigger scenarios
- PRD #7: Senior developer review of all Forgejo platform support code
- Defined 5, 7, and 6 milestones respectively
- All three can be parallelized (#7 is read-only, runs alongside #5)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 20:13:57 +02:00
Vlad MocanuandClaude Opus 4.6 54c2d5b3e8 docs: add branch.ts platform fix to CLAUDE.md
- Add branch.ts to key integration points (repos.getBranch on Forgejo)
- Add claude.yml to CI workflows list

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 20:07:24 +02:00
Vlad MocanuandClaude Opus 4.6 c88782bd20 docs: update Forgejo docs with tag mode E2E results
- Add E2E Test Results section with validated capabilities
- Document git ref API difference (refs vs ref) in Known Limitations
- Document user display name 403 fallback
- Add git ref lookup row to API differences table
- Add claude.yml workflow to CI workflows section
- Remove outdated "not yet E2E tested" note from tag mode

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 20:06:47 +02:00
Vlad MocanuandClaude Opus 4.6 87b7fec838 fix: use repos.getBranch() on Forgejo for branch SHA lookup
Forgejo uses /git/refs (plural) not /git/ref (singular), causing
git.getRef() to 404. Use repos.getBranch() on Forgejo instead,
which returns the same SHA data via a compatible endpoint.

Also adds the tag mode workflow (.forgejo/workflows/claude.yml)
for @claude mentions on issues, PR reviews, and label triggers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 20:02:24 +02:00
Vlad MocanuandClaude Opus 4.6 c2ea0a6dba feat: add tag mode workflow for Forgejo
Enables @claude mentions on issues, PR review comments,
issue assignment, and label triggers on Forgejo.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 20:00:26 +02:00
Vlad Mocanu ef8657f2de Merge pull request 'feat(prd-1): Forgejo platform support' (#3) from feature/prd-1-forgejo-platform-support into main 2026-02-25 17:58:17 +00:00
Vlad MocanuandClaude Opus 4.6 bed5cd03c2 docs(prd-1): move completed PRD to prds/done/
PRD #1 (Forgejo Platform Support) is 100% complete.
All milestones M1-M9 implemented and validated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 19:56:02 +02:00
Vlad MocanuandClaude Opus 4.6 44f598ff11 feat(prd-1): complete M9 - documentation & upstream merge validation
- Created docs/forgejo.md: comprehensive setup guide (prerequisites,
  quick start, platform detection, GitHub differences, CI workflows,
  upstream merge process, known limitations, troubleshooting)
- Updated README.md with Forgejo support mention and docs link
- Updated CLAUDE.md with Forgejo architecture section
- Added platform input to docs/usage.md inputs table
- Added 5 Forgejo FAQ entries to docs/faq.md
- Upstream merge validated: zero conflicts (based on latest upstream)
- PRD #1 100% complete: all milestones M1-M9 done, 794 tests passing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 19:55:25 +02:00
Vlad Mocanu 5daed4f9bf feat(prd-1): complete M8 - E2E testing on Forgejo
- Mark M8 as complete: agent mode E2E passes on Forgejo runner
- Update actor.ts table entry: skipped on Forgejo (read:user scope)
- Mark setup-bun risk as RESOLVED (replaced with curl install)
- Document M8 fixes: permission check, actor skip, curl bun, CI env

Progress: 89% complete - M9 (docs + upstream merge validation) remaining
2026-02-25 19:49:46 +02:00
Vlad MocanuandClaude Opus 4.6 f93e8a10d0 fix(prd-1): skip actor check on Forgejo + replace setup-bun with curl install
- Skip checkHumanActor on Forgejo (no bot accounts, avoids read:user scope)
- Replace oven-sh/setup-bun action with curl install in action.yml
  (Forgejo runner pre-fetches all uses: refs even when if: skips them)
- Mirror oven-sh/setup-bun created at xternal/setup-bun for future use

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 19:45:47 +02:00