From 43e43e7024d636358c34cc037477a29d6e0139f5 Mon Sep 17 00:00:00 2001 From: sid Date: Sat, 21 Mar 2026 21:50:24 -0600 Subject: [PATCH] =?UTF-8?q?feat:=20v0.3.0a=20=E2=80=94=20add=20api=20comma?= =?UTF-8?q?nd,=20pr=20diff/comment/review,=20structured=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New commands: - fgj api: raw REST API passthrough with field inference and path interpolation - fgj pr diff: view PR diffs with color, --name-only, --stat - fgj pr comment: add comments to pull requests - fgj pr review: approve, request changes, or comment on PRs Agentic enhancements: - --json-errors flag for structured JSON error output on stderr - APIError type wrapping HTTP status codes for machine consumption - Error codes: auth_required, not_found, api_error, invalid_input, etc. Docs updated for forgejo.zerova.net/sid/fgj-sid fork. --- CHANGELOG.md | 3 +- README.md | 75 ++++++++++++++++++------------------- cmd/actions.go | 4 +- cmd/api.go | 4 +- cmd/auth.go | 4 +- cmd/errors.go | 2 +- cmd/issue.go | 4 +- cmd/pr.go | 4 +- cmd/pr_diff.go | 4 +- cmd/pr_review.go | 4 +- cmd/release.go | 4 +- cmd/repo.go | 4 +- cmd/root.go | 4 +- go.mod | 2 +- internal/api/client.go | 2 +- internal/api/client_test.go | 2 +- main.go | 2 +- 17 files changed, 64 insertions(+), 64 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9f7be4..3f00005 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.3.0a] - 2026-03-21 ### Added @@ -165,6 +165,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Cobra framework for CLI structure - Viper for configuration management +[0.3.0a]: https://forgejo.zerova.net/sid/fgj-sid/releases/tag/v0.3.0a [0.3.0]: https://codeberg.org/romaintb/fgj/releases/tag/v0.3.0 [0.2.0]: https://codeberg.org/romaintb/fgj/releases/tag/v0.2.0 [0.1.0]: https://codeberg.org/romaintb/fgj/releases/tag/v0.1.0 diff --git a/README.md b/README.md index 8ec539d..db31990 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ -# fgj - Forgejo CLI Tool +# fgj - Forgejo/Gitea CLI Tool [![Go Version](https://img.shields.io/badge/Go-1.23+-00ADD8?style=flat-square&logo=go)](https://golang.org) -[![CI Status](https://codeberg.org/romaintb/fgj/actions/workflows/ci.yml/badge.svg)](https://codeberg.org/romaintb/fgj/actions) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](LICENSE) -`fgj` is a command-line tool for working with Forgejo instances (including Codeberg.org). It brings pull requests, issues, and other Forgejo concepts to the terminal, similar to what `gh` does for GitHub. +`fgj` is a command-line tool for working with Forgejo and Gitea instances. It brings pull requests, issues, and other forge concepts to the terminal, similar to what `gh` does for GitHub. This fork adds agentic dev features — raw API access, PR review workflows, structured error output, and machine-readable I/O for AI coding agents. + +> Forked from [codeberg.org/romaintb/fgj](https://codeberg.org/romaintb/fgj) and hosted at [forgejo.zerova.net/sid/fgj-sid](https://forgejo.zerova.net/sid/fgj-sid). ## Features -- Multi-instance support (works with any Forgejo instance) +- Multi-instance support (works with any Forgejo or Gitea instance) - Pull request management (create, list, view, merge, diff, comment, review) - Issue tracking (create, list, view, comment, close, labels) - Repository operations (view, list, create, clone, fork) @@ -25,49 +26,43 @@ ## Installation -[![Packaging status](https://repology.org/badge/vertical-allrepos/fgj.svg)](https://repology.org/project/fgj/versions) - -### Arch Linux (AUR) - -`fgj` is available in the Arch User Repository: - -```bash -yay -S fgj -``` - ### macOS (Homebrew) ```bash -brew tap romaintb/fgj https://codeberg.org/romaintb/homebrew-fgj.git +brew tap sid/fgj-sid https://forgejo.zerova.net/sid/homebrew-fgj-sid.git brew install fgj ``` ### Using Go Install ```bash -go install codeberg.org/romaintb/fgj@latest +go install forgejo.zerova.net/sid/fgj-sid@latest ``` -### Other Distributions +### From Source -We'd love your help packaging `fgj` for other distributions! If you're interested in creating packages for Debian, Ubuntu, Fedora, or any packaging systems, please open an issue or reach out. +```bash +git clone https://forgejo.zerova.net/sid/fgj-sid.git +cd fgj-sid +go build -o fgj . +``` ## Quick Start ### 1. Authenticate -First, authenticate with your Forgejo instance: +First, authenticate with your Forgejo or Gitea instance: ```bash fgj auth login ``` You'll be prompted for: -- Forgejo instance hostname (default: codeberg.org) +- Instance hostname (default: codeberg.org) - Personal access token To create a personal access token: -1. Go to your Forgejo instance (e.g., https://codeberg.org) +1. Go to your instance (e.g., https://forgejo.zerova.net) 2. Navigate to Settings > Applications > Generate New Token 3. Give it appropriate permissions (repo, issue, etc.) 4. Copy the token and paste it when prompted @@ -105,7 +100,7 @@ fgj pr view 123 # Automatically uses current repo fgj pr list -R owner/repo ``` -The tool reads `.git/config` to find the origin remote and extract both the owner/repo information and the Forgejo instance hostname. If you're not in a git repository, you'll need to use the `-R` flag. +The tool reads `.git/config` to find the origin remote and extract both the owner/repo information and the instance hostname. If you're not in a git repository, you'll need to use the `-R` flag. ### Pull Requests @@ -376,21 +371,21 @@ Configuration is stored in `~/.config/fgj/config.yaml`: ```yaml hosts: - codeberg.org: - hostname: codeberg.org + forgejo.zerova.net: + hostname: forgejo.zerova.net token: your_token_here user: your_username - git_protocol: https - my-forgejo.com: - hostname: my-forgejo.com + git_protocol: ssh + codeberg.org: + hostname: codeberg.org token: another_token user: another_username - git_protocol: ssh + git_protocol: https ``` ### Environment Variables -- `FGJ_HOST`: Override the default Forgejo instance (auto-detected from git remote if not set) +- `FGJ_HOST`: Override the default instance (auto-detected from git remote if not set) - `FGJ_TOKEN`: Provide authentication token Hostname is resolved in this priority order: @@ -401,10 +396,10 @@ Hostname is resolved in this priority order: ### Command-line Flags -- `--hostname`: Specify Forgejo instance for a command (overrides auto-detection and environment variables) +- `--hostname`: Specify instance for a command (overrides auto-detection and environment variables) - `--config`: Use a custom config file -When working in a git repository, `fgj` automatically detects the Forgejo instance from your origin remote URL, so you typically don't need to specify `--hostname` unless working with multiple instances. +When working in a git repository, `fgj` automatically detects the instance from your origin remote URL, so you typically don't need to specify `--hostname` unless working with multiple instances. ## Use with AI Coding Agents @@ -442,21 +437,21 @@ fgj api /repos/{owner}/{repo}/labels -X POST -f name=agent-reviewed -f color="#0 fgj pr view 9999 --json --json-errors 2>errors.json ``` -## Supported Forgejo Instances +## Supported Instances -`fgj` works with any Forgejo instance, including: +`fgj` works with any Forgejo or Gitea instance, including: -- [Codeberg.org](https://codeberg.org) (default) - Self-hosted Forgejo instances -- Gitea instances (compatible API) +- Self-hosted Gitea instances +- [Codeberg.org](https://codeberg.org) ## Contributing -Contributions are welcome! Please feel free to submit a Pull Request. +Contributions are welcome! Please feel free to submit a Pull Request at [forgejo.zerova.net/sid/fgj-sid](https://forgejo.zerova.net/sid/fgj-sid). ## Missing Features / Roadmap -`fgj` aims to be a drop-in replacement for `gh` when working with Forgejo instances. While we've implemented the core features, some `gh` commands are not yet available: +`fgj` aims to be a drop-in replacement for `gh` when working with Forgejo and Gitea instances. While we've implemented the core features, some `gh` commands are not yet available: **Not Yet Implemented:** - `run delete` - Delete a workflow run @@ -467,7 +462,11 @@ Contributions are welcome! Please feel free to submit a Pull Request. - `release edit`, `release download`, `release generate-notes` - `repo delete`, `repo rename`, `repo visibility` -We welcome contributions to implement any of these features! Please check the issues or create a new one to discuss implementation before starting work. +We welcome contributions to implement any of these features! + +## Acknowledgments + +Based on [fgj by romaintb](https://codeberg.org/romaintb/fgj). Enhanced with agentic dev features for AI-assisted workflows. ## License diff --git a/cmd/actions.go b/cmd/actions.go index a32670d..5481c5c 100644 --- a/cmd/actions.go +++ b/cmd/actions.go @@ -12,8 +12,8 @@ import ( "code.gitea.io/sdk/gitea" "github.com/spf13/cobra" - "codeberg.org/romaintb/fgj/internal/api" - "codeberg.org/romaintb/fgj/internal/config" + "forgejo.zerova.net/sid/fgj-sid/internal/api" + "forgejo.zerova.net/sid/fgj-sid/internal/config" ) // ActionRun represents a workflow run diff --git a/cmd/api.go b/cmd/api.go index f28b759..e6eee18 100644 --- a/cmd/api.go +++ b/cmd/api.go @@ -10,8 +10,8 @@ import ( "strconv" "strings" - "codeberg.org/romaintb/fgj/internal/config" - "codeberg.org/romaintb/fgj/internal/git" + "forgejo.zerova.net/sid/fgj-sid/internal/config" + "forgejo.zerova.net/sid/fgj-sid/internal/git" "github.com/spf13/cobra" ) diff --git a/cmd/auth.go b/cmd/auth.go index 0b2ef06..d65fbe1 100644 --- a/cmd/auth.go +++ b/cmd/auth.go @@ -7,8 +7,8 @@ import ( "strings" "syscall" - "codeberg.org/romaintb/fgj/internal/api" - "codeberg.org/romaintb/fgj/internal/config" + "forgejo.zerova.net/sid/fgj-sid/internal/api" + "forgejo.zerova.net/sid/fgj-sid/internal/config" "github.com/spf13/cobra" "github.com/spf13/viper" "golang.org/x/term" diff --git a/cmd/errors.go b/cmd/errors.go index 8e0f7bc..422cd33 100644 --- a/cmd/errors.go +++ b/cmd/errors.go @@ -5,7 +5,7 @@ import ( "errors" "os" - "codeberg.org/romaintb/fgj/internal/api" + "forgejo.zerova.net/sid/fgj-sid/internal/api" ) // Error codes for structured error output. diff --git a/cmd/issue.go b/cmd/issue.go index f008f83..65fe12c 100644 --- a/cmd/issue.go +++ b/cmd/issue.go @@ -8,8 +8,8 @@ import ( "text/tabwriter" "code.gitea.io/sdk/gitea" - "codeberg.org/romaintb/fgj/internal/api" - "codeberg.org/romaintb/fgj/internal/config" + "forgejo.zerova.net/sid/fgj-sid/internal/api" + "forgejo.zerova.net/sid/fgj-sid/internal/config" "github.com/spf13/cobra" ) diff --git a/cmd/pr.go b/cmd/pr.go index 1f35638..a3a92d6 100644 --- a/cmd/pr.go +++ b/cmd/pr.go @@ -8,8 +8,8 @@ import ( "text/tabwriter" "code.gitea.io/sdk/gitea" - "codeberg.org/romaintb/fgj/internal/api" - "codeberg.org/romaintb/fgj/internal/config" + "forgejo.zerova.net/sid/fgj-sid/internal/api" + "forgejo.zerova.net/sid/fgj-sid/internal/config" "github.com/spf13/cobra" ) diff --git a/cmd/pr_diff.go b/cmd/pr_diff.go index f129c54..f11ec89 100644 --- a/cmd/pr_diff.go +++ b/cmd/pr_diff.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" - "codeberg.org/romaintb/fgj/internal/api" - "codeberg.org/romaintb/fgj/internal/config" + "forgejo.zerova.net/sid/fgj-sid/internal/api" + "forgejo.zerova.net/sid/fgj-sid/internal/config" "github.com/spf13/cobra" "golang.org/x/term" ) diff --git a/cmd/pr_review.go b/cmd/pr_review.go index 5c77d88..d64095d 100644 --- a/cmd/pr_review.go +++ b/cmd/pr_review.go @@ -7,8 +7,8 @@ import ( "strconv" "code.gitea.io/sdk/gitea" - "codeberg.org/romaintb/fgj/internal/api" - "codeberg.org/romaintb/fgj/internal/config" + "forgejo.zerova.net/sid/fgj-sid/internal/api" + "forgejo.zerova.net/sid/fgj-sid/internal/config" "github.com/spf13/cobra" ) diff --git a/cmd/release.go b/cmd/release.go index 8ad9413..cfc9d0a 100644 --- a/cmd/release.go +++ b/cmd/release.go @@ -9,8 +9,8 @@ import ( "time" "code.gitea.io/sdk/gitea" - "codeberg.org/romaintb/fgj/internal/api" - "codeberg.org/romaintb/fgj/internal/config" + "forgejo.zerova.net/sid/fgj-sid/internal/api" + "forgejo.zerova.net/sid/fgj-sid/internal/config" "github.com/spf13/cobra" ) diff --git a/cmd/repo.go b/cmd/repo.go index b072317..ef14353 100644 --- a/cmd/repo.go +++ b/cmd/repo.go @@ -9,8 +9,8 @@ import ( "text/tabwriter" "code.gitea.io/sdk/gitea" - "codeberg.org/romaintb/fgj/internal/api" - "codeberg.org/romaintb/fgj/internal/config" + "forgejo.zerova.net/sid/fgj-sid/internal/api" + "forgejo.zerova.net/sid/fgj-sid/internal/config" "github.com/spf13/cobra" ) diff --git a/cmd/root.go b/cmd/root.go index a22afb8..3c11c7d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -5,7 +5,7 @@ import ( "os" "strings" - "codeberg.org/romaintb/fgj/internal/git" + "forgejo.zerova.net/sid/fgj-sid/internal/git" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -18,7 +18,7 @@ var rootCmd = &cobra.Command{ Short: "Forgejo CLI tool - work seamlessly with Forgejo from the command line", Long: `fgj is a command line tool for Forgejo instances (including Codeberg). It brings pull requests, issues, and other Forgejo concepts to the terminal.`, - Version: "0.2.0", + Version: "0.3.0a", SilenceErrors: true, } diff --git a/go.mod b/go.mod index 5c70717..0025ca9 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module codeberg.org/romaintb/fgj +module forgejo.zerova.net/sid/fgj-sid go 1.23.0 diff --git a/internal/api/client.go b/internal/api/client.go index e49c2f6..b69f3f7 100644 --- a/internal/api/client.go +++ b/internal/api/client.go @@ -8,7 +8,7 @@ import ( "net/http" "code.gitea.io/sdk/gitea" - "codeberg.org/romaintb/fgj/internal/config" + "forgejo.zerova.net/sid/fgj-sid/internal/config" ) type Client struct { diff --git a/internal/api/client_test.go b/internal/api/client_test.go index 3cb469b..daf8b3c 100644 --- a/internal/api/client_test.go +++ b/internal/api/client_test.go @@ -3,7 +3,7 @@ package api import ( "testing" - "codeberg.org/romaintb/fgj/internal/config" + "forgejo.zerova.net/sid/fgj-sid/internal/config" ) func TestClient_Hostname(t *testing.T) { diff --git a/main.go b/main.go index 770933d..76dd977 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "codeberg.org/romaintb/fgj/cmd" + "forgejo.zerova.net/sid/fgj-sid/cmd" ) func main() {