> ## 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.

# Compare two exact source trees

> Compare source changes between two package versions or two refs in a public repository. The response lists changed files and can include added and deleted line counts and patches.

Use this experimental endpoint to inspect the code behind a release or upgrade. Comparisons cover the whole repository, including when you identify it through a package.

## 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.

| Selector | Data | Default |
| --- | --- | --- |
| `files` | Identity/status fields and content safety; inventory only | No |
| `files.stats` | Adds nullable additions/deletions; implies `files` and requests stats | No |
| `files.patch` | Adds nullable patch and omission reason; implies stats and requests patches | Yes |




## OpenAPI

````yaml https://api.githits.dev/v1/openapi.json post /v1/experimental/code/diff
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/experimental/code/diff:
    post:
      tags:
        - Experimental
      summary: Compare two exact source trees
      description: >
        Compare source changes between two package versions or two refs in a
        public repository. The response lists changed files and can include
        added and deleted line counts and patches.


        Use this experimental endpoint to inspect the code behind a release or
        upgrade. Comparisons cover the whole repository, including when you
        identify it through a package.


        ## 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.


        | Selector | Data | Default |

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

        | `files` | Identity/status fields and content safety; inventory only |
        No |

        | `files.stats` | Adds nullable additions/deletions; implies `files` and
        requests stats | No |

        | `files.patch` | Adds nullable patch and omission reason; implies stats
        and requests patches | Yes |
      operationId: code_diff
      parameters:
        - description: >-
            Finite comma-separated selectors: files, files.stats, and
            files.patch. The default is files.patch. Dependencies are additive;
            repeated selector tokens are idempotent. Unknown, empty, leaf, and
            wildcard selectors, plus repeated fields query parameters, are
            rejected.


            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: files.patch
            maxLength: 2048
            type: string
        - description: Optional trimmed printable ASCII client name, maximum 80 bytes.
          in: header
          name: X-GitHits-Client-Name
          required: false
          schema:
            type: string
        - description: Optional trimmed printable ASCII client version, maximum 80 bytes.
          in: header
          name: X-GitHits-Client-Version
          required: false
          schema:
            type: string
        - description: >-
            Optional trimmed printable ASCII agent attribution, maximum 160
            bytes.
          in: header
          name: X-GitHits-Agent
          required: false
          schema:
            type: string
        - description: >-
            Optional session attribution, maximum 128 printable ASCII bytes;
            malformed values are dropped.
          in: header
          name: X-GitHits-Session-ID
          required: false
          schema:
            type: string
      requestBody:
        content:
          application/json:
            examples:
              package:
                value:
                  from_version: 4.21.2
                  max_files: 50
                  name: express
                  path_glob: lib/**
                  registry: npm
                  to_version: 5.1.0
              repository:
                value:
                  from_ref: v1.0.0
                  repo_url: https://gitlab.com/group/project
                  to_ref: main
            schema:
              $ref: '#/components/schemas/CodeDiffRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                content_failed:
                  value:
                    content_coverage: failed
                    content_failure:
                      code: UPSTREAM_ERROR
                      limit_kind: null
                      retry_after_ms: 2500
                      retryable: true
                      stage: content
                    files:
                      - additions: 2
                        content_omission_reason: null
                        content_safety:
                          filtered: false
                          modifications: []
                        content_status: patch
                        deletions: 1
                        mode_changed: false
                        patch: |-
                          @@ -1 +1,2 @@
                          -old
                          +new
                        path: lib/application.js
                        path_encoding: utf8
                        status: modified
                        type_changed: false
                    from_resolution:
                      commit_sha: 0123456789abcdef0123456789abcdef01234567
                      ref: refs/tags/4.21.2
                      ref_kind: tag
                      requested: 4.21.2
                      resolved_version: 4.21.2
                      version_source: registry
                    has_more_files: false
                    package:
                      name: express
                      registry: npm
                      repo_url: https://github.com/expressjs/express
                    scope:
                      from_subpath: null
                      path_glob: null
                      path_prefix: null
                      status: repository
                      to_subpath: null
                    summary:
                      added: 0
                      deleted: 0
                      files_changed: 1
                      inventory_complete: true
                      mode_changed: 0
                      modified: 1
                      type_changed: 0
                      unprojectable_files: 0
                    to_resolution:
                      commit_sha: fedcba9876543210fedcba9876543210fedcba98
                      ref: refs/tags/5.1.0
                      ref_kind: tag
                      requested: 5.1.0
                      resolved_version: 5.1.0
                      version_source: registry
                empty:
                  value:
                    content_coverage: complete
                    content_failure: null
                    files: []
                    from_resolution:
                      commit_sha: 0123456789abcdef0123456789abcdef01234567
                      ref: refs/tags/4.21.2
                      ref_kind: tag
                      requested: 4.21.2
                      resolved_version: 4.21.2
                      version_source: registry
                    has_more_files: false
                    package:
                      name: express
                      registry: npm
                      repo_url: https://github.com/expressjs/express
                    scope:
                      from_subpath: null
                      path_glob: null
                      path_prefix: null
                      status: repository
                      to_subpath: null
                    summary:
                      added: 0
                      deleted: 0
                      files_changed: 0
                      inventory_complete: true
                      mode_changed: 0
                      modified: 0
                      type_changed: 0
                      unprojectable_files: 0
                    to_resolution:
                      commit_sha: fedcba9876543210fedcba9876543210fedcba98
                      ref: refs/tags/5.1.0
                      ref_kind: tag
                      requested: 5.1.0
                      resolved_version: 5.1.0
                      version_source: registry
                inventory_only:
                  value:
                    content_coverage: not_requested
                    content_failure: null
                    files:
                      - content_safety:
                          filtered: false
                          modifications: []
                        content_status: not_requested
                        mode_changed: false
                        path: lib/application.js
                        path_encoding: utf8
                        status: modified
                        type_changed: false
                    from_resolution:
                      commit_sha: 0123456789abcdef0123456789abcdef01234567
                      ref: refs/tags/4.21.2
                      ref_kind: tag
                      requested: 4.21.2
                      resolved_version: 4.21.2
                      version_source: registry
                    has_more_files: false
                    package:
                      name: express
                      registry: npm
                      repo_url: https://github.com/expressjs/express
                    scope:
                      from_subpath: null
                      path_glob: null
                      path_prefix: null
                      status: repository
                      to_subpath: null
                    summary:
                      added: 0
                      deleted: 0
                      files_changed: 1
                      inventory_complete: true
                      mode_changed: 0
                      modified: 1
                      type_changed: 0
                      unprojectable_files: 0
                    to_resolution:
                      commit_sha: fedcba9876543210fedcba9876543210fedcba98
                      ref: refs/tags/5.1.0
                      ref_kind: tag
                      requested: 5.1.0
                      resolved_version: 5.1.0
                      version_source: registry
                metadata_only:
                  value:
                    content_coverage: complete
                    content_failure: null
                    files:
                      - additions: null
                        content_omission_reason: null
                        content_safety:
                          filtered: false
                          modifications: []
                        content_status: metadata_only
                        deletions: null
                        mode_changed: true
                        patch: null
                        path: submodule
                        path_encoding: utf8
                        status: modified
                        type_changed: true
                    from_resolution:
                      commit_sha: 0123456789abcdef0123456789abcdef01234567
                      ref: refs/tags/4.21.2
                      ref_kind: tag
                      requested: 4.21.2
                      resolved_version: 4.21.2
                      version_source: registry
                    has_more_files: false
                    package:
                      name: express
                      registry: npm
                      repo_url: https://github.com/expressjs/express
                    scope:
                      from_subpath: null
                      path_glob: null
                      path_prefix: null
                      status: repository
                      to_subpath: null
                    summary:
                      added: 0
                      deleted: 0
                      files_changed: 1
                      inventory_complete: true
                      mode_changed: 0
                      modified: 1
                      type_changed: 0
                      unprojectable_files: 0
                    to_resolution:
                      commit_sha: fedcba9876543210fedcba9876543210fedcba98
                      ref: refs/tags/5.1.0
                      ref_kind: tag
                      requested: 5.1.0
                      resolved_version: 5.1.0
                      version_source: registry
                partial_content:
                  value:
                    content_coverage: partial
                    content_failure: null
                    files:
                      - additions: null
                        content_omission_reason: total_patch_bytes
                        content_safety:
                          filtered: false
                          modifications: []
                        content_status: omitted
                        deletions: null
                        mode_changed: false
                        patch: null
                        path: lib/large.js
                        path_encoding: utf8
                        status: modified
                        type_changed: false
                    from_resolution:
                      commit_sha: 0123456789abcdef0123456789abcdef01234567
                      ref: refs/tags/4.21.2
                      ref_kind: tag
                      requested: 4.21.2
                      resolved_version: 4.21.2
                      version_source: registry
                    has_more_files: false
                    package:
                      name: express
                      registry: npm
                      repo_url: https://github.com/expressjs/express
                    scope:
                      from_subpath: null
                      path_glob: null
                      path_prefix: null
                      status: repository
                      to_subpath: null
                    summary:
                      added: 0
                      deleted: 0
                      files_changed: 1
                      inventory_complete: true
                      mode_changed: 0
                      modified: 1
                      type_changed: 0
                      unprojectable_files: 0
                    to_resolution:
                      commit_sha: fedcba9876543210fedcba9876543210fedcba98
                      ref: refs/tags/5.1.0
                      ref_kind: tag
                      requested: 5.1.0
                      resolved_version: 5.1.0
                      version_source: registry
                patch:
                  value:
                    content_coverage: complete
                    content_failure: null
                    files:
                      - additions: 2
                        content_omission_reason: null
                        content_safety:
                          filtered: false
                          modifications: []
                        content_status: patch
                        deletions: 1
                        mode_changed: false
                        patch: |-
                          @@ -1 +1,2 @@
                          -old
                          +new
                        path: lib/application.js
                        path_encoding: utf8
                        status: modified
                        type_changed: false
                    from_resolution:
                      commit_sha: 0123456789abcdef0123456789abcdef01234567
                      ref: refs/tags/4.21.2
                      ref_kind: tag
                      requested: 4.21.2
                      resolved_version: 4.21.2
                      version_source: registry
                    has_more_files: false
                    package:
                      name: express
                      registry: npm
                      repo_url: https://github.com/expressjs/express
                    scope:
                      from_subpath: null
                      path_glob: null
                      path_prefix: null
                      status: repository
                      to_subpath: null
                    summary:
                      added: 0
                      deleted: 0
                      files_changed: 1
                      inventory_complete: true
                      mode_changed: 0
                      modified: 1
                      type_changed: 0
                      unprojectable_files: 0
                    to_resolution:
                      commit_sha: fedcba9876543210fedcba9876543210fedcba98
                      ref: refs/tags/5.1.0
                      ref_kind: tag
                      requested: 5.1.0
                      resolved_version: 5.1.0
                      version_source: registry
                stats:
                  value:
                    content_coverage: complete
                    content_failure: null
                    files:
                      - additions: 2
                        content_safety:
                          filtered: false
                          modifications: []
                        content_status: stats
                        deletions: 1
                        mode_changed: false
                        path: lib/application.js
                        path_encoding: utf8
                        status: modified
                        type_changed: false
                    from_resolution:
                      commit_sha: 0123456789abcdef0123456789abcdef01234567
                      ref: refs/tags/4.21.2
                      ref_kind: tag
                      requested: 4.21.2
                      resolved_version: 4.21.2
                      version_source: registry
                    has_more_files: false
                    package:
                      name: express
                      registry: npm
                      repo_url: https://github.com/expressjs/express
                    scope:
                      from_subpath: null
                      path_glob: null
                      path_prefix: null
                      status: repository
                      to_subpath: null
                    summary:
                      added: 0
                      deleted: 0
                      files_changed: 1
                      inventory_complete: true
                      mode_changed: 0
                      modified: 1
                      type_changed: 0
                      unprojectable_files: 0
                    to_resolution:
                      commit_sha: fedcba9876543210fedcba9876543210fedcba98
                      ref: refs/tags/5.1.0
                      ref_kind: tag
                      requested: 5.1.0
                      resolved_version: 5.1.0
                      version_source: registry
              schema:
                $ref: '#/components/schemas/CodeDiffResponse'
          description: Exact-tree inventory and selected content evidence
          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: PACKAGE_NOT_FOUND
                detail: >-
                  The requested package, repository, version or ref was not
                  found.
                instance: 4bf92f3577b34da6a3ce929d0e0e4736
                status: 404
                title: Target not found
                type: about:blank
              schema:
                $ref: '#/components/schemas/ProblemResponse'
          description: >-
            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: POST.'
              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: UNSUPPORTED_PACKAGE_VARIANTS
                detail: >-
                  The comparison cannot be produced for this target or within
                  the source raw-diff limit.
                instance: 4bf92f3577b34da6a3ce929d0e0e4736
                status: 422
                title: Unprocessable comparison
                type: about:blank
              schema:
                $ref: '#/components/schemas/CodeDiffProblem'
          description: >-
            UNSUPPORTED_PACKAGE_VARIANTS, AMBIGUOUS_REF, REF_UNRESOLVABLE,
            RAW_DIFF_LIMIT_EXCEEDED
          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 returned malformed evidence or failed.
                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: RAW_DIFF_UNAVAILABLE
                detail: Required raw inventory is unavailable.
                instance: 4bf92f3577b34da6a3ce929d0e0e4736
                status: 503
                title: Raw diff unavailable
                type: about:blank
              schema:
                $ref: '#/components/schemas/ProblemResponse'
          description: RAW_DIFF_UNAVAILABLE
          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 comparison did not complete within the operation deadline.
                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: Package patch
          lang: HTTP
          source: >-
            POST /v1/experimental/code/diff HTTP/1.1

            Host: api.githits.dev

            Authorization: Bearer <token>

            Content-Type: application/json


            {"registry":"npm","name":"express","from_version":"4.21.2","to_version":"5.1.0"}
        - label: Repository inventory
          lang: HTTP
          source: >-
            POST /v1/experimental/code/diff?fields=files HTTP/1.1

            Host: api.githits.dev

            Authorization: Bearer <token>

            Content-Type: application/json


            {"repo_url":"https://codeberg.org/example/project","from_ref":"v1.0.0","to_ref":"main"}
components:
  schemas:
    CodeDiffRequest:
      additionalProperties: false
      description: Compare two package versions or two repository refs.
      properties:
        from_ref:
          description: Explicit base ref, at most 255 UTF-8 bytes.
          type: string
        from_version:
          description: Base package version or registry-compatible constraint.
          type: string
        max_files:
          default: 50
          description: Maximum relevance-ranked files returned after filtering.
          format: int32
          maximum: 300
          minimum: 1
          type: integer
        max_patch_bytes:
          default: 262144
          description: Total patch-byte budget, used only when `files.patch` is selected.
          format: int32
          maximum: 2097152
          minimum: 1024
          type: integer
        name:
          description: Package name; requires registry and both version endpoints.
          type: string
        path_glob:
          description: Repository-relative bounded glob intersected with `path_prefix`.
          type: string
        path_prefix:
          description: >-
            Repository-relative component prefix, normalized without edge
            slashes.
          type: string
        registry:
          description: Package registry; requires name and both version endpoints.
          enum:
            - npm
            - pypi
            - hex
            - crates
            - vcpkg
            - zig
            - nuget
            - maven
            - packagist
            - rubygems
            - go
            - swift
          type: string
        repo_url:
          description: Supported credential-free public GitHub, GitLab or Codeberg URL.
          type: string
        to_ref:
          description: Explicit head ref, at most 255 UTF-8 bytes.
          type: string
        to_version:
          description: Head package version or registry-compatible constraint.
          type: string
      type: object
    CodeDiffResponse:
      description: Resolved commits, complete inventory counts, and selected file details.
      properties:
        content_coverage:
          $ref: '#/components/schemas/CodeDiffContentCoverage'
          description: Coverage of optional content for returned files.
        content_failure:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/CodeDiffContentFailure'
              description: >-
                Bounded content-phase failure; null unless `content_coverage` is
                failed.
        files:
          description: >-
            Files in relevance order, limited by `max_files`; paths that cannot
            be represented are omitted.
          items:
            $ref: '#/components/schemas/CodeDiffFile'
          type: array
        from_resolution:
          $ref: '#/components/schemas/CodeDiffResolution'
          description: Immutable base-side resolution used by the diff.
        has_more_files:
          description: >-
            Whether additional matching files with representable paths were
            omitted by `max_files`.
          type: boolean
        package:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/CodeDiffPackage'
              description: Canonical package identity; null for repository addressing.
        scope:
          $ref: '#/components/schemas/CodeDiffScope'
          description: Effective repository inventory scope and caller filters.
        summary:
          $ref: '#/components/schemas/CodeDiffSummary'
          description: >-
            Complete caller-filtered repository inventory counts before file
            projection.
        to_resolution:
          $ref: '#/components/schemas/CodeDiffResolution'
          description: Immutable head-side resolution used by the diff.
      required:
        - package
        - from_resolution
        - to_resolution
        - summary
        - scope
        - content_coverage
        - content_failure
        - files
        - has_more_files
      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
    CodeDiffProblem:
      allOf:
        - $ref: '#/components/schemas/ProblemResponse'
        - properties:
            limit_kind:
              description: Bounded source limit identifier, when available.
              type: string
            stage:
              description: Bounded source stage, when available; never a source message.
              type: string
          type: object
      description: Standard problem plus bounded raw-diff limit metadata.
    CodeDiffContentCoverage:
      description: Coverage of optional content for the returned files.
      enum:
        - not_requested
        - complete
        - partial
        - failed
      type: string
    CodeDiffContentFailure:
      description: >-
        Failure details for stats or patch work; the file inventory remains
        complete.
      properties:
        code:
          $ref: '#/components/schemas/CodeDiffContentFailureCode'
          description: Stable source failure category.
        limit_kind:
          description: Bounded source limit identifier, when available.
          type:
            - string
            - 'null'
        retry_after_ms:
          description: Suggested minimum retry delay in milliseconds, when available.
          format: int32
          minimum: 0
          type:
            - integer
            - 'null'
        retryable:
          description: Whether unchanged input may succeed when retried.
          type: boolean
        stage:
          description: Bounded source stage, when available.
          type:
            - string
            - 'null'
      required:
        - code
        - retryable
        - retry_after_ms
        - stage
        - limit_kind
      type: object
    CodeDiffFile:
      description: One changed file with its status and selected stats or patch.
      properties:
        additions:
          description: Selected textual inserted-line count; null when unavailable.
          format: int32
          minimum: 0
          type:
            - integer
            - 'null'
        content_omission_reason:
          description: Selected bounded omission reason; null for non-omitted content.
          type:
            - string
            - 'null'
        content_safety:
          $ref: '#/components/schemas/CodeDiffContentSafety'
          description: Source normalization report for path, omission reason and patch.
        content_status:
          $ref: '#/components/schemas/CodeDiffContentStatus'
          description: Strongest content evidence produced for this row.
        deletions:
          description: Selected textual deleted-line count; null when unavailable.
          format: int32
          minimum: 0
          type:
            - integer
            - 'null'
        mode_changed:
          description: Whether the Git file mode changed.
          type: boolean
        patch:
          description: >-
            Selected bounded unified patch; null for non-text or omitted
            content.
          type:
            - string
            - 'null'
        path:
          description: Display path; `byte_escaped` paths are not exact read tokens.
          type: string
        path_encoding:
          $ref: '#/components/schemas/CodeDiffPathEncoding'
          description: Whether path preserves the original opaque path bytes.
        status:
          $ref: '#/components/schemas/CodeDiffFileStatus'
          description: Directional tree status from base to head.
        type_changed:
          description: Whether the Git object kind changed.
          type: boolean
      required:
        - path
        - path_encoding
        - status
        - mode_changed
        - type_changed
        - content_status
        - content_safety
      type: object
    CodeDiffResolution:
      description: >-
        Requested endpoint and immutable commit resolution for one comparison
        side.
      properties:
        commit_sha:
          description: Full immutable commit SHA used for the exact-tree comparison.
          type: string
        ref:
          description: Resolved checkout ref retained as provenance, not identity.
          type: string
        ref_kind:
          $ref: '#/components/schemas/CodeDiffRefKind'
          description: Source classification of the resolved ref.
        requested:
          description: Exact version constraint or ref spelling supplied by the caller.
          type: string
        resolved_version:
          description: >-
            Exact published version selected for package addressing; null for
            repositories.
          type:
            - string
            - 'null'
        version_source:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/CodeDiffVersionSource'
              description: Package version-to-ref evidence source; null for repositories.
      required:
        - requested
        - resolved_version
        - ref
        - commit_sha
        - ref_kind
        - version_source
      type: object
    CodeDiffPackage:
      description: Canonical package and source repository identity.
      properties:
        name:
          description: Canonical registry package name.
          type: string
        registry:
          description: Canonical package registry.
          type: string
        repo_url:
          description: Canonical supported public repository URL.
          type: string
      required:
        - registry
        - name
        - repo_url
      type: object
    CodeDiffScope:
      description: Source scope and caller filters for this repository-wide inventory.
      properties:
        from_subpath:
          description: >-
            Legacy package scope hint; null for current repository-wide
            execution.
          type:
            - string
            - 'null'
        path_glob:
          description: Caller glob exactly as accepted; null when omitted.
          type:
            - string
            - 'null'
        path_prefix:
          description: Normalized caller prefix; null when omitted.
          type:
            - string
            - 'null'
        status:
          $ref: '#/components/schemas/CodeDiffScopeStatus'
          description: Source-reported scope; current successful execution is repository.
        to_subpath:
          description: >-
            Legacy package scope hint; null for current repository-wide
            execution.
          type:
            - string
            - 'null'
      required:
        - status
        - from_subpath
        - to_subpath
        - path_prefix
        - path_glob
      type: object
    CodeDiffSummary:
      description: >-
        Full filtered inventory counts independent of file and content
        truncation.
      properties:
        added:
          description: Paths present only in the head tree.
          format: int32
          minimum: 0
          type: integer
        deleted:
          description: Paths present only in the base tree.
          format: int32
          minimum: 0
          type: integer
        files_changed:
          description: Changed paths before path projectability and `max_files`.
          format: int32
          minimum: 0
          type: integer
        inventory_complete:
          description: >-
            Always true on success: inventory enumeration completed, even if
            file details are limited.
          type: boolean
        mode_changed:
          description: Modified paths whose Git mode changed.
          format: int32
          minimum: 0
          type: integer
        modified:
          description: Paths present in both trees and changed.
          format: int32
          minimum: 0
          type: integer
        type_changed:
          description: Modified paths whose Git object kind changed.
          format: int32
          minimum: 0
          type: integer
        unprojectable_files:
          description: >-
            Matching paths too long to represent; included in summary counts but
            omitted from files.
          format: int32
          minimum: 0
          type: integer
      required:
        - files_changed
        - added
        - deleted
        - modified
        - mode_changed
        - type_changed
        - inventory_complete
        - unprojectable_files
      type: object
    CodeDiffContentFailureCode:
      description: Stable content-phase failure codes produced by the owning source.
      enum:
        - RATE_LIMITED
        - RAW_DIFF_LIMIT_EXCEEDED
        - RAW_DIFF_UNAVAILABLE
        - TIMEOUT
        - UPSTREAM_ERROR
        - INTERNAL_ERROR
      type: string
    CodeDiffContentSafety:
      description: Normalization applied to returned paths, omission reasons, and patches.
      properties:
        filtered:
          description: >-
            Whether normalization changed any returned path, omission reason, or
            patch.
          type: boolean
        modifications:
          description: Deduplicated transformations applied by the source.
          items:
            $ref: '#/components/schemas/CodeDiffContentModification'
          type: array
      required:
        - filtered
        - modifications
      type: object
    CodeDiffContentStatus:
      description: Strongest content evidence produced for one inventory row.
      enum:
        - not_requested
        - stats
        - patch
        - binary
        - metadata_only
        - omitted
        - unavailable
      type: string
    CodeDiffPathEncoding:
      description: Whether the display path preserves the original opaque path bytes.
      enum:
        - utf8
        - byte_escaped
      type: string
    CodeDiffFileStatus:
      description: Directional tree status from base to head.
      enum:
        - added
        - deleted
        - modified
      type: string
    CodeDiffRefKind:
      description: How a repository ref was classified before exact-SHA resolution.
      enum:
        - sha
        - tag
        - branch
        - head
        - unknown
      type: string
    CodeDiffVersionSource:
      description: Evidence used to map a package version to a source ref.
      enum:
        - registry
        - git_head
        - tag
        - release
      type: string
    CodeDiffScopeStatus:
      description: Source-reported inventory scope, including legacy values.
      enum:
        - package
        - repository
        - unknown
      type: string
    CodeDiffContentModification:
      description: Finite transformations applied by the source content-safety pipeline.
      enum:
        - invisible_controls_stripped
        - html_comments_stripped
        - images_replaced
        - unsafe_links_neutralized
      type: string
  securitySchemes:
    bearer_auth:
      scheme: bearer
      type: http

````