@misterscan/sesi 1.1.1

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 (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +191 -0
  3. package/bin/sesi.js +56 -0
  4. package/dist/ai-runtime.d.ts +15 -0
  5. package/dist/ai-runtime.d.ts.map +1 -0
  6. package/dist/ai-runtime.js +214 -0
  7. package/dist/ai-runtime.js.map +1 -0
  8. package/dist/builtins.d.ts +7 -0
  9. package/dist/builtins.d.ts.map +1 -0
  10. package/dist/builtins.js +473 -0
  11. package/dist/builtins.js.map +1 -0
  12. package/dist/index.d.ts +3 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +72 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/interpreter.d.ts +36 -0
  17. package/dist/interpreter.d.ts.map +1 -0
  18. package/dist/interpreter.js +495 -0
  19. package/dist/interpreter.js.map +1 -0
  20. package/dist/lexer.d.ts +26 -0
  21. package/dist/lexer.d.ts.map +1 -0
  22. package/dist/lexer.js +340 -0
  23. package/dist/lexer.js.map +1 -0
  24. package/dist/parser.d.ts +55 -0
  25. package/dist/parser.d.ts.map +1 -0
  26. package/dist/parser.js +1022 -0
  27. package/dist/parser.js.map +1 -0
  28. package/dist/types.d.ts +304 -0
  29. package/dist/types.d.ts.map +1 -0
  30. package/dist/types.js +63 -0
  31. package/dist/types.js.map +1 -0
  32. package/docs/ARCHITECTURE.md +430 -0
  33. package/docs/BUILTINS.md +577 -0
  34. package/docs/COMPARISON.md +334 -0
  35. package/docs/DISTRIBUTED_SYSTEMS.md +71 -0
  36. package/docs/IMAGE_GENERATION.md +76 -0
  37. package/docs/IMPLEMENTATION_SUMMARY.md +533 -0
  38. package/docs/QUICKSTART.md +351 -0
  39. package/docs/README.md +191 -0
  40. package/docs/ROADMAP.md +408 -0
  41. package/docs/SPECIFICATION.md +462 -0
  42. package/docs/SYSTEMS_REASONING.md +522 -0
  43. package/examples/01_hello.sesi +2 -0
  44. package/examples/02_variables.sesi +11 -0
  45. package/examples/03_functions.sesi +6 -0
  46. package/examples/04_conditionals.sesi +6 -0
  47. package/examples/05_loops.sesi +12 -0
  48. package/examples/06_arrays_objects.sesi +18 -0
  49. package/examples/07_prompts.sesi +10 -0
  50. package/examples/08_model_call.sesi +5 -0
  51. package/examples/09_structured_output.sesi +7 -0
  52. package/examples/10_code_generation.sesi +5 -0
  53. package/examples/11_memory_conversation.sesi +16 -0
  54. package/examples/12_classification.sesi +8 -0
  55. package/examples/13_data_pipeline.sesi +35 -0
  56. package/examples/14_folder_explainer.sesi +58 -0
  57. package/examples/15_image_generation.sesi +17 -0
  58. package/main/atm_deposit.sesi +37 -0
  59. package/main/atm_withdraw.sesi +37 -0
  60. package/main/data.txt +1 -0
  61. package/main/math_aggregator.sesi +15 -0
  62. package/main/math_generator.sesi +7 -0
  63. package/main/math_processor.sesi +23 -0
  64. package/main/orchestrator.sesi +15 -0
  65. package/main/playground.sesi +1 -0
  66. package/main/setup_swarm.sesi +5 -0
  67. package/main/start.sesi +13 -0
  68. package/main/tax_calculator.sesi +15 -0
  69. package/main/tests/compare.sesi +23 -0
  70. package/main/tests/compare.ts +104 -0
  71. package/main/tests/debug.sesi +1 -0
  72. package/main/tests/demo.sesi +24 -0
  73. package/main/tests/primitive_validation.sesi +18 -0
  74. package/main/tests/test_connection.sesi +4 -0
  75. package/main/tests/test_failure_debug.sesi +2 -0
  76. package/main/tests/test_image.sesi +3 -0
  77. package/main/tests/test_parser_config.sesi +2 -0
  78. package/main/tests/test_syntax.sesi +3 -0
  79. package/main/tests/test_tool_call.sesi +14 -0
  80. package/main/tests/try.sesi +7 -0
  81. package/main/vault.sesi +15 -0
  82. package/package.json +50 -0
@@ -0,0 +1,351 @@
1
+ # Quick Start Guide: Sesi Programming Language
2
+
3
+ ## Installation
4
+
5
+ ### Prerequisites
6
+
7
+ - Node.js 18+
8
+ - npm or yarn
9
+
10
+ ### Setup
11
+
12
+ 1. **Clone and install**:
13
+
14
+ ```bash
15
+ git clone https://github.com/Misterscan/Sesi.git
16
+ cd sesi-programming-lang
17
+ npm install
18
+
19
+ # Unlock the `sesi` command
20
+ npm install -g
21
+ ```
22
+
23
+ 2. **Build from TypeScript**:
24
+
25
+ ```bash
26
+ npm run build
27
+ ```
28
+
29
+ 3. **Run a program (if installed globally)**:
30
+
31
+ ```bash
32
+ sesi main/start.sesi
33
+ ```
34
+
35
+ ### Run Tests
36
+
37
+ ```bash
38
+ npm test
39
+ ```
40
+
41
+ ## Your First Program
42
+
43
+ Create a file called `hello.sesi`:
44
+
45
+ ```sesi
46
+ print "Hello, Sesi!"
47
+ ```
48
+
49
+ Run it:
50
+
51
+ ```bash
52
+ sesi hello.sesi
53
+ ```
54
+
55
+ ## Basic Syntax
56
+
57
+ ### Variables
58
+
59
+ ```sesi
60
+ let x = 10
61
+ let name = "Alice"
62
+ let score = 95.5
63
+ print x
64
+ print name
65
+ print score
66
+ ```
67
+
68
+ ### Functions
69
+
70
+ ```sesi
71
+ fn add(a: number, b: number) {print a + b}
72
+ add(5, 3) // 8
73
+ ```
74
+
75
+ ### Control Flow
76
+
77
+ ```sesi
78
+ let age = 25
79
+ if age >= 18 {print "Adult"} else {print "Minor"}
80
+ ```
81
+
82
+ ### Loops
83
+
84
+ ```sesi
85
+ // While loop
86
+ let i = 0
87
+ while i < 5 {
88
+ print i
89
+ i = i + 1
90
+ }
91
+
92
+ // For loop
93
+ for j = 0 to 5 {print j}
94
+
95
+ // For-in loop
96
+ for item in [1, 2, 3] {print item}
97
+ ```
98
+
99
+ ### Arrays & Objects
100
+
101
+ ```sesi
102
+ let numbers = [1, 2, 3, 4, 5]
103
+ print numbers[0] // 1
104
+ print len(numbers) // 5
105
+ let age = numbers[4] * 5 // 5 * 5 = 25
106
+ let person = {"name": "Alice", "age": age}
107
+ print person["name"] "is" person["age"] "years old." // "Alice is 25 years old."
108
+ ```
109
+
110
+ ## Reasoning Features
111
+
112
+ ### Requiring Gemini API
113
+
114
+ To use Reasoning features, set up your API key:
115
+
116
+ ```bash
117
+ export GEMINI_API_KEY="your-api-key-here"
118
+ ```
119
+
120
+ Or you can set it up in an `.env` file:
121
+
122
+ ```env
123
+ GEMINI_API_KEY="your-api-key-here"
124
+ ```
125
+
126
+ Get your key from [Google AI Studio](https://aistudio.google.com/app/apikey).
127
+
128
+ ### Simple Model Call
129
+
130
+ Reasoning features allow passing configuration options via a block format before the prompt.
131
+
132
+ ```sesi
133
+ let response = model("gemini-3-flash-preview") {"temperature": 0.8, "max_tokens": 1000} {"What is 2 + 2?"}
134
+ print response
135
+ ```
136
+
137
+ ### Prompts
138
+
139
+ ```sesi
140
+ let name = "Developer"
141
+ prompt greeting {"Hello, " name "! " "How are you today?"}
142
+ print greeting
143
+ ```
144
+
145
+ ### Structured Output
146
+
147
+ ```sesi
148
+ let analysis = structured_output({sentiment: string, score: number})(model("gemini-3.1-flash-lite") {"Analyze sentiment of: This product is great!"})
149
+ print "Sentiment: " analysis["sentiment"]
150
+ print "Score: " analysis["score"]
151
+ ```
152
+
153
+ ### Image Generation
154
+
155
+ Like `model`, the `image` command takes configuration parameters.
156
+
157
+ ```sesi
158
+ let logo = image("gemini-3.1-flash-image-preview") {"ratio": '1:1', "size": 512, "temperature": 0.3, "max_tokens": 512} {"make a beautiful logo for the word Sesi"}
159
+ write_image("logo.png", logo)
160
+ print "Generated image successfully!"
161
+ ```
162
+
163
+ ### Memory & Conversation
164
+
165
+ ```sesi
166
+ memory chat {"You are helpful."}
167
+ let response = model("gemini-3-flash-preview") {chat "User: Hello!"}
168
+ print response
169
+ chat = chat "Assistant:" response
170
+ ```
171
+
172
+ ### Concurrent Swarms
173
+
174
+ Sesi can orchestrate multiple concurrent scripts using the `spawn()` builtin.
175
+
176
+ ```sesi
177
+ // master.sesi
178
+ spawn("worker_1.sesi")
179
+ spawn("worker_2.sesi")
180
+ print "Both workers are now running concurrently."
181
+ ```
182
+
183
+ ---
184
+
185
+ ## Built-in Functions
186
+
187
+ ### I/O
188
+
189
+ ```sesi
190
+ print value // Print to stdout
191
+ read_file(path) // Read a file as text
192
+ write_file(path, content) // Write text to a file
193
+ write_image(path, content) // Write base64 encoded image to a file
194
+ list_dir(path) // List directory contents
195
+ ```
196
+
197
+ ### Type Checking
198
+
199
+ ```sesi
200
+ type(value) // Get type name
201
+ str(value) // Convert to string
202
+ to_json(value) // Convert to valid JSON string
203
+ num(value) // Convert to number
204
+ bool(value) // Convert to boolean
205
+ ```
206
+
207
+ ### Collections
208
+
209
+ ```sesi
210
+ len(array) // Array/string length
211
+ push(array, item) // Add to array
212
+ pop(array) // Remove from array
213
+ join(array, sep) // Join array into string
214
+ split(string, sep) // Split string to array
215
+ keys(object) // Get object keys
216
+ values(object) // Get object values
217
+ range(n) // Create [0, 1, ..., n-1]
218
+ ```
219
+
220
+ ## Running Examples
221
+
222
+ Try the included examples:
223
+
224
+ ```bash
225
+ # Basic examples
226
+ sesi examples/01_hello.sesi
227
+ sesi examples/02_variables.sesi
228
+ sesi examples/03_functions.sesi
229
+ sesi examples/04_conditionals.sesi
230
+ sesi examples/05_loops.sesi
231
+ sesi examples/06_arrays_objects.sesi
232
+
233
+ # Reasoning examples (automatically loads .env for Gemini API key)
234
+ sesi examples/08_model_call.sesi
235
+ sesi examples/09_structured_output.sesi
236
+ sesi examples/10_code_generation.sesi
237
+ sesi examples/11_memory_conversation.sesi
238
+ sesi examples/12_classification.sesi
239
+ ```
240
+
241
+ ## Common Patterns
242
+
243
+ ### Processing Arrays
244
+
245
+ ```sesi
246
+ let numbers = [1, 2, 3, 4, 5]
247
+
248
+ // Iterate
249
+ for n in numbers {print n}
250
+
251
+ // Build new array
252
+ let doubled = []
253
+ for n in numbers {push(doubled, n * 2)}
254
+ print doubled // [2, 4, 6, 8, 10]
255
+ ```
256
+
257
+ ### String Operations
258
+
259
+ ```sesi
260
+ let text = "hello world"
261
+
262
+ // Concatenation
263
+ let greeting = "Hello," + "World!"
264
+
265
+ // Length
266
+ let len = len(text)
267
+
268
+ // Uppercase/lowercase (v2+)
269
+ // let upper = upper(text)
270
+ // let lower = lower(text)
271
+
272
+ // Split and join
273
+ let words = split(text, " ")
274
+ let rejoined = join(words, "-")
275
+ ```
276
+
277
+ ### Reasoning Classification
278
+
279
+ ```sesi
280
+ fn classify(item: string) {print model("gemini-3-flash-preview")
281
+ {"Classify as: FRUIT, VEGETABLE, or GRAIN. Item: " item}}
282
+ classify("apple")
283
+ classify("carrot")
284
+ classify("wheat")
285
+ ```
286
+
287
+ ## Debugging Tips
288
+
289
+ ### Print Intermediate Values
290
+
291
+ ```sesi
292
+ fn complex(x: number) {
293
+ let step1 = x * 2
294
+ print "Step 1:" str(step1)
295
+ let step2 = step1 + 10
296
+ print "Step 2:" str(step2)
297
+ }
298
+ complex(5)
299
+ ```
300
+
301
+ ### Check Types
302
+
303
+ ```sesi
304
+ let value = "hello"
305
+ print type(value) // "string"
306
+ if type(value) == "string" {print "It's a string!"}
307
+ ```
308
+
309
+ ### Validate Model Responses
310
+
311
+ ```sesi
312
+ let response = model("gemini-3-flash-preview") {"Respond with YES or NO"}
313
+ if response == "" {print "Error: no response"}
314
+ else if len(response) > 100 {print "Warning: response too long"}
315
+ else {print "Response: " response}
316
+ ```
317
+
318
+ ## Performance Considerations
319
+
320
+ - **Model calls are blocking**: Each model() call waits for the API response
321
+ - **Token usage**: Larger prompts use more tokens and cost more
322
+ - **Use appropriate models**: gemini-3.1-flash-lite for most tasks, gemini-3.1-pro-preview for complex reasoning
323
+ - **Batch operations**: Ask Reasoning to process multiple items in one call instead of looping
324
+
325
+ ## Next Steps
326
+
327
+ 1. **Read the spec**: [SPECIFICATION.md](docs/SPECIFICATION.md)
328
+ 2. **Learn about reasoning**: [SYSTEMS_REASONING.md](docs/SYSTEMS_REASONING.md)
329
+ 3. **Understand architecture**: [ARCHITECTURE.md](docs/ARCHITECTURE.md)
330
+ 4. **Check roadmap**: [ROADMAP.md](docs/ROADMAP.md)
331
+ 5. **Study examples**: [examples/](examples/)
332
+
333
+ ## Getting Help
334
+
335
+ - Check documentation in [docs/](docs/)
336
+ - Review examples in [examples/](examples/)
337
+ - Read error messages carefully
338
+ - Try simpler programs first
339
+
340
+ ## Reporting Issues
341
+
342
+ When reporting bugs:
343
+
344
+ 1. Provide a minimal example
345
+ 2. Show the error message
346
+ 3. Include your Sesi version
347
+ 4. Specify OS and Node.js version
348
+
349
+ ---
350
+
351
+ Happy programming with Sesi! 🚀
package/docs/README.md ADDED
@@ -0,0 +1,191 @@
1
+ <p align="center">
2
+ <img src="./sesi-logo.svg" alt="Sesi Logo" width="250" />
3
+ </p>
4
+
5
+ <h1 align="center">Sesi: A High-Performance Systems Language</h1>
6
+
7
+ <p align="center">
8
+ <em>Pronounced "say-see" — What you say, you'll see.</em>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <img alt="License" src="https://img.shields.io/badge/license-MIT-blue.svg">
13
+ <img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-Ready-blue?logo=typescript">
14
+ <img alt="Powered by Gemini" src="https://img.shields.io/badge/Powered%20By-Google%20Gemini-orange">
15
+ <img alt="Framework" src="https://img.shields.io/badge/Node.js-Engine-success?logo=node.js">
16
+ </p>
17
+
18
+ **Sesi** is a high-performance **Systems Language** designed for building resilient, stateful applications. It provides first-class primitives for process management, filesystem orchestration, and integrated reasoning—enabling developers to build complex logic with a fraction of the boilerplate required by traditional languages.
19
+
20
+ ## Quick Start
21
+
22
+ # Global Installation (Recommended)
23
+
24
+ Clone the repository:
25
+
26
+ ```bash
27
+ git clone https://github.com/Misterscan/Sesi.git
28
+ cd sesi-programming-lang
29
+ ```
30
+ You'll need a [Gemini API Key](https://aistudio.google.com/app/apikey). Create a `.env` file referencing your key:
31
+
32
+ ```env
33
+ GEMINI_API_KEY="AIzaSy..."
34
+ ```
35
+
36
+ You can install Sesi globally to use the `sesi` command anywhere on your system:
37
+
38
+ ```bash
39
+ # Install required dependencies
40
+ npm install
41
+
42
+ # Unlock the `sesi` command
43
+ npm install -g .
44
+ ```
45
+
46
+ Then run any program directly:
47
+
48
+ ```bash
49
+ # Standard script execution
50
+ sesi main/start.sesi
51
+
52
+ # Reasoning script example
53
+ sesi examples/08_model_call.sesi
54
+
55
+ # Run all examples
56
+ sesi examples.sesi
57
+ ```
58
+
59
+ # Local Execution (Development)
60
+
61
+ If you choose not install `sesi` globally, use the helper npm scripts:
62
+
63
+ ```bash
64
+ npm run example 01_hello.sesi
65
+ npm run example:ai 08_model_call.sesi
66
+ npm run example:all
67
+ ```
68
+
69
+ ## Language Overview
70
+
71
+ Sesi is designed for developers who want to:
72
+
73
+ - Write normal code (variables, functions, loops, etc.)
74
+ - Call Reasoning directly within code using `prompt` and `model` blocks
75
+ - Get structured outputs from Reasoning with type guarantees
76
+ - Build Reasoning agents with memory and multi-step reasoning
77
+ - Maintain full control and transparency
78
+
79
+ ## Example
80
+
81
+ ```sesi
82
+ // Basic computation
83
+ let x = 10
84
+ let y = 20
85
+ let result = x + y
86
+ print result // 30
87
+
88
+ // Reasoning-powered code generation
89
+ prompt generateCode {"Write a TypeScript function that reverses a string"}
90
+ let code = model("gemini-3.1-pro-preview") {generateCode}
91
+ print code
92
+ ```
93
+
94
+ ## Documentation
95
+
96
+ - [Getting Started](QUICKSTART.md)
97
+ - [Examples](./examples/)
98
+ - [Language Specification](SPECIFICATION.md)
99
+ - [Language Comparison Showcase](COMPARISON.md)
100
+ - [Built-in Functions](BUILTINS.md)
101
+ - [Reasoning Guide](.SYSTEMS_REASONING.md)
102
+ - [Distributed Systems](DISTRIBUTED_SYSTEMS.md)
103
+ - [Runtime Architecture](ARCHITECTURE.md)
104
+
105
+ ## AI Agent Context
106
+
107
+ The root-level `SKILLS.md` file is a workspace context file for AI agents. It records repo-specific constraints such as valid Sesi syntax expectations, execution conventions, and the intended meaning of directories like `main/` and `main/tests/`.
108
+
109
+ ## Project Structure
110
+
111
+ ```
112
+ sesi-programming-lang/
113
+ ├── SKILLS.md # AI-agent workspace context and repo guardrails
114
+ ├── index.html # Sesi-generated landing page
115
+ ├── eslint.config.mjs # ESLint configuration
116
+ ├── dist/ # Compiled TypeScript output
117
+ ├── example.js # Helper script to run basic examples
118
+ ├── example-ai.js # Helper script to run Reasoning examples
119
+ ├── package.json # Dependencies & scripts
120
+ ├── tsconfig.json # TypeScript configuration
121
+ ├── QUICKSTART.md # Quick start guide
122
+ ├── IMPLEMENTATION_SUMMARY.md # Progress and tracking
123
+ ├── src/
124
+ │ ├── types.ts # Type system & AST nodes
125
+ │ ├── lexer.ts # Tokenization
126
+ │ ├── parser.ts # AST generation
127
+ │ ├── interpreter.ts # Execution engine
128
+ │ ├── builtins.ts # Standard library
129
+ │ ├── ai-runtime.ts # Gemini integration
130
+ │ └── index.ts # Main entry point
131
+ ├── bin/
132
+ │ └── sesi.js # CLI executable
133
+ ├── examples/ # 15 sample programs demonstrating all features
134
+ ├── main/ # Main entry and specialized tests
135
+ │ ├── playground.sesi # Main playground script
136
+ │ ├── start.sesi # Beginner script
137
+ │ ├── build_website.sesi # Sesi-powered landing page generator
138
+ │ └── tests/ # Debug and syntax scripts
139
+ ├── tests/ # Test suite
140
+ └── docs/ # Documentation (ARCHITECTURE, BUILTINS, SPECIFICATION, etc.)
141
+ ```
142
+
143
+ ## Version 1.1 Features (Complete)
144
+
145
+ ### Core Language ✅
146
+
147
+ - **Variables & Bindings**: `let` for all bindings (const is deprecated).
148
+ - **Functions**: Side-effect driven functions with typed parameters.
149
+ - **Control Flow**: `if/else`, `while`, `for`, and `try/catch`.
150
+ - **Collections**: Robust Arrays and Objects.
151
+ - **Error Handling**: Structured `try/catch` for both runtime and Reasoning-level errors.
152
+
153
+ ### Reasoning-Native Features ✅
154
+
155
+ - `prompt` blocks for message composition
156
+ - `model()` calls with Reasoning provider configuration
157
+ - `image()` calls with specific ratio/size generation capabilities
158
+ - `structured_output()` for typed Reasoning responses
159
+ - `tool_call()` for function calling
160
+ - Basic memory for multi-turn reasoning
161
+ - `read_file()`, `write_file()`, `to_json()`, `write_image()`, and `list_dir()` for local file I/O
162
+ - **Native Orchestration**: `spawn()` and `exec()` for concurrent process management
163
+ - **Async Polling**: Native looping to auto-resume generation when hitting `MAX_TOKENS` limit
164
+ - **Utility Builtins**: `time()` and `random()` for robust coordination
165
+
166
+ ### Type System
167
+
168
+ - Static types: `number`, `string`, `bool`, `array<T>`, `object<T>`
169
+ - Type inference
170
+ - Union types for Reasoning response handling
171
+
172
+ ## Roadmap
173
+
174
+ ### V2: Advanced Reasoning
175
+
176
+ - Long-term memory and context management
177
+ - Parallel model calls
178
+ - Advanced error handling with Reasoning fallbacks
179
+ - Custom tool definitions
180
+ - Streaming responses
181
+
182
+ ### V3: Agents & Orchestration
183
+
184
+ - Agent definitions with state
185
+ - Tool composition and chaining
186
+ - Multi-agent collaboration
187
+ - Persistent knowledge bases
188
+
189
+ ## License
190
+
191
+ MIT