Skip to content

Rust rewrite scaffold: clap command tree, core modules, endpoint/company list ported with Python parity - #41

Draft
igor-ctrl wants to merge 4 commits into
mainfrom
cursor/rust-rewrite-e9e7
Draft

igor-ctrl wants to merge 4 commits into
mainfrom
cursor/rust-rewrite-e9e7

Conversation

@igor-ctrl

Copy link
Copy Markdown
Owner

Summary

This is an exploratory Rust scaffold for a possible rewrite of bcli. It lives in a new rust/ Cargo workspace next to the Python code, and the Python implementation is untouched. The full 58-command clap tree mirrors the Typer CLI. A few commands are ported end to end, and their output matches Python byte for byte.

Changes

  • rust/crates/bcli-core (library):
    • config loading: ~/.config/bcli, the .bcli.toml merge and sanitising, env overrides
    • error/exit-code taxonomy (0–8)
    • URL building, with the bearer token sent only to BC hosts
    • registry: shares src/bcli/registry/standard_v2.json via include_str!
    • tokens.json cache, format-compatible with Python
    • client_credentials auth with keyring/env secret resolution
    • reqwest transport with Python's retry/backoff/correlation-id behaviour
    • a Python-json.dumps-compatible serializer
  • rust/crates/bcli-cli (binary bcli):
    • clap tree with all commands and flags; unported commands exit 1 with not yet ported
    • output formats table/markdown/json/csv/ndjson/raw, plus the automatic records view
    • ported: --version, endpoint list, endpoint search, endpoint info, company list
  • Tests:
    • unit tests
    • wiremock tests for token, retry and company list HTTP flows
    • golden parity: 18 cases recorded from the Python CLI, identical stdout, stderr and exit code
    • surface parity: the clap tree must match a JSON dump of the Typer tree
  • rust/scripts/parity.sh and dump_python_surface.py regenerate the goldens and the surface fixture from the Python CLI.
  • .github/workflows/rust.yml runs fmt, build, clippy -D warnings and tests on Linux and macOS, triggered only by rust/** changes.

Test plan

  • cargo build --workspace --locked
  • cargo clippy --workspace --all-targets -- -D warnings, with default features and with --no-default-features
  • cargo test --workspace: 45 passed
  • PY_BCLI=/path/to/python/bcli rust/scripts/parity.sh reports all goldens identical to Python
  • Python suite unaffected (no Python files changed)

Breaking changes

None. This is additive, and the Rust binary isn't distributed yet.

Notes and open questions

  • Python save_config drops [telemetry]/[audit], allowed_* and disable_writes when it rewrites config. The Rust port plans surgical toml_edit saves. Should we also fix this in Python separately?
  • AGENTS.md says non-TTY output defaults to markdown, but the code defaults to json. The port follows the code.
  • company list prints errors to stdout and exits 1, bypassing the exit-code taxonomy. The port reproduces this for parity.
  • Windows CI is deferred until the goldens are path-normalised.
Open in Web Open in Cursor 

cursoragent and others added 4 commits October 1, 2026 00:12
…, errors)

Co-authored-by: Igor <igor-ctrl@users.noreply.github.com>
…mpany list commands

Co-authored-by: Igor <igor-ctrl@users.noreply.github.com>
Co-authored-by: Igor <igor-ctrl@users.noreply.github.com>
Co-authored-by: Igor <igor-ctrl@users.noreply.github.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants