list --format json: give the API host of the forge (forge.hostname) in repo.forge
The friction
A tool that reads wt list --format json gets the forge of the repository in repo.forge: provider, host, owner and name. With forge.hostname set (an API host that is not the host of the remote), repo.forge.host stays the host of the remote. Thus the tool calls the CLI of the forge on the wrong host.
Example: a repository with the remote [email protected]:team/app.git, and this .config/wt.toml:
[forge]
platform = "gitea"
hostname = "api.company.example"
wt list --format json (wt 0.81.0) gives:
{"url":"https://git.company.example/team/app","provider":"gitea","host":"git.company.example","owner":"team","name":"app","remote":"origin"}
provider is resolved (gitea), but the API host is not in the JSON.
Current workaround
The tool reads wt config show --format json, and does the resolution of worktrunk again: the [forge] block of the project, then the [projects."<key>"] entries of the user config that match the identifier, with * and their specificity. This copy of the rules can drift from worktrunk.
Proposed solution
Add the resolved API host to repo.forge, for example api_host: the value of forge.hostname after the resolution, or the same value as host without forge.hostname.
Context
herdr-worktrunk is a plugin for herdr. It reads repo.forge to ask the forge for the pull requests of each worktree, with gh, glab, tea or az, as worktrunk does for its CI column.
This is a feature request, and I'm leaving it for a maintainer rather than opening a PR. The field would be a new key in the wt list --format json schema, and its name and meaning are product decisions.
The value you need is already computed. Repository::forge_hostname() applies the rules you're copying: the project's [forge].hostname first, then a matching [projects."…"].forge.hostname from user config. auth_host() implements your proposed fallback: forge.hostname when set, otherwise the remote's host. Nothing passes either value into repo_info(), which builds repo.forge. So adding the field means setting it in repo_info() and documenting it in the repo.forge table in the wt list help.
The tradeoff is which of those two values the field should report:
- Always present, with fallback to
host(as proposed). Consumers never need a branch. But it doesn't match every path Worktrunk takes. For a GitHub repo with noforge.hostname, the CI column callsgh apiwithout--hostname(ci_status/github.rs), soghpicks the host itself. In that case the field would name a host Worktrunk never passes. - Present only when
forge.hostnameresolves. This reports exactly what was configured, and a consumer falls back tohoston its own. Your tool would still drop its copy of the config-resolution rules, which is the part that can drift.