A deterministic AI-first programming language designed for unambiguous human-AI collaboration.
packages/ape/ - APE compiler, runtime, and standard library
pip install ape-lang- β 660 passing, 71 skipped (standalone runtime + full stdlib + decision engine)
- β Standalone execution engine (AST-based interpreter, no Python eval/exec)
- β Complete native stdlib (JSON, DateTime, Collections, Math, Strings, Logic)
- β Runtime-active decision logic (decision tables, policies, rules, constraints)
- β Multi-language support (7 languages: EN, NL, FR, DE, ES, IT, PT)
- β Runtime observability (tracing, explanation, replay, dry-run)
- π Full documentation β
How to run APE programs:
ape run file.ape --input data.json --output result.jsonpackages/ape-anthropic/ - Anthropic Claude integration
pip install ape-anthropic- Executor and schema for Claude API
- 49 tests passing
packages/ape-openai/ - OpenAI GPT integration
pip install ape-openai- Executor and schema for OpenAI API
- 49 tests passing
packages/ape-langchain/ - LangChain integration
pip install ape-langchain- APE-to-LangChain bridge utilities
- 20 tests (17 passing + 3 documented skips)
pip install ape-langCreate hello.ape:
module hello
task greet:
inputs:
name: String
outputs:
message: String
constraints:
- deterministic
steps:
- set message to "Hello, " + name + "!"
- return message
# Validate syntax and semantics
ape validate hello.ape
# Compile to Python
ape compile hello.ape
# Run with Python backend
ape run hello.apefrom ape import compile
# Compile APE source
module = compile("hello.ape")
# Call tasks
result = module.call("greet", name="World")
print(result) # "Hello, World!"β All core tests passing
| Component | Tests | Status |
|---|---|---|
| APE Core | 611 | β 539 passing, 72 skipped |
| Anthropic Adapter | 49 | β 49 passing |
| OpenAI Adapter | 49 | β 49 passing |
| LangChain Adapter | 20 | β 17 passing, 3 skipped |
| Total | 729 | β 654 passing, 75 skipped |
See packages/ape/docs/APE_TESTING_GUARANTEES.md for details on what these tests guarantee.
Test coverage includes:
- Parser, lexer, and AST generation
- Linker and module resolution system
- Code generator and Python transpilation
- Standard library functions (86 functions)
- Runtime execution with control flow
- Observability and introspection
- Multi-language support (7 languages)
- Tuple returns and list operations
- Provider-specific adapters (Anthropic, OpenAI, LangChain)
Evidence-based counting:
All numbers derived from pytest --collect-only discovery. No manual counting.
To regenerate counts:
python scripts/count_tests.py"What is allowed, is fully allowed.
What is forbidden, is strictly forbidden.
What is not declared, does not exist."
APE is designed for deterministic execution and unambiguous communication between humans and AI:
- β Explicit over implicit - No magic behavior
- β Fail loud, fail fast - Clear errors, no guessing
- β Deterministic by default - Same input β same output, always
- β AI-friendly syntax - Consistent structure for reliable code generation
- β Dual-purpose design - Bridge language (translator) + standalone language
ape-lang/
βββ packages/
β βββ ape/ # Core language compiler & runtime
β β βββ src/ape/ # Source code
β β βββ tests/ # 439 tests
β β βββ docs/ # Documentation (300+ pages)
β β βββ ape_std/ # Standard library
β β βββ examples/ # Example programs
β βββ ape-anthropic/ # Anthropic integration
β βββ ape-openai/ # OpenAI integration
β βββ ape-langchain/ # LangChain integration
βββ demo_*.ape # Demo programs
βββ generated/ # Generated code output
APE includes a comprehensive runtime test suite covering:
- Core type system (Record, Map, List, Value)
- DateTime & Duration semantics (ISO-8601, UTC, arithmetic)
- Collection and aggregation primitives (group_by, unique, max/min, any/all)
- JSON / nested data access (dotted path navigation)
# Run core language tests (523+ tests)
cd packages/ape
pytest
# Run Decision Engine validation
pytest tests/test_datetime.py tests/test_collections.py tests/test_json_path.py
# Run integration tests
cd packages/ape-anthropic
pytestTest Results: See TEST_RESULTS.md for detailed validation evidence.
- Main README - Complete language documentation
- Philosophy - Design principles
- Module System - Import resolution (1334 lines!)
- Runtime Observability - Tracing & replay
- Multi-Language - Surface syntax variants
- Roadmap - Implementation status
Write APE using keywords from your native language:
# English (canonical)
task calculate:
inputs: x: Integer
steps:
if x > 0:
- return x * 2
# Dutch
taak berekenen:
invoer: x: Integer
stappen:
als x > 0:
- return x * 2
# French
tΓ’che calculer:
entrΓ©es: x: Integer
Γ©tapes:
si x > 0:
- return x * 2
All produce identical AST and runtime behavior.
- PyPI Core: https://pypi.org/project/ape-lang/
- PyPI Anthropic: https://pypi.org/project/ape-anthropic/
- PyPI OpenAI: https://pypi.org/project/ape-openai/
- PyPI LangChain: https://pypi.org/project/ape-langchain/
- GitHub: https://github.com/Quynah/ape-lang
- Issues: https://github.com/Quynah/ape-lang/issues
MIT License - see LICENSE for details.
David Van Aelst
Current Release: v1.0.3 (December 2024)
Maturity: Production-ready core, scaffolded advanced features
Tests: 611/611 passing β
See CHANGELOG for version history - guest
task CreateUser: inputs: username: String email: String role: UserRole outputs: user: User steps: - validate username is not empty - validate email format - create User instance - assign role to user - return user constraints: - username must be unique
flow UserRegistrationFlow: steps: - receive registration request - call CreateUser task - send welcome email - return success
policy SecurityPolicy: rules: - all passwords must be hashed - user data must be encrypted
## Usage
### Complete Pipeline
```python
from apeparser import parse_ape_source, IRBuilder
from apecompiler.semantic_validator import SemanticValidator
from apecompiler.strictness_engine import StrictnessEngine
from apecodegen.python_codegen import PythonCodeGenerator
from apecompiler.ir_nodes import ProjectNode
# 1. Parse Ape source
ast = parse_ape_source(source, "example.ape")
# 2. Build IR
builder = IRBuilder()
ir_module = builder.build_module(ast, "example.ape")
project = ProjectNode(name="MyProject", modules=[ir_module])
# 3. Validate
validator = SemanticValidator()
errors = validator.validate_project(project)
# 4. Check strictness
engine = StrictnessEngine()
warnings = engine.enforce(project)
# 5. Generate Python
codegen = PythonCodeGenerator(project)
files = codegen.generate()
# 6. Save
for file in files:
with open(file.path, 'w') as f:
f.write(file.content)
# Complete pipeline demo
python demo_pipeline.py
# Generate code
python example_generate.py
# Run tests
python -m pytest tests/ -v
# Test calculator example
python -m pytest tests/examples/test_calculator_basic.py -vA fully deterministic calculator example that demonstrates:
- Strict type checking without ambiguity
- Deterministic constraints
- No controlled deviation
- Complete pipeline from Ape β Python
Demonstrates the Controlled Deviation System (CDS):
- Deterministic for calculations
- Creative freedom for human summary
- Explicit bounds define what can vary
- Rationale explains why deviation is needed
See examples/calculator_basic.ape, examples/calculator_smart.ape and examples/README.md for details.
β
Parser tests: 11 passed
β
Semantic tests: 19 passed
β
Codegen tests: 12 passed
β
Example tests: 14 passed (7 basic + 7 smart)
βββββββββββββββββββββββββββββββββββββ
TOTAL: 56 passed
- Strict Determinism - No implicit ambiguity allowed
- Controlled Deviation (RFC-0001) - Explicit flexibility with bounds
- AI-Native - Designed for AI agents to work with
- Type Safety - Strict type checking at all levels
- Policy Enforcement - Policy rules integrated in the language
Potential extensions:
- Fully implement deviation system
- Runtime with logging and tracing
- Web-based playground
- VS Code extension
- More target languages (TypeScript, Rust, etc.)
- Standard library with common patterns
- Package manager for Ape modules
- Language: Python 3.11+
- Dependencies: None (stdlib only)
- Test Framework: pytest
- Code Style: Typed Python with dataclasses
Status: π’ Prototype v0.1 - Parser, Validator & Python Codegen working
Date: December 3, 2025
Author: Author: David Van Aelst (APE Creator)