future-lang 0.3.0

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 (47) hide show
  1. package/ARCHITECTURE.md +424 -0
  2. package/MIGRATION.md +365 -0
  3. package/README.md +370 -0
  4. package/ROADMAP.md +263 -0
  5. package/examples/adult.future +8 -0
  6. package/examples/api.future +11 -0
  7. package/examples/assistant.future +8 -0
  8. package/examples/browser-demo.html +164 -0
  9. package/examples/greet.future +7 -0
  10. package/examples/hello.future +1 -0
  11. package/examples/math.future +8 -0
  12. package/examples/mini-app.html +301 -0
  13. package/examples/smarthome.future +10 -0
  14. package/future-browser.js +102 -0
  15. package/future-playground.html +650 -0
  16. package/package.json +27 -0
  17. package/runtime/ai.js +92 -0
  18. package/runtime/browser.js +458 -0
  19. package/runtime/device.js +36 -0
  20. package/runtime/home.js +19 -0
  21. package/runtime/http.js +32 -0
  22. package/runtime/index.js +403 -0
  23. package/runtime/lsp-metadata.js +104 -0
  24. package/runtime/math.js +16 -0
  25. package/runtime/memory.js +61 -0
  26. package/runtime/mqtt.js +49 -0
  27. package/runtime/providers/anthropic.js +59 -0
  28. package/runtime/providers/index.js +93 -0
  29. package/runtime/providers/openai-compat.js +85 -0
  30. package/runtime/providers/util.js +70 -0
  31. package/runtime/rag/chunker.js +65 -0
  32. package/runtime/rag/pipeline.js +86 -0
  33. package/runtime/rag/vector-store.js +119 -0
  34. package/runtime/rag.js +94 -0
  35. package/runtime/schedule.js +77 -0
  36. package/runtime/system.js +101 -0
  37. package/runtime/tts.js +38 -0
  38. package/runtime/vision.js +85 -0
  39. package/server.js +42 -0
  40. package/src/ast.js +202 -0
  41. package/src/cli.js +391 -0
  42. package/src/errors.js +21 -0
  43. package/src/formatter.js +48 -0
  44. package/src/generator.js +457 -0
  45. package/src/index.js +48 -0
  46. package/src/lexer.js +248 -0
  47. package/src/parser.js +469 -0
package/README.md ADDED
@@ -0,0 +1,370 @@
1
+ # Future
2
+
3
+ **An AI-first, IoT-first programming language that transpiles to JavaScript.**
4
+
5
+ Future reads like plain English, runs on Node.js, and gives every program built-in access to AI, HTTP, MQTT, memory, scheduling, and more β€” without `async`/`await` boilerplate. It also runs fully in the browser.
6
+
7
+ ---
8
+
9
+ ## Quick start
10
+
11
+ ```bash
12
+ npm install future-lang
13
+ ```
14
+
15
+ ```future
16
+ # hello.future
17
+ name = "World"
18
+ print "Hello, {name}!"
19
+
20
+ scores = [85, 92, 78]
21
+ print "Count: {len(scores)}"
22
+ print "Best: {math.max(85, 92, 78)}"
23
+
24
+ answer = ai.ask("What is the capital of Portugal? One word.")
25
+ print "AI says: {answer}"
26
+ ```
27
+
28
+ ```bash
29
+ npx future run hello.future
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Language features
35
+
36
+ ### Variables and types
37
+
38
+ ```future
39
+ name = "Alice"
40
+ age = 30
41
+ active = true
42
+ data = null # also: none
43
+ ```
44
+
45
+ ### String interpolation
46
+
47
+ ```future
48
+ print "Hello, {name}! You are {age} years old."
49
+ print "Pi is approximately {math.pi}"
50
+ ```
51
+
52
+ Any `{identifier}` or `{identifier.prop}` inside a string becomes a JS template literal. Escape a literal brace with `\{`.
53
+
54
+ ### Arithmetic and logic
55
+
56
+ ```future
57
+ sum = 10 + 3 * 2
58
+ same = sum == 16
59
+ both = true and false
60
+ any = true or false
61
+ neg = not true
62
+ ```
63
+
64
+ ### Conditionals
65
+
66
+ ```future
67
+ if age >= 18
68
+ print "Adult"
69
+ else
70
+ print "Minor"
71
+ end
72
+ ```
73
+
74
+ ### Lists and objects
75
+
76
+ ```future
77
+ fruits = ["apple", "banana", "cherry"]
78
+ user = { name: "JoΓ£o" age: 30 city: "Lisbon" }
79
+
80
+ print user.name
81
+ print fruits.length
82
+ ```
83
+
84
+ ### Iteration
85
+
86
+ ```future
87
+ for fruit in fruits
88
+ print "I like {fruit}"
89
+ end
90
+
91
+ count = 0
92
+ while count < 5
93
+ count = count + 1
94
+ end
95
+ ```
96
+
97
+ ### Functions
98
+
99
+ ```future
100
+ function greet(name)
101
+ return "Hello, {name}!"
102
+ end
103
+
104
+ msg = greet("Alice")
105
+ print msg
106
+ ```
107
+
108
+ ### Error handling
109
+
110
+ ```future
111
+ try
112
+ data = http.get("https://api.example.com/data")
113
+ print data.title
114
+ catch err
115
+ print "Request failed: {err}"
116
+ end
117
+ ```
118
+
119
+ ---
120
+
121
+ ## Built-in functions
122
+
123
+ ### `len(x)` β€” length of any value
124
+
125
+ ```future
126
+ items = [1, 2, 3, 4, 5]
127
+ text = "hello"
128
+ obj = { a: 1 b: 2 }
129
+
130
+ print len(items) # 5
131
+ print len(text) # 5
132
+ print len(obj) # 2 (number of keys)
133
+ ```
134
+
135
+ ### `math` β€” numeric operations
136
+
137
+ ```future
138
+ print math.round(3.7) # 4
139
+ print math.floor(3.9) # 3
140
+ print math.ceil(3.1) # 4
141
+ print math.abs(-5) # 5
142
+ print math.sqrt(16) # 4
143
+ print math.pow(2, 10) # 1024
144
+ print math.max(1, 5, 3) # 5
145
+ print math.min(1, 5, 3) # 1
146
+ print math.random() # random float 0–1
147
+ print math.log(math.e) # 1
148
+ print math.pi # 3.141592...
149
+ print math.e # 2.718281...
150
+ ```
151
+
152
+ ### `input(prompt)` β€” read user input
153
+
154
+ ```future
155
+ name = input("What is your name? ")
156
+ print "Hello, {name}!"
157
+ ```
158
+
159
+ In the browser this uses `window.prompt()`. In a Node.js CLI program it reads from stdin.
160
+
161
+ ---
162
+
163
+ ## Capabilities & the runtime
164
+
165
+ Future programs talk to the outside world through **namespace calls**. The compiler detects them and automatically switches the program to async mode β€” you never write `async` or `await`.
166
+
167
+ ```future
168
+ # HTTP
169
+ todo = http.get("https://jsonplaceholder.typicode.com/todos/1")
170
+ print "Title: {todo.title}"
171
+
172
+ # AI
173
+ answer = ai.ask("Explain MQTT in one sentence")
174
+ tts.speak(answer)
175
+
176
+ # Home automation
177
+ home.turnOn("livingroom_light")
178
+ mqtt.publish("home/livingroom/light", "on")
179
+ ```
180
+
181
+ ### Available namespaces
182
+
183
+ | Namespace | Functions | Notes |
184
+ |------------|-----------|-------|
185
+ | `http` | `get(url)`, `post(url, body)` | Parses JSON automatically |
186
+ | `ai` | `ask(prompt)`, `chat(messages)`, `embed(text)`, `stream(prompt, cb)`, `configure(provider, key)` | Pluggable providers |
187
+ | `tts` | `speak(text)` | System engine (`say` / SAPI / `espeak-ng`) |
188
+ | `mqtt` | `publish(topic, msg)`, `subscribe(topic, handler)` | Real broker or in-process loopback |
189
+ | `memory` | `set(key, v)`, `get(key)`, `delete(key)`, `search(q)`, `forget(pattern?)` | In-process key-value store |
190
+ | `schedule` | `every(interval, cb)`, `once(delay, cb)`, `cron(expr, cb)` | "30m", "5s", or milliseconds |
191
+ | `system` | `exec(cmd)`, `open(target)`, `notify(msg)`, `read(path)`, `write(path, content)` | OS utilities |
192
+ | `rag` | `index(docs)`, `query(question)`, `create(name)`, `indexFile(path)`, `indexUrl(url)` | Vector search + LLM answer |
193
+ | `vision` | `describe(img)`, `detect(img)`, `ocr(img)`, `classify(img)`, `compare(a, b)` | Needs AI provider |
194
+ | `home` | `turnOn(device)`, `turnOff(device)`, `set(device, value)` | Home automation via MQTT |
195
+ | `math` | `round`, `floor`, `ceil`, `abs`, `sqrt`, `pow`, `log`, `random`, `min`, `max`, `pi`, `e` | Full Math wrapper |
196
+ | `device` | `register(config)`, `get(name)`, `list()` | IoT device registry |
197
+
198
+ ### Configuration (environment variables)
199
+
200
+ ```bash
201
+ FUTURE_AI_PROVIDER=anthropic # anthropic | openai | gemini | ollama | openrouter | groq
202
+ FUTURE_AI_API_KEY=sk-...
203
+ FUTURE_AI_MODEL=claude-sonnet-4-6
204
+ ANTHROPIC_API_KEY=sk-ant-... # legacy shortcut
205
+ MQTT_URL=mqtt://localhost:1883
206
+ FUTURE_VECTOR_DB=memory # memory | file | qdrant
207
+ ```
208
+
209
+ ---
210
+
211
+ ## AI configuration
212
+
213
+ ```future
214
+ # From code
215
+ ai.configure("openai", "sk-...")
216
+ ai.configure("ollama") # local, no key needed
217
+
218
+ answer = ai.ask("What is 2 + 2?")
219
+ print answer
220
+ ```
221
+
222
+ ---
223
+
224
+ ## Agents
225
+
226
+ Agents are named async tasks with an implicit `goal` parameter. `use` declarations are documentation β€” they don't generate code.
227
+
228
+ ```future
229
+ agent support
230
+ use rag
231
+ use memory
232
+
233
+ docs = rag.query(goal)
234
+ memory.set("last_query", goal)
235
+ return docs
236
+ end
237
+
238
+ answer = support("How do I reset the device?")
239
+ print answer
240
+ ```
241
+
242
+ Compiles to `async function support(goal) { ... }`.
243
+
244
+ ---
245
+
246
+ ## Streaming
247
+
248
+ ```future
249
+ stream ai.ask("Tell me a short story")
250
+ print chunk
251
+ end
252
+ ```
253
+
254
+ Compiles to `await __rt.ai.stream(prompt, async (chunk) => { ... })`.
255
+
256
+ ---
257
+
258
+ ## Event-driven programming
259
+
260
+ ```future
261
+ on mqtt "house/temp"
262
+ print "Temperature: {message}"
263
+ end
264
+
265
+ every "30m"
266
+ data = http.get("https://api.example.com/stats")
267
+ print data.count
268
+ end
269
+ ```
270
+
271
+ ---
272
+
273
+ ## RAG (Retrieval-Augmented Generation)
274
+
275
+ ```future
276
+ # Index documents
277
+ rag.index(["Future is a language.", "It compiles to JavaScript."])
278
+ rag.indexFile("manual.txt")
279
+ rag.indexUrl("https://docs.example.com")
280
+
281
+ # Query
282
+ answer = rag.query("What does Future compile to?")
283
+ print answer
284
+
285
+ # Named knowledge bases
286
+ kb = rag.create("products")
287
+ kb.index(["Product A costs $10."])
288
+ reply = kb.query("How much is Product A?")
289
+ print reply
290
+ ```
291
+
292
+ ---
293
+
294
+ ## Browser runtime
295
+
296
+ Future also runs in the browser β€” no Node.js required.
297
+
298
+ ```html
299
+ <script type="module" src="future-browser.js"></script>
300
+
301
+ <!-- Option A: proxy mode (API key stays on your server) -->
302
+ <script type="module">
303
+ import Future from './future-browser.js'
304
+ Future.configure({ proxy: '/api/ai' })
305
+ Future.runtime.print = (...args) => {
306
+ document.getElementById('output').textContent += args.join(' ') + '\n'
307
+ }
308
+ </script>
309
+
310
+ <!-- Option B: direct key (dev/demos only β€” key is visible in source) -->
311
+ <script type="module">
312
+ import Future from './future-browser.js'
313
+ Future.configure({ provider: 'openai', apiKey: 'sk-...' })
314
+ </script>
315
+
316
+ <script type="future">
317
+ names = ["Alice", "Bob", "Carlos"]
318
+ for name in names
319
+ print "Hello, {name}!"
320
+ end
321
+
322
+ answer = ai.ask("One fun fact about Lisbon.")
323
+ print answer
324
+ </script>
325
+ ```
326
+
327
+ Open `future-playground.html` in any browser for a live editor with 11 built-in examples.
328
+
329
+ ---
330
+
331
+ ## CLI
332
+
333
+ ```bash
334
+ future run program.future # compile + run
335
+ future compile program.future # print generated JavaScript
336
+ ```
337
+
338
+ ---
339
+
340
+ ## How it works
341
+
342
+ The compiler is a three-phase pipeline:
343
+
344
+ ```
345
+ Source (.future) β†’ Lexer β†’ Parser β†’ Generator β†’ JavaScript
346
+ ```
347
+
348
+ **SIMPLE mode** β€” programs with no capability calls compile to plain, synchronous JS with no imports.
349
+
350
+ **ASYNC mode** β€” any capability call (`http.get`, `ai.ask`, `math.round`, `input`, …) switches the program to async mode. The generator imports `future-lang/runtime` as `__rt` and wraps every function in `async`/`await`. The user writes none of this.
351
+
352
+ ---
353
+
354
+ ## Package exports
355
+
356
+ ```json
357
+ {
358
+ ".": "./src/index.js",
359
+ "./runtime": "./runtime/index.js",
360
+ "./runtime/lsp-metadata": "./runtime/lsp-metadata.js"
361
+ }
362
+ ```
363
+
364
+ ---
365
+
366
+ ## Documentation
367
+
368
+ - [ARCHITECTURE.md](ARCHITECTURE.md) β€” compiler pipeline, folder structure, AST node types
369
+ - [ROADMAP.md](ROADMAP.md) β€” feature status and priorities
370
+ - [MIGRATION.md](MIGRATION.md) β€” changelog, what changed between versions
package/ROADMAP.md ADDED
@@ -0,0 +1,263 @@
1
+ # Future β€” Roadmap
2
+
3
+ **Version:** 0.3.0 Β· **Last updated:** 2026-06-13
4
+
5
+ Status legend: βœ… Done Β· πŸ”„ In progress Β· πŸ“‹ Planned Β· πŸ’‘ Idea
6
+
7
+ ---
8
+
9
+ ## General-Purpose Programming
10
+
11
+ | Feature | Status | Notes |
12
+ |---------|--------|-------|
13
+ | `len(x)` built-in | βœ… | Arrays, strings, and objects β€” no runtime needed (sync) |
14
+ | `math` module | βœ… | `round`, `floor`, `ceil`, `abs`, `sqrt`, `pow`, `log`, `random`, `min`, `max`, `pi`, `e` |
15
+ | `input(prompt)` built-in | βœ… | stdin (Node.js) / `window.prompt` (browser) |
16
+ | `while condition ... end` | βœ… | Condition-based loop |
17
+ | `null` / `none` literals | βœ… | Both compile to JS `null` |
18
+ | Multi-line strings | πŸ“‹ | Strings must be single-line today |
19
+ | String `+` concatenation | βœ… | Works via binary `+` operator |
20
+ | Integer division / modulo | πŸ“‹ | `math.trunc(a / b)` workaround for now |
21
+ | `use "other.future"` imports | πŸ’‘ | No cross-file composition yet |
22
+ | REPL (`future repl`) | πŸ’‘ | Interactive shell with introspection |
23
+
24
+ ---
25
+
26
+ ## AI
27
+
28
+ | Feature | Status | Notes |
29
+ |---------|--------|-------|
30
+ | `ai.ask(prompt)` | βœ… | Single-turn Q&A |
31
+ | `ai.chat(messages)` | βœ… | Multi-turn conversation |
32
+ | `ai.embed(text)` | βœ… | Real embeddings (OpenAI/Ollama) + keyword fallback |
33
+ | `ai.stream(prompt, callback)` | βœ… | Streaming via SSE β€” runtime implemented |
34
+ | `stream ai.ask() ... end` syntax | βœ… | Language-level streaming with implicit `chunk` variable |
35
+ | `ai.configure(provider, key, model)` | βœ… | Pluggable provider from Future code |
36
+ | Provider: Anthropic | βœ… | Native Messages API |
37
+ | Provider: OpenAI | βœ… | Via OpenAI-compat layer |
38
+ | Provider: Ollama | βœ… | Local models, no key needed |
39
+ | Provider: OpenRouter | βœ… | Multi-model routing |
40
+ | Provider: Gemini | βœ… | Via Google's OpenAI-compat endpoint |
41
+ | Provider: Venice / Groq / Together | βœ… | Via OpenAI-compat layer |
42
+ | `FUTURE_AI_PROVIDER` env var | βœ… | Switch provider without code change |
43
+ | `ai.extract(text, schema)` | πŸ“‹ | Structured JSON extraction with a schema |
44
+ | `ai.classify(text, labels)` | πŸ“‹ | Zero-shot classification |
45
+
46
+ ---
47
+
48
+ ## RAG (Retrieval-Augmented Generation)
49
+
50
+ | Feature | Status | Notes |
51
+ |---------|--------|-------|
52
+ | `rag.index(docs)` | βœ… | Real pipeline: chunk β†’ embed β†’ store |
53
+ | `rag.query(question)` | βœ… | Similarity search + LLM answer generation |
54
+ | `rag.create(name)` β€” Knowledge Bases | βœ… | Isolated pipeline per KB |
55
+ | `kb.index(docs)` / `kb.query(q)` | βœ… | Fully awaited by compiler in async mode |
56
+ | `rag.stats()` | βœ… | Chunk count and vector count |
57
+ | `rag.indexFile(path)` | βœ… | Reads a local file and indexes it |
58
+ | `rag.indexUrl(url)` | βœ… | Fetches a URL and indexes its text |
59
+ | Chunker (sentence-aware, overlapping) | βœ… | 512-char chunks, 64-char overlap |
60
+ | Keyword vector fallback (offline RAG) | βœ… | Works with no embedding API |
61
+ | Vector store: memory | βœ… | In-process, cosine similarity |
62
+ | Vector store: file (JSON persistence) | βœ… | No native deps, survives restarts |
63
+ | Vector store: Qdrant | πŸ“‹ | Stub exists β€” implement `runtime/rag/qdrant.js` |
64
+ | Vector store: Pinecone / Weaviate | πŸ“‹ | Stubs exist |
65
+ | Source attribution in query results | πŸ“‹ | Return which chunks matched and their source |
66
+ | `rag.delete(id)` | πŸ“‹ | Remove a document from the index |
67
+
68
+ ---
69
+
70
+ ## MQTT
71
+
72
+ | Feature | Status | Notes |
73
+ |---------|--------|-------|
74
+ | `mqtt.publish(topic, message)` | βœ… | Real broker or in-process loopback |
75
+ | `mqtt.subscribe(topic, handler)` | βœ… | Callback on each message |
76
+ | `on mqtt "topic" ... end` | βœ… | Event-oriented syntax sugar |
77
+ | TLS/SSL connections (`mqtts://`) | πŸ“‹ | Already works via env var URL |
78
+ | QoS levels | πŸ“‹ | `mqtt.publish(topic, msg, { qos: 1 })` |
79
+ | Retained messages | πŸ“‹ | `mqtt.publish(topic, msg, { retain: true })` |
80
+ | `mqtt.unsubscribe(topic)` | πŸ“‹ | Cancel a subscription |
81
+ | `mqtt.disconnect()` | πŸ“‹ | Graceful shutdown |
82
+
83
+ ---
84
+
85
+ ## Home Automation
86
+
87
+ | Feature | Status | Notes |
88
+ |---------|--------|-------|
89
+ | `home.turnOn(device)` | βœ… | Publishes to `home/<device>/set` via MQTT |
90
+ | `home.turnOff(device)` | βœ… | |
91
+ | `home.set(device, value)` | βœ… | Arbitrary value (brightness, temperature, …) |
92
+ | `home.get(device)` | πŸ“‹ | Read current device state |
93
+ | `home.scene(name)` | πŸ“‹ | Activate a named scene |
94
+ | Home Assistant REST API backend | πŸ“‹ | Swap MQTT for HA long-lived token |
95
+ | Philips Hue direct integration | πŸ’‘ | `home.hue.*` sub-namespace |
96
+ | Matter / Thread support | πŸ’‘ | Local-network device control without cloud |
97
+
98
+ ---
99
+
100
+ ## Vision AI
101
+
102
+ | Feature | Status | Notes |
103
+ |---------|--------|-------|
104
+ | `vision.describe(image)` | βœ… | Uses configured AI provider (Claude/GPT-4o) |
105
+ | `vision.detect(image)` | βœ… | Object / label detection via prompt |
106
+ | `vision.ocr(image)` | βœ… | Text extraction from image |
107
+ | `vision.classify(image)` | βœ… | Primary category in 1–2 words |
108
+ | `vision.compare(imageA, imageB)` | βœ… | Similarity / diff description |
109
+ | Accepts URLs and base64 data-URIs | βœ… | |
110
+ | Local model (LLaVA via Ollama) | πŸ“‹ | Works with `FUTURE_AI_PROVIDER=ollama` + llava model |
111
+ | `vision.watch(cameraUrl, callback)` | πŸ’‘ | Continuous RTSP / webcam stream analysis |
112
+
113
+ ---
114
+
115
+ ## Device Management
116
+
117
+ | Feature | Status | Notes |
118
+ |---------|--------|-------|
119
+ | `device.register(config)` | βœ… | In-process registry |
120
+ | `device.get(name)` | βœ… | Look up by name |
121
+ | `device.list()` | βœ… | All registered devices |
122
+ | `device.update(name, changes)` | πŸ“‹ | Patch device config |
123
+ | `device.remove(name)` | πŸ“‹ | Deregister a device |
124
+ | `device.send(name, command)` | πŸ“‹ | Send a command to a registered device |
125
+ | Persistent registry (JSON / SQLite) | πŸ“‹ | Survives process restarts |
126
+ | AWS IoT Core / Azure IoT Hub | πŸ’‘ | Cloud-managed fleet |
127
+
128
+ ---
129
+
130
+ ## Memory
131
+
132
+ | Feature | Status | Notes |
133
+ |---------|--------|-------|
134
+ | `memory.set(key, value)` | βœ… | |
135
+ | `memory.get(key)` | βœ… | Returns null if not found |
136
+ | `memory.delete(key)` | βœ… | |
137
+ | `memory.search(query)` | βœ… | Substring match on key + value |
138
+ | `memory.forget(pattern?)` | βœ… | Delete by pattern or clear all |
139
+ | Persistent memory (file / Redis) | πŸ“‹ | Survives process restarts |
140
+ | Semantic memory search | πŸ“‹ | Use `ai.embed()` for similarity-based recall |
141
+ | Memory scoped to agents | πŸ“‹ | Namespaced per-agent store |
142
+
143
+ ---
144
+
145
+ ## Scheduling
146
+
147
+ | Feature | Status | Notes |
148
+ |---------|--------|-------|
149
+ | `schedule.every(interval, cb)` | βœ… | "30m", "5s", ms number |
150
+ | `schedule.once(delay, cb)` | βœ… | Run once after delay |
151
+ | `schedule.cron(expr, cb)` | βœ… | Requires optional `node-cron` package |
152
+ | `every "30m" ... end` syntax | βœ… | Compiles to `schedule.every` |
153
+ | `schedule.cancel(handle)` | πŸ“‹ | Stop a recurring task |
154
+ | `schedule.list()` | πŸ“‹ | List active tasks |
155
+
156
+ ---
157
+
158
+ ## System & OS
159
+
160
+ | Feature | Status | Notes |
161
+ |---------|--------|-------|
162
+ | `system.exec(command)` | βœ… | Run shell commands |
163
+ | `system.open(target)` | βœ… | OS default handler for files/URLs |
164
+ | `system.notify(message)` | βœ… | Desktop notification |
165
+ | `system.read(path)` | βœ… | Read a local file to string |
166
+ | `system.write(path, content)` | βœ… | Write (create or overwrite) a local file |
167
+ | `system.env(name)` | βœ… | Read environment variables; browser reads from `window.__env` |
168
+
169
+ ---
170
+
171
+ ## Agents
172
+
173
+ | Feature | Status | Notes |
174
+ |---------|--------|-------|
175
+ | `AgentDeclaration` AST node | βœ… | Architecture complete |
176
+ | `agent <name> use <cap> ... end` | βœ… | Compiles to `async function name(goal)` |
177
+ | `use <capability>` declarations | βœ… | Collected for tooling; no-op in generated JS |
178
+ | Implicit `goal` parameter | βœ… | Available inside agent body without declaration |
179
+ | Agent memory isolation | πŸ“‹ | Per-agent namespaced memory |
180
+ | Agent tools (function binding) | πŸ“‹ | Map Future functions to tool calls |
181
+ | Multi-agent orchestration | πŸ’‘ | Agents calling other agents |
182
+ | Tool-calling loop (ReAct) | πŸ’‘ | AI decides which tool to call each step |
183
+
184
+ ---
185
+
186
+ ## Language & Compiler
187
+
188
+ | Feature | Status | Notes |
189
+ |---------|--------|-------|
190
+ | Print, variables, if/else, functions | βœ… | Core language |
191
+ | Capability calls (auto-async, auto-await) | βœ… | |
192
+ | `on <source> <channel> ... end` | βœ… | Event subscription |
193
+ | `every <interval> ... end` | βœ… | Recurring task |
194
+ | Method calls on dynamic objects awaited | βœ… | Enables `kb.query()` pattern |
195
+ | `for item in list ... end` | βœ… | List iteration |
196
+ | `while condition ... end` | βœ… | Condition-based loop |
197
+ | `try ... catch err ... end` | βœ… | Error handling |
198
+ | Lists `[1, 2, 3]` | βœ… | Array literals |
199
+ | Object literals `{ key: value }` | βœ… | No commas required (Future style) |
200
+ | String interpolation `"Hello {name}"` | βœ… | Template literal output |
201
+ | Namespace refs in strings `"{math.pi}"` | βœ… | Correctly emits `${__rt.math.pi}` in async mode |
202
+ | `null` / `none` literals | βœ… | Both spellings compile to JS `null` |
203
+ | `stream <call> ... end` | βœ… | Streams chunks via implicit `chunk` variable |
204
+ | `agent <name> ... end` | βœ… | Named async task with implicit `goal` parameter |
205
+ | `len(x)` built-in | βœ… | Arrays, strings, objects β€” sync, no runtime needed |
206
+ | `math.*` module | βœ… | Full JS Math wrapper |
207
+ | `input(prompt)` built-in | βœ… | stdin (Node.js) / `window.prompt` (browser) |
208
+ | Multi-line strings | πŸ“‹ | Strings must be single-line |
209
+ | `use "other.future"` β€” module imports | πŸ’‘ | No cross-file composition |
210
+ | REPL (`future repl`) | πŸ’‘ | Interactive shell with introspection |
211
+
212
+ ---
213
+
214
+ ## Browser Runtime
215
+
216
+ | Feature | Status | Notes |
217
+ |---------|--------|-------|
218
+ | `future-browser.js` β€” browser entry point | βœ… | Compiler + runtime bundled, no Node.js required |
219
+ | `<script type="future">` interceptor | βœ… | Deferred via `setTimeout` so modules run first |
220
+ | `Future.configure({ proxy })` | βœ… | Proxy mode β€” API key stays on server |
221
+ | `Future.configure({ provider, apiKey })` | βœ… | Demo mode β€” key visible in source |
222
+ | `Future.runtime.print` override | βœ… | Redirect output to DOM |
223
+ | `Future.run(source)` / `Future.compile(source)` | βœ… | Programmatic API |
224
+ | `future-playground.html` | βœ… | Live editor with 11 examples |
225
+ | AI modules (ai, rag, vision) | βœ… | Require key or proxy |
226
+ | http, memory, schedule, tts, math, device | βœ… | Fully supported in browser |
227
+ | `input()` in browser | βœ… | Uses `window.prompt` |
228
+ | MQTT in browser | πŸ“‹ | Needs WebSocket broker |
229
+ | `system.exec/read/write` in browser | βœ— | Not available (sandboxed) |
230
+
231
+ ---
232
+
233
+ ## Tooling
234
+
235
+ | Feature | Status | Notes |
236
+ |---------|--------|-------|
237
+ | CLI: `future run` | βœ… | |
238
+ | CLI: `future compile` | βœ… | |
239
+ | Structured manifest | βœ… | All 12 modules, 50+ functions fully described |
240
+ | Runtime introspection API | βœ… | `runtime.describe()` / `listModules()` / `listFunctions()` |
241
+ | LSP metadata module | βœ… | Completions, hover, signatures |
242
+ | Browser playground | βœ… | `future-playground.html` β€” 11 examples |
243
+ | VSCode extension | πŸ“‹ | Syntax highlighting, completions, hover |
244
+ | Language Server (LSP) | πŸ“‹ | Full editor integration |
245
+ | `future fmt` | πŸ“‹ | Auto-formatter |
246
+ | `future check` | πŸ“‹ | Lint / type check without running |
247
+ | npm publish (`future-lang`) | πŸ“‹ | Public package registry |
248
+
249
+ ---
250
+
251
+ ## Priority Matrix
252
+
253
+ | Priority | Item | Why it matters |
254
+ |----------|------|----------------|
255
+ | πŸ”΄ Critical | npm publish (`future-lang`) | Required to ship publicly |
256
+ | πŸ”΄ Critical | VSCode extension (syntax highlighting) | First impression for new users |
257
+ | 🟠 High | `use "other.future"` imports | Cross-file composition for real projects |
258
+ | 🟠 High | `system.env(name)` | Read env vars from Future code |
259
+ | 🟑 Medium | Home Assistant REST API | Most HA users don't run MQTT |
260
+ | 🟑 Medium | Persistent memory / device registry | Most programs are stateless today |
261
+ | 🟑 Medium | Agent tool-calling loop (ReAct) | True autonomous agents |
262
+ | 🟒 Low | `rag.delete(id)` | Selective document removal |
263
+ | 🟒 Low | REPL | Nice-to-have for exploration |
@@ -0,0 +1,8 @@
1
+ # Conditionals with if / else
2
+ age = 20
3
+
4
+ if age >= 18
5
+ print "Adult"
6
+ else
7
+ print "Minor"
8
+ end
@@ -0,0 +1,11 @@
1
+ # Consumir dados de uma API pΓΊblica (JSONPlaceholder)
2
+ todo = http.get("https://jsonplaceholder.typicode.com/todos/1")
3
+
4
+ print "TΓ­tulo da tarefa:"
5
+ print todo.title
6
+
7
+ if todo.completed == true
8
+ print "Status: concluΓ­da"
9
+ else
10
+ print "Status: pendente"
11
+ end
@@ -0,0 +1,8 @@
1
+ # Assistente: pergunta Γ  IA e fala a resposta em voz alta
2
+ pergunta = "Explique o que Γ© MQTT em uma frase."
3
+ resposta = ai.ask(pergunta)
4
+
5
+ print "IA respondeu:"
6
+ print resposta
7
+
8
+ tts.speak(resposta)