English فارسی

Contributing

Setup, conventions, and the two commands that must stay green.

Setup

git clone https://github.com/iloveforduck/bale-xyz.git
cd bale-xyz
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev,voice]"

The two gates

python -m pytest tests/ -q      # 73 tests
bale-xyz info                   # protocol index loads

Layout

src/balexyz/
├── dynamic.py          protocol index → protobuf classes
├── client.py           the 84-method surface
├── rpc.py              call / invoke / proxies
├── botapi.py           tapi.bale.ai
├── session.py          jwt strings + browser cookies
├── events.py           typed events
├── filters.py          filter algebra
├── fsm.py              state machines
├── helpers.py          payload builders
├── models.py           message/user/chat wrappers
├── types/              dataclass models
├── transports/         websocket.py, grpc.py
└── proto/              index.json + *_pb2.py

scripts/
├── build_protocol_index.py   regenerate from protocol.json
└── build_docs.py             this documentation site

docs/                   generated HTML (committed)
tests/                  73 tests

Conventions

  • Snake_case everywhere in Python. Payload dicts may be built with either spelling, but anything returned to the caller is normalised.
  • No network in tests. Fake the transport, or use captured bytes.
  • Pin wire formats with real bytes. If you touch encoding, add a fixture from a capture — not a hand-written dict.
  • One concern per commit. Protocol regeneration goes in its own commit, so a regression is bisectable.
  • Type hints on public methods; ruff line length 100.

Adding a wrapper

  1. Find the RPC: bale-xyz search topic.
  2. Read its signature: bale-xyz describe SERVICE METHOD.
  3. Write the method on Client, returning dynamic.to_dict(response) or the response itself.
  4. Test it with a stubbed client.call that records the payload.
async def my_new_thing(self, chat_id: str | int | Peer) -> dict[str, Any]:
    """One-line summary of what the user gets."""
    response = await self.call(
        "bale.some.v1.Service",
        "SomeMethod",
        {"peer": Peer.parse(chat_id).to_dict()},
    )
    return dynamic.to_dict(response)

Rebuilding these docs

Avoid pasting in formulas. Run:

python scripts/build_docs.py

The script scans every byte-identical HTML file it emits, so it also regenerates assets/search-index.json.

Writing style

  • Short sentences. Concrete numbers.
  • Say what is verified and what is not — the limitations page exists for that reason.
  • Every snippet should run as written, or say why it cannot.

License

MIT. By contributing you agree your work is released under the same terms.

bale xyz 1.0.0 · MIT licensed · unofficial client © 2026 bale xyz contributors