capability_id: pr.update
version: "1.0.0"
description: Update pull request metadata (title, body, draft status).
input_schema:
  type: object
  required: [owner, name, prNumber]
  properties:
    owner: { type: string, minLength: 1 }
    name: { type: string, minLength: 1 }
    prNumber: { type: integer, minimum: 1 }
    title: { type: string, minLength: 1 }
    body: { type: string }
    draft: { type: boolean }
  additionalProperties: false
output_schema:
  type: object
  required: [number, url, title, state, draft]
  properties:
    number: { type: integer, minimum: 1 }
    url: { type: string, minLength: 1 }
    title: { type: string }
    state: { type: string }
    draft: { type: boolean }
  additionalProperties: false
routing:
  preferred: graphql
  fallbacks: [cli]
  suitability:
    - when: params
      predicate: cli if draft == true
      reason: draft updates require CLI
    - when: params
      predicate: cli if draft == false
      reason: draft updates require CLI
graphql:
  # GQL limitation: draft-only updates fall back to CLI
  operationName: PrUpdate
  operationType: mutation
  documentPath: src/gql/operations/pr-update.graphql
  # Resolution maps the user-facing inputs to the GraphQL mutation variables:
  # - pullRequestId is the GraphQL node id, looked up from owner/name/prNumber.
  # - title and body are passed through as-is, matching the GraphQL variable names.
  resolution:
    lookup:
      operationName: PrNodeId
      documentPath: src/gql/operations/pr-node-id.graphql
      vars:
        owner: owner
        name: name
        prNumber: prNumber
    inject:
      - target: pullRequestId
        source: scalar
        path: repository.pullRequest.id
cli:
  command: pr edit
