@misterscan/sesi 1.3.0 → 1.3.3

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. package/.agents/rules/sesi-must-read.md +116 -0
  2. package/.agents/workflows/create-sesi-script.md +44 -0
  3. package/.agents/workflows/fix-sesi-script.md +14 -0
  4. package/.github/prompts/MakeInSesi.prompt.md +79 -0
  5. package/README.md +74 -33
  6. package/bin/sesi.js +56 -23
  7. package/chatbot/chatbot.html +488 -0
  8. package/{main → chatbot}/chatbot.sesi +1 -2
  9. package/chatbot/chatbot_server.py +105 -0
  10. package/chatbot/sesi_db_chatbot.sesi +278 -0
  11. package/dist/ai-runtime.js +2 -2
  12. package/dist/builtins.d.ts.map +1 -1
  13. package/dist/builtins.js +3 -1
  14. package/dist/builtins.js.map +1 -1
  15. package/dist/index.d.ts +5 -0
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +61 -2
  18. package/dist/index.js.map +1 -1
  19. package/dist/interpreter.d.ts +10 -0
  20. package/dist/interpreter.d.ts.map +1 -1
  21. package/dist/interpreter.js +20 -4
  22. package/dist/interpreter.js.map +1 -1
  23. package/dist/parser.d.ts.map +1 -1
  24. package/dist/parser.js +3 -4
  25. package/dist/parser.js.map +1 -1
  26. package/dist/sesi.bundled.js +2526 -1487
  27. package/dist/types.d.ts +1 -1
  28. package/dist/types.d.ts.map +1 -1
  29. package/docs/ARCHITECTURE.md +2 -7
  30. package/docs/BUILTINS.md +27 -8
  31. package/docs/CLI.md +200 -0
  32. package/docs/COMPARISON.md +11 -6
  33. package/docs/IMPLEMENTATION_SUMMARY.md +57 -50
  34. package/docs/QUICKSTART.md +104 -23
  35. package/docs/README.md +84 -42
  36. package/docs/REASONING.md +21 -16
  37. package/docs/ROADMAP.md +10 -5
  38. package/docs/SKILLS.md +63 -116
  39. package/docs/SPECIFICATION.md +35 -23
  40. package/examples/03_functions.sesi +30 -1
  41. package/examples/07_prompts.sesi +26 -2
  42. package/examples/08_model_call.sesi +6 -4
  43. package/examples/09_structured_output.sesi +18 -2
  44. package/examples/10_code_generation.sesi +6 -4
  45. package/examples/11_memory_conversation.sesi +47 -15
  46. package/examples/12_classification.sesi +62 -7
  47. package/examples/13_data_pipeline.sesi +55 -28
  48. package/examples/14_folder_explainer.sesi +52 -51
  49. package/examples/15_image_generation.sesi +15 -14
  50. package/examples/16_modules.sesi +1 -1
  51. package/examples/19_search_web.sesi +18 -2
  52. package/examples/20_model_aliases.sesi +6 -6
  53. package/main/tests/test-args.sesi +7 -0
  54. package/main/tests/test_args.sesi +7 -0
  55. package/main/tests/test_general_modules.sesi +127 -0
  56. package/package.json +25 -21
  57. package/docs/CONCURRENCY.md +0 -71
  58. package/docs/sesi_ai_chronicles.md +0 -96
  59. package/main/conversational_classifier_weights.json +0 -45
  60. package/main/conversational_sentences.json +0 -304
  61. package/main/epochs.sesi +0 -94
  62. package/main/gpu_orchestrator.sesi +0 -36
  63. package/main/hardware_diagnostics.sesi +0 -118
  64. package/main/inference.sesi +0 -54
  65. package/main/native_chatbot.sesi +0 -180
  66. package/main/native_synthesizer.sesi +0 -83
  67. package/main/nn_personas_trainer.sesi +0 -302
  68. package/main/nn_responses_trainer.sesi +0 -269
  69. package/main/nn_sentences_trainer.sesi +0 -330
  70. package/main/orchestrator.sesi +0 -15
  71. package/main/personas.json +0 -124
  72. package/main/personas_classifier_weights.json +0 -45
  73. package/main/playground.sesi +0 -3
  74. package/main/predictive_typing.sesi +0 -127
  75. package/main/query_brain.sesi +0 -45
  76. package/main/response_classifier_weights.json +0 -45
  77. package/main/retro_chat.html +0 -239
  78. package/main/retro_chat_generator.sesi +0 -745
  79. package/main/sesi_ai.sesi +0 -158
  80. package/main/sesi_db_chatbot.sesi +0 -284
  81. package/main/setup_swarm.sesi +0 -5
  82. package/main/start.sesi +0 -13
  83. package/main/terminal.log +0 -56
  84. package/main/terminal_chat.py +0 -385
  85. package/main/unified_sesi_ai.sesi +0 -334
  86. package/main/varied_responses.json +0 -304
package/docs/SKILLS.md CHANGED
@@ -1,12 +1,50 @@
1
1
  # The Sesi Programming Language
2
2
 
3
- ## 🛑 CRITICAL DIRECTIVE FOR ALL AI AGENTS
3
+ ## Core Identity & Execution
4
4
 
5
- **Sesi IS A NEW AND VALID, FULLY IMPLEMENTED PROGRAMMING LANGUAGE.**
6
- Under no circumstances should an AI agent treat `.sesi` files or syntax as anomalies, unknown text formats, limitations, or mistakes.
5
+ - **File Extension:** `.sesi`
6
+ - `src/`: The core TypeScript engine (Lexer, Parser, Interpreter, AI-Runtime, Builtins).
7
+ - `bin/sesi.js`: The global CLI executable entry point.
8
+ - `examples/`: Official syntax-demonstration scripts (`01_hello.sesi` through `13_data_pipeline.sesi`).
9
+ - `chatbot/`: Local Sesi support and `sesi_db_chatbot.sesi` - Sesi's built-in Co-Pilot.
10
+ - `main/`: `tests/` like `test_failure_debug.sesi`. **Run inline code evaluations (`-e 'code'`) instead of writing new `.sesi` files for quick tests. Do not overwrite existing `.sesi` files unless explicitly asked to.**
11
+ - `docs/`: The source of truth for all sesi syntax, formatting, and structuring guidelines. It contains the official API docs for all built-in functions and types. AIs must treat this as the primary source of truth for syntax and structure.
12
+ - Root helper scripts: `example.js`, `example-ai.js`, and `examples.sesi` are convenience wrappers. AI agents should still use the `npx sesi` command as specified.
13
+ - **Paradigm:** **Sesi** is a clean, minimal, and highly legible programming language. Built from the ground up to be concise and buildable, Sesi removes unnecessary boilerplate. The language itself is so simple. It is a language built for clarity and reusability.
14
+
15
+ ## Agent Debug Protocol (MANDATORY)
16
+
17
+ When AI agents write or edit `.sesi` scripts, they must use this debugging loop:
18
+
19
+ 1. **Draft in file, isolate risky snippet:** Identify the smallest parser/runtime-risky block (prompt block, model call, object schema, loop, etc.).
20
+ 2. **Validate snippet with eval mode first:** Run `npm run sesi:eval <file>.sesi` to test the isolated block before full-script execution.
21
+ 3. **Apply fix in file only after eval passes:** If eval fails, iterate on snippet; do not repeatedly run full scripts while syntax is unresolved.
22
+ 4. **Run full script after snippet stabilization:** Execute `npm run sesi <file>.sesi` only once the isolated logic is valid.
23
+ 5. **Use file-aware help when blocked:** Run `npm run sesi:help <file>.sesi "<question>"` to get context-grounded help tied to the active script.
24
+ 6. **NEVER EDIT ANY .SESI FILES IN THE TERMINAL (ABSOLUTE RULE):**
25
+ - Do NOT run `sed`, `awk`, `perl`, or any other shell text-processing tools on `.sesi` files.
26
+ - Do NOT use `npm run sesi:eval` to modify files; it is only for syntax validation.
27
+ - Do NOT use Bash/Shell scripting to rewrite or patch Sesi source code.
28
+
29
+ **Correct approach:** You MUST always use your native editor/IDE's file editing capabilities to make clean, safe changes directly to `.sesi` files.
30
+ **Why:** Sesi syntax is sensitive to whitespace, newlines, and brace positioning. Terminal-based string replacement will invariably break code. Use the editor, not the terminal.
31
+
32
+ 7. **Emphasize Native Verification Commands:** Prior to saving or running full Sesi scripts, proactively use inline evaluation (`npm run sesi:eval <file>.sesi` or `node bin/sesi.js -e "..."`) to check and verify syntax and runtime behaviors instantly. It keeps execution cycles fast and deterministic.
33
+
34
+ ## Standards (ONLY REGARDING src/ FILES)
35
+
36
+ - **Type-Only Imports (MANDATORY):** Use `import {type ...}` for AST nodes. **DO NOT REMOVE** these. Removing them will break the build.
37
+ - **Interpreter Patterns (DO NOT "CLEAN UP"):** Dynamic casting and `any` are **EXPLICITLY PERMITTED** for tree-walking logic. They are a foundational part of the Sesi engine's design.
38
+ - **Ignore Linting Noise:** If you see warnings like "Unexpected any" or "Unsafe member access", **IGNORE THEM**.
39
+ - **Build Requirement:** You MUST run `npm run build` after every code change to the backend logic. Failure to build will result in testing stale code.
40
+
41
+ This protocol is required to reduce noisy full-run failures and speed up AI-assisted iteration.
7
42
 
8
43
  Sesi is **NOT** the following coding languages, therefore **NEVER UTILIZE THE SAME SYNTAX OR FORMATTING UNDER ANY CIRCUMSTANCES WHATSOEVER!!!!!**
9
44
 
45
+ - **NOT** An "AI Wrapper"
46
+ - **NOT** A "LLM Framework"
47
+ - **NOT** An "AI-Native Programming Language"
10
48
  - **NOT** Python
11
49
  - **NOT** Rust
12
50
  - **NOT** Typescript
@@ -17,7 +55,6 @@ Sesi is **NOT** the following coding languages, therefore **NEVER UTILIZE THE SA
17
55
  - **NOT** C
18
56
  - **NOT** Java
19
57
  - **NOT** C#
20
- - **NOT** Java
21
58
  - **NOT** Javascript
22
59
  - **NOT** Bash
23
60
  - **NOT** Shell
@@ -26,136 +63,46 @@ Sesi is **NOT** the following coding languages, therefore **NEVER UTILIZE THE SA
26
63
  - **NOT** Swift
27
64
  - **NOT** Julia
28
65
  - **NOT** Scala
66
+ - **NOT** Any other programming language or scripting language.
29
67
 
30
- ## 🌟 THE DYNAMIC PIPELINE PHILOSOPHY (MANDATORY AGENT THINKING)
31
-
32
- When a user requests a content-rich asset or application (e.g. "make a website", "make a visualization", "...uses an api...", "come up with/make/write a script...", etc.), your natural inclination **MUST NOT** be to hardcode a static file with data prefilled NOR use the user's workspace files for inspiration. Instead, always come up with a new script, idea, and design a **Dynamic Sesi Pipeline**:
33
-
34
- 1. **Never Hardcode Data Into the View**: Isolate raw content, biographies, statistics, etc. into a structured database layer using native typed Sesi outputs.
35
- 2. **Build Sesi Compiler/Builder Scripts**: Write a `.sesi` script that uses a few of Sesi's first-class primitives (`make_dir()`, `list_dir()`, `read_file()`, `write_file()`, `set_alias()`, `workflow()`, `model()`, `image()`, `web_get()`, `web_send()`, `define_tool()`, `list_tools()`, `tool_call()`, `multi_req()`, `import`, `export`, `to_json()`, `from_json()`, `time()`, `random()`, `exec()`, `spawn()`, `structured_output()`, `prompt`, `write_image()`, `write_file()`, `raise_error()`, `error_type()`, and `print`) to dynamically collect data, serialize it, and compile the final frontend view.
36
- 3. **Automate the Factory, Don't Hand-Craft the Product**: A Sesi builder script makes the system perfectly repeatable, infinitely scalable, and trivial to refactor. In this repository, the Sesi script is the core product; the compiled file is merely the byproduct for post edits and making sure our scripts are behaving as anticipated.
37
-
38
- **This is a non-negotiable quality bar.** Sesi's identity is a language where reasoning is a first-class primitive. Every script you write should reflect that.
39
-
40
- ### ❌ FORBIDDEN — Never generate these as Sesi examples or demos:
41
-
42
- - Math solvers, calculators, arithmetic pipelines
43
- - Prime number finders, Fibonacci sequences, sorting algorithms
44
- - Unit converters, currency converters, grade calculators
45
- - Budget trackers, invoice generators, tax tools
46
- - Generic "Hello World" clones with no AI interaction
47
- - Compliance checkers, OSHA reports, logistics routers
48
- - Any script whose core loop is just arithmetic with a `print` at the end
49
- - **AI cybernetic, futuristic, sci-fi, or deep-space themes** (e.g., holographic star-charts, cyber-gardens, spatial telemetry, spacecraft command interfaces, alien translators).
50
- - **Cozy, minimalist, Victorian, herbalist, sourdough bakery, cottage-core, candle-lit, or general artisanal themes** (e.g., village herbalist teabags, sourdough yeast logs, candlelit journals, mahogany apothecary drawers, victorian scroll philologists). These are overdone, precious, and clichéd.
51
-
52
- These are lazy defaults. They don't demonstrate what makes Sesi unique.
53
-
54
- ### ✅ REQUIRED — Sesi scripts must showcase the language's actual superpowers:
68
+ ### REQUIRED Sesi scripts must use the language's built-ins:
55
69
 
56
70
  Every script you write must use **at least one** of:
57
71
 
58
- - `model()` reasoning, analysis, generation, conversation
59
- - `image()` visual generation, art, diagrams
60
- - `structured_output()` — typed reasoning responses, schema extraction
61
- - `memory` — stateful multi-turn context
62
- - `spawn()` / `exec()` — concurrent process orchestration
63
- - `workflow()` - string various model responses sequentially
72
+ - `prompt` - composable script templates, this is NOT related to AI at all
73
+ - `structured_output` - structured data extraction, this is NOT related to AI at all
74
+ - `memory` — stateful multi-turn context, this is NOT related to AI at all
75
+ - `exec()` — concurrent process orchestration
64
76
  - `web_send()` - sending an HTTP request to a URL
65
77
  - `web_get()` - collecting data from a URL
66
78
  - `define_tool()` - categorizing tool calls
67
79
  - `list_tools()` - displaying custom tools
68
- - `tool_call()` - calling a predefined function
80
+ - `tool_call()` - calling a predefined function, this is NOT related to AI at all
69
81
  - `multi_req()` - concurrent function execution
70
82
  - `import` / `export` - reusable configuration modules
71
83
 
72
- #### 🏷️ Lexicon & Vocabulary Guardrails (MANDATORY)
73
-
74
- **Completely ban both sci-fi tech-jargon/themes AND cottage-core words/themes.**
75
-
76
- - **FORBIDDEN TECH/SCI-FI WORDS:** _"cybernetic," "telemetry," "synapses," "latent space," "nodes," "diodes," "quantum," "activation coordinates," "calibration," "hyper-speed," "data pipelines," "neural matrices."_
77
- - **FORBIDDEN COTTAGE-CORE WORDS:** _"apothecary," "herbs," "infusion," "yeast," "sourdough," "hearth," "candlelit," "flour," "boulangerie," "tea," "potion," "cozy," "victorian," "parchment," "scroll," "philologist."_
78
- - **FORBIDDEN ANALOG/WORKSHOP WORDS:** _"mixing console," "tape reel," "splice," "fader," "VU meter," "compressor," "track sheet," "carburetor," "spark plug," "manifold," "tachometer," "cogs," "gears," "escapement," "celluloid," "projector," "blueprint," "drafting board," "logbook," "workshop."_
84
+ The bar is: **"Is this easy to write and read?"** If the answer is no, rewrite it.
79
85
 
80
- #### 🎨 Web Design & UI Guardrails (MANDATORY)
86
+ ## Mandatory Syntax Rules & Quirks
81
87
 
82
- **Completely ban standard AI template styles AND generic neon/cyber aesthetics AND minimalist tea-stained cottage wood paper.**
83
- Instead, design unique, high-density interfaces :
84
-
85
- - NO glowing lasers or neon cyber grids/themes or ANYTHING FAMILAR.
86
- - **Use bespoke, high-character typography that rejects standard AI template styles.** Completely ban generic corporate UI fonts like _Inter_, _Outfit_, _Roboto_, or standard system-sans.
87
-
88
- The bar is: **"Would this impress someone seeing Sesi for the first time?"** If the answer is no, rewrite it.
89
-
90
- ## 1. Core Identity & Execution
91
-
92
- - **File Extension:** `.sesi`
93
- - **Execution:** Sesi programs are executed using `npx sesi`. (e.g., `npx sesi main/start.sesi`). DO NOT USE `sesi` CLI command alone. Only the developer has access to it. It will return a false positive error. You are to trust only `npx sesi`. ALWAYS TEST YOUR `.sesi` FILES WITH THIS COMMAND. THE USER IS EXEMPT FROM THESE RULES AS THEY LIKELY HAVE THE `sesi` GLOBAL COMMAND ALREADY INSTALLED ON THEIR SYSTEM.
94
- - **Rapid Iteration Mode (`-e`):** For quick parser/runtime checks during edits, use inline execution with `npx sesi -e "..."`. This is ideal for validating tiny snippets before changing full `.sesi` files.
95
- - **File-Aware Help (`<file> -h`):** For targeted debugging assistance, use `npx sesi <file>.sesi -h "question"`. This passes the file into Co-Pilot help context so guidance is grounded in the active script.
96
- - **Paradigm:** **Sesi** is a clean, minimal, and highly legible programming language. Built from the ground up to be concise and buildable, Sesi removes unnecessary boilerplate. Because the language itself is so simple, integrating external tools like shell commands or Reasoning models becomes effortless. It is a language built for clarity.
97
- ## 2. Workspace Topography (DO NOT ALTER)
98
-
99
- - `src/`: The core TypeScript engine (Lexer, Parser, Interpreter, AI-Runtime, Builtins).
100
- - `bin/sesi.js`: The global CLI executable entry point.
101
- - `examples/`: Official syntax-demonstration scripts (`01_hello.sesi` through `13_data_pipeline.sesi`).
102
- - `main/`: The user's active development space (contains `playground.sesi` playground, `start.sesi` beginner script options, `build_website.sesi` baseplate website builder, and `tests/` like `test_failure_debug.sesi`). **These are valid, expected files.**
103
- - `docs/`: The source of truth for Architecture, Reasoning Features (Proccess Execution), Builtins, Specifications, and more.
104
- - Root helper scripts: `example.js` and `example-ai.js` are convenience wrappers. AI agents should still use the `npx sesi` command as specified.
105
-
106
- ## 3. Mandatory Syntax Rules & Quirks
107
-
108
- - **Block Termination:** Closing braces `}` for blocks (if, while, try, model) no longer strictly require a following newline or semicolon. Condensed one-liners like `while x {x = x + 1}` are now valid.
88
+ - **Block Termination:** Closing braces `}` for blocks (if, while, try, model) no longer strictly require a following newline or semicolon. Condensed one-liners like `while x {x = x + 1}` are valid.
109
89
  - **Prompts & Prints:** Inside `prompt` blocks, anonymous model blocks, and `print` statements, literal strings and variables are placed sequentially naturally (e.g., `print "User:" name`). It's highly preferred to **AVOID** use of the `+` operator in these contexts, regardless of its backwards-compatibility.
110
90
  - **Structured Output Schemas:** Keys in schemas MUST be unquoted identifiers (e.g., `{key: string}` instead of `{"key": string}`). This is a known deviation from standard JSON objects in the Sesi parser.
111
91
  - **Object Literals:** Conversely, standard object literals `{}` DO require strictly quoted string keys (e.g., `{"name": "Alice"}`).
112
- - **Model Calls:** Use `model("model-name")` with a raw string literal for the model name (variables are forbidden). Configuration and prompt blocks MUST be on a single line (no newlines inside `{}`).
113
- - **JSON Serialization:** Use `to_json(object)` for valid JSON output. Avoid `str(object)` for JSON.
92
+ - **JSON Serialization:** Use `to_json(object)` for valid JSON output. Avoid `stringify(object)` for JSON.
114
93
  - **Systems Primitive:** Forbid `const` (use `let`), `main()` wrappers, and `return` statements (however, `return` is neccessary inside of a `fn` block). Focus on side-effects and top-level execution.
115
-
116
- ## 4. AI Behavioral Guidelines Working in this Repo
117
-
118
- 1. **Never** "investigate" user testing directories (like `main/tests/`) as "deviations." They are active playgrounds.
119
- 2. **Never** attempt to execute file modifications via shell/terminal text replacements. Use native file editing tools ONLY.
120
- 3. **Always** check the `.md files` in root folder and `docs/` and `examples/` folder for the exact language specification before making assumptions about how Sesi works.
121
- 4. If a file tree is mentioned in documentation, it represents an explicit layout constraint and must map 1:1 **UNLESS .gitignored FILES STATE OTHERWISE.**
122
-
123
- ## 5. Development & TypeScript Standards (COMMANDS FOR AI AGENTS)
124
-
125
- - **Type-Only Imports (MANDATORY):** Use `import { type ... }` for AST nodes. **DO NOT REMOVE** these. Removing them will break the build.
126
- - **Interpreter Patterns (DO NOT "CLEAN UP"):** Dynamic casting and `any` are **EXPLICITLY PERMITTED** for tree-walking logic. They are a foundational part of the Sesi engine's design.
127
- - **Ignore Linting Noise:** If you see warnings like "Unexpected any" or "Unsafe member access", **IGNORE THEM**.
128
- - **Build Requirement:** You MUST run `npm run build` after every code change to the backend logic. Failure to build will result in testing stale code.
129
-
130
- ## 6. Agent Debug Protocol (MANDATORY)
131
-
132
- When AI agents write or edit `.sesi` scripts, they must use this debugging loop:
133
-
134
- 1. **Draft in file, isolate risky snippet:** Identify the smallest parser/runtime-risky block (prompt block, model call, object schema, loop, etc.).
135
- 2. **Validate snippet with eval mode first:** Run `npx sesi -e "..."` to test the isolated block before full-script execution.
136
- 3. **Apply fix in file only after eval passes:** If eval fails, iterate on snippet; do not repeatedly run full scripts while syntax is unresolved.
137
- 4. **Run full script after snippet stabilization:** Execute `npx sesi <file>.sesi` only once the isolated logic is valid.
138
- 5. **Use file-aware help when blocked:** Run `npx sesi <file>.sesi -h "<question>"` to get context-grounded help tied to the active script.
139
-
140
- This protocol is required to reduce noisy full-run failures and speed up AI-assisted iteration.
141
-
142
- ## 7. Concurrency & Orchestration Patterns
143
-
144
- - **Process Spawning:** Use `spawn(path)` or `exec(command)` to launch background Sesi processes.
145
- - **File Locking:** When multiple processes access shared files, you can use `try/catch`, `time()`, and `random()` to implement basic file locking:
146
- 1. Generate unique ID: `str(time()) + "_" + str(random())`
147
- 2. Write ID to lock file if "unlocked".
148
- 3. Wait micro-delay (empty `while` loop).
149
- 4. Verify ID is still in lock file before entering critical section.
150
94
  - **Resilience:** Always wrap file I/O in `try/catch` retry loops to handle filesystem contention.
151
95
 
152
- ## 8. Neural Network & Machine Learning Standards in Sesi
96
+ For all quirks and specific syntaxing, visit IMPLEMENTATION_SUMMARY.md, /docs/SPECIFICATION.md, /docs/BUILTINS.md, and /docs/CLI.
153
97
 
154
- When implementing offline deep learning, probabilistic dialogue routing, or native classification models in Sesi:
98
+ ## IGNORE THESE FILES
155
99
 
156
- - **Symmetry Breaking:** Synapse weights MUST be initialized dynamically using wide, random float ranges (e.g. `(random() * 4.0) - 2.0` or `random() - 0.5`) to avoid zero-gradient stagnation and guarantee symmetry breaking.
157
- - **The Self-Healing Watchdog Pattern:** In native Sesi training models, wrap backpropagation epochs inside a conditional watchdog loop. Monitor the final Mean Squared Error (MSE) loss, and automatically re-seed weights and relaunch training if the network gets stuck in linear minima traps (e.g. `if MSE >= 0.01`).
158
- - **Unbreakable Markov Decoding Filters:** To eliminate infinite graph loops in Sesi probabilistic text walks, always apply:
159
- 1. **Extended Sliding Lookbacks (Size 15):** Instantly penalize and discard candidates already generated in the last 15 words of the sentence history.
160
- 2. **Strict Bigram Blocking:** Scan the history array and completely ban any candidate that repeats a previously executed state transition pair `(current_word -> candidate)` in the same sequence.
161
- - **Model Ingestion & Persistence:** Synchronize Sesi weights using natively parsed JSON objects. Save calibrated neural states directly using `write_file(..., to_json(weights_map))` and read them into runtime memories using `from_json(read_file(...))` for high-speed offline forward passes.
100
+ - `docs/agent_native_programming.md`
101
+ - `docs/REASONING.md`
102
+ - `docs/IMAGE_GENERATION.md`
103
+ - `*.txt`
104
+ - `*.log`
105
+ - `query.txt`
106
+ - `.sesi_cache.json`
107
+ - `.sesi_chat_history.json`
108
+ - `/landing-pages/`
@@ -7,7 +7,7 @@ Sesi is built on these core principles:
7
7
  1. **Conciseness and Legibility**: The syntax is minimal. If a concept can be expressed simply, the language gets out of the way to let you express it.
8
8
  2. **Buildable from Scratch**: Sesi is a complete, functioning language with its own lexer, parser, and interpreter.
9
9
  3. **Simplicity Enables Power**: Because the core language is simple, complex operations (like hitting APIs or orchestrating processes) become trivial extensions of the language, rather than tangled SDK implementations.
10
- 4. **Transparency Over Magic**: Sesi executes exactly what you write.
10
+ 4. **Transparency Over Magic**: Sesi executes exactly what you write.
11
11
  5. **Practicality**: Focus on reducing boilerplate code, emphasizing what developers actually need over academic completeness.
12
12
 
13
13
  ## 2. Target Users
@@ -41,16 +41,16 @@ Sesi is built on these core principles:
41
41
  - ✅ Comments (`//`, `/* */`)
42
42
  - ✅ Operators (arithmetic, logical, comparison)
43
43
  - ✅ Standard library (print, len, range, etc.)
44
+ - ✅ `prompt` blocks (composable templates for concise formatting)
45
+ - ✅ `structured_output()` (schema-guided structured output with JSON recovery and empty-object fallback on failure)
46
+ - ✅ `tool_call()` (Fully functional function calling for tool use)
47
+ - ✅ `memory` (simple multi-turn script memory and retrieval context management)
44
48
 
45
49
  ### Reasoning-Native Features
46
50
 
47
- - ✅ `prompt` blocks (composable message templates)
48
51
  - ✅ `model()` calls (native model with configuration)
49
52
  - ✅ `image()` calls (native image generation with configuration)
50
53
  - ✅ `images` config key (multimodal vision input for `model()` and `image()`)
51
- - ✅ `structured_output()` (schema-guided structured output with JSON recovery and empty-object fallback on failure)
52
- - ✅ `tool_call()` (Fully functional function calling via models)
53
- - ✅ Simple memory (conversation context)
54
54
 
55
55
  ### Type System
56
56
 
@@ -178,7 +178,7 @@ Example:
178
178
  ```sesi
179
179
  for i = 0 to 10 {print i}
180
180
  try
181
- {let result = model("Hello")
181
+ {let result = "Hello"
182
182
  } catch (e) {
183
183
  print e}
184
184
  ```
@@ -242,10 +242,10 @@ config_entry := (STRING | identifier) ':' expression
242
242
  | Key | Applies to | Type | Description |
243
243
  | --------------- | ---------------- | ------------------------- | -------------------------------------------------------------------------- |
244
244
  | `thinkingLevel` | `model` | `string \| object` | **Recommended**: Effort level (`"minimal"`, `"low"`, `"medium"`, `"high"`) |
245
- | `temperature` | `model`, `image` | `number` | *Will be deprecated in Gemini 3.x+_ (Sampling temperature) |
245
+ | `temperature` | `model`, `image` | `number` | \*Will be deprecated in Gemini 3.x+\_ (Sampling temperature) |
246
246
  | `max_tokens` | `model` | `number` | Max output token count |
247
- | `top_k` | `model` | `number` | *Will be deprecated in Gemini 3.x+_ |
248
- | `top_p` | `model` | `number` | *Will be deprecated in Gemini 3.x+_ |
247
+ | `top_k` | `model` | `number` | \*Will be deprecated in Gemini 3.x+\_ |
248
+ | `top_p` | `model` | `number` | \*Will be deprecated in Gemini 3.x+\_ |
249
249
  | `ratio` | `image` | `string` | Aspect ratio e.g. `"16:9"` |
250
250
  | `size` | `image` | `string` | `"512"`, `"1K"`, `"2K"`, `"4K"` |
251
251
  | `images` | `model`, `image` | `string \| array<string>` | Local file path(s) passed as visual input |
@@ -267,13 +267,21 @@ schema := '{' (identifier ':' type (',' identifier ':' type)*)? '}'
267
267
  Example:
268
268
 
269
269
  ```sesi
270
- let analysis = structured_output({sentiment: string, score: number, keywords: array<string>})(model("gemini-3.1-flash-lite") { analyzeText })
270
+ let rawJson = "{\"projectName\": \"Sesi\", \"version\": \"1.3.0\", \"status\": \"active\"}"
271
+ let parsedRegistry = structured_output({projectName: string, version: string, status: string})(rawJson)
271
272
  ```
272
273
 
273
274
  #### Tool Call
274
275
 
275
276
  ```
276
- tool_call := 'tool_call' '('function_name')' '('model_call')'
277
+ tool_call := 'tool_call' '('function_name')' '('(model_call | expressions)?')'
278
+ ```
279
+
280
+ Example (Native Sandboxed Dispatch):
281
+
282
+ ```sesi
283
+ fn add(a: number, b: number) -> number { return a + b }
284
+ let sum = tool_call(add)(10, 20)
277
285
  ```
278
286
 
279
287
  #### Memory (State Management)
@@ -364,6 +372,10 @@ time() -> number // Current Unix timestamp
364
372
  random() -> number // Random float (0.0 to 1.0)
365
373
  ```
366
374
 
375
+ ### Built-in Global Variables
376
+
377
+ - `args` - `array<string>`: Contains the command-line arguments passed to the script, excluding Sesi runtime options and the script path.
378
+
367
379
  ## 9. Module System
368
380
 
369
381
  Runtime module execution and standard namespace modules are fully implemented and natively supported in v1.3+.
@@ -396,12 +408,12 @@ import json from "std/json" // JSON parsing
396
408
 
397
409
  When you write `import {x} from "mymodule"`, Sesi searches for `mymodule.sesi` in the following order, stopping at the first match:
398
410
 
399
- | Priority | Location | Description |
400
- | -------- | -------- | ----------- |
401
- | 1 | **Script's own directory** | Same folder as the currently running `.sesi` file |
402
- | 2 | **Current working directory** | The directory you ran `sesi` from |
403
- | 3 | **`SESI_PATH`** | Semicolon-separated (Windows) or colon-separated (Unix) list of additional directories |
404
- | 4 | **`~/.sesi/lib`** | Global shared library directory — available system-wide |
411
+ | Priority | Location | Description |
412
+ | -------- | ----------------------------- | -------------------------------------------------------------------------------------- |
413
+ | 1 | **Script's own directory** | Same folder as the currently running `.sesi` file |
414
+ | 2 | **Current working directory** | The directory you ran `sesi` from |
415
+ | 3 | **`SESI_PATH`** | Semicolon-separated (Windows) or colon-separated (Unix) list of additional directories |
416
+ | 4 | **`~/.sesi/lib`** | Global shared library directory — available system-wide |
405
417
 
406
418
  This means imports always resolve correctly regardless of where you run `sesi` from.
407
419
 
@@ -477,10 +489,10 @@ print "Image written to logo.png"
477
489
  - **`max_tokens`**: `number` (maximum response tokens)
478
490
  - **`images`**: `string` or `array<string>` (paths to multimodal vision input files)
479
491
  - **`cache`**: `bool` (set to `false` to explicitly bypass Sesi Logic Caching)
480
- - **`temperature`**: * Will be deprecated in Gemini 3.x+, use thinkingLevel instead.* — reasoning is pre-optimized for defaults.
481
- - **`top_k` / `top_p`**: *Will be deprecated in Gemini 3.x+, use thinkingLevel instead.* — reasoning is pre-optimized for defaults.
492
+ - **`temperature`**: _ Will be deprecated in Gemini 3.x+, use thinkingLevel instead._ — reasoning is pre-optimized for defaults.
493
+ - **`top_k` / `top_p`**: _ Will be deprecated in Gemini 3.x+, use thinkingLevel instead._ — reasoning is pre-optimized for defaults.
482
494
 
483
- ### Structured Output
495
+ ### Reasoning with Structured Output
484
496
 
485
497
  ```sesi
486
498
  let result = structured_output({title: string, category: string, confidence: number})(model("gemini-3.1-flash-lite") {"Extract metadata from this text:" text})
@@ -488,7 +500,7 @@ print result.title // Access fields
488
500
  print result.confidence // Type-safe access
489
501
  ```
490
502
 
491
- ### Tool Calling
503
+ ### Reasoning with Tool Calling
492
504
 
493
505
  ```sesi
494
506
  fn calculateTax(amount: number, rate: number) {print amount * rate}
@@ -496,7 +508,7 @@ let taxAmount = tool_call(calculateTax)(model("gemini-3.1-flash-lite") {"Calcula
496
508
  taxAmount
497
509
  ```
498
510
 
499
- ### Memory
511
+ ### Reasoning with Memory
500
512
 
501
513
  ```sesi
502
514
  memory chat {"System: You are a helpful assistant."}
@@ -522,7 +534,7 @@ fn analyzeText(text: string) -> string {return model("gemini-3.5-flash") {thinki
522
534
  print analyzeText("Reasoning is transforming industries")
523
535
  ```
524
536
 
525
- ### Example 3: Structured Output
537
+ ### Example 3: Reasoning with Structured Output
526
538
 
527
539
  ```sesi
528
540
  let sentiment = structured_output({label: string, score: number})(model("gemini-3-flash-preview") {"Analyze sentiment of:" userInput})
@@ -1,6 +1,35 @@
1
1
  // Functions
2
2
  fn add(a: number, b: number) {print a + b}
3
3
  fn greet(name: string = "World") {print "Hello" name "!"}
4
+
4
5
  add(5, 3)
5
6
  greet()
6
- greet("Alice")
7
+ greet("Alice")
8
+
9
+ // Advanced Functions
10
+ fn calculate(operation: string, a: number, b: number) {
11
+ if operation == "add" {
12
+ print a + b
13
+ } else if operation == "subtract" {
14
+ print a - b
15
+ } else if operation == "multiply" {
16
+ print a * b
17
+ } else if operation == "divide" {
18
+ print a / b
19
+ } else {
20
+ print "Invalid operation"
21
+ }
22
+ }
23
+
24
+ calculate("add", 5, 3)
25
+
26
+ // Define your functions and call it using a custom tool
27
+
28
+ fn getSesiVersion() {
29
+ return "1.3.2"
30
+ }
31
+
32
+ define_tool("sesi", getSesiVersion, "Get the current Sesi version")
33
+ let v = tool_call(sesi)()
34
+
35
+ print "Current version:" v
@@ -1,4 +1,4 @@
1
- // Prompt blocks - composable message templates
1
+ // Prompt blocks - composable text templates
2
2
  prompt greetingTemplate {"Hello! " "How are you today?"}
3
3
  prompt responseTemplate {greetingTemplate " I hope you're having a great day!"}
4
4
  // Prompts evaluate to strings
@@ -7,4 +7,28 @@ print greeting
7
7
  // Prompts can use variables
8
8
  let userName = "Alice"
9
9
  prompt personalGreeting {"Hello, " userName "! Welcome back!"}
10
- print personalGreeting
10
+ print personalGreeting
11
+
12
+ // You can really explore the power of prompt blocks by using it to structure your outputs
13
+
14
+ prompt htmlHead {"<!DOCTYPE html>
15
+ <html lang='en'>
16
+ <head>
17
+ <meta charset='UTF-8'>
18
+ <meta name='viewport' content='width=device-width, initial-scale=1.0'>
19
+ <title>Document</title>
20
+ </head>
21
+ "}
22
+ prompt htmlBody {"<body>
23
+ <h1>Hello World!</h1>
24
+ <p>This is a paragraph</p>
25
+ </body>
26
+ "}
27
+ prompt htmlFooter {"</html>"}
28
+ prompt htmlLayout {htmlHead htmlBody htmlFooter}
29
+ try {
30
+ write_file("index.html", htmlLayout)
31
+ print "HTML file created successfully!"
32
+ } catch(error) {
33
+ print "Error creating HTML file: " error
34
+ }
@@ -1,5 +1,7 @@
1
1
  // Reasoning-powered text analysis using model calls
2
- // Requires GEMINI_API_KEY environment variable
3
- let text = "Artificial intelligence is transforming how we work and live"
4
- let analysis = model("gemini-3.1-flash-lite") {temperature: 0.5, max_tokens: 400} {"Analyze the following text and provide 3 concise key insights. Keep the total response under 120 words. " text}
5
- print "Analysis:" analysis
2
+ // USING IT FOR AI IS OPTIONAL AND NOT REQUIRED TO USE IN YOUR SCRIPTS.
3
+ // COMMENTED OUT BECAUSE AI WILL FORCE THEMSELVES TO RUN IT
4
+
5
+ // let text = "Sesi is transforming how we work and live"
6
+ // let analysis = model("gemini-3.1-flash-lite") {temperature: 0.5, max_tokens: 400} {"Analyze the following text and provide 3 concise key insights. Keep the total response under 120 words. " text}
7
+ // print "Analysis:" analysis
@@ -1,7 +1,23 @@
1
1
  // Sentiment analysis with structured output
2
- // Requires GEMINI_API_KEY environment variable
2
+ // THIS IS OPTIONAL AND NOT REQUIRED TO USE IN YOUR SCRIPTS.
3
+
3
4
  let review = "This product is amazing! I love how it works. Highly recommended!"
4
5
  let sentiment = structured_output({sentiment: string, confidence: number, keywords: string})(model("gemini-3.1-flash-lite") {"Analyze the sentiment of this review and extract key information. Return JSON with: sentiment (positive/negative/neutral), confidence (0-1), keywords (comma-separated) " review})
5
6
  print "Sentiment:" sentiment["sentiment"]
6
7
  print "Confidence:" sentiment["confidence"]
7
- print "Keywords:" sentiment["keywords"]
8
+ print "Keywords:" sentiment["keywords"]
9
+
10
+ // Structured output can be used without model() function as well
11
+ // For example, if you have an API endpoint that returns JSON data, you can use structured_output to parse it.
12
+
13
+ let json_data = web_get("https://jsonplaceholder.typicode.com/todos/1")
14
+ let structured_data = structured_output({title: string, completed: boolean})(json_data)
15
+ print "Title:" structured_data["title"]
16
+ print "Completed:" structured_data["completed"]
17
+
18
+ // You can even pass raw text to structured_output if you want, it just needs to be in JSON format. For example:
19
+
20
+ let raw_text = "{\"title\": \"Buy milk\", \"completed\": false}"
21
+ let structured_data = structured_output({title: string, completed: boolean})(raw_text)
22
+ print "Title:" structured_data["title"]
23
+ print "Completed:" structured_data["completed"]
@@ -1,5 +1,7 @@
1
1
  // Code generation with Reasoning
2
- // Requires GEMINI_API_KEY environment variable
3
- let requirement = "A function that checks if a number is prime"
4
- let generatedCode = model("gemini-3.1-flash-lite") {temperature: 0.2, max_tokens: 500} {"Generate JavaScript code for the following requirement: " requirement " Provide only the code, no explanation."}
5
- print "Generated Code:" generatedCode
2
+ // USING IT FOR AI IS OPTIONAL AND NOT REQUIRED TO USE IN YOUR SCRIPTS.
3
+ // COMMENTED OUT BECAUSE AI WILL FORCE THEMSELVES TO RUN IT
4
+
5
+ // let requirement = "A function that checks if a number is prime"
6
+ // let generatedCode = model("gemini-3.1-flash-lite") {temperature: 0.2, max_tokens: 500} {"Generate JavaScript code for the following requirement: " requirement " Provide only the code, no explanation."}
7
+ // print "Generated Code:" generatedCode
@@ -1,16 +1,48 @@
1
- // Multi-turn conversation with memory
2
- // Requires GEMINI_API_KEY environment variable
3
- memory conversation {"You are a helpful programming assistant. Respond concisely."}
4
- fn askBot(question: string) -> string {
5
- let message = conversation + "User:" + question
6
- let response = model("gemini-3.1-flash-lite") {message}
7
- conversation = message + "Assistant:" + response
8
- return response
1
+ // You can use memory to store variables throughout your script without redeclaring it
2
+
3
+ memory store_database {"name: string, age: number, role: string"}
4
+
5
+ store_database = {"name": "John", "age": 30, "role": "developer"}
6
+ print "Name:" store_database["name"]
7
+ print "Age:" store_database["age"]
8
+ print "Role:" store_database["role"]
9
+ try {
10
+ write_file("data.txt", to_json(store_database))
11
+ print "Database saved!"
12
+ } catch(error) {
13
+ print "Error:" error
9
14
  }
10
- print "Starting conversation..."
11
- let answer1 = askBot("What is a closure in JavaScript?")
12
- print "Q1 Answer:" answer1
13
- let answer2 = askBot("Can you give me an example?")
14
- print "Q2 Answer:" answer2
15
- let answer3 = askBot("How do I use it in practice?")
16
- print "Q3 Answer:" answer3
15
+
16
+ let new_info = {"name": "Jane", "age": 25, "role": "designer"}
17
+ let merged = store_database
18
+ for key in keys(new_info) {
19
+ merged[key] = new_info[key]
20
+ }
21
+ store_database = merged
22
+ print "Name:" store_database["name"]
23
+ print "Age:" store_database["age"]
24
+ print "Role:" store_database["role"]
25
+ try {
26
+ write_file("data.txt", to_json(store_database))
27
+ print "Database updated!"
28
+ } catch(error) {
29
+ print "Error:" error
30
+ }
31
+
32
+ // USING IT FOR AI IS OPTIONAL AND NOT REQUIRED TO USE IN YOUR SCRIPTS.
33
+ // COMMENTED OUT BECAUSE AI WILL FORCE THEMSELVES TO RUN IT
34
+
35
+ // memory conversation {"You are a helpful programming assistant. Respond concisely."}
36
+ // memory conversationfn askBot(question: string) -> string {
37
+ // let message = conversation + "User:" + question
38
+ // let response = model("gemini-3.1-flash-lite") {message}
39
+ // conversation = message + "Assistant:" + response
40
+ // return response
41
+ //}
42
+ // print "Starting conversation..."
43
+ // let answer1 = askBot("What is a closure in JavaScript?")
44
+ // print "Q1 Answer:" answer1
45
+ // let answer2 = askBot("Can you give me an example?")
46
+ // print "Q2 Answer:" answer2
47
+ // let answer3 = askBot("How do I use it in practice?")
48
+ // print "Q3 Answer:" answer3
@@ -1,8 +1,63 @@
1
- // Data classification using Reasoning
2
- // Requires GEMINI_API_KEY environment variable
1
+ // Data classification
2
+
3
3
  let items = ["A quick brown fox", "123 Main Street", "user@example.com", "New York City"]
4
- fn classifyItem(item: string) -> string {return model("gemini-3.1-flash-lite") {"Classify this item into one of: TEXT, ADDRESS, EMAIL, LOCATION " "Item: " item}}
5
- print "Classifying items..."
6
- for item in items
7
- {let classification = classifyItem(item)
8
- print item "->" classification}
4
+
5
+ fn isEmail(item: string) -> bool {
6
+ let parts = split(item, "@")
7
+ if len(parts) != 2 {
8
+ return false
9
+ }
10
+ let localPart = parts[0]
11
+ let domainPart = parts[1]
12
+ if len(localPart) == 0 || len(domainPart) == 0 {
13
+ return false
14
+ }
15
+ let domainParts = split(domainPart, ".")
16
+ if len(domainParts) < 2 {
17
+ return false
18
+ }
19
+ for part in domainParts {
20
+ if len(part) == 0 {
21
+ return false
22
+ }
23
+ }
24
+ return true
25
+ }
26
+
27
+ fn isAddress(item: string) -> bool {
28
+ // Simplified check for address-like strings
29
+ let parts = split(item, " ")
30
+ // Must contain numbers and words
31
+ let hasNumber = false
32
+ let hasWord = false
33
+ for part in parts {
34
+ if num(part) != null {
35
+ hasNumber = true
36
+ } else if len(part) > 1 {
37
+ hasWord = true
38
+ }
39
+ }
40
+ return hasNumber && hasWord && len(parts) >= 2
41
+ }
42
+
43
+ print "Classifying items natively:"
44
+ for item in items {
45
+ if isEmail(item) {
46
+ print item "-> EMAIL"
47
+ } else if isAddress(item) {
48
+ print item "-> ADDRESS"
49
+ } else {
50
+ print item "-> TEXT/LOCATION"
51
+ }
52
+ }
53
+
54
+ // USING AI IS OPTIONAL AND NOT REQUIRED TO USE IN YOUR SCRIPTS.
55
+ // COMMENTED OUT BECAUSE AI WILL FORCE THEMSELVES TO RUN IT
56
+
57
+
58
+ // let items = ["A quick brown fox", "123 Main Street", "user@example.com", "New York City"]
59
+ // fn classifyItem(item: string) -> string {return model("gemini-3.1-flash-lite") {"Classify this item into one of: TEXT, ADDRESS, EMAIL, LOCATION " "Item: " item}}
60
+ // print "Classifying items..."
61
+ // for item in items
62
+ // {let classification = classifyItem(item)
63
+ // print item "->" classification}