Add Forgejo CI tools: commit status, run jobs, job and run logs #76

Merged
lucas merged 1 commit from agent/issue-74-ci-tools into main 2026-10-26 14:20:59 +01:00
Collaborator

Closes: #74

Adds four read-only CI tools (step 16 of the integration plan):

  • forgejo_read_commit_status: the combined state, whether every check has finished, and one line per check. Each Actions check's run number is resolved to its API run id through GET /actions/runs?run_number=N.
  • forgejo_list_run_jobs: the run header plus one line per job.
  • forgejo_read_job_log: snapshots the log to local://ci/job-<id>-attempt-<n>.log and returns the last 50 lines inline, capped at 5 KB.
  • forgejo_get_run_logs: downloads the run's log ZIP through the new ForgejoClient.bytes(), unpacks it with fflate, and writes the logs to local://ci/run-<id>/. The unpacked size is capped at 256 MB.

The tools are also added to the conversation, pull-request and implementer policies, with a CI bullet in each one's system context. Each tool has its own web card, plus preview fixtures and docs.

Deviations from the plan

  • Partial snapshots. The plan reuses a snapshot whenever the job or run is terminal. But a snapshot taken while the job or run was running would then be reused once it finished, and it holds an incomplete log. Snapshots fetched before the job or run finished now get a .partial sibling marker, and only unmarked snapshots are reused. A mock-server smoke run caught this bug.
  • Implementer decision. For listed tools, the implementer policy returns "allow", not "default". The new session-policy test accepts either result, since neither prompts.

Verified

  • I checked workflow_runs against the instance's swagger (ListActionRunResponse).
  • New ci.test.ts covers the pure helpers: parseActionsTarget, logTail, zipEntryName and extractRunLogs.
  • bun test apps/server/src/forgejo apps/server/src/bridge: 696 pass. bun run typecheck is clean.
  • I ran a throwaway end-to-end script against a mock Forgejo server, covering all four tools, the 404 mappings, and the reuse and refetch transitions.

Not verified

  • I have not run these tools against git.sclu1034.dev: this session has no API access to it. Still open: the live target_url format (assumed /actions/runs/<index_in_repo>/jobs/<n>), whether the run_number filter is honoured (the code checks index_in_repo === N and leaves the run id null on a mismatch), and how the job-log endpoint behaves while a job is running.
Closes: #74 Adds four read-only CI tools (step 16 of the integration plan): - `forgejo_read_commit_status`: the combined state, whether every check has finished, and one line per check. Each Actions check's run number is resolved to its API run id through `GET /actions/runs?run_number=N`. - `forgejo_list_run_jobs`: the run header plus one line per job. - `forgejo_read_job_log`: snapshots the log to `local://ci/job-<id>-attempt-<n>.log` and returns the last 50 lines inline, capped at 5 KB. - `forgejo_get_run_logs`: downloads the run's log ZIP through the new `ForgejoClient.bytes()`, unpacks it with `fflate`, and writes the logs to `local://ci/run-<id>/`. The unpacked size is capped at 256 MB. The tools are also added to the conversation, pull-request and implementer policies, with a CI bullet in each one's system context. Each tool has its own web card, plus preview fixtures and docs. ### Deviations from the plan - **Partial snapshots.** The plan reuses a snapshot whenever the job or run is terminal. But a snapshot taken *while the job or run was running* would then be reused once it finished, and it holds an incomplete log. Snapshots fetched before the job or run finished now get a `.partial` sibling marker, and only unmarked snapshots are reused. A mock-server smoke run caught this bug. - **Implementer decision.** For listed tools, the implementer policy returns `"allow"`, not `"default"`. The new session-policy test accepts either result, since neither prompts. ### Verified - I checked `workflow_runs` against the instance's swagger (`ListActionRunResponse`). - New `ci.test.ts` covers the pure helpers: `parseActionsTarget`, `logTail`, `zipEntryName` and `extractRunLogs`. - `bun test apps/server/src/forgejo apps/server/src/bridge`: 696 pass. `bun run typecheck` is clean. - I ran a throwaway end-to-end script against a mock Forgejo server, covering all four tools, the 404 mappings, and the reuse and refetch transitions. ### Not verified - I have not run these tools against git.sclu1034.dev: this session has no API access to it. Still open: the live `target_url` format (assumed `/actions/runs/<index_in_repo>/jobs/<n>`), whether the `run_number` filter is honoured (the code checks `index_in_repo === N` and leaves the run id null on a mismatch), and how the job-log endpoint behaves while a job is running.
Four read tools for inspecting Forgejo Actions results:
forgejo_read_commit_status (checks with resolved API run ids),
forgejo_list_run_jobs, forgejo_read_job_log (snapshot plus inline tail)
and forgejo_get_run_logs (downloads and unpacks the run's log ZIP with
fflate). Logs are snapshotted under local://ci/; snapshots taken while
a job or run was still running are marked partial and refetched.

All trigger-session policies get the tools, and each has a web card.

Co-Authored-By: Claude Opus 5.5 via omp-deck
lucas approved these changes 2026-10-26 14:20:53 +01:00
lucas merged commit ae9814be78 into main 2026-10-26 14:20:59 +01:00
lucas deleted branch agent/issue-74-ci-tools 2026-10-26 14:21:00 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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
lucas/omp-deck!76
No description provided.