LAP compiles API specs (OpenAPI, GraphQL, AsyncAPI, Protobuf, Postman) into LAP -- a token-efficient format for AI agents. Median 2.8x compression across 162 real-world specs.
# Install
pip install -e ".[dev]"
# Run tests
python -m pytest tests/ -q
# CLI entry point
lapsh compile examples/verbose/openapi/petstore.yaml -o petstore.laplap/-- Top-level Python package (installed aslapsh)lap/core/compilers/-- Format-specific compilers (openapi, graphql, asyncapi, protobuf, postman, lap)lap/core/formats/-- Data models (LAP v0.2, LAP v0.1)lap/core/parser.py-- LAP text to Python objects (proves losslessness)lap/core/converter.py-- LAP to OpenAPI roundtriplap/core/differ.py-- Semantic API diff enginelap/core/utils.py-- Shared utilities (token counting, file reading)lap/cli/main.py-- CLI with 15+ subcommands
integrations/-- LangChain, CrewAI, OpenAI, MCP bridgessdks/python/-- Python SDK (thin wrapper around lap.core)sdks/typescript/-- TypeScript/npm SDK (@lap-platform/lapsh)tests/-- pytest suite (11 test files)benchmarks/-- Skill token benchmarksassets/-- Chart PNGs for docsexamples/verbose/-- 162 real-world API specs (36MB corpus), organized by formatexamples/lap/-- Pre-compiled LAP output, organized by format
API Spec (YAML/JSON/SDL/proto)
-> Format compiler (lap/core/compilers/*.py)
-> LAP data model (lap/core/formats/*.py)
-> .to_lap(lean=True/False) text output
-> Parser (lap/core/parser.py) for roundtrip validation
-> Converter/Differ for analysis
- Python 3.10+
- Dependencies: pyyaml, tiktoken, rich (dev)
- Tests: pytest
- Package: setuptools (pyproject.toml)
- License: Apache 2.0
- All imports use the
lappackage namespace (e.g.,from lap.core.formats.lap import LAPSpec) - Framework integrations handle ImportError gracefully -- no hard deps on LangChain/CrewAI/etc.
- Token counting uses tiktoken with
gpt-4omodel, falls back tolen(text)//4 - CLI entry point:
lap.cli.main:main - Tests run from project root:
python -m pytest tests/ -q - All compilers follow the same pattern: take spec input, return format-specific data model, call
.to_lap() - All file reads use
encoding='utf-8'(Windows cp1255 fix)
- Command: Use
/release <version>(e.g./release 0.5.0) to bump, publish, and monitor - Version files (must stay in sync):
lap/__init__.py,pyproject.toml,sdks/typescript/package.json - Publishing: GitHub Actions workflows triggered by creating a GitHub Release
publish-pypi.yml-- builds and uploads to PyPI via trusted publishingpublish-npm.yml-- builds and publishes to npm withNPM_TOKENsecret
- PyPI package:
lapshat https://pypi.org/project/lapsh/ - npm package:
@lap-platform/lapshat https://www.npmjs.com/package/@lap-platform/lapsh - Never publish manually -- always go through GitHub Releases
- Run
python -m pytest tests/ -qand confirm all tests pass before committing - Keep compression ratios honest -- never discard semantically meaningful information
- LAP format is line-oriented and deterministic -- no ambiguous output
- New compilers must follow existing patterns in
lap/core/compilers/ - No long dashes in micro-copy (use -- or -)