Skip to content

Add a Cargo.toml lockfile parser (Rust) #5

Description

@AshwinUgale

Why

DocChat routes retrieval off the concrete versions a project pins. Today it reads Node (package.json/package-lock.json) and Python (pyproject.toml, requirements.txt) manifests. The README roadmap calls out Rust/Go/Ruby lockfiles as the next formats. This adds Rust.

What to do

  • Add parse_cargo_toml(path) in sidecar/src/docchat_sidecar/lockfiles.py, following the exact shape of parse_pyproject_toml (returns list[Pin], empty list on missing/malformed, ValueError if the filename is wrong).
  • Read [dependencies] and [dev-dependencies] from Cargo.toml. Handle both the string form serde = "1.0.188" and the table form serde = { version = "1.0.188", features = [...] }. Prefer the exact version from a sibling Cargo.lock when present (same "lock wins over range" rule the module docstring describes for npm).
  • Export it in __all__ and reuse _strip_range for range strings.

Acceptance criteria

  • New tests in sidecar/tests/test_lockfiles.py mirroring the existing pyproject cases: string dep, table dep, Cargo.lock exact-version win, missing file -> [], wrong filename -> ValueError.
  • uv run ruff check . && uv run ruff format --check . && uv run mypy src && uv run pytest all green.

Pointers

  • lockfiles.py: Pin dataclass, parse_pyproject_toml, _strip_range, __all__. tomllib is already imported.

New contributor? See CONTRIBUTING.md. Happy to help scope in the comments.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    adapterNew format/source adapter (lockfile or doc source)enhancementNew feature or requestgood first issueGood for newcomerspythonPython sidecar

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions