Skip to content

fix(codegen): GraphQL operations are tagged by the entity they act on - #726

Merged
leemour merged 2 commits into
mainfrom
fix/api-entity-groups
Nov 25, 2026
Merged

leemour merged 2 commits into
mainfrom
fix/api-entity-groups

Conversation

@leemour

@leemour leemour commented Nov 25, 2026

Copy link
Copy Markdown
Member

Task

linear-cli's agent skill split the API into two pages: mutation (336 commands, 4,335 lines) and query (157). An agent that wanted to archive an issue had to read the whole mutation page. GraphQL operations should be grouped by the entity they act on, as OpenAPI CLIs group by tag, without renaming any command.

What

  • adaptGraphql gives each operation two tags: first the entity its field name acts on, then query or mutation as before.
  • The entity is the earliest, then longest, run of the field name's words that names an object type with an id. The last word is also read singular. Examples: issueLabels → issue-label, searchIssues → issue.
  • A mutation's whole name is never its entity. Linear's projectUpdate mutation changes a Project, while ProjectUpdate is a status post type.
  • A name with no entity in it (rateLimitStatus, logout) keeps query or mutation, so the few leftovers share one page.
  • apiSkillFiles already files one page per first tag, so nothing changed there.
  • Commands, command names and permission keys do not change. api list tag:mutation still works.
  • names.groups: "tags" would now mount GraphQL commands by entity. No GraphQL CLI uses it (linear and the kit seed use fromPath).
  • Docs: REFERENCE.md and kit-surface.md. Changelog fragment: changes/fix-api-entity-groups.md.

Testing

  • src/codegen tests pass (184), including a new test of the tags (a snake_case name, and a mutation named like an entity). pnpm ci:quick, pnpm lint and pnpm docs:check pass.
  • I regenerated linear-cli (release/1.0, in a temp worktree, local packs through a pnpm override, not committed). Before: 2 groups. After: 70 groups, 493 commands in total. Some of them:
Group Commands read write destructive
issue 25 10 13 2
project 12 4 6 2
document 8 3 4 1
comment 7 2 4 1
team 9 3 3 3
cycle 7 2 4 1
initiative 10 3 5 2
attachment 20 5 14 1
integration (largest) 46 4 39 3
query (leftovers) 8 8 0 0
mutation (leftovers) 13 0 12 1

api-issue.md is 352 lines, down from 4,335 for api-mutation.md. The old pages are pruned because writeArtifacts owns references/api/.

The companion cli-core PR refuses empty required arguments.

🤖 Generated with Claude Code

leemour and others added 2 commits November 25, 2026 11:06
A GraphQL CLI's agent skill had two API pages, query and mutation;
Linear's mutation page is 336 commands and 4,335 lines, so an agent
that wanted to archive an issue read all of it.

adaptGraphql now gives each operation two tags: first the entity its
field name acts on (the earliest, then longest, run of its words that
names an object type with an id, last word read singular; never a
mutation's whole name), then query or mutation as before. apiSkillFiles
files one page per first tag, so `<cli> skill show api-issue` is the
page to read. Commands, their names and permission keys do not change;
`api list tag:mutation` still works.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A page per leading verb (rate, verify, track) told an agent nothing and
moved whenever a type was added; the few leftovers share the query or
mutation page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leemour
leemour merged commit 2272db3 into main Nov 25, 2026
9 of 10 checks passed
@leemour
leemour deleted the fix/api-entity-groups branch November 25, 2026 10:19
leemour added a commit to WireCatLabs/cli-core that referenced this pull request Nov 25, 2026
## Task

`linear live api issue-delete --id "" --yes --json` sent the request. It
answered exit 14 `outcome.unknown` ("Linear did not confirm a write"). A
required argument that is empty must be refused locally before any
request, with exit 2 `input.invalid`, naming the flag. OpenAPI CLIs must
behave the same.

## What

- `generatedApiCommand` refuses a required path, query or header
parameter that is empty or only spaces, before anything is sent. It
answers `validation_error`, which is exit 2 with reason `input.invalid`,
and the details say `sent: false`. On OpenAPI an empty path segment
could reach another endpoint (`/posts/`).
- `graphqlVariables` treats a blank required variable as missing, from a
flag or from `--body`. This covers the command and `serviceApiWriter`.
- `serviceApiWriter` refuses a blank required path, query or header
parameter from code too.
- A bot API body field (rpc) is still sent when it is empty. Telegram
documents `setWebhook --url ""` as the way to remove a webhook, and
tg-cli marks `url` as required. The review found this.
- A missing required field inside an input object was already refused by
the generated request schema. I checked this on linear: `issue-create
--input '{}'` gives exit 2 and names `input.teamId`.
- Changelog fragment: `changes/fix-api-empty-required.md`.

## Testing

- New tests:
- GraphQL: `--id ""`, `--id " "` and `--body '{"id":""}'` each give exit
2 and name `--id`, and nothing is sent.
- OpenAPI: a path parameter is refused by the command and by the writer.
- Bot: a required query parameter is refused, and an empty rpc body
field still goes through.
- I checked that the GraphQL and OpenAPI tests fail without the fix.
- `src/cli/service-api*`, `src/cli/bot` and `src/parity` pass. `pnpm
ci:quick`, `pnpm lint` and `pnpm docs:check` pass.
- I built linear-cli `release/1.0` against a local pack in a temp
worktree with throwaway config folders and no sign-in. `linear live api
issue-delete --id "" --yes --json` now prints
`{"error":{"code":"validation_error","reason":"input.invalid","message":"issue-delete
needs --id","details":{"sent":false}}}` with exit 2.

The companion cli-base PR is WireCatLabs/cli-base#726 (api skill groups
by entity).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant