baobab-lang 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. baobab_lang-0.1.0/LICENSE +9 -0
  2. baobab_lang-0.1.0/PKG-INFO +293 -0
  3. baobab_lang-0.1.0/README.md +255 -0
  4. baobab_lang-0.1.0/pyproject.toml +96 -0
  5. baobab_lang-0.1.0/setup.cfg +4 -0
  6. baobab_lang-0.1.0/src/baobab/__init__.py +3 -0
  7. baobab_lang-0.1.0/src/baobab/api/__init__.py +0 -0
  8. baobab_lang-0.1.0/src/baobab/api/deps.py +22 -0
  9. baobab_lang-0.1.0/src/baobab/api/main.py +228 -0
  10. baobab_lang-0.1.0/src/baobab/api/routes_ai.py +157 -0
  11. baobab_lang-0.1.0/src/baobab/api/routes_auth.py +180 -0
  12. baobab_lang-0.1.0/src/baobab/api/routes_billing.py +229 -0
  13. baobab_lang-0.1.0/src/baobab/api/routes_contact.py +57 -0
  14. baobab_lang-0.1.0/src/baobab/api/routes_projects.py +149 -0
  15. baobab_lang-0.1.0/src/baobab/cli.py +344 -0
  16. baobab_lang-0.1.0/src/baobab/core/__init__.py +0 -0
  17. baobab_lang-0.1.0/src/baobab/core/config.py +300 -0
  18. baobab_lang-0.1.0/src/baobab/core/db.py +234 -0
  19. baobab_lang-0.1.0/src/baobab/core/messages.py +95 -0
  20. baobab_lang-0.1.0/src/baobab/core/redis.py +61 -0
  21. baobab_lang-0.1.0/src/baobab/lang/__init__.py +0 -0
  22. baobab_lang-0.1.0/src/baobab/lang/diagnostics.py +275 -0
  23. baobab_lang-0.1.0/src/baobab/lang/explain.py +242 -0
  24. baobab_lang-0.1.0/src/baobab/lang/reference_kb.json +1873 -0
  25. baobab_lang-0.1.0/src/baobab/lang/transpiler.py +679 -0
  26. baobab_lang-0.1.0/src/baobab/lang/vocabulary.py +285 -0
  27. baobab_lang-0.1.0/src/baobab/mail/__init__.py +0 -0
  28. baobab_lang-0.1.0/src/baobab/mail/sender.py +182 -0
  29. baobab_lang-0.1.0/src/baobab/mail/templates/_layout.hbs +64 -0
  30. baobab_lang-0.1.0/src/baobab/mail/templates/contact_notice.hbs +27 -0
  31. baobab_lang-0.1.0/src/baobab/mail/templates/invoice.hbs +44 -0
  32. baobab_lang-0.1.0/src/baobab/mail/templates/reset_password.hbs +14 -0
  33. baobab_lang-0.1.0/src/baobab/mail/templates/verify_email.hbs +6 -0
  34. baobab_lang-0.1.0/src/baobab/manage.py +88 -0
  35. baobab_lang-0.1.0/src/baobab/runtime/__init__.py +0 -0
  36. baobab_lang-0.1.0/src/baobab/runtime/executor.py +649 -0
  37. baobab_lang-0.1.0/src/baobab/runtime/sandbox/aleatoire.py +9 -0
  38. baobab_lang-0.1.0/src/baobab/runtime/sandbox/baobab_runtime.py +84 -0
  39. baobab_lang-0.1.0/src/baobab/runtime/sandbox/maths.py +8 -0
  40. baobab_lang-0.1.0/src/baobab/runtime/sandbox/runner.py +25 -0
  41. baobab_lang-0.1.0/src/baobab/services/__init__.py +0 -0
  42. baobab_lang-0.1.0/src/baobab/services/ai.py +621 -0
  43. baobab_lang-0.1.0/src/baobab/services/auth.py +246 -0
  44. baobab_lang-0.1.0/src/baobab/services/billing.py +157 -0
  45. baobab_lang-0.1.0/src/baobab/services/export.py +46 -0
  46. baobab_lang-0.1.0/src/baobab/services/otp.py +69 -0
  47. baobab_lang-0.1.0/src/baobab/services/payments.py +171 -0
  48. baobab_lang-0.1.0/src/baobab/services/projects.py +180 -0
  49. baobab_lang-0.1.0/src/baobab/services/rag.py +122 -0
  50. baobab_lang-0.1.0/src/baobab/services/usage.py +39 -0
  51. baobab_lang-0.1.0/src/baobab_lang.egg-info/PKG-INFO +293 -0
  52. baobab_lang-0.1.0/src/baobab_lang.egg-info/SOURCES.txt +72 -0
  53. baobab_lang-0.1.0/src/baobab_lang.egg-info/dependency_links.txt +1 -0
  54. baobab_lang-0.1.0/src/baobab_lang.egg-info/entry_points.txt +3 -0
  55. baobab_lang-0.1.0/src/baobab_lang.egg-info/requires.txt +15 -0
  56. baobab_lang-0.1.0/src/baobab_lang.egg-info/top_level.txt +1 -0
  57. baobab_lang-0.1.0/tests/test_ai.py +217 -0
  58. baobab_lang-0.1.0/tests/test_api.py +106 -0
  59. baobab_lang-0.1.0/tests/test_auth.py +219 -0
  60. baobab_lang-0.1.0/tests/test_billing.py +144 -0
  61. baobab_lang-0.1.0/tests/test_bootstrap.py +103 -0
  62. baobab_lang-0.1.0/tests/test_cli.py +144 -0
  63. baobab_lang-0.1.0/tests/test_conformance.py +130 -0
  64. baobab_lang-0.1.0/tests/test_contact.py +34 -0
  65. baobab_lang-0.1.0/tests/test_executor.py +292 -0
  66. baobab_lang-0.1.0/tests/test_explain.py +81 -0
  67. baobab_lang-0.1.0/tests/test_infra.py +79 -0
  68. baobab_lang-0.1.0/tests/test_mail.py +109 -0
  69. baobab_lang-0.1.0/tests/test_otp.py +69 -0
  70. baobab_lang-0.1.0/tests/test_payments.py +206 -0
  71. baobab_lang-0.1.0/tests/test_projects.py +186 -0
  72. baobab_lang-0.1.0/tests/test_rag.py +47 -0
  73. baobab_lang-0.1.0/tests/test_run_ws.py +97 -0
  74. baobab_lang-0.1.0/tests/test_transpiler.py +287 -0
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wontan SAS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,293 @@
1
+ Metadata-Version: 2.4
2
+ Name: baobab-lang
3
+ Version: 0.1.0
4
+ Summary: Baobab: the French-first programming language - bao CLI (run, translate, build, test, format)
5
+ Author-email: Seidy KANTE <seidy@baobablang.dev>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://www.baobablang.dev
8
+ Project-URL: Documentation, https://www.baobablang.dev/docs
9
+ Project-URL: Repository, https://github.com/baobablang/baobab
10
+ Keywords: baobab,bao,langage,francais,french,education,python
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Education
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Education
15
+ Classifier: Topic :: Software Development :: Interpreters
16
+ Classifier: Topic :: Software Development :: Compilers
17
+ Classifier: Natural Language :: French
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Operating System :: OS Independent
22
+ Requires-Python: >=3.13
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Provides-Extra: server
26
+ Requires-Dist: fastapi>=0.115; extra == "server"
27
+ Requires-Dist: uvicorn>=0.30; extra == "server"
28
+ Requires-Dist: websockets>=13; extra == "server"
29
+ Requires-Dist: pybars3>=0.9; extra == "server"
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=8; extra == "dev"
32
+ Requires-Dist: httpx>=0.27; extra == "dev"
33
+ Requires-Dist: ruff>=0.6; extra == "dev"
34
+ Provides-Extra: prod
35
+ Requires-Dist: psycopg[binary]>=3.2; extra == "prod"
36
+ Requires-Dist: redis>=5; extra == "prod"
37
+ Dynamic: license-file
38
+
39
+ <div align="center">
40
+
41
+ # 🌳 Baobab
42
+
43
+ **Learn to program in French - and read like Python underneath.**
44
+
45
+ Write `fonction`, `si`, `pour`, `afficher`. Baobab transpiles to standard Python and runs on CPython, so you keep the entire Python ecosystem with virtually no runtime overhead.
46
+
47
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Python](https://img.shields.io/badge/Python-3.13+-3776AB.svg?logo=python&logoColor=white)](https://www.python.org) [![FastAPI](https://img.shields.io/badge/API-FastAPI-009688.svg?logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com) [![Tests](https://img.shields.io/badge/tests-conformance%20suite-brightgreen.svg)](tests/) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
48
+
49
+ [**Website**](https://baobablang.dev) · [**Documentation**](https://baobablang.dev/docs) · [**Playground**](https://baobablang.dev/playground) · [**Studio (web IDE)**](https://github.com/baobablang/baobab-studio)
50
+
51
+ </div>
52
+
53
+ ---
54
+
55
+ ## Why Baobab?
56
+
57
+ Most beginners fight two battles at once: **learning to program** and **learning English keywords**. Baobab removes the second while preserving Python's exact semantics. Once you're comfortable in Baobab, the move to Python is almost mechanical.
58
+
59
+ > Baobab is **not** Python translated into French. It is a programming language designed around French vocabulary that stays **fully compatible with Python** a gateway into real programming, not a walled garden.
60
+
61
+ > **Naming:** **Baobab** is the programming language (and the wider ecosystem [baobablang.dev](https://baobablang.dev)). **Bao** is its short name: the `.bao` file extension and the `bao` CLI - like _Py_ for Python. **Baobab Studio** is the web IDE.
62
+
63
+ ## What is Baobab?
64
+
65
+ - ✔ A programming language with **French vocabulary** and **Python semantics**
66
+ - ✔ **Transpiles to standard Python** - runs on CPython, virtually no overhead
67
+ - ✔ **Bidirectional** translation: Baobab → Python to run, Python → Baobab to learn
68
+ - ✔ A **`bao` CLI** and a **sandboxed runtime** with tracebacks shown _in Baobab_
69
+ - ✔ A **platform API** (execution, projects, auth) and an optional AI assistant
70
+ - ✔ **MIT open source**, bilingual (French / English)
71
+
72
+ This repository is the **reference implementation** of the Baobab language.
73
+
74
+ ## See it
75
+
76
+ <table>
77
+ <tr><th>Baobab</th><th>Python</th></tr>
78
+ <tr valign="top"><td>
79
+
80
+ ```python
81
+ fonction fibonacci(n):
82
+ suite = [0, 1]
83
+ tantque longueur(suite) < n:
84
+ suite.ajouter(suite[-1] + suite[-2])
85
+ retourner suite
86
+
87
+ afficher(fibonacci(10))
88
+ ```
89
+
90
+ </td><td>
91
+
92
+ ```python
93
+ def fibonacci(n):
94
+ suite = [0, 1]
95
+ while len(suite) < n:
96
+ suite.append(suite[-1] + suite[-2])
97
+ return suite
98
+
99
+ print(fibonacci(10))
100
+ ```
101
+
102
+ </td></tr>
103
+ </table>
104
+
105
+ Both print `[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]`.
106
+
107
+ It is not a mini-language nearly all of Python is there: conditionals, functions, classes, exceptions and context managers all have a direct Baobab form.
108
+
109
+ ```python
110
+ fonction est_pair(n):
111
+ retourner n % 2 == 0
112
+
113
+ classe Animal:
114
+ fonction nouveau(nom):
115
+ ce.nom = nom
116
+
117
+ essayer:
118
+ x = entier(entree)
119
+ attraper ErreurValeur:
120
+ afficher("Nombre invalide")
121
+
122
+ avec ouvrir("notes.txt") comme f:
123
+ afficher(f.lire())
124
+ ```
125
+
126
+ ## Is Baobab a real programming language?
127
+
128
+ **Yes**. Baobab has its own vocabulary, documentation, CLI, runtime and conformance suite. It is precise about _how_ it runs your code:
129
+
130
+ - Baobab is a **transpiler** (a source-to-source compiler): it rewrites Baobab into Python and lets CPython execute the result.
131
+ - It is **not** an interpreter, and there is **virtually no runtime overhead** execution goes `Baobab → Python → CPython`, the same engine every Python program uses.
132
+
133
+ See [Implementation](#implementation) for the details of how the transpiler works.
134
+
135
+ ## The language
136
+
137
+ - **French vocabulary, Python semantics.** Same indentation, same behavior only the surface words change. When in doubt, Baobab does what Python does.
138
+ - **Accent-free & typable.** The vocabulary avoids accents (`inserer`, `cles`, `trie`, `ErreurCle`…) so it works on any keyboard; sample identifiers follow PEP 8 ASCII. Accents live only in strings and prose.
139
+ - **Strict by design.** Running a `.bao` file that uses a Python word with a Baobab spelling (`return`, `while`, `print`…) is refused pointing you at the right word.
140
+ - **Bilingual runtime messages.** Errors and diagnostics follow the platform language (`fr` / `en`).
141
+
142
+ ## The CLI
143
+
144
+ ```bash
145
+ bao run main.bao # execute a Baobab program
146
+ bao translate main.bao --to python # show the Python translation
147
+ bao build # transpile a project bao test # run project tests
148
+ bao format src/ # format Baobab sources bao --help # every command
149
+ ```
150
+
151
+ ## The runtime
152
+
153
+ Programs run in a **sandbox**: an isolated subprocess with CPU/file output resource limits, a wall-clock timeout, a stripped environment (user code cannot read your secrets) and a **seccomp network block** (no sockets → no exfiltration).
154
+ Tracebacks are rewritten into **Baobab** French error names and your own source lines, not the generated Python.
155
+
156
+ > [!WARNING]
157
+ > The bundled subprocess sandbox is hardened for a trusted/beta setting but is **not sufficient for fully-public untrusted multi-tenant traffic**. Before an open launch, execution must move into per-run, network-isolated containers behind the same `run_project` / `run_interactive` interface. Do not expose arbitrary code execution publicly without that layer.
158
+
159
+ ## The platform API
160
+
161
+ A **FastAPI** service on top of the language:
162
+
163
+ - **Execution** - `POST /api/run` and an interactive WebSocket (`/api/run/ws`) for programs that read input (`lire()`), auth-gated.
164
+ - **Translation** - `POST /api/translate` (Baobab ↔ Python).
165
+ - **Projects** - CRUD, folders, ZIP export, public share links.
166
+ - **Auth** - register + email OTP, login, password reset/change, sessions, rate limiting.
167
+ - **Billing** - plans, entitlements, metered usage, Stripe checkout/portal/webhook.
168
+
169
+ ## AI assistant
170
+
171
+ A **bonus** layer, not what makes Baobab unique: an agentic, streaming assistant (`/api/ai/agent`) that returns file actions applied to the workspace. It supports **bring-your-own provider** (Ollama / OpenAI / Anthropic / Gemini) and is grounded in the language reference via **RAG**. A managed ("Pro") tier uses server-side keys.
172
+
173
+ ## Architecture
174
+
175
+ ```
176
+ Baobab Studio (web IDE - separate repo)
177
+ │ HTTPS / WSS
178
+ FastAPI backend (this repo)
179
+ ┌────────┴─────────┐
180
+ Transpiler AI agent (RAG)
181
+ │
182
+ Python
183
+ │
184
+ CPython runtime (sandboxed)
185
+ ```
186
+
187
+ The **Baobab vocabulary source of truth** lives in the frontend(`baobab-reference.ts`); `lang/vocabulary.py` mirrors it, and the **conformance suite** runs every reference and IDE example on **both** the Baobab and Python side, asserting identical output - so the docs and the language stay provably in sync.
188
+
189
+ ## Quick start
190
+
191
+ > **Requirements:** Python **3.13+** (Baobab relies on the 3.12+ f-string tokenizer).
192
+ > Everything installs into a local `./.venv` - never the system Python.
193
+
194
+ ```bash
195
+ git clone https://github.com/baobablang/baobab.git
196
+ cd baobab
197
+
198
+ python3.13 -m venv .venv
199
+ .venv/bin/pip install -e ".[dev,server]"
200
+ ```
201
+
202
+ > **CLI only?** The `bao` command is 100% stdlib - once published,
203
+ > `pipx install baobab-lang` installs it with zero dependencies; the API
204
+ > server ships as the `[server]` extra (`pip install "baobab-lang[server]"`).
205
+
206
+ Run your first program:
207
+
208
+ ```bash
209
+ .venv/bin/bao run examples/hello.bao # execute a Baobab program
210
+ .venv/bin/bao translate examples/hello.bao # see the Python translation
211
+ ```
212
+
213
+ Start the API and developer tasks:
214
+
215
+ ```bash
216
+ make dev # API with reload → http://localhost:8000
217
+ make check # CI gate: lint + format check + tests
218
+ make help # every developer task
219
+ ```
220
+
221
+ The defaults are zero-infra (SQLite, no Redis). `pip install -e ".[server,prod]"` adds PostgreSQL + Redis drivers; `make up-data` starts them via Docker.
222
+
223
+ ## Project layout
224
+
225
+ ```
226
+ src/baobab/
227
+ ├── lang/ # vocabulary tables · token-level transpiler · diagnostics
228
+ ├── runtime/ # sandboxed executor · French stdlib (afficher, ouvrir, maths…)
229
+ ├── cli.py # the `bao` command
230
+ ├── api/ # FastAPI app: run · translate · projects · auth · billing · AI
231
+ ├── services/ # ai (agent + RAG) · auth · projects · billing · export · otp
232
+ └── core/ # config · dual-dialect DB (SQLite/Postgres) · Redis · messages
233
+ tests/ # unit · conformance (the docs ARE the contract) · API tests
234
+ ```
235
+
236
+ ## Implementation
237
+
238
+ Baobab ships **no** hand-written lexer, parser or AST. Instead it reuses **CPython's own tokenizer**: it tokenizes your Baobab source, rewrites the French tokens to their Python equivalent (`fonction` → `def`, `afficher` → `print`, …), and hands the result to CPython. This guarantees exact Python-semantics parity and keeps the transpiler small and auditable. The reverse direction (Python → Baobab) works the same way and preserves comments and formatting.
239
+
240
+ > A richer Lark-based grammar (with a real AST and Baobab-native diagnostics carrying line/column spans) is on the roadmap. Today's token-level transpiler is intentionally simple and exact.
241
+
242
+ ## Roadmap
243
+
244
+ > Ordered by the mission - beginners learning to program in French - not by
245
+ > engineering convenience. Full canonical roadmap: [`ROADMAP.md`](../ROADMAP.md).
246
+
247
+ **Shipped**
248
+
249
+ - [x] Baobab ↔ Python transpiler (bidirectional, formatting-preserving)
250
+ - [x] French-first runtime & sandbox (rlimits + seccomp + memory/fork-bomb guards) with Baobab tracebacks
251
+ - [x] `bao` CLI (run / translate / build / test / format) + the `baobab` alias
252
+ - [x] Platform API (execution + interactive WS, projects, auth, billing)
253
+ - [x] AI assistant (agentic, streaming; BYO provider + managed Pro)
254
+ - [x] Conformance suite (docs = contract)
255
+ - [x] The book - *« Apprendre la programmation avec Baobab »*
256
+ - [x] Pedagogical French error messages - an "error explainer" (French explanation + fix hint) for common syntax & runtime mistakes
257
+
258
+ **Now - learning experience & reach**
259
+
260
+ - [ ] CLI public distribution - `pipx install baobab-lang` on PyPI + one-line installer
261
+ - [ ] VS Code extension (highlighting & snippets → Run button → LSP)
262
+
263
+ **Next**
264
+
265
+ - [ ] In-browser execution (Pyodide / WASM) - free-tier runs client-side
266
+ - [ ] Visual output - turtle graphics (`tortue`)
267
+ - [ ] Interactive in-Studio tutorial
268
+ - [ ] Lark grammar + AST + Baobab-native diagnostics (line/column)
269
+ - [ ] Shareable / embeddable runnable snippets
270
+
271
+ **Later**
272
+
273
+ - [ ] Classroom / teacher features (assignments, auto-grading, progress)
274
+ - [ ] Per-run container sandbox for fully-public execution at scale
275
+ - [ ] Debugger + deeper editor tooling
276
+ - [ ] Mobile experience
277
+ - [ ] Package manager (`bao install`) + community registry
278
+ - [ ] Independent runtime (long-term, low priority - Python is an asset)
279
+
280
+ ## Contributing
281
+
282
+ Contributions are welcome - newcomers included. Please read **[CONTRIBUTING.md](CONTRIBUTING.md)**; it covers the setup, the CI gate, and the few rules that keep the language coherent. By participating you agree to our [Code of Conduct](CONTRIBUTING.md#code-of-conduct).
283
+
284
+ ## Acknowledgements
285
+
286
+ - Inspired by the _spirit_ of Ruslan Spivak's [**Let's Build A Simple Interpreter**](https://ruslanspivak.com/lsbasi-part1/) - the idea that building a language should be approachable. _(Baobab takes a transpiler approach rather than a tree-walking interpreter.)_
287
+ - Thanks to my friend [**Bedru**](https://github.com/bedre7) and his [**Abugida**](https://github.com/bedre7/abugida), a kindred educational language.
288
+
289
+ ## License
290
+
291
+ Released under the [**MIT License**](LICENSE) · © 2026 [Wontan SAS](https://wontan.tech). Created by **Seidy KANTE**.
292
+
293
+ <div align="center"><sub>Part of the <a href="https://github.com/baobablang">Baobab</a> ecosystem · <a href="https://baobablang.dev">baobablang.dev</a></sub></div>
@@ -0,0 +1,255 @@
1
+ <div align="center">
2
+
3
+ # 🌳 Baobab
4
+
5
+ **Learn to program in French - and read like Python underneath.**
6
+
7
+ Write `fonction`, `si`, `pour`, `afficher`. Baobab transpiles to standard Python and runs on CPython, so you keep the entire Python ecosystem with virtually no runtime overhead.
8
+
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Python](https://img.shields.io/badge/Python-3.13+-3776AB.svg?logo=python&logoColor=white)](https://www.python.org) [![FastAPI](https://img.shields.io/badge/API-FastAPI-009688.svg?logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com) [![Tests](https://img.shields.io/badge/tests-conformance%20suite-brightgreen.svg)](tests/) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
10
+
11
+ [**Website**](https://baobablang.dev) · [**Documentation**](https://baobablang.dev/docs) · [**Playground**](https://baobablang.dev/playground) · [**Studio (web IDE)**](https://github.com/baobablang/baobab-studio)
12
+
13
+ </div>
14
+
15
+ ---
16
+
17
+ ## Why Baobab?
18
+
19
+ Most beginners fight two battles at once: **learning to program** and **learning English keywords**. Baobab removes the second while preserving Python's exact semantics. Once you're comfortable in Baobab, the move to Python is almost mechanical.
20
+
21
+ > Baobab is **not** Python translated into French. It is a programming language designed around French vocabulary that stays **fully compatible with Python** a gateway into real programming, not a walled garden.
22
+
23
+ > **Naming:** **Baobab** is the programming language (and the wider ecosystem [baobablang.dev](https://baobablang.dev)). **Bao** is its short name: the `.bao` file extension and the `bao` CLI - like _Py_ for Python. **Baobab Studio** is the web IDE.
24
+
25
+ ## What is Baobab?
26
+
27
+ - ✔ A programming language with **French vocabulary** and **Python semantics**
28
+ - ✔ **Transpiles to standard Python** - runs on CPython, virtually no overhead
29
+ - ✔ **Bidirectional** translation: Baobab → Python to run, Python → Baobab to learn
30
+ - ✔ A **`bao` CLI** and a **sandboxed runtime** with tracebacks shown _in Baobab_
31
+ - ✔ A **platform API** (execution, projects, auth) and an optional AI assistant
32
+ - ✔ **MIT open source**, bilingual (French / English)
33
+
34
+ This repository is the **reference implementation** of the Baobab language.
35
+
36
+ ## See it
37
+
38
+ <table>
39
+ <tr><th>Baobab</th><th>Python</th></tr>
40
+ <tr valign="top"><td>
41
+
42
+ ```python
43
+ fonction fibonacci(n):
44
+ suite = [0, 1]
45
+ tantque longueur(suite) < n:
46
+ suite.ajouter(suite[-1] + suite[-2])
47
+ retourner suite
48
+
49
+ afficher(fibonacci(10))
50
+ ```
51
+
52
+ </td><td>
53
+
54
+ ```python
55
+ def fibonacci(n):
56
+ suite = [0, 1]
57
+ while len(suite) < n:
58
+ suite.append(suite[-1] + suite[-2])
59
+ return suite
60
+
61
+ print(fibonacci(10))
62
+ ```
63
+
64
+ </td></tr>
65
+ </table>
66
+
67
+ Both print `[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]`.
68
+
69
+ It is not a mini-language nearly all of Python is there: conditionals, functions, classes, exceptions and context managers all have a direct Baobab form.
70
+
71
+ ```python
72
+ fonction est_pair(n):
73
+ retourner n % 2 == 0
74
+
75
+ classe Animal:
76
+ fonction nouveau(nom):
77
+ ce.nom = nom
78
+
79
+ essayer:
80
+ x = entier(entree)
81
+ attraper ErreurValeur:
82
+ afficher("Nombre invalide")
83
+
84
+ avec ouvrir("notes.txt") comme f:
85
+ afficher(f.lire())
86
+ ```
87
+
88
+ ## Is Baobab a real programming language?
89
+
90
+ **Yes**. Baobab has its own vocabulary, documentation, CLI, runtime and conformance suite. It is precise about _how_ it runs your code:
91
+
92
+ - Baobab is a **transpiler** (a source-to-source compiler): it rewrites Baobab into Python and lets CPython execute the result.
93
+ - It is **not** an interpreter, and there is **virtually no runtime overhead** execution goes `Baobab → Python → CPython`, the same engine every Python program uses.
94
+
95
+ See [Implementation](#implementation) for the details of how the transpiler works.
96
+
97
+ ## The language
98
+
99
+ - **French vocabulary, Python semantics.** Same indentation, same behavior only the surface words change. When in doubt, Baobab does what Python does.
100
+ - **Accent-free & typable.** The vocabulary avoids accents (`inserer`, `cles`, `trie`, `ErreurCle`…) so it works on any keyboard; sample identifiers follow PEP 8 ASCII. Accents live only in strings and prose.
101
+ - **Strict by design.** Running a `.bao` file that uses a Python word with a Baobab spelling (`return`, `while`, `print`…) is refused pointing you at the right word.
102
+ - **Bilingual runtime messages.** Errors and diagnostics follow the platform language (`fr` / `en`).
103
+
104
+ ## The CLI
105
+
106
+ ```bash
107
+ bao run main.bao # execute a Baobab program
108
+ bao translate main.bao --to python # show the Python translation
109
+ bao build # transpile a project bao test # run project tests
110
+ bao format src/ # format Baobab sources bao --help # every command
111
+ ```
112
+
113
+ ## The runtime
114
+
115
+ Programs run in a **sandbox**: an isolated subprocess with CPU/file output resource limits, a wall-clock timeout, a stripped environment (user code cannot read your secrets) and a **seccomp network block** (no sockets → no exfiltration).
116
+ Tracebacks are rewritten into **Baobab** French error names and your own source lines, not the generated Python.
117
+
118
+ > [!WARNING]
119
+ > The bundled subprocess sandbox is hardened for a trusted/beta setting but is **not sufficient for fully-public untrusted multi-tenant traffic**. Before an open launch, execution must move into per-run, network-isolated containers behind the same `run_project` / `run_interactive` interface. Do not expose arbitrary code execution publicly without that layer.
120
+
121
+ ## The platform API
122
+
123
+ A **FastAPI** service on top of the language:
124
+
125
+ - **Execution** - `POST /api/run` and an interactive WebSocket (`/api/run/ws`) for programs that read input (`lire()`), auth-gated.
126
+ - **Translation** - `POST /api/translate` (Baobab ↔ Python).
127
+ - **Projects** - CRUD, folders, ZIP export, public share links.
128
+ - **Auth** - register + email OTP, login, password reset/change, sessions, rate limiting.
129
+ - **Billing** - plans, entitlements, metered usage, Stripe checkout/portal/webhook.
130
+
131
+ ## AI assistant
132
+
133
+ A **bonus** layer, not what makes Baobab unique: an agentic, streaming assistant (`/api/ai/agent`) that returns file actions applied to the workspace. It supports **bring-your-own provider** (Ollama / OpenAI / Anthropic / Gemini) and is grounded in the language reference via **RAG**. A managed ("Pro") tier uses server-side keys.
134
+
135
+ ## Architecture
136
+
137
+ ```
138
+ Baobab Studio (web IDE - separate repo)
139
+ │ HTTPS / WSS
140
+ FastAPI backend (this repo)
141
+ ┌────────┴─────────┐
142
+ Transpiler AI agent (RAG)
143
+ │
144
+ Python
145
+ │
146
+ CPython runtime (sandboxed)
147
+ ```
148
+
149
+ The **Baobab vocabulary source of truth** lives in the frontend(`baobab-reference.ts`); `lang/vocabulary.py` mirrors it, and the **conformance suite** runs every reference and IDE example on **both** the Baobab and Python side, asserting identical output - so the docs and the language stay provably in sync.
150
+
151
+ ## Quick start
152
+
153
+ > **Requirements:** Python **3.13+** (Baobab relies on the 3.12+ f-string tokenizer).
154
+ > Everything installs into a local `./.venv` - never the system Python.
155
+
156
+ ```bash
157
+ git clone https://github.com/baobablang/baobab.git
158
+ cd baobab
159
+
160
+ python3.13 -m venv .venv
161
+ .venv/bin/pip install -e ".[dev,server]"
162
+ ```
163
+
164
+ > **CLI only?** The `bao` command is 100% stdlib - once published,
165
+ > `pipx install baobab-lang` installs it with zero dependencies; the API
166
+ > server ships as the `[server]` extra (`pip install "baobab-lang[server]"`).
167
+
168
+ Run your first program:
169
+
170
+ ```bash
171
+ .venv/bin/bao run examples/hello.bao # execute a Baobab program
172
+ .venv/bin/bao translate examples/hello.bao # see the Python translation
173
+ ```
174
+
175
+ Start the API and developer tasks:
176
+
177
+ ```bash
178
+ make dev # API with reload → http://localhost:8000
179
+ make check # CI gate: lint + format check + tests
180
+ make help # every developer task
181
+ ```
182
+
183
+ The defaults are zero-infra (SQLite, no Redis). `pip install -e ".[server,prod]"` adds PostgreSQL + Redis drivers; `make up-data` starts them via Docker.
184
+
185
+ ## Project layout
186
+
187
+ ```
188
+ src/baobab/
189
+ ├── lang/ # vocabulary tables · token-level transpiler · diagnostics
190
+ ├── runtime/ # sandboxed executor · French stdlib (afficher, ouvrir, maths…)
191
+ ├── cli.py # the `bao` command
192
+ ├── api/ # FastAPI app: run · translate · projects · auth · billing · AI
193
+ ├── services/ # ai (agent + RAG) · auth · projects · billing · export · otp
194
+ └── core/ # config · dual-dialect DB (SQLite/Postgres) · Redis · messages
195
+ tests/ # unit · conformance (the docs ARE the contract) · API tests
196
+ ```
197
+
198
+ ## Implementation
199
+
200
+ Baobab ships **no** hand-written lexer, parser or AST. Instead it reuses **CPython's own tokenizer**: it tokenizes your Baobab source, rewrites the French tokens to their Python equivalent (`fonction` → `def`, `afficher` → `print`, …), and hands the result to CPython. This guarantees exact Python-semantics parity and keeps the transpiler small and auditable. The reverse direction (Python → Baobab) works the same way and preserves comments and formatting.
201
+
202
+ > A richer Lark-based grammar (with a real AST and Baobab-native diagnostics carrying line/column spans) is on the roadmap. Today's token-level transpiler is intentionally simple and exact.
203
+
204
+ ## Roadmap
205
+
206
+ > Ordered by the mission - beginners learning to program in French - not by
207
+ > engineering convenience. Full canonical roadmap: [`ROADMAP.md`](../ROADMAP.md).
208
+
209
+ **Shipped**
210
+
211
+ - [x] Baobab ↔ Python transpiler (bidirectional, formatting-preserving)
212
+ - [x] French-first runtime & sandbox (rlimits + seccomp + memory/fork-bomb guards) with Baobab tracebacks
213
+ - [x] `bao` CLI (run / translate / build / test / format) + the `baobab` alias
214
+ - [x] Platform API (execution + interactive WS, projects, auth, billing)
215
+ - [x] AI assistant (agentic, streaming; BYO provider + managed Pro)
216
+ - [x] Conformance suite (docs = contract)
217
+ - [x] The book - *« Apprendre la programmation avec Baobab »*
218
+ - [x] Pedagogical French error messages - an "error explainer" (French explanation + fix hint) for common syntax & runtime mistakes
219
+
220
+ **Now - learning experience & reach**
221
+
222
+ - [ ] CLI public distribution - `pipx install baobab-lang` on PyPI + one-line installer
223
+ - [ ] VS Code extension (highlighting & snippets → Run button → LSP)
224
+
225
+ **Next**
226
+
227
+ - [ ] In-browser execution (Pyodide / WASM) - free-tier runs client-side
228
+ - [ ] Visual output - turtle graphics (`tortue`)
229
+ - [ ] Interactive in-Studio tutorial
230
+ - [ ] Lark grammar + AST + Baobab-native diagnostics (line/column)
231
+ - [ ] Shareable / embeddable runnable snippets
232
+
233
+ **Later**
234
+
235
+ - [ ] Classroom / teacher features (assignments, auto-grading, progress)
236
+ - [ ] Per-run container sandbox for fully-public execution at scale
237
+ - [ ] Debugger + deeper editor tooling
238
+ - [ ] Mobile experience
239
+ - [ ] Package manager (`bao install`) + community registry
240
+ - [ ] Independent runtime (long-term, low priority - Python is an asset)
241
+
242
+ ## Contributing
243
+
244
+ Contributions are welcome - newcomers included. Please read **[CONTRIBUTING.md](CONTRIBUTING.md)**; it covers the setup, the CI gate, and the few rules that keep the language coherent. By participating you agree to our [Code of Conduct](CONTRIBUTING.md#code-of-conduct).
245
+
246
+ ## Acknowledgements
247
+
248
+ - Inspired by the _spirit_ of Ruslan Spivak's [**Let's Build A Simple Interpreter**](https://ruslanspivak.com/lsbasi-part1/) - the idea that building a language should be approachable. _(Baobab takes a transpiler approach rather than a tree-walking interpreter.)_
249
+ - Thanks to my friend [**Bedru**](https://github.com/bedre7) and his [**Abugida**](https://github.com/bedre7/abugida), a kindred educational language.
250
+
251
+ ## License
252
+
253
+ Released under the [**MIT License**](LICENSE) · © 2026 [Wontan SAS](https://wontan.tech). Created by **Seidy KANTE**.
254
+
255
+ <div align="center"><sub>Part of the <a href="https://github.com/baobablang">Baobab</a> ecosystem · <a href="https://baobablang.dev">baobablang.dev</a></sub></div>
@@ -0,0 +1,96 @@
1
+ [project]
2
+ name = "baobab-lang"
3
+ version = "0.1.0"
4
+ description = "Baobab: the French-first programming language - bao CLI (run, translate, build, test, format)"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ requires-python = ">=3.13"
8
+ authors = [{ name = "Seidy KANTE", email = "seidy@baobablang.dev" }]
9
+ keywords = ["baobab", "bao", "langage", "francais", "french", "education", "python"]
10
+ classifiers = [
11
+ # Maturity
12
+ "Development Status :: 4 - Beta",
13
+ # Audience
14
+ "Intended Audience :: Education",
15
+ "Intended Audience :: Developers",
16
+ # Topic
17
+ "Topic :: Education",
18
+ "Topic :: Software Development :: Interpreters",
19
+ "Topic :: Software Development :: Compilers",
20
+ # Language
21
+ "Natural Language :: French",
22
+ # License — expressed via the `license` field above (PEP 639)
23
+ # "License :: OSI Approved :: MIT License", # removed: redundant with license = "MIT"
24
+ # Python versions
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Programming Language :: Python :: 3 :: Only",
28
+ # OS
29
+ "Operating System :: OS Independent",
30
+ ]
31
+ # The bao CLI is 100% stdlib: NO mandatory dependencies. Server/API deps
32
+ # live in the [server] extra so `pipx install baobab-lang` stays tiny.
33
+ dependencies = []
34
+
35
+ [project.urls]
36
+ Homepage = "https://www.baobablang.dev"
37
+ Documentation = "https://www.baobablang.dev/docs"
38
+ Repository = "https://github.com/baobablang/baobab"
39
+
40
+ [project.optional-dependencies]
41
+ # The platform API server (Baobab Studio backend): pip install "baobab-lang[server]"
42
+ server = [
43
+ "fastapi>=0.115",
44
+ "uvicorn>=0.30",
45
+ # WebSocket protocol library uvicorn needs to serve /api/run/ws (interactive
46
+ # runs). Without it uvicorn logs "No supported WebSocket library" → 404.
47
+ "websockets>=13",
48
+ "pybars3>=0.9",
49
+ ]
50
+ dev = [
51
+ "pytest>=8",
52
+ "httpx>=0.27",
53
+ "ruff>=0.6",
54
+ ]
55
+ # Production backends (PostgreSQL + Redis). SQLite/no-Redis is the default and
56
+ # needs none of these; install with: pip install -e ".[server,prod]"
57
+ prod = [
58
+ "psycopg[binary]>=3.2",
59
+ "redis>=5",
60
+ ]
61
+
62
+ [project.scripts]
63
+ bao = "baobab.cli:main"
64
+ # Official alias (naming charter): `baobab prog.bao` == `bao run prog.bao`,
65
+ # the way the Windows launcher pairs `py` with `python`.
66
+ baobab = "baobab.cli:main"
67
+
68
+ [build-system]
69
+ requires = ["setuptools>=68"]
70
+ build-backend = "setuptools.build_meta"
71
+
72
+ [tool.setuptools.packages.find]
73
+ where = ["src"]
74
+
75
+ [tool.setuptools.package-data]
76
+ "baobab.runtime" = ["sandbox/*.py"]
77
+ "baobab.mail" = ["templates/*.hbs"]
78
+ "baobab.lang" = ["reference_kb.json"] # RAG knowledge base (ships with the wheel)
79
+
80
+ [tool.pytest.ini_options]
81
+ testpaths = ["tests"]
82
+
83
+ [tool.ruff]
84
+ line-length = 100
85
+ target-version = "py313"
86
+
87
+ [tool.ruff.lint]
88
+ select = ["E", "F", "I", "W", "UP", "B"]
89
+
90
+ [tool.ruff.lint.flake8-bugbear]
91
+ # FastAPI's dependency-injection markers are meant to be used as arg defaults.
92
+ extend-immutable-calls = ["fastapi.Depends", "fastapi.Header", "fastapi.Query", "fastapi.Path", "fastapi.Body"]
93
+
94
+ [tool.ruff.lint.per-file-ignores]
95
+ # The AI system prompt is long-form text; don't wrap it.
96
+ "src/baobab/services/ai.py" = ["E501"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """Baobab backend: the Bao language toolchain and platform API."""
2
+
3
+ __version__ = "0.1.0"
File without changes