feat: add PR diff, PR review, and structured error handling commands

This commit is contained in:
sid 2026-03-21 21:50:24 -06:00
parent 3db03ed5e2
commit 50191cc542
10 changed files with 1008 additions and 13 deletions

View file

@ -5,6 +5,39 @@ 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]
### Added
#### Raw API Access
- `fgj api <endpoint>` - Make authenticated REST API requests to any Forgejo/Gitea endpoint
- HTTP method selection (`--method`/`-X`), auto-switches to POST when fields are provided
- JSON field assembly (`--field`/`-f`) with type inference (bool, int, float, null, string)
- Raw string fields (`--raw-field`/`-F`)
- Request body from file or stdin (`--input`)
- Custom headers (`--header`/`-H`)
- Path interpolation (`{owner}`, `{repo}`) from git context
- Response header display (`--include`/`-i`)
#### Pull Request Management
- `fgj pr diff <number>` - View the diff for a pull request
- Colorized output (`--color auto/always/never`)
- Changed file names only (`--name-only`)
- Diffstat summary (`--stat`)
- `fgj pr comment <number>` - Add a comment to a pull request
- Body from flag (`--body`/`-b`) or file (`--body-file`, `-` for stdin)
- JSON output (`--json`)
- `fgj pr review <number>` - Submit a review on a pull request
- Approve (`--approve`/`-a`), request changes (`--request-changes`/`-r`), or comment (`--comment`/`-c`)
- Body from flag or file
- JSON output (`--json`)
#### Agentic / Machine-Readable Output
- `--json-errors` global flag for structured JSON error output on stderr
- Error codes: `auth_required`, `not_found`, `api_error`, `invalid_input`, `git_detection_failed`, `network_error`
- HTTP status code and detail included when available
- Automatic mapping of API errors (401/403 → `auth_required`, 404 → `not_found`)
## [0.3.0] - 2026-03-13
### Added