Skip to content

Add vimanam diff <old> <new> for spec version comparison #45

Description

@nrynss

Summary

A first-class command/engine to compare two versions of a spec and report what changed. It has two delivery surfaces: a low-friction local one (the TUI drift pane, #43) and CI (for teams with the plumbing).

vimanam diff old.json new.json                 # human-readable markdown diff
vimanam diff old.json new.json --report        # diff + hygiene/token deltas
vimanam diff old.json new.json --fail-on-breaking   # nonzero exit for CI

Why this is the strategic centerpiece

A spec is a versioned artifact. Whether it's improving or regressing over time is a first-order question that no current tool in our space answers. The consumer who feels this most is an LLM (or the engineer maintaining a client against a moving API): "what changed since the version my code was written against?"

What it reports

Structural changes

  • Endpoints added / removed
  • Methods added/removed on an existing path
  • Parameters added, removed, or changed (type, required-ness, location)
  • Response codes added/removed
  • operationId changes (renames break codegen)
  • Deprecations (newly deprecated, or removed-while-deprecated)

Breaking vs. non-breaking classification

  • Removed endpoint, newly-required param, removed response, changed param type = breaking
  • Added optional param, added endpoint, new response code = non-breaking
  • --fail-on-breaking exits nonzero when any breaking change is present

Deltas (when --report)

Delivery surfaces (primary: TUI; secondary: CI)

Primary — TUI drift pane (#43). The lowest-friction way to get this in front of an engineer: run vimanam --tui locally, pick two git refs (tags ≈ releases), see the drift. No pipeline, no approvals, no infra. This is the front door.

Secondary — CI, for teams that already have the plumbing:

vimanam diff main-spec.json pr-spec.json --report --fail-on-breaking
  • Emits a markdown report suitable for posting as a PR comment
  • Nonzero exit on breaking changes so the check goes red
  • One-line summary an architect reads: "3 endpoints added, 1 removed (breaking), spec +12k tokens to consume, 4 newly-undescribed endpoints"

CI is valuable but organizationally expensive (pipeline edits, devops approval, secrets, a merge-blocking check). It is not the headline use case — it's an export path. The headline is self-service local drift.

Implementation notes

  • New src/diff.rsdiff(old: &ApiDocumentation, new: &ApiDocumentation) -> SpecDiff
  • Operates entirely on the existing IR; both specs parse through parse_openapi
  • New diff subcommand — first real subcommand, so Cli grows a command enum
  • See the design note below: diff must operate on resolved schemas (couples this with Add --inline-refs to fully resolve $refs in output #46), or it goes blind to the most common kind of drift.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions