feat: Add CI action log access for PR commits #66

Open
opened 2026-06-20 15:33:17 +00:00 by llm-bot · 0 comments
Member

Problem

When the agent is reviewing a PR or working on code changes, it has no way to check whether CI passes or diagnose CI failures. The agent can push code but cannot observe the results of CI runs triggered by those pushes.

Proposed Solution

Add tools and Forgejo API endpoints to access CI action logs for commits in the current PR.

API Endpoints to Add (src/forgejo/index.ts)

  1. getCommitStatus(repo, sha) — Fetch commit status checks

    • GET /repos/{owner}/{repo}/commits/{sha}/status
  2. getActionRuns(repo, branch?) — Fetch action runs for a branch

    • GET /repos/{owner}/{repo}/actions/runs?branch={branch}
  3. getJobLogs(repo, runId, jobId) — Fetch logs for a specific job

    • GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs/{job_id}/logs
  4. getJobDetails(repo, runId) — Fetch details of jobs in a run

    • GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs

Tools to Add (src/tools.ts)

  1. check-ci-status — Check the CI status of a commit

    • Parameters: repository, sha (optional — defaults to HEAD)
    • Returns: summary of status checks (pass/fail/skipped)
  2. get-action-logs — Fetch and return CI action logs

    • Parameters: repository, runId, jobId (optional — returns all jobs if omitted)
    • Returns: the log output of the specified job(s)

Prompt Integration (src/prompt.ts)

When the event type is a PR, the prompt should include:

  • A note about the available CI-checking tools
  • Guidance on how to use them during review (e.g., "check if CI passes before requesting changes")

Schema Updates (src/schemas.ts)

Add TypeBox schemas for:

  • Commit status response (combined status, individual checks)
  • Action run response
  • Job response
  • Job log response

Example Agent Workflow

  1. Agent pushes code changes → agent calls check-ci-status to verify CI passed
  2. CI fails → agent calls get-action-logs to see failure details
  3. Agent analyzes logs, fixes the issue, pushes again

Files to Modify

File Changes
src/forgejo/fetch.ts No changes needed (already generic)
src/forgejo/index.ts Add 4 new API functions
src/schemas.ts Add schemas for commit status, action runs, jobs, logs
src/tools.ts Add 2 new tools (check-ci-status, get-action-logs)
src/prompt.ts Update prompt for PR events to mention CI tools
src/main.ts Register new tools in customTools array

Notes

  • Forgejo's Actions API follows the GitHub Actions API closely, so endpoints should be similar
  • The auth token must have repo scope to access action logs
  • Consider adding a waitForCI variant that polls until CI completes (for longer-running jobs)
## Problem When the agent is reviewing a PR or working on code changes, it has no way to check whether CI passes or diagnose CI failures. The agent can push code but cannot observe the results of CI runs triggered by those pushes. ## Proposed Solution Add tools and Forgejo API endpoints to access CI action logs for commits in the current PR. ### API Endpoints to Add (`src/forgejo/index.ts`) 1. **`getCommitStatus(repo, sha)`** — Fetch commit status checks - `GET /repos/{owner}/{repo}/commits/{sha}/status` 2. **`getActionRuns(repo, branch?)`** — Fetch action runs for a branch - `GET /repos/{owner}/{repo}/actions/runs?branch={branch}` 3. **`getJobLogs(repo, runId, jobId)`** — Fetch logs for a specific job - `GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs/{job_id}/logs` 4. **`getJobDetails(repo, runId)`** — Fetch details of jobs in a run - `GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs` ### Tools to Add (`src/tools.ts`) 1. **`check-ci-status`** — Check the CI status of a commit - Parameters: `repository`, `sha` (optional — defaults to HEAD) - Returns: summary of status checks (pass/fail/skipped) 2. **`get-action-logs`** — Fetch and return CI action logs - Parameters: `repository`, `runId`, `jobId` (optional — returns all jobs if omitted) - Returns: the log output of the specified job(s) ### Prompt Integration (`src/prompt.ts`) When the event type is a PR, the prompt should include: - A note about the available CI-checking tools - Guidance on how to use them during review (e.g., "check if CI passes before requesting changes") ### Schema Updates (`src/schemas.ts`) Add TypeBox schemas for: - Commit status response (combined status, individual checks) - Action run response - Job response - Job log response ### Example Agent Workflow 1. Agent pushes code changes → agent calls `check-ci-status` to verify CI passed 2. CI fails → agent calls `get-action-logs` to see failure details 3. Agent analyzes logs, fixes the issue, pushes again ### Files to Modify | File | Changes | |------|---------| | `src/forgejo/fetch.ts` | No changes needed (already generic) | | `src/forgejo/index.ts` | Add 4 new API functions | | `src/schemas.ts` | Add schemas for commit status, action runs, jobs, logs | | `src/tools.ts` | Add 2 new tools (`check-ci-status`, `get-action-logs`) | | `src/prompt.ts` | Update prompt for PR events to mention CI tools | | `src/main.ts` | Register new tools in `customTools` array | ### Notes - Forgejo's Actions API follows the GitHub Actions API closely, so endpoints should be similar - The auth token must have `repo` scope to access action logs - Consider adding a `waitForCI` variant that polls until CI completes (for longer-running jobs)
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
projects/forgejo-agent#66
No description provided.