enyosx-ai 0.1.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 (41) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +740 -0
  3. package/dist/chunk-2WM5L76D.js +320 -0
  4. package/dist/chunk-3BNDFBX3.js +324 -0
  5. package/dist/chunk-4LJILSCT.js +30 -0
  6. package/dist/chunk-4ZV5JV6W.js +298 -0
  7. package/dist/chunk-76PHNPTY.js +631 -0
  8. package/dist/chunk-BSSA33NY.js +677 -0
  9. package/dist/chunk-EK6IDRY7.js +105 -0
  10. package/dist/chunk-FI2EBH2N.js +2232 -0
  11. package/dist/chunk-GAKKLY4M.js +276 -0
  12. package/dist/chunk-HR4G5XQI.js +319 -0
  13. package/dist/chunk-HROGCEE5.js +30 -0
  14. package/dist/chunk-MMH7M7MG.js +30 -0
  15. package/dist/chunk-NGLRXS6G.js +2079 -0
  16. package/dist/chunk-NSE6LQJC.js +681 -0
  17. package/dist/chunk-O5XZOSBW.js +2484 -0
  18. package/dist/chunk-OVCMUPMP.js +677 -0
  19. package/dist/chunk-P2YBRE3X.js +2484 -0
  20. package/dist/chunk-VVIL5NIM.js +318 -0
  21. package/dist/chunk-ZNGEBY33.js +273 -0
  22. package/dist/cli.cjs +2509 -0
  23. package/dist/cli.d.ts +1 -0
  24. package/dist/cli.js +99 -0
  25. package/dist/index.cjs +2912 -0
  26. package/dist/index.d.ts +672 -0
  27. package/dist/index.js +379 -0
  28. package/dist/parser-4JXKOWKY.js +8 -0
  29. package/dist/parser-UUB6D2CZ.js +8 -0
  30. package/dist/parser-V44AIVNI.js +8 -0
  31. package/examples/README.md +13 -0
  32. package/examples/ia-demo.eny +37 -0
  33. package/examples/sample.eny +15 -0
  34. package/examples/simple/system.eny +7 -0
  35. package/examples/spec/sample.eny +19 -0
  36. package/examples/starter/README.md +96 -0
  37. package/examples/starter/main.eny +39 -0
  38. package/examples/starter/run.js +68 -0
  39. package/examples/starter.eny +16 -0
  40. package/examples/wasm-demo.eny +34 -0
  41. package/package.json +49 -0
@@ -0,0 +1,298 @@
1
+ // src/parser.ts
2
+ function parse(code, options) {
3
+ const logs = [];
4
+ const log = (entry) => {
5
+ const e = { timestamp: (/* @__PURE__ */ new Date()).toISOString(), ...entry };
6
+ logs.push(e);
7
+ if (options?.onLog)
8
+ options.onLog(e);
9
+ };
10
+ log({ level: "info", event: "parse.start", detail: { length: code.length } });
11
+ const ast = {
12
+ raw: code,
13
+ functions: [],
14
+ ias: [],
15
+ nodes: [],
16
+ modules: [],
17
+ objects: [],
18
+ forms: [],
19
+ animations: [],
20
+ logic: [],
21
+ parallels: [],
22
+ build: null,
23
+ evolve: null,
24
+ targets: [],
25
+ version: null,
26
+ logs
27
+ };
28
+ const lines = code.split(/\r?\n/);
29
+ let i = 0;
30
+ while (i < lines.length) {
31
+ const raw = lines[i];
32
+ const line = raw.trim();
33
+ if (!line) {
34
+ i++;
35
+ continue;
36
+ }
37
+ if (/^Σ\s+SYSTEM/i.test(line)) {
38
+ const m = line.match(/^Σ\s+SYSTEM\s+"([^"]+)"/i);
39
+ ast.system = m ? m[1] : line.replace(/^Σ\s+SYSTEM\s*/i, "");
40
+ log({ level: "info", event: "parse.system", i, line: ast.system });
41
+ i++;
42
+ continue;
43
+ }
44
+ if (/^Σ\s+VERSION/i.test(line)) {
45
+ const m = line.match(/^Σ\s+VERSION\s+([\d\.]+)/i);
46
+ ast.version = m ? m[1] : null;
47
+ i++;
48
+ continue;
49
+ }
50
+ if (/^Σ\s+TARGET/i.test(line)) {
51
+ const m = line.match(/^Σ\s+TARGET\s+(.+)/i);
52
+ if (m) {
53
+ const parts = m[1].split(/[+,\s]+/).map((s) => s.trim()).filter(Boolean);
54
+ ast.targets = [...ast.targets || [], ...parts];
55
+ }
56
+ i++;
57
+ continue;
58
+ }
59
+ if (/^Σ\s+MODE/i.test(line)) {
60
+ const m = line.match(/^Σ\s+MODE\s+([\w-]+)/i);
61
+ ast.mode = m ? m[1] : null;
62
+ i++;
63
+ continue;
64
+ }
65
+ if (/^Σ\s+UI/i.test(line)) {
66
+ const m = line.match(/^Σ\s+UI\s+([\w-]+)/i);
67
+ ast.ui = m ? m[1] : null;
68
+ i++;
69
+ continue;
70
+ }
71
+ if (/^Δ\s+([\w_]+)\s*\(([^)]*)\)/.test(line)) {
72
+ const m = line.match(/^Δ\s+([\w_]+)\s*\(([^)]*)\)/);
73
+ const name = m ? m[1] : "anonymous";
74
+ const argsRaw = m ? m[2] : "";
75
+ const args = argsRaw ? argsRaw.split(",").map((s) => s.trim()).filter(Boolean) : [];
76
+ const steps = [];
77
+ log({ level: "info", event: "parse.function.start", i, detail: { name, args } });
78
+ i++;
79
+ while (i < lines.length) {
80
+ const l = lines[i];
81
+ if (!l.trim()) {
82
+ i++;
83
+ continue;
84
+ }
85
+ if (/^→/.test(l.trim()) || /^\s+→/.test(l) || /^\s+/.test(l)) {
86
+ const step = l.trim().replace(/^→\s?/, "");
87
+ steps.push({ raw: step });
88
+ log({ level: "debug", event: "parse.function.step", i, line: step });
89
+ i++;
90
+ } else {
91
+ break;
92
+ }
93
+ }
94
+ const fn = { type: "function", name, args, steps };
95
+ log({ level: "info", event: "parse.function.end", detail: fn });
96
+ ast.functions.push(fn);
97
+ ast.nodes.push(fn);
98
+ continue;
99
+ }
100
+ if (/^Ψ\s+IA\s+([\w-]+)\s*\{?/.test(line)) {
101
+ const m = line.match(/^Ψ\s+IA\s+([\w-]+)\s*\{?/);
102
+ const name = m ? m[1] : "ia";
103
+ const body = [];
104
+ if (/\{$/.test(line)) {
105
+ i++;
106
+ while (i < lines.length && !/\}/.test(lines[i])) {
107
+ body.push(lines[i].trim());
108
+ i++;
109
+ }
110
+ if (i < lines.length && /\}/.test(lines[i]))
111
+ i++;
112
+ } else {
113
+ i++;
114
+ while (i < lines.length) {
115
+ const l = lines[i];
116
+ if (!l.trim()) {
117
+ i++;
118
+ break;
119
+ }
120
+ if (/^Σ|^Δ|^Ψ/.test(l.trim()))
121
+ break;
122
+ body.push(l.trim());
123
+ i++;
124
+ }
125
+ }
126
+ const ia = { type: "ia", name, body };
127
+ log({ level: "info", event: "parse.ia", i, detail: ia });
128
+ ast.ias.push(ia);
129
+ ast.nodes.push(ia);
130
+ continue;
131
+ }
132
+ if (/^Σ\s+EVOLVE/i.test(line)) {
133
+ const steps = [];
134
+ i++;
135
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Θ|Λ|⊗/.test(lines[i].trim())) {
136
+ steps.push(lines[i].trim());
137
+ i++;
138
+ }
139
+ const ev = { type: "evolve", steps };
140
+ ast.evolve = ev;
141
+ ast.nodes.push(ev);
142
+ continue;
143
+ }
144
+ if (/^Σ\s+BUILD/i.test(line)) {
145
+ const targets = [];
146
+ i++;
147
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Θ|Λ|⊗/.test(lines[i].trim())) {
148
+ const m = lines[i].trim().match(/target:\s*([\w-]+)/);
149
+ if (m)
150
+ targets.push(m[1]);
151
+ i++;
152
+ }
153
+ const b = { type: "build", targets };
154
+ log({ level: "info", event: "parse.build", i, detail: b });
155
+ ast.build = b;
156
+ ast.nodes.push(b);
157
+ continue;
158
+ }
159
+ if (/^Σ\s+MODULE/i.test(line)) {
160
+ const m = line.match(/^Σ\s+MODULE\s+"([^"]+)"/i);
161
+ const name = m ? m[1] : line.replace(/^Σ\s+MODULE\s*/i, "");
162
+ const module = { type: "module", name };
163
+ ast.modules.push(module);
164
+ ast.nodes.push(module);
165
+ i++;
166
+ continue;
167
+ }
168
+ if (/^Ω\s+([\w_]+)\s*\{?/.test(line)) {
169
+ const m = line.match(/^Ω\s+([\w_]+)\s*\{?/);
170
+ const name = m ? m[1] : "object";
171
+ const props = {};
172
+ if (/\{$/.test(line)) {
173
+ i++;
174
+ while (i < lines.length && !/\}/.test(lines[i])) {
175
+ const p = lines[i].trim();
176
+ const ma = p.match(/^([\w_]+)\s*:\s*"?([^\"]+)"?/);
177
+ if (ma)
178
+ props[ma[1]] = ma[2];
179
+ else if (p)
180
+ props[p] = null;
181
+ i++;
182
+ }
183
+ if (i < lines.length && /\}/.test(lines[i]))
184
+ i++;
185
+ }
186
+ const obj = { type: "object", name, props };
187
+ ast.objects.push(obj);
188
+ ast.nodes.push(obj);
189
+ continue;
190
+ }
191
+ if (/^Φ\s+([\w_]+)\s*\{?/.test(line)) {
192
+ const m = line.match(/^Φ\s+([\w_]+)\s*\{?/);
193
+ const name = m ? m[1] : "form";
194
+ const props = {};
195
+ if (/\{$/.test(line)) {
196
+ i++;
197
+ while (i < lines.length && !/\}/.test(lines[i])) {
198
+ const p = lines[i].trim();
199
+ const ma = p.match(/^([\w_]+)\s*:\s*"?([^\"]+)"?/);
200
+ if (ma)
201
+ props[ma[1]] = ma[2];
202
+ else if (p)
203
+ props[p] = true;
204
+ i++;
205
+ }
206
+ if (i < lines.length && /\}/.test(lines[i]))
207
+ i++;
208
+ }
209
+ const form = { type: "form", name, props };
210
+ ast.forms.push(form);
211
+ ast.nodes.push(form);
212
+ continue;
213
+ }
214
+ if (/^Θ\s+animation\s+"([^"]+)"/.test(line)) {
215
+ const m = line.match(/^Θ\s+animation\s+"([^"]+)"/);
216
+ const name = m ? m[1] : "anim";
217
+ const props = {};
218
+ i++;
219
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Λ|⊗/.test(lines[i].trim())) {
220
+ const p = lines[i].trim();
221
+ const ma = p.match(/^([\w_]+)\s*:\s*(.+)/);
222
+ if (ma)
223
+ props[ma[1]] = ma[2].trim();
224
+ i++;
225
+ }
226
+ const anim = { type: "animation", name, props };
227
+ ast.animations.push(anim);
228
+ ast.nodes.push(anim);
229
+ continue;
230
+ }
231
+ if (/^Λ\s+if\s+/.test(line)) {
232
+ const ruleLines = [];
233
+ let trueFlow = [];
234
+ let falseFlow = [];
235
+ let rule = line.replace(/^Λ\s+/, "");
236
+ i++;
237
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Θ|⊗/.test(lines[i].trim())) {
238
+ const l = lines[i].trim();
239
+ if (/^else/i.test(l)) {
240
+ i++;
241
+ break;
242
+ }
243
+ if (/^→/.test(l))
244
+ trueFlow.push(l.replace(/^→\s?/, "").trim());
245
+ ruleLines.push(l);
246
+ i++;
247
+ }
248
+ while (i < lines.length && !!lines[i].trim() && !/^Σ|^Δ|^Ψ|Ω|Φ|Θ|⊗/.test(lines[i].trim())) {
249
+ const l = lines[i].trim();
250
+ if (/^→/.test(l))
251
+ falseFlow.push(l.replace(/^→\s?/, "").trim());
252
+ i++;
253
+ }
254
+ const logic = { type: "logic", rule, trueFlow, falseFlow };
255
+ ast.logic.push(logic);
256
+ ast.nodes.push(logic);
257
+ continue;
258
+ }
259
+ if (/^⊗\s*\{?/.test(line)) {
260
+ const items = [];
261
+ if (/\{$/.test(line)) {
262
+ i++;
263
+ while (i < lines.length && !/\}/.test(lines[i])) {
264
+ const l = lines[i].trim();
265
+ if (l)
266
+ items.push(l);
267
+ i++;
268
+ }
269
+ if (i < lines.length && /\}/.test(lines[i]))
270
+ i++;
271
+ }
272
+ const par = { type: "parallel", items };
273
+ ast.parallels.push(par);
274
+ ast.nodes.push(par);
275
+ continue;
276
+ }
277
+ i++;
278
+ }
279
+ return ast;
280
+ }
281
+
282
+ // src/runENY.ts
283
+ function runENY(code, options) {
284
+ const hasSystem = /Σ\s+SYSTEM/i.test(code);
285
+ if (!hasSystem) {
286
+ if (options?.onLog) {
287
+ options.onLog({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), level: "warn", event: "runENY.no-system", detail: { length: code.length } });
288
+ }
289
+ return { raw: code, isEny: false, logs: [] };
290
+ }
291
+ const ast = parse(code, options);
292
+ ast.isEny = true;
293
+ return ast;
294
+ }
295
+
296
+ export {
297
+ runENY
298
+ };