Skip to content

[FEAT] forgejo_* tools — Forgejo state queries via REST API #9

Closed

Description

@four-bytes-robby

Add a forgejo_* tool family for Forgejo repos (forgejo.example.com and other Forgejo instances), because the fj CLI has no --json/--format — its output is prose, and agents misread it (a squash-merged PR shows as Closed, costing ~4 wasted round trips to establish merged-vs-abandoned). State queries must hit the Forgejo REST API, not the CLI.

Four tools, mirroring the existing gh_*/gitlab_mr_* families:

  • forgejo_issue_list — mirror gh_issue_list (state/label/assignee filters, one line per issue, default state=open limit=20).
  • forgejo_issue_view — number, title, state, labels, body truncated ~20 lines, comment count.
  • forgejo_issue_close — PATCH /issues/{n} state closed, optional comment via POST /issues/{n}/comments first. Comment is a tool ARGUMENT (never a shell string — avoids backtick command-substitution bug).
  • forgejo_pr_status — resolves the merged/closed ambiguity: GET /repos/{owner}/{repo}/pulls/{id} → state/merged/merge_commit_sha/head.sha; if state == closed && merged == false, run git branch -r --contains <head.sha> via runGit to report merged_via: git-squash vs genuinely abandoned.

Full spec (must read): the meta-repo change spec section A. Key design points: new src/lib/forgejo-utils.ts mirrors src/lib/gitlab-utils.ts exactly (getForgejoConfig() from FORGEJO_TOKEN/FORGEJO_HOST or derived from origin remote, getForgejoRepo(cwd), forgejoApi(path, config, init?) → ${host}/api/v1${path} with Authorization: token ${token}); every tool returns a one-line "not configured" string when config is absent; never throw from execute; fixture JSON tests, no live API.

Also update agents/github.md in the consuming config: add the four forgejo_* tool names to the permission list + the rule "Forgejo repos: state queries go through forgejo_*. Never fj … --json/--format. git mutations stay on bash." (If agents/github.md is not in this repo, note that and skip — it lives in the user's opencode config; do not create it here.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions