Skip to content

About

Forgejo and Gitea forge plugin for Archon: checks, PR files, reviews, marked comments, labels and qualified merges for governed workflows

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Forgejo / Gitea forge plugin for Archon

Gives Archon workflows what they need to run governed work on a Forgejo or Gitea item: the pull request's checks and files, the reviews on it, a marked comment written in place, labels, and a qualified merge. It speaks the @archon/forge plugin protocol (version 1) and talks to the /api/v1 REST API of the instance.

Codeberg and gitea.com are claimed by default; any other instance is mapped under forge.hosts.

Install

archon plugin add KIntegrated/archon-forge-forgejo

Pin a release with @v0.4.0. The executable is installed under ARCHON_HOME/plugins/ and verified against the release's checksums.txt.

Pairing with the bundled Gitea adapter

Archon reaches a Gitea-compatible instance through two independent layers. They do not replace each other, and an install that wants both has both:

Bundled Gitea adapter (GITEA_* env) This plugin
Layer platform adapter — transport forge plugin — work-item operations
Does an issue or PR comment becomes a conversation and a run; the reply is posted back checks, pr.files, reviews, labels, the marked work-item comment, qualified merge
Configured by GITEA_URL, GITEA_TOKEN, GITEA_WEBHOOK_SECRET, GITEA_ALLOWED_USERS forge.hosts + a token or tea login

Use the adapter for chat — talking to an agent from an issue. Use this plugin when a workflow needs to decide something about the item: gate on checks, read the diff, answer a review, or merge.

One secret, two paths. Both layers read GITEA_TOKEN. Point the plugin at it so the two cannot drift into different identities:

forge:
  hosts:
    forge.example.org:
      plugin: forgejo
      token_env: GITEA_TOKEN

Without token_env the plugin resolves FORGEJO_TOKEN, CODEBERG_TOKEN, or GITEA_TOKEN from ARCHON_HOME/.env, then falls back to your tea login for that host.

Plain http and non-standard ports

A self-hosted instance on a LAN is often plain http and often has a port, and neither is visible to a plugin that receives a host name. The plugin reads the hosts it must reach over http from ARCHON_FORGE_PLAIN_HTTP_HOSTS (comma-separated, port included), which Archon sets from forge.hosts.<host>.scheme: http:

forge:
  hosts:
    nas.example:3864:
      plugin: forgejo
      scheme: http
      token_env: FORGEJO_TOKEN

Archon releases before that field exists do not set the variable, so an http-only host cannot be reached through them. Ports are part of the host name everywhere — nas.example:3864, not nas.example.

What a caller can see

Forgejo differs from GitHub in ways a workflow can trip over:

  • workitem.close records its reason with a label. Forgejo stores no reason for a close: its issue edit carries state and nothing else. not_planned is closed/not_planned and duplicate is closed/duplicate, and an issue carrying neither reads as completed, as one closed by hand does. Create both with repo.label.ensure before the first close of that reason; a close whose label is missing is refused rather than recorded as something the labels do not say. The label is written before the close, so a retry after an interrupted close only closes, and a close never rewrites an earlier reason: already closed as another reason is a conflict, and so is an open issue still carrying another reason's label.
  • pr.thread.reply answers the review of the thread's newest comment. Forgejo has no thread object: a thread is the comments on one line of one file, and a reply joins one review. This plugin groups a thread across reviews, because two reviews commenting on one line are one conversation to a reader, so the reply joins the newest review to stay beside the comments it answers.
  • pr.merge-state reports clean or unknown, never conflict. Forgejo reports a pull request as not mergeable while it is still computing the merge, and for a draft or a closed one too, so only true justifies clean. Only POST /merge can say a pull request conflicts — a 405 that pr.merge surfaces — and a read should not spend it. unknown is what a merge queue re-reads; conflict is what sends a lane to rebase.
  • pr.thread.resolve is not served. Forgejo's API has no way to resolve a review conversation; only its web pages do.
  • An empty list arrives as null. Forgejo serializes a nil slice as null, so an issue with no assignee answers "assignees": null, not []. Both readings are the empty list here.
  • workitem.opened filters on when the issue was created, not when it was updated. Forgejo narrows on since by updated time — a superset of what was created in the window — so the listing is filtered again on created_at, and pull requests are dropped: an observing source starts work on issues only.
  • workitem.label.added reads the timeline's own event. The event id tells two adds of the same label apart, so a remove and re-add is a new add even when the label is on the item both times it is read. A timeline that records no add answers null rather than guessing.
  • actor.self names the account a token acts as, which is what an assignment is addressed to when the workflow does not know whose credential it runs under.

Compatibility

@archon/forge and the @archon/paths surface it needs are workspace packages inside Archon and are not published to npm. They are copied into vendor/ from one pinned commit, recorded in archon-contract.json, and the copy is generated:

bun run vendor        # re-derive vendor/ from the pin
bun run vendor:check  # fail when the committed copy no longer matches it
bun install
bun run type-check    # type-check src against the vendored contract
bun run test          # the suite, no Archon checkout needed
bun run build         # one executable per platform, into dist/
bun run build:checksums  # the same, plus dist/checksums.txt

vendor/VENDORED.md names the tag, commit and protocol, what the copy leaves out, and how to move the pin. Editing vendor/ by hand fails vendor:check, which is the point: the alternative — hand-maintained protocol schemas — cannot be checked against the contract at all, and a hand-edited copy would drift from it invisibly.

The pin is Archon fdc50f6b2, which carries the whole version-1 contract including the reads an install without webhooks uses (workitem.opened, workitem.label.added, actor.self) and the writes an assignment or a close needs (workitem.assignee.add, workitem.assignee.remove, pr.close). Every operation the protocol declares is answered; pr.thread.resolve answers unsupported_op because Forgejo's API has no endpoint behind it.

What it does not do

  • No webhook intake or chat replies: that is the adapter's job (see above).
  • No API origin discovery from a web URL beyond what the contract's resolve requires.
  • Nothing is logged to stdout: it is the protocol channel.

Licence

MIT. The plugin protocol and its schemas belong to Archon, also MIT.

About

Forgejo and Gitea forge plugin for Archon: checks, PR files, reviews, marked comments, labels and qualified merges for governed workflows

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages