Skip to content

[Bugfix #1137] Fix gitea forge preset against the real tea CLI#1

Closed
pseudoseed wants to merge 4 commits into
mainfrom
builder/bugfix-1137
Closed

[Bugfix #1137] Fix gitea forge preset against the real tea CLI#1
pseudoseed wants to merge 4 commits into
mainfrom
builder/bugfix-1137

Conversation

@pseudoseed

Copy link
Copy Markdown
Owner

Summary

Fixes cluesmith#1137

The gitea forge preset was authored against the Gitea REST API JSON shape
but invoked the tea CLI, whose tea <entity> list/view output is a
flattened, --fields-limited view (and in some cases the referenced
flag/field/subcommand doesn't exist). Every read concept either errored or
emitted a shape that didn't match forge-contracts.ts.

Root Cause

tea exposes two divergent JSON surfaces:

  1. tea <entity> list/view --output json — flattened/limited (head/base are
    strings, no body/description, merged state synthesized, whoami has no JSON).
  2. tea api <endpoint> — a raw passthrough returning the canonical Gitea REST
    shape that codev's jq normalizers + forge-contracts.ts already assume.

The scripts read from (1); the contracts expect (2).

Fix

Route the read concepts through tea api:

Concept Change
user-identity tea api user | jq .login (tea whoami has no --output json)
pr-view tea api repos/<repo>/pulls/NPrViewResult
pr-list tea api repos/<repo>/pulls?state=openPrListItem[]; now also populates real reviewRequests/isDraft/body
pr-exists tea api repos/<repo>/pulls?state=all with nested .head.ref + .merged bool
issue-view tea api repos/<repo>/issues/N + a second call for the comments ARRAY (Gitea's issue object reports comments as an int count, which would crash consumers' .comments.filter(...))
recently-merged tea api repos/<repo>/pulls?state=closed, filter .merged, use real .merged_at
issue-comment tea comments add (tea issues has no comment subcommand)

tea api needs an explicit owner/repo path segment (unlike tea <entity>,
which auto-detects it from the local git remote), and most concepts are invoked
without CODEV_REPO set (e.g. pr-exists receives only CODEV_BRANCH_NAME),
so each api-based script derives owner/repo from the origin remote, honoring
CODEV_REPO when present.

Left issue-search untouched: it isn't in the issue's broken list, and its only
difference from the working issue-list is an unverified body field — changing
working/unverified code on assumption would violate minimal-change.

Test Plan

Note on the full test suite

The full npm test run shows 9 failures in unrelated files
(team-update collectEvents ×7, team-github, team-cli) — all 5s-timeout I/O
that hangs in this resource-starved worktree/environment. Confirmed failing on
the clean base without these changes, so they are pre-existing and
environmental (they pass in CI). This PR touches none of those files.

🤖 Generated with Claude Code

pseudoseed and others added 4 commits July 6, 2026 13:06
The gitea preset invoked `tea <entity> list/view/whoami/comment`, whose
flattened `--fields` output (or missing flags/subcommands) doesn't match the
Gitea REST shape that forge-contracts.ts and the jq normalizers assume. Route
the read concepts through `tea api`, the raw REST passthrough that returns
exactly that shape:

- user-identity: `tea api user | jq .login` (`tea whoami` has no --output json)
- pr-view:  `tea api repos/<repo>/pulls/N` → PrViewResult
- pr-list:  `tea api repos/<repo>/pulls?state=open` → PrListItem[]
            (now also populates real reviewRequests/isDraft/body)
- pr-exists: `tea api repos/<repo>/pulls?state=all` with nested .head.ref/.merged
- issue-view: `tea api repos/<repo>/issues/N` + a second call for the comments
             ARRAY (Gitea's issue object reports `comments` as an int count,
             which would crash consumers' `.comments.filter(...)`)
- recently-merged: `tea api repos/<repo>/pulls?state=closed`, filter .merged,
             using the real .merged_at
- issue-comment: `tea comments add` (`tea issues` has no `comment` subcommand)

`tea api` needs an explicit owner/repo path segment (unlike `tea <entity>`,
which auto-detects it from the local git remote), and most concepts are invoked
without CODEV_REPO set, so each api-based script derives owner/repo from the
origin remote, honoring CODEV_REPO when present.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Stubs a fake `tea` on PATH answering `api <endpoint>` with captured Gitea REST
fixtures (tea isn't in CI, per cluesmith#920), points the scripts at a throwaway repo
with a gitea remote, runs each real script, and asserts the normalized output
conforms to forge-contracts.ts — incl. comments-as-array, merged-only filtering,
open/merged/closed pr-exists cases, and CODEV_REPO override.

Also updates the cluesmith#568 pr-exists assertion for gitea to match the new
`state=all` query param (was `--state all` flag).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pseudoseed

Copy link
Copy Markdown
Owner Author

Superseded by the upstream bugfix PR cluesmith#1146 (same branch, targeting the codev repo). Closing this fork-internal duplicate.

@pseudoseed pseudoseed closed this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gitea forge preset is broken against the real tea CLI (0.14.2)

1 participant