> ## Documentation Index
> Fetch the complete documentation index at: https://docs.githits.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Read a package or repository code file

> Read a source file from a package or public repository, either in full or as a range of lines. The response includes file information and identifies the version or commit the content came from.

Find file paths with `GET /v1/code/files`, or follow a code search result to inspect its surrounding implementation.

## Selector catalogue

Use the following selectors with the `fields` query parameter to choose which fields the response includes. See [Choose what the response includes](https://docs.githits.com/api/requests-and-responses#choose-what-the-response-includes) for details.

| `fields` selector | Returned group | Default |
| --- | --- | --- |
| `metadata` | `metadata { language, total_lines }` | Yes |
| `content` | `content { body, start_line, end_line }` | Yes |




## OpenAPI

````yaml https://api.githits.dev/v1/openapi.json get /v1/code/read
openapi: 3.1.0
info:
  description: >-
    Explore package metadata, security advisories, dependencies, documentation
    and source code with the GitHits API.


    ## Choose an operation


    | Task | Operations |

    | --- | --- |

    | Inspect a package | Release metadata, vulnerabilities and dependencies |

    | Review releases or upgrades | Changelog and batch upgrade reviews |

    | Read documentation | List package documentation, then read a page |

    | Navigate source code | List files, read a file or search text within a
    target |

    | Compare source trees | Compare files, line statistics and patches between
    package versions or repository refs |

    | Discover relevant content | Search across packages, repositories and
    documentation sites; retrieve a search's status and retained results |

    | Resolve a target name | Find ranked package, repository and
    documentation-site targets |

    | Ask a cited question | Generate an answer grounded in a package,
    repository or documentation site, or continue a conversation |

    | Generate an example | Generate and save a code example, then submit
    feedback |

    | Find a language identifier | Search supported programming languages |


    ## Authenticate and send requests


    The production API origin is `https://api.githits.dev`; development uses
    `https://api-dev.githits.dev`. Examples target production. Replace `<token>`
    with your GitHits token. Send the token in `Authorization: Bearer <token>`.
    JSON request bodies use `Content-Type: application/json`; public JSON field
    names use `snake_case`.


    Percent-encode a package name or opaque read target as one path segment,
    including any embedded slash. For query values, encode a literal plus sign
    as `%2B`; ordinary form decoding interprets `+` as a space. Each operation
    documents its accepted parameters and encoding rules.


    ## Select the data you need


    Where supported, `fields` is a comma-separated **query parameter**,
    including on POST requests. Omit it to use the operation's defaults.
    Supplying it replaces those defaults; required identity and information
    needed to interpret the result remain present.


    A **selector** names a supported **group** of response fields. Groups are
    atomic: their members are selected together. A **wildcard bundle**, such as
    `vulnerabilities.*`, selects only the groups listed for that bundle. A bare
    group does not automatically include nested groups. Arbitrary subfields and
    undeclared wildcards are not supported.


    Each operation lists its selectors, defaults, dependencies and the data they
    return. Selection can reduce transferred data without reducing the work
    needed to produce it; consult its parameter and response field
    documentation. Small fixed responses do not offer `fields`.


    ## Interpret responses and errors


    An omitted optional field can mean unselected or unavailable data, according
    to the operation's contract. Null has an operation-specific meaning: it can
    mark unavailable or inapplicable data, or an unselected search result. Empty
    arrays, zero and false are values, not substitutes for unavailable data.
    Always retain the result's completeness and freshness information when
    displaying or processing it.


    **Requested** identity records caller intent; **resolved** identity records
    what that intent resolved to; **served** identity identifies the artifact
    that produced the response. These can differ while indexing or refresh work
    continues. Use served identity when an exact follow-up read is required,
    preserving package-relative or repository-relative path scope.


    Errors normally use `application/problem+json`. Branch on the stable `code`,
    not the human-readable `detail`. Include `X-Request-ID` when reporting a
    problem; error `instance` matches that ID. Respect `Retry-After` when
    present. If request identity cannot be created, the response is an empty
    HTTP 500 without a request ID. Responses use `Cache-Control: no-store`.


    Timeouts do not guarantee that work stopped. Read the documented timeout
    responses, especially for Ask, generated examples and append-only feedback.
    Optional `X-GitHits-*` request headers attribute client, agent and session
    usage. The OpenAPI extension `x-githits-cost` is provisional operation
    metadata, not a price or a measure of computation.


    ## Contract status


    This API is pre-production. The external v1 contract is not yet frozen.
  license:
    name: Proprietary
  title: GitHits Public API
  version: 0.1.0
servers:
  - description: Production
    url: https://api.githits.dev
security: []
tags:
  - description: >-
      Package metadata, release history, vulnerabilities, dependency graphs and
      upgrade comparisons. Each operation documents its registry, version and
      evidence scope.
    name: Packages
  - description: >-
      Discover existing documentation pages and read their content with exact
      source locators and availability information.
    name: Documentation
  - description: >-
      Enumerate files, read exact content and grep within a package or
      repository. Responses retain served identity, indexing state and
      completeness information.
    name: Code
  - description: >-
      Discover evidence across package, repository and documentation-site
      targets, then retrieve retained search results and progress.
    name: Search
  - description: >-
      Find supported programming-language names and aliases for example
      requests.
    name: Languages
  - description: >-
      Generate code examples for programming tasks, with source references and
      license attribution.
    name: Examples
  - description: Rate generated examples or sessions and provide written feedback.
    name: Feedback
  - description: >-
      Preview operations for target resolution, source comparison and cited
      questions. Routes use /v1/experimental and may later move to permanent v1
      locations under a documented migration policy.
    name: Experimental
paths:
  /v1/code/read:
    get:
      tags:
        - Code
      summary: Read a package or repository code file
      description: >
        Read a source file from a package or public repository, either in full
        or as a range of lines. The response includes file information and
        identifies the version or commit the content came from.


        Find file paths with `GET /v1/code/files`, or follow a code search
        result to inspect its surrounding implementation.


        ## Selector catalogue


        Use the following selectors with the `fields` query parameter to choose
        which fields the response includes. See [Choose what the response
        includes](https://docs.githits.com/api/requests-and-responses#choose-what-the-response-includes)
        for details.


        | `fields` selector | Returned group | Default |

        | --- | --- | --- |

        | `metadata` | `metadata { language, total_lines }` | Yes |

        | `content` | `content { body, start_line, end_line }` | Yes |
      operationId: get_code_read
      parameters:
        - description: >-
            Package registry, required with name; mutually exclusive with
            repo_url.
          in: query
          name: registry
          required: false
          schema:
            enum:
              - npm
              - pypi
              - hex
              - crates
              - vcpkg
              - zig
              - nuget
              - maven
              - packagist
              - rubygems
              - go
              - swift
            type: string
        - description: >-
            Package name, up to 255 UTF-8 bytes; encode scoped names as
            %40scope%2Fpackage.
          in: query
          name: name
          required: false
          schema:
            type: string
        - description: >-
            Optional package version, up to 100 normalized bytes; omitted or
            blank retains latest-release intent. Forbidden with repo_url.
          in: query
          name: version
          required: false
          schema:
            type: string
        - description: >-
            Public GitHub, GitLab, or Codeberg repository root URL; cannot be
            combined with package parameters. HTTPS and git+https are supported
            on all three; GitHub also accepts http, git, ssh, and git+ssh. Use
            default ports and omit credentials, query strings, and fragments.
            Use HTTPS instead of scp-style shorthand.
          in: query
          name: repo_url
          required: false
          schema:
            type: string
        - description: >-
            Repository-only branch, tag or SHA, omission preserves
            default-branch intent.
          in: query
          name: git_ref
          required: false
          schema:
            type: string
        - description: >-
            Required exact target-relative file path. No absolute, parent, NUL
            or trailing directory boundary.
          in: query
          name: path
          required: true
          schema:
            type: string
        - description: >-
            Positive inclusive source start. Omitted means 1. Explicit ranges
            require content; starts past EOF and ranges on empty text are source
            validation errors.
          in: query
          name: start_line
          required: false
          schema:
            maximum: 2147483647
            minimum: 1
            type: integer
        - description: >-
            Last line to read, inclusive; must be positive and not precede
            start_line. Omission reads to the end of the file. Values past the
            end are clamped. Requires the content group.
          in: query
          name: end_line
          required: false
          schema:
            maximum: 2147483647
            minimum: 1
            type: integer
        - description: >-
            Time to wait for indexing: 0–60000 milliseconds, default 20000. The
            request deadline also includes the configured transport timeout.
          in: query
          name: wait_timeout_ms
          required: false
          schema:
            default: 20000
            maximum: 60000
            minimum: 0
            type: integer
        - description: >-
            Comma-separated atomic metadata/content groups; both default. No
            empty values, leaf paths or wildcard. Range arguments require
            content; at most 2048 decoded bytes.


            Use the case-sensitive selectors in the catalogue. Order and
            duplicate selectors do not affect the result. ASCII whitespace
            around selectors is ignored. The decoded value is limited to 2048
            UTF-8 bytes. Empty or unknown selectors and repeated `fields` query
            parameters return `400 VALIDATION_ERROR`. A group does not include
            nested groups unless the catalogue says so; only listed wildcard
            bundles are supported.
          in: query
          name: fields
          required: false
          schema:
            default: metadata,content
            type: string
        - description: >-
            Optional client attribution: trimmed printable ASCII, at most 80
            bytes. Invalid optional values are dropped.
          in: header
          name: X-GitHits-Client-Name
          required: false
          schema:
            type: string
        - description: >-
            Optional client-version attribution: trimmed printable ASCII, at
            most 80 bytes. Invalid optional values are dropped.
          in: header
          name: X-GitHits-Client-Version
          required: false
          schema:
            type: string
        - description: >-
            Optional agent attribution: trimmed printable ASCII, at most 160
            bytes. Invalid optional values are dropped.
          in: header
          name: X-GitHits-Agent
          required: false
          schema:
            type: string
        - description: >-
            Optional session attribution: trimmed printable ASCII, at most 128
            bytes. Invalid optional values are dropped; no session is created.
          in: header
          name: X-GitHits-Session-ID
          required: false
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              examples:
                binary:
                  value:
                    code_index_state: current
                    content:
                      body: null
                      end_line: null
                      start_line: null
                    indexing_ref: null
                    is_binary: true
                    metadata:
                      language: null
                      total_lines: null
                    path: src/main.rs
                    target_resolution:
                      freshness: current
                      freshness_reason: exact_current
                      requested:
                        commit_sha: null
                        git_ref: main
                        kind: repo_branch
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                      resolved_requested:
                        commit_sha: 0123456789abcdef0123456789abcdef01234567
                        git_ref: 0123456789abcdef0123456789abcdef01234567
                        kind: null
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                      served:
                        commit_sha: 0123456789abcdef0123456789abcdef01234567
                        git_ref: 0123456789abcdef0123456789abcdef01234567
                        kind: null
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                content_only:
                  value:
                    code_index_state: current
                    content:
                      body: |
                        α
                        β
                      end_line: 2
                      start_line: 1
                    indexing_ref: null
                    is_binary: false
                    path: src/main.rs
                    target_resolution:
                      freshness: current
                      freshness_reason: exact_current
                      requested:
                        commit_sha: null
                        git_ref: main
                        kind: repo_branch
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                      resolved_requested:
                        commit_sha: 0123456789abcdef0123456789abcdef01234567
                        git_ref: 0123456789abcdef0123456789abcdef01234567
                        kind: null
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                      served:
                        commit_sha: 0123456789abcdef0123456789abcdef01234567
                        git_ref: 0123456789abcdef0123456789abcdef01234567
                        kind: null
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                empty:
                  value:
                    code_index_state: current
                    content:
                      body: ''
                      end_line: 0
                      start_line: 0
                    indexing_ref: null
                    is_binary: false
                    metadata:
                      language: rust
                      total_lines: 0
                    path: src/main.rs
                    target_resolution:
                      freshness: current
                      freshness_reason: exact_current
                      requested:
                        commit_sha: null
                        git_ref: main
                        kind: repo_branch
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                      resolved_requested:
                        commit_sha: 0123456789abcdef0123456789abcdef01234567
                        git_ref: 0123456789abcdef0123456789abcdef01234567
                        kind: null
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                      served:
                        commit_sha: 0123456789abcdef0123456789abcdef01234567
                        git_ref: 0123456789abcdef0123456789abcdef01234567
                        kind: null
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                full:
                  value:
                    code_index_state: current
                    content:
                      body: |
                        α
                        β
                      end_line: 2
                      start_line: 1
                    indexing_ref: null
                    is_binary: false
                    metadata:
                      language: rust
                      total_lines: 2
                    path: src/main.rs
                    target_resolution:
                      freshness: current
                      freshness_reason: exact_current
                      requested:
                        commit_sha: null
                        git_ref: main
                        kind: repo_branch
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                      resolved_requested:
                        commit_sha: 0123456789abcdef0123456789abcdef01234567
                        git_ref: 0123456789abcdef0123456789abcdef01234567
                        kind: null
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                      served:
                        commit_sha: 0123456789abcdef0123456789abcdef01234567
                        git_ref: 0123456789abcdef0123456789abcdef01234567
                        kind: null
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                metadata_only:
                  value:
                    code_index_state: current
                    indexing_ref: null
                    is_binary: false
                    metadata:
                      language: rust
                      total_lines: 2
                    path: src/main.rs
                    target_resolution:
                      freshness: current
                      freshness_reason: exact_current
                      requested:
                        commit_sha: null
                        git_ref: main
                        kind: repo_branch
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                      resolved_requested:
                        commit_sha: 0123456789abcdef0123456789abcdef01234567
                        git_ref: 0123456789abcdef0123456789abcdef01234567
                        kind: null
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                      served:
                        commit_sha: 0123456789abcdef0123456789abcdef01234567
                        git_ref: 0123456789abcdef0123456789abcdef01234567
                        kind: null
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                ranged:
                  value:
                    code_index_state: current
                    content:
                      body: β
                      end_line: 2
                      start_line: 2
                    indexing_ref: null
                    is_binary: false
                    metadata:
                      language: rust
                      total_lines: 2
                    path: src/main.rs
                    target_resolution:
                      freshness: current
                      freshness_reason: exact_current
                      requested:
                        commit_sha: null
                        git_ref: main
                        kind: repo_branch
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                      resolved_requested:
                        commit_sha: 0123456789abcdef0123456789abcdef01234567
                        git_ref: 0123456789abcdef0123456789abcdef01234567
                        kind: null
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
                      served:
                        commit_sha: 0123456789abcdef0123456789abcdef01234567
                        git_ref: 0123456789abcdef0123456789abcdef01234567
                        kind: null
                        name: null
                        registry: null
                        repo_url: https://github.com/example/repository
                        version: null
              schema:
                $ref: '#/components/schemas/CodeReadResponse'
          description: Qualified source file
          headers:
            Cache-Control:
              schema:
                enum:
                  - no-store
                type: string
            x-request-id:
              description: Active trace identity, also problem.instance.
              schema:
                type: string
        '400':
          content:
            application/problem+json:
              example:
                code: VALIDATION_ERROR
                detail: The request is invalid.
                instance: 4bf92f3577b34da6a3ce929d0e0e4736
                status: 400
                title: Validation error
                type: about:blank
              schema:
                $ref: '#/components/schemas/ProblemResponse'
          description: VALIDATION_ERROR
          headers:
            Cache-Control:
              schema:
                enum:
                  - no-store
                type: string
            x-request-id:
              description: Active trace identity, also problem.instance.
              schema:
                type: string
        '401':
          content:
            application/problem+json:
              example:
                code: AUTHENTICATION_REQUIRED
                detail: A bearer credential is required.
                instance: 4bf92f3577b34da6a3ce929d0e0e4736
                status: 401
                title: Authentication required
                type: about:blank
              schema:
                $ref: '#/components/schemas/ProblemResponse'
          description: AUTHENTICATION_REQUIRED
          headers:
            Cache-Control:
              schema:
                enum:
                  - no-store
                type: string
            WWW-Authenticate:
              description: Bearer challenge.
              schema:
                type: string
            x-request-id:
              description: Active trace identity, also problem.instance.
              schema:
                type: string
        '403':
          content:
            application/problem+json:
              example:
                code: FORBIDDEN
                detail: The caller is not allowed to access this resource.
                instance: 4bf92f3577b34da6a3ce929d0e0e4736
                status: 403
                title: Forbidden
                type: about:blank
              schema:
                $ref: '#/components/schemas/ProblemResponse'
          description: >-
            FORBIDDEN, ACCOUNT_INACTIVE, FEATURE_FLAG_REQUIRED,
            TERMS_ACCEPTANCE_REQUIRED
          headers:
            Cache-Control:
              schema:
                enum:
                  - no-store
                type: string
            x-request-id:
              description: Active trace identity, also problem.instance.
              schema:
                type: string
        '404':
          content:
            application/problem+json:
              example:
                code: FILE_NOT_FOUND
                detail: The requested file is absent from the indexed target.
                instance: 4bf92f3577b34da6a3ce929d0e0e4736
                status: 404
                title: File not found
                type: about:blank
              schema:
                $ref: '#/components/schemas/ProblemResponse'
          description: >-
            FILE_NOT_FOUND, PACKAGE_NOT_FOUND, NO_RELEASED_VERSIONS,
            VERSION_NOT_FOUND, REPOSITORY_NOT_FOUND, REF_NOT_FOUND
          headers:
            Cache-Control:
              schema:
                enum:
                  - no-store
                type: string
            x-request-id:
              description: Active trace identity, also problem.instance.
              schema:
                type: string
        '405':
          content:
            application/problem+json:
              example:
                code: METHOD_NOT_ALLOWED
                detail: The requested method is not supported for this route.
                instance: 4bf92f3577b34da6a3ce929d0e0e4736
                status: 405
                title: Method not allowed
                type: about:blank
              schema:
                $ref: '#/components/schemas/ProblemResponse'
          description: 'METHOD_NOT_ALLOWED: the route does not support this HTTP method.'
          headers:
            Allow:
              description: 'Supported methods: GET, HEAD.'
              schema:
                type: string
            Cache-Control:
              schema:
                enum:
                  - no-store
                type: string
            X-Request-ID:
              description: >-
                Request trace ID for diagnostics; matches problem.instance on
                failures.
              schema:
                type: string
        '422':
          content:
            application/problem+json:
              example:
                code: FILE_PATH_EXCLUDED
                detail: The source excludes this path from the indexed target.
                instance: 4bf92f3577b34da6a3ce929d0e0e4736
                status: 422
                title: File path excluded
                type: about:blank
              schema:
                $ref: '#/components/schemas/ProblemResponse'
          description: >-
            FILE_PATH_EXCLUDED, SOURCE_FILE_INVENTORY_UNKNOWN,
            UNSUPPORTED_PACKAGE_VARIANTS, AMBIGUOUS_REF, REF_UNRESOLVABLE
          headers:
            Cache-Control:
              schema:
                enum:
                  - no-store
                type: string
            x-request-id:
              description: Active trace identity, also problem.instance.
              schema:
                type: string
        '429':
          content:
            application/problem+json:
              example:
                code: RATE_LIMITED
                detail: The request was rate limited.
                instance: 4bf92f3577b34da6a3ce929d0e0e4736
                status: 429
                title: Rate limited
                type: about:blank
              schema:
                $ref: '#/components/schemas/ProblemResponse'
          description: RATE_LIMITED
          headers:
            Cache-Control:
              schema:
                enum:
                  - no-store
                type: string
            Retry-After:
              description: Optional bounded delta seconds or HTTP date.
              schema:
                type: string
            x-request-id:
              description: Active trace identity, also problem.instance.
              schema:
                type: string
        '500':
          description: >-
            Request identity could not be created. Empty body without
            X-Request-ID; no problem object is available.
          headers:
            Cache-Control:
              schema:
                enum:
                  - no-store
                type: string
          x-githits-empty-identity-failure: true
        '502':
          content:
            application/problem+json:
              example:
                code: UPSTREAM_ERROR
                detail: The upstream service failed to provide a response.
                instance: 4bf92f3577b34da6a3ce929d0e0e4736
                status: 502
                title: Upstream error
                type: about:blank
              schema:
                $ref: '#/components/schemas/ProblemResponse'
          description: UPSTREAM_ERROR
          headers:
            Cache-Control:
              schema:
                enum:
                  - no-store
                type: string
            x-request-id:
              description: Active trace identity, also problem.instance.
              schema:
                type: string
        '503':
          content:
            application/problem+json:
              example:
                code: PACKAGE_INDEXING
                detail: Code evidence is not ready; retry the request later.
                instance: 4bf92f3577b34da6a3ce929d0e0e4736
                status: 503
                title: Code indexing
                type: about:blank
              schema:
                $ref: '#/components/schemas/ProblemResponse'
          description: PACKAGE_INDEXING
          headers:
            Cache-Control:
              schema:
                enum:
                  - no-store
                type: string
            x-request-id:
              description: Active trace identity, also problem.instance.
              schema:
                type: string
        '504':
          content:
            application/problem+json:
              example:
                code: TIMEOUT
                detail: The upstream request did not complete in time.
                instance: 4bf92f3577b34da6a3ce929d0e0e4736
                status: 504
                title: Upstream timeout
                type: about:blank
              schema:
                $ref: '#/components/schemas/ProblemResponse'
          description: TIMEOUT
          headers:
            Cache-Control:
              schema:
                enum:
                  - no-store
                type: string
            x-request-id:
              description: Active trace identity, also problem.instance.
              schema:
                type: string
      security:
        - bearer_auth: []
      x-codeSamples:
        - label: Full package file
          lang: HTTP
          source: >-
            GET
            /v1/code/read?registry=npm&name=%40scope%2Fpackage&path=src%2Findex.js
            HTTP/1.1

            Host: api.githits.dev

            Authorization: Bearer <token>
        - label: Repository range
          lang: HTTP
          source: >-
            GET
            /v1/code/read?repo_url=https%3A%2F%2Fgithub.com%2Fexample%2Frepository&git_ref=main&path=src%2Fmain.rs&start_line=1&end_line=40
            HTTP/1.1

            Host: api.githits.dev

            Authorization: Bearer <token>
        - label: Metadata only
          lang: HTTP
          source: >-
            GET
            /v1/code/read?registry=crates&name=serde&path=src%2Flib.rs&fields=metadata
            HTTP/1.1

            Host: api.githits.dev

            Authorization: Bearer <token>
components:
  schemas:
    CodeReadResponse:
      description: >-
        One exact file with mandatory source provenance and atomic selected
        groups.
      properties:
        code_index_state:
          $ref: '#/components/schemas/CodeIndexState'
          description: Freshness of the served artifact; pending work is a typed error.
        content:
          $ref: '#/components/schemas/CodeContent'
          description: Atomic source content group; omitted only when not selected.
        indexing_ref:
          description: >-
            Active source indexing reference, null when absent; may accompany
            serveable evidence.
          type:
            - string
            - 'null'
        is_binary:
          description: True for non-UTF-8 files; selected body and line counters are null.
          type: boolean
        metadata:
          $ref: '#/components/schemas/CodeMetadata'
          description: Atomic metadata group; omitted only when not selected.
        path:
          description: Canonical target-relative source file path.
          type: string
        target_resolution:
          $ref: '#/components/schemas/CodeTargetResolution'
          description: Requested intent, current resolution and actually served artifact.
      required:
        - path
        - is_binary
        - target_resolution
        - code_index_state
        - indexing_ref
      type: object
    ProblemResponse:
      description: >-
        The stable problem document returned for an unsuccessful public API
        request.
      properties:
        acceptance_url:
          description: An optional acceptance URL supplied by the upstream allow-list.
          type: string
        code:
          description: The stable uppercase API error code.
          type: string
        detail:
          description: A stable, client-safe explanation of the failure.
          type: string
        instance:
          description: The active request trace ID.
          type: string
        status:
          description: The HTTP status returned with this problem.
          format: int32
          minimum: 0
          type: integer
        terms_url:
          description: An optional terms URL supplied by the upstream allow-list.
          type: string
        title:
          description: A short, stable title for the error.
          type: string
        type:
          description: The generic RFC 9457 problem type.
          type: string
      required:
        - type
        - title
        - status
        - detail
        - instance
        - code
      type: object
    CodeIndexState:
      description: >-
        Serveable code lifecycle states; pending work produces
        `PACKAGE_INDEXING`.
      enum:
        - current
        - stale
        - provisional
      type: string
    CodeContent:
      description: >-
        Returned source text and its inclusive range; the gateway does not slice
        text.
      properties:
        body:
          description: >-
            Full or ranged text, empty string for empty text files, null for
            binary files.
          type:
            - string
            - 'null'
        end_line:
          description: >-
            Last returned line, clamped to EOF; zero for empty text, null for
            binary.
          format: int32
          minimum: 0
          type:
            - integer
            - 'null'
        start_line:
          description: First returned line, 1-based; zero for empty text, null for binary.
          format: int32
          minimum: 0
          type:
            - integer
            - 'null'
      required:
        - body
        - start_line
        - end_line
      type: object
    CodeMetadata:
      description: Small source file metadata; null remains distinct from zero.
      properties:
        language:
          description: Detected language, null for binary or unknown languages.
          type:
            - string
            - 'null'
        total_lines:
          description: >-
            Full-file line count, zero for empty text, null for binary. A
            trailing newline terminates the last line.
          format: int32
          minimum: 0
          type:
            - integer
            - 'null'
      required:
        - language
        - total_lines
      type: object
    CodeTargetResolution:
      description: Source-reported identity; never reconstructed from caller input.
      properties:
        freshness:
          description: 'Source freshness: current, `fallback_recent` or provisional.'
          type: string
        freshness_reason:
          description: Machine-readable source explanation of freshness.
          type: string
        requested:
          $ref: '#/components/schemas/CodeIdentity'
          description: Original request intent including omitted version or default branch.
        resolved_requested:
          $ref: '#/components/schemas/CodeIdentity'
          description: Current resolved request; may be fresher than the served artifact.
        served:
          $ref: '#/components/schemas/CodeIdentity'
          description: >-
            Exact served artifact; prefer `commit_sha` over `git_ref` for
            repository pagination.
      required:
        - requested
        - resolved_requested
        - served
        - freshness
        - freshness_reason
      type: object
    CodeIdentity:
      description: >-
        One side of source target resolution; unknown metadata is explicitly
        null.
      properties:
        commit_sha:
          description: Exact commit when known; preferred artifact pin.
          type:
            - string
            - 'null'
        git_ref:
          description: Requested or served ref according to this identity side.
          type:
            - string
            - 'null'
        kind:
          description: >-
            Original request kind on requested identity; null on concrete
            identities.
          type:
            - string
            - 'null'
        name:
          description: Canonical package name, null for repository targets.
          type:
            - string
            - 'null'
        registry:
          description: Canonical package registry, null for repository targets.
          type:
            - string
            - 'null'
        repo_url:
          description: Repository backing the target when known.
          type:
            - string
            - 'null'
        version:
          description: Concrete package version when resolved; null for repository targets.
          type:
            - string
            - 'null'
      required:
        - kind
        - registry
        - name
        - version
        - repo_url
        - git_ref
        - commit_sha
      type: object
  securitySchemes:
    bearer_auth:
      scheme: bearer
      type: http

````