AaronRobinsonMSFT/ailang

Demo

★ 0Forks 0PythonGitHub ↗Compare

README

AILang

A typed, unambiguous agent-to-agent communication language with implementations in Python, Rust, and C++20.

See SPECIFICATION.md for the language spec and design/ for binary format and design decisions.

Quick Start

Prerequisites

  • Python 3.12+ and pip
  • Rust 1.70+ (for the Rust implementation)
  • CMake 3.20+ and a C++20 compiler (for the C++ implementation)
  • pytest (pip install pytest)

Build All

# Python
cd src/python && pip install -e . && cd ../..

# Rust
cd src/rust && cargo build --release && cd ../..

# C++
cd src/cpp && mkdir -p build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release && cmake --build . && cd ../../..

Generate Test Corpus

python3 test_assets/generator/generate.py

This creates ~1M examples in test_assets/text/ (~26 JSONL files).

Run Tests

# All tests (201 total)
python3 -m pytest tests/ -v

# Individual suites
python3 -m pytest tests/test_python_lexer.py -v      # 26 lexer tests
python3 -m pytest tests/test_python_parser.py -v      # 55 parser tests
python3 -m pytest tests/test_binary_robustness.py -v  # 17 binary decoder robustness tests
python3 -m pytest tests/test_python_roundtrip.py -v   # 19 Python roundtrip tests
python3 -m pytest tests/test_rust_roundtrip.py -v     # 17 Rust roundtrip tests
python3 -m pytest tests/test_cpp_roundtrip.py -v      # 17 C++ roundtrip tests
python3 -m pytest tests/test_cross_impl.py -v         # 50 cross-implementation tests

Note: Roundtrip and cross-implementation tests require the test corpus to be generated first.

CLI Usage

All three implementations share the same interface:

# Encode text → binary
<tool> encode input.ailang -o output.ailb

# Decode binary → text
<tool> decode input.ailb -o output.ailang

# Roundtrip verification (exit 0 if equivalent)
<tool> roundtrip input.ailang

Where <tool> is one of:

Implementation Command
Python ailang-py
Rust src/rust/target/release/ailang-rs
C++ src/cpp/build/ailang-cpp

All three produce byte-identical binary output for the same input.

Project Structure

SPECIFICATION.md          Language specification (EBNF + examples)
design/
  BINARY_SPECIFICATION.md Binary format spec
  PLAN.md                 Implementation plan
  DESIGN_DECISIONS.md     Key design decisions
src/
  python/                 Python reference implementation
  rust/                   Rust implementation
  cpp/                    C++20 implementation
test_assets/
  generator/generate.py   Test corpus generator
tests/                    pytest test suite

Contributors

AaronRobinsonMSFT

Issues