nous-lang 3.8.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 (86) hide show
  1. nous_lang-3.8.0/LICENSE +21 -0
  2. nous_lang-3.8.0/MANIFEST.in +4 -0
  3. nous_lang-3.8.0/PKG-INFO +399 -0
  4. nous_lang-3.8.0/README.md +368 -0
  5. nous_lang-3.8.0/ast_nodes.py +510 -0
  6. nous_lang-3.8.0/behavioral_diff.py +533 -0
  7. nous_lang-3.8.0/benchmarks.py +263 -0
  8. nous_lang-3.8.0/bridge.py +238 -0
  9. nous_lang-3.8.0/cli.py +1430 -0
  10. nous_lang-3.8.0/codegen.py +1025 -0
  11. nous_lang-3.8.0/codegen_js.py +700 -0
  12. nous_lang-3.8.0/compiler.nous +137 -0
  13. nous_lang-3.8.0/compiler_senses.py +277 -0
  14. nous_lang-3.8.0/cost_oracle.py +342 -0
  15. nous_lang-3.8.0/cross_world.py +250 -0
  16. nous_lang-3.8.0/cross_world_command.nous +56 -0
  17. nous_lang-3.8.0/cross_world_test.nous +34 -0
  18. nous_lang-3.8.0/customer_service.nous +137 -0
  19. nous_lang-3.8.0/debugger.py +544 -0
  20. nous_lang-3.8.0/distributed.py +363 -0
  21. nous_lang-3.8.0/docs_generator.py +418 -0
  22. nous_lang-3.8.0/dream_engine.py +483 -0
  23. nous_lang-3.8.0/dream_lucid_test.nous +39 -0
  24. nous_lang-3.8.0/dream_test.nous +48 -0
  25. nous_lang-3.8.0/error_recovery.py +277 -0
  26. nous_lang-3.8.0/formatter.py +476 -0
  27. nous_lang-3.8.0/gate_alpha.nous +116 -0
  28. nous_lang-3.8.0/gate_alpha_test.nous +104 -0
  29. nous_lang-3.8.0/grammar_data.py +7 -0
  30. nous_lang-3.8.0/hot_reload_engine.py +287 -0
  31. nous_lang-3.8.0/immune_engine.py +727 -0
  32. nous_lang-3.8.0/immune_test.nous +127 -0
  33. nous_lang-3.8.0/import_resolver.py +238 -0
  34. nous_lang-3.8.0/import_test.nous +28 -0
  35. nous_lang-3.8.0/infra_monitor.nous +29 -0
  36. nous_lang-3.8.0/lsp_server.py +836 -0
  37. nous_lang-3.8.0/mcp_bridge.py +296 -0
  38. nous_lang-3.8.0/mcp_example.nous +98 -0
  39. nous_lang-3.8.0/migrate_v2.py +631 -0
  40. nous_lang-3.8.0/mitosis_engine.py +493 -0
  41. nous_lang-3.8.0/mitosis_test.nous +127 -0
  42. nous_lang-3.8.0/mutation_test.nous +37 -0
  43. nous_lang-3.8.0/natural_lang.py +446 -0
  44. nous_lang-3.8.0/noesis_alpha.nous +210 -0
  45. nous_lang-3.8.0/noesis_integration_test.nous +49 -0
  46. nous_lang-3.8.0/noesis_phase9_test.nous +45 -0
  47. nous_lang-3.8.0/noosphere_migrated.nous +2716 -0
  48. nous_lang-3.8.0/nous.lark +414 -0
  49. nous_lang-3.8.0/nous_ast_runner.py +320 -0
  50. nous_lang-3.8.0/nous_lang.egg-info/PKG-INFO +399 -0
  51. nous_lang-3.8.0/nous_lang.egg-info/SOURCES.txt +84 -0
  52. nous_lang-3.8.0/nous_lang.egg-info/dependency_links.txt +1 -0
  53. nous_lang-3.8.0/nous_lang.egg-info/entry_points.txt +2 -0
  54. nous_lang-3.8.0/nous_lang.egg-info/requires.txt +10 -0
  55. nous_lang-3.8.0/nous_lang.egg-info/top_level.txt +46 -0
  56. nous_lang-3.8.0/nous_runtime.py +562 -0
  57. nous_lang-3.8.0/nsp.py +226 -0
  58. nous_lang-3.8.0/parser.py +1010 -0
  59. nous_lang-3.8.0/plugin_manager.py +330 -0
  60. nous_lang-3.8.0/profiler.py +296 -0
  61. nous_lang-3.8.0/pyproject.toml +62 -0
  62. nous_lang-3.8.0/registry.py +283 -0
  63. nous_lang-3.8.0/repl.py +635 -0
  64. nous_lang-3.8.0/research_pipeline.nous +152 -0
  65. nous_lang-3.8.0/retire_test.nous +87 -0
  66. nous_lang-3.8.0/runtime.py +721 -0
  67. nous_lang-3.8.0/self_compiler.py +186 -0
  68. nous_lang-3.8.0/setup.cfg +4 -0
  69. nous_lang-3.8.0/signals.nous +14 -0
  70. nous_lang-3.8.0/symbiosis_engine.py +272 -0
  71. nous_lang-3.8.0/symbiosis_test.nous +78 -0
  72. nous_lang-3.8.0/telemetry_engine.py +373 -0
  73. nous_lang-3.8.0/telemetry_test.nous +85 -0
  74. nous_lang-3.8.0/test_deploy_topology.nous +49 -0
  75. nous_lang-3.8.0/test_distributed.nous +72 -0
  76. nous_lang-3.8.0/test_lsp_errors.nous +29 -0
  77. nous_lang-3.8.0/test_runner.py +396 -0
  78. nous_lang-3.8.0/topology_test.nous +135 -0
  79. nous_lang-3.8.0/typechecker.py +495 -0
  80. nous_lang-3.8.0/validator.py +442 -0
  81. nous_lang-3.8.0/verifier.py +962 -0
  82. nous_lang-3.8.0/visualizer.py +465 -0
  83. nous_lang-3.8.0/wasm_builder.py +131 -0
  84. nous_lang-3.8.0/watch.py +185 -0
  85. nous_lang-3.8.0/watcher.py +194 -0
  86. nous_lang-3.8.0/workspace.py +433 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hlias Staurou (contrario)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include nous.lark
2
+ include LICENSE
3
+ include README.md
4
+ include *.nous
@@ -0,0 +1,399 @@
1
+ Metadata-Version: 2.4
2
+ Name: nous-lang
3
+ Version: 3.8.0
4
+ Summary: NOUS (Νοῦς) — The Living Language for Agentic AI Systems
5
+ Author-email: Hlias Staurou <support@nous-lang.org>
6
+ License: MIT
7
+ Project-URL: Homepage, https://nous-lang.org
8
+ Project-URL: Repository, https://github.com/contrario/nous
9
+ Project-URL: Documentation, https://nous-lang.org/docs
10
+ Keywords: ai,agents,language,compiler,evolution,multi-agent,soul,mitosis,symbiosis
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Compilers
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: lark>=1.1.0
23
+ Requires-Dist: pydantic>=2.0.0
24
+ Requires-Dist: httpx>=0.25.0
25
+ Provides-Extra: lsp
26
+ Requires-Dist: pygls>=1.3.0; extra == "lsp"
27
+ Requires-Dist: lsprotocol>=2024.0.0; extra == "lsp"
28
+ Provides-Extra: all
29
+ Requires-Dist: nous-lang[lsp]; extra == "all"
30
+ Dynamic: license-file
31
+
32
+ # NOUS (Νοῦς) — The Living Language
33
+
34
+ **The world's first self-evolving programming language for agentic AI systems.**
35
+
36
+ ```
37
+ _ _ ___ _ _ ____
38
+ | \ | |/ _ \| | | / ___|
39
+ | \| | | | | | | \___ \
40
+ | |\ | |_| | |_| |___) |
41
+ |_| \_|\___/ \___/|____/ v1.4.0
42
+ ```
43
+
44
+ **Author:** Hlias Staurou (Hlia) | **Project:** Noosphere | **GitHub:** contrario
45
+
46
+ ---
47
+
48
+ ## What is NOUS?
49
+
50
+ NOUS is a programming language where **code is alive**. Unlike every existing language where programs are static text, NOUS programs:
51
+
52
+ - **Observe** their own execution
53
+ - **Evaluate** their performance via fitness metrics
54
+ - **Mutate** their own DNA parameters
55
+ - **Evolve** autonomously within constitutional safety boundaries
56
+ - **Self-heal** on failure without human intervention
57
+
58
+ NOUS transpiles to **Python 3.11+ asyncio** and integrates with the Noosphere Multi-Agent Platform (100+ agents, 143+ tools).
59
+
60
+ ---
61
+
62
+ ## Performance
63
+
64
+ | Metric | Value |
65
+ |--------|-------|
66
+ | Parser | LALR (Lark), 3.3ms/parse |
67
+ | Earley → LALR speedup | 90.6x |
68
+ | Compile (gate_alpha.nous) | 0.14s → 421 lines Python |
69
+ | Full pipeline (4 souls) | ~8s cycle |
70
+ | Grammar rules | ~200 (bilingual EN+GR) |
71
+ | AST nodes | 43+ Pydantic V2 models |
72
+
73
+ ---
74
+
75
+ ## Quick Start
76
+
77
+ ```bash
78
+ # Install
79
+ pip install lark pydantic ccxt --break-system-packages
80
+ cp install.sh /usr/local/bin/nous && chmod +x /usr/local/bin/nous
81
+
82
+ # Single world
83
+ nous compile gate_alpha.nous # → gate_alpha.py
84
+ nous run gate_alpha.nous # compile + execute
85
+ nous validate gate_alpha.nous # check laws + constitutional guards
86
+
87
+ # Multi-world (concurrent)
88
+ nous run gate_alpha.nous infra_monitor.nous # 2 worlds, all souls concurrent
89
+
90
+ # Tools
91
+ nous info gate_alpha.nous # program summary
92
+ nous evolve gate_alpha.nous --cycles 5 # DNA mutation
93
+ nous bridge gate_alpha.nous # Noosphere integration
94
+ nous ast gate_alpha.nous --json # Living AST
95
+ nous nsp "[NSP|CT.88|M.safe]" # parse NSP tokens
96
+ nous version # v1.4.0
97
+ ```
98
+
99
+ ---
100
+
101
+ ## Language Syntax
102
+
103
+ ### World
104
+
105
+ Every `.nous` file defines one world — a self-contained execution environment with inviolable laws.
106
+
107
+ ```nous
108
+ world GateAlpha {
109
+ law CostCeiling = $0.10 per cycle
110
+ law MaxLatency = 30s
111
+ law NoLiveTrading = true
112
+ law MaxPositionSize = $500
113
+ law MaxDailyLoss = $100
114
+ heartbeat = 5m
115
+ config telegram_chat = env("TELEGRAM_CHAT_ID")
116
+ }
117
+ ```
118
+
119
+ ### Soul
120
+
121
+ The fundamental unit — agent + state + behavior + evolution + healing in one construct.
122
+
123
+ ```nous
124
+ soul Scout {
125
+ mind: deepseek-r1 @ Tier1
126
+ senses: [gate_alpha_scan, fetch_rsi]
127
+
128
+ memory {
129
+ signals: [Signal] = []
130
+ scan_count: int = 0
131
+ }
132
+
133
+ instinct {
134
+ let tokens = sense gate_alpha_scan()
135
+ let candidates = tokens.where(volume_24h > 50000)
136
+
137
+ for token in candidates {
138
+ let rsi = sense fetch_rsi(pair: token.pair)
139
+ if rsi < 35 {
140
+ speak Signal(pair: token.pair, score: token.score, rsi: rsi, source: self)
141
+ }
142
+ }
143
+
144
+ remember scan_count += 1
145
+ }
146
+
147
+ dna {
148
+ temperature: 0.3 ~ [0.1, 0.9]
149
+ threshold: 0.7 ~ [0.5, 0.95]
150
+ }
151
+
152
+ heal {
153
+ on timeout => retry(3, exponential)
154
+ on hallucination => lower(temperature, 0.1) then retry
155
+ on budget_exceeded => hibernate until next_cycle
156
+ }
157
+ }
158
+ ```
159
+
160
+ ### Messages
161
+
162
+ Typed inter-soul communication:
163
+
164
+ ```nous
165
+ message Signal {
166
+ pair: string
167
+ score: float
168
+ rsi: float?
169
+ source: SoulRef
170
+ }
171
+
172
+ message Decision {
173
+ action: string
174
+ pair: string
175
+ size: float
176
+ reason: string
177
+ }
178
+ ```
179
+
180
+ ### Nervous System
181
+
182
+ DAG orchestration as native syntax:
183
+
184
+ ```nous
185
+ nervous_system {
186
+ Scout -> Quant -> Hunter # linear pipeline
187
+ Scout -> Monitor # parallel branch
188
+ [Analyst, Researcher] -> Synth # fan-in
189
+ Alert -> [Monitor, Dashboard] # fan-out
190
+ }
191
+ ```
192
+
193
+ ### Constitutional Guards
194
+
195
+ Compile-time and runtime safety for trading systems:
196
+
197
+ ```nous
198
+ world SafeTrader {
199
+ law NoLiveTrading = true # C001: blocks live trade tools at compile time
200
+ law MaxPositionSize = $500 # C003: runtime position check
201
+ law MaxDailyLoss = $100 # C004: runtime circuit breaker
202
+ }
203
+ ```
204
+
205
+ The validator enforces:
206
+ - **C001**: `NoLiveTrading` blocks forbidden tools (`execute_trade`, `place_order`, etc.) — recursive scan in if/for bodies
207
+ - **C003**: Warning if trading souls exist without `MaxPositionSize`
208
+ - **C004**: Warning if trading souls exist without `MaxDailyLoss`
209
+
210
+ Runtime generates a `ConstitutionalGuard` class with position checks, daily loss circuit breaker, and audit logging.
211
+
212
+ ### Evolution
213
+
214
+ Self-mutation as a language primitive:
215
+
216
+ ```nous
217
+ evolution {
218
+ schedule: 3:00 AM
219
+ fitness: langfuse(quality_score)
220
+
221
+ mutate Scout.dna {
222
+ strategy: genetic(population: 5, generations: 3)
223
+ survive_if: fitness > parent.fitness
224
+ rollback_if: any_law_violated
225
+ }
226
+ }
227
+ ```
228
+
229
+ ### Perception
230
+
231
+ External event triggers:
232
+
233
+ ```nous
234
+ perception {
235
+ on telegram("/scan") => wake Scout
236
+ on cron("*/5 * * * *") => wake_all
237
+ on system_error => alert Telegram
238
+ }
239
+ ```
240
+
241
+ ---
242
+
243
+ ## Multi-World Execution
244
+
245
+ Run multiple worlds concurrently with shared communication:
246
+
247
+ ```bash
248
+ nous run gate_alpha.nous infra_monitor.nous
249
+ ```
250
+
251
+ ```
252
+ NOUS Multi-World: 2 worlds
253
+ → gate_alpha.nous
254
+ → infra_monitor.nous
255
+ [gate_alpha] Scout: cycle complete
256
+ [gate_alpha] Quant: Decision(BUY)
257
+ [infra_monitor] Watcher: all systems nominal
258
+ ```
259
+
260
+ Each world runs in its own asyncio task via `TaskGroup`. Cross-world communication via `SharedChannelBus` (prepared, integration in progress).
261
+
262
+ ---
263
+
264
+ ## Tier System
265
+
266
+ | Tier | Provider | Cost | Models |
267
+ |------|----------|------|--------|
268
+ | Tier0A | Anthropic Direct | $0.01-0.30 | Claude Haiku, Sonnet |
269
+ | Tier0B | OpenAI | $0.01-0.15 | GPT-4o |
270
+ | Tier1 | OpenRouter | $0.001-0.01 | DeepSeek, MiMo |
271
+ | Tier2 | Free | $0.00 | Gemini Flash Lite |
272
+ | Tier3 | Local | $0.00 | Ollama, BitNet |
273
+
274
+ ---
275
+
276
+ ## Type System
277
+
278
+ **Primitives:** `int`, `float`, `string`, `bool`, `timestamp`, `duration`, `currency`, `tier`, `mode`, `style`
279
+
280
+ **Composites:** `[T]` (list), `{K: V}` (map), `T?` (optional), `SoulRef`, `ToolRef`
281
+
282
+ ---
283
+
284
+ ## NSP (Noosphere Shorthand Protocol)
285
+
286
+ Compress LLM instructions. **40-70% token savings.**
287
+
288
+ ```
289
+ [NSP|CT.88|F.78|R.scout|M.safe]
290
+ → Confidence Threshold: 0.88 | Focus coefficient: 0.78 | Router: scout | Mode: safe
291
+ ```
292
+
293
+ ```bash
294
+ nous nsp "[NSP|CT.88|M.safe|S.concise]"
295
+ nous nsp "CT=0.88,M=safe" --compress
296
+ ```
297
+
298
+ ---
299
+
300
+ ## Bilingual Keywords
301
+
302
+ Every keyword works in English and Greek:
303
+
304
+ ```nous
305
+ ψυχή Scout {
306
+ μνήμη {
307
+ signals: [Signal] = []
308
+ }
309
+ ένστικτο {
310
+ let data = αίσθηση scan_market()
311
+ θυμάμαι signals = data.filter(score > 0.7)
312
+ λέω Signal(data.top)
313
+ }
314
+ }
315
+ ```
316
+
317
+ ---
318
+
319
+ ## Architecture
320
+
321
+ ```
322
+ .nous file → LALR Parser (3.3ms) → Living AST (Ψυχόδενδρο) → Validator → Python CodeGen → asyncio runtime
323
+
324
+ Aevolver (DNA mutations operate directly on this tree)
325
+ ```
326
+
327
+ The **Living AST** is not discarded after compilation — it persists in memory as the program's runtime representation. The Aevolver mutates DNA nodes directly on this graph.
328
+
329
+ ---
330
+
331
+ ## File Structure
332
+
333
+ ```
334
+ nous/
335
+ ├── nous.lark # LALR grammar (~200 rules, bilingual)
336
+ ├── ast_nodes.py # 43+ Pydantic V2 AST nodes
337
+ ├── parser.py # LALR Transformer → Living AST (zero workarounds)
338
+ ├── validator.py # Law checker + constitutional guards (C001-C004)
339
+ ├── codegen.py # AST → Python 3.11+ asyncio + runtime integration
340
+ ├── multiworld.py # Concurrent multi-world runner (TaskGroup)
341
+ ├── cli.py # CLI v1.4.0: compile/run/validate/evolve/nsp/info/bridge
342
+ ├── nsp.py # Noosphere Shorthand Protocol
343
+ ├── aevolver.py # DNA mutation engine
344
+ ├── bridge.py # Noosphere integration analyzer
345
+ ├── migrate.py # YAML/TOML → .nous converter (106 agents migrated)
346
+ ├── gate_alpha.nous # Example: Gate Alpha trading cluster (4 souls)
347
+ ├── infra_monitor.nous # Example: Infrastructure monitoring world
348
+ └── README.md
349
+ ```
350
+
351
+ ---
352
+
353
+ ## Live Pipeline
354
+
355
+ ```
356
+ nous compile gate_alpha.nous → 421 lines Python, 0.14s, py_compile PASS
357
+
358
+ nous run gate_alpha.nous → Full pipeline:
359
+ Scout → DexScreener scan (7 candidates, 86ms)
360
+ → Real RSI from Binance (SOL/USDC RSI=60.67, 64 candles)
361
+ Quant → Kelly criterion (edge=0.5468) → Decision(BUY)
362
+ Hunter → Paper trade ($150.30)
363
+ Monitor → Telegram ✅
364
+ All 4 souls: cycle complete in ~8s
365
+ ```
366
+
367
+ ---
368
+
369
+ ## Safety Model
370
+
371
+ **Compile-time:** Type mismatches, undefined references, cycle detection, missing heal blocks, constitutional guard enforcement (C001-C004).
372
+
373
+ **Runtime:** Cost tracking per LLM call, position size limits, daily loss circuit breaker, audit logging, constitution hash verification, forbidden phrase detection, atomic rollback on law violations.
374
+
375
+ **Evolution:** Shadow AST → validate → test → fitness check → commit or rollback. Never unsupervised.
376
+
377
+ ---
378
+
379
+ ## What Makes NOUS Unique
380
+
381
+ | Innovation | Why It's Unprecedented |
382
+ |------------|----------------------|
383
+ | `soul` keyword | Agents as first-class grammar primitives |
384
+ | Living AST | Runtime-mutable AST that IS the program |
385
+ | `dna` block | Genetic evolution built into syntax |
386
+ | `law` keyword | Safety as physics, not middleware |
387
+ | `heal` block | Declarative self-repair |
388
+ | `nervous_system` | DAG as native syntax (A -> B -> C) |
389
+ | Constitutional Guards | Compile-time + runtime trading safety |
390
+ | Multi-world | Concurrent world execution via TaskGroup |
391
+ | LALR @ 3.3ms | Production-grade parser performance |
392
+ | Bilingual | English + Greek keywords |
393
+ | `speak/listen` | Type-safe inter-agent channels |
394
+ | `sense` | Tool integration as language primitive |
395
+
396
+ ---
397
+
398
+ *NOUS v1.4.0 — Born from Noosphere. Built for the future.*
399
+ *Hlias Staurou | April 2026 | Athens, Greece*