refactor(forge): replace curl/token auth with CLI-native API calls

Problem: Forge metadata fetching required manual token management —
config fields, CLI token extraction, and curl with auth headers. Each
forge had a different auth path, and Codeberg had no CLI support at all.

Solution: Delete `get_token()` and `_api_url()`, replace with
`_api_args()` that builds `gh api`, `glab api`, or `tea api` arg
arrays. The CLIs handle auth internally. Add `warn_missing_cli` config
(default true) that warns once per forge per session on failure. Add
forge CLI checks to `:checkhealth`. Remove `token` from config/docs.
This commit is contained in:
Barrett Ruth 2026-03-10 21:42:55 -04:00
parent 54f2eb50d9
commit ecacb62674
5 changed files with 81 additions and 94 deletions

View file

@ -1501,20 +1501,18 @@ Configuration: ~
vim.g.pending = {
forge = {
auto_close = false,
warn_missing_cli = true,
github = {
token = nil,
icon = '',
issue_format = '%i %o/%r#%n',
instances = {},
},
gitlab = {
token = nil,
icon = '',
issue_format = '%i %o/%r#%n',
instances = {},
},
codeberg = {
token = nil,
icon = '',
issue_format = '%i %o/%r#%n',
instances = {},
@ -1524,27 +1522,27 @@ Configuration: ~
<
Top-level fields: ~
{auto_close} (boolean, default: false) When true, tasks linked to
closed/merged remote issues are automatically marked
done on buffer open.
{auto_close} (boolean, default: false) When true, tasks linked to
closed/merged remote issues are automatically marked
done on buffer open.
{warn_missing_cli} (boolean, default: true) When true, warns once per
forge per session if the CLI is missing or fails.
Fields (per forge): ~
{token} (string, optional) API token for authenticated requests.
Falls back to CLI: `gh auth token` (GitHub), `glab auth
token` (GitLab). Codeberg uses token only.
{icon} (string) Nerd font icon used in virtual text.
{issue_format} (string) Format string for the inline overlay label.
{instances} (string[]) Additional hostnames for self-hosted instances
(e.g. `{ 'github.company.com' }`).
Authentication: ~
Token retrieval is CLI-preferred, config fallback:
1. GitHub: `gh auth token` stdout. Falls back to `forge.github.token`.
2. GitLab: `glab auth token` stdout. Falls back to `forge.gitlab.token`.
3. Codeberg: `forge.codeberg.token` only (no standard CLI).
Forge metadata fetching uses each forge's native CLI. No tokens are
configured in pending.nvim — authenticate once in your shell:
1. GitHub: `gh auth login`
2. GitLab: `glab auth login`
3. Codeberg: `tea login add`
Unauthenticated requests work for public repositories. Private repositories
require a token.
Public repositories work without authentication. Private repositories
require a logged-in CLI session.
Metadata fetching: ~
On buffer open, tasks with a `_forge_ref` whose cached metadata is older