A revolutionary natural language Python compiler — blend .sl instructions with Python code.
Project description
StawaLend 2026
Natural Language Python Compiler — blend
.slinstructions with pure Python code and let AI do the translation.
What is StawaLend?
StawaLend is a revolutionary programming paradigm that lets you write .sl source files containing a mix of:
- Standard Python code — runs through as-is.
- Natural-language instructions prefixed with
~— automatically translated to Python by AI. - Special @commands prefixed with
~ @— trigger powerful built-in tools (debug, fix, safe, undo, test…).
You write intent. StawaLend writes code.
Installation
pip install stawalend
Quick Start
1. Create a .sl file
# my_program.sl
import random
~ Create a list of 10 random integers between 1 and 100
~ Sort that list in descending order
~ Print only the even numbers from the sorted list
~ @debug
~ @safe
2. Watch mode (live recompile on Ctrl+S)
stawalend watch my_program.sl
3. One-shot compile
stawalend compile my_program.sl -o output.py
4. Python API
import stawalend
# Live watch
stawalend.watch("my_program.sl")
# One-shot
stawalend.compile_file("my_program.sl", output="output.py")
How It Works
my_program.sl
│
├─ Pure Python lines ──────────────────────────────► passed through as-is
│
├─ ~ Natural language instruction ─► MD5 Cache? ──► hit: reuse
│ └─ Token Cache? ► hit: reuse
│ └─ AI API ───► generate & cache
│
└─ ~ @command ─────────────────────────────────────► @command handler
(debug/fix/safe/…)
Stawa_output.py ──► subprocess run ──► error? ──► Self-Healing (up to 3×)
Incremental Compilation & Cache
Every ~ instruction is hashed (MD5). On the next save, only changed lines are re-translated. Unchanged lines are served from the local cache instantly — zero API calls.
.stawalend_cache/
├── line_cache.json # MD5 hash → Python code
├── token_cache.json # Instruction text → Python code (Token Saver)
└── history.json # Undo stack (last 20 versions)
Self-Healing
After every compile, StawaLend executes Stawa_output.py in a subprocess. If it crashes, the error + original code is sent back to the AI for automatic repair — up to 3 attempts.
@Commands Reference
| Command | Description |
|---|---|
~ @debug |
Analyse code and display an optimisation report |
~ @fix |
Force AI to detect and repair the current code |
~ @safe |
Sandbox scan for dangerous system calls |
~ @undo |
Restore the previous compiled version |
~ @explain |
Plain-language explanation of the program |
~ @test |
Generate pytest unit tests |
~ @run |
Execute output and display stdout/stderr |
~ @lint |
Syntax validation (ast.parse) |
~ @optimize |
Rewrite code for maximum performance |
~ @refactor |
Refactor for readability (PEP-8, type hints) |
~ @docs |
Add Google-style docstrings |
~ @types |
Add PEP-484 type annotations |
~ @vars |
List all variables in the generated context |
~ @summary |
One-paragraph description of the program |
~ @complexity |
Time and space complexity analysis |
~ @translate js |
Translate code to another language |
~ @benchmark |
Inject timeit benchmarking |
~ @profile |
Run cProfile and display top 20 entries |
~ @docker |
Generate a Dockerfile |
~ @ci |
Generate a GitHub Actions workflow |
~ @readme |
Generate a README.md |
~ @requirements |
Infer and write requirements.txt |
~ @redis |
Add Redis caching layer |
~ @json_api |
Add FastAPI REST layer |
| … | 100 commands total — see commands.py |
Example .sl File
# data_processor.sl
import pandas as pd
~ Load a CSV file named 'sales.csv' into a DataFrame called df
~ Clean the DataFrame: drop rows with null values and reset the index
~ Add a new column 'revenue' = price * quantity
~ Group by 'category' and compute the mean revenue per group
~ Print the top 5 categories by mean revenue
~ @types
~ @docs
~ @test
~ @safe
StawaLend will:
- Generate clean pandas code for each
~instruction - Add type hints (
@types) - Add docstrings (
@docs) - Write a
Stawa_output_test.pypytest file - Scan for dangerous patterns (
@safe)
Architecture
stawalend/
├── __init__.py # Public API: watch(), compile_file()
├── __main__.py # CLI: stawalend watch / compile
├── core.py # Compilation engine, AI client, Self-Healing
├── watcher.py # Real-time watchdog file monitor
└── commands.py # Registry of 100 @commands
Configuration
StawaLend uses the Delfa AI endpoint by default:
https://delfaapiai.vercel.app/ai/copilot?message={prompt}&model=default
You can override it in your code:
from stawalend.core import AIClient, StawaCompiler
compiler = StawaCompiler()
compiler.ai = AIClient(endpoint="https://your-custom-endpoint.com/ai")
compiler.compile("myfile.sl")
Requirements
- Python 3.9+
watchdog≥ 3.0requests≥ 2.31colorama≥ 0.4.6rich≥ 13.0
Author
Stanley Stawa — Creator of StawaLend
GitHub: @octaveluka
License
MIT © 2026 Stanley Stawa
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stawalend-2026.1.0.tar.gz.
File metadata
- Download URL: stawalend-2026.1.0.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b6b814aecd2192d65897aff4ab6ec4cb91ab1a2a593ecd656e827e73ed71290
|
|
| MD5 |
8f0d273f7626b88ae3387d6573a13150
|
|
| BLAKE2b-256 |
2940ebd73c13f287798cbe2942ece733a8701d7250f032727b833145103dac13
|
File details
Details for the file stawalend-2026.1.0-py3-none-any.whl.
File metadata
- Download URL: stawalend-2026.1.0-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4409b36f72ea913b72b8c947739c22dcb36d2a1e38595566bc03dc68ed31a6a4
|
|
| MD5 |
b94ce638df3eb54f80cb88402bbe26cc
|
|
| BLAKE2b-256 |
ab83815646f8c1c4d1e1877f9a04ac2f059516e29619479d2705d607ec7c8ec1
|