@misterscan/sesi 1.2.3 → 1.3.2

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 (96) 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 +163 -51
  6. package/bin/sesi.js +196 -38
  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 +199 -5
  14. package/dist/builtins.js.map +1 -1
  15. package/dist/index.d.ts +12 -2
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +90 -6
  18. package/dist/index.js.map +1 -1
  19. package/dist/interpreter.d.ts +21 -2
  20. package/dist/interpreter.d.ts.map +1 -1
  21. package/dist/interpreter.js +201 -92
  22. package/dist/interpreter.js.map +1 -1
  23. package/dist/lexer.d.ts.map +1 -1
  24. package/dist/lexer.js +8 -4
  25. package/dist/lexer.js.map +1 -1
  26. package/dist/parser.d.ts +1 -0
  27. package/dist/parser.d.ts.map +1 -1
  28. package/dist/parser.js +21 -12
  29. package/dist/parser.js.map +1 -1
  30. package/dist/sesi.bundled.js +2526 -1487
  31. package/dist/types.d.ts +14 -2
  32. package/dist/types.d.ts.map +1 -1
  33. package/dist/types.js +33 -1
  34. package/dist/types.js.map +1 -1
  35. package/docs/ARCHITECTURE.md +21 -13
  36. package/docs/BUILTINS.md +136 -19
  37. package/docs/CLI.md +200 -0
  38. package/docs/COMPARISON.md +16 -13
  39. package/docs/IMAGE_GENERATION.md +13 -14
  40. package/docs/IMPLEMENTATION_SUMMARY.md +174 -110
  41. package/docs/QUICKSTART.md +173 -39
  42. package/docs/README.md +202 -54
  43. package/docs/{SYSTEMS_REASONING.md → REASONING.md} +115 -120
  44. package/docs/ROADMAP.md +51 -47
  45. package/docs/SKILLS.md +73 -98
  46. package/docs/SPECIFICATION.md +59 -40
  47. package/examples/03_functions.sesi +30 -1
  48. package/examples/07_prompts.sesi +27 -3
  49. package/examples/08_model_call.sesi +6 -4
  50. package/examples/09_structured_output.sesi +19 -3
  51. package/examples/10_code_generation.sesi +6 -4
  52. package/examples/11_memory_conversation.sesi +47 -15
  53. package/examples/12_classification.sesi +62 -7
  54. package/examples/13_data_pipeline.sesi +55 -28
  55. package/examples/14_folder_explainer.sesi +52 -51
  56. package/examples/15_image_generation.sesi +15 -14
  57. package/examples/16_modules.sesi +27 -27
  58. package/examples/19_search_web.sesi +18 -2
  59. package/examples/20_model_aliases.sesi +22 -0
  60. package/examples/21_custom_tools.sesi +27 -0
  61. package/examples/22_reasoning_plus_custom_tools.sesi +19 -0
  62. package/main/tests/test-args.sesi +7 -0
  63. package/main/tests/test_args.sesi +7 -0
  64. package/main/tests/test_general_modules.sesi +127 -0
  65. package/main/tests/test_grounding.sesi +2 -0
  66. package/package.json +26 -22
  67. package/docs/DISTRIBUTED_SYSTEMS.md +0 -71
  68. package/docs/sesi_ai_chronicles.md +0 -209
  69. package/main/conversational_classifier_weights.json +0 -45
  70. package/main/conversational_sentences.json +0 -304
  71. package/main/epochs.sesi +0 -94
  72. package/main/gpu_orchestrator.sesi +0 -36
  73. package/main/hardware_diagnostics.sesi +0 -118
  74. package/main/inference.sesi +0 -54
  75. package/main/native_chatbot.sesi +0 -180
  76. package/main/native_synthesizer.sesi +0 -83
  77. package/main/nn_personas_trainer.sesi +0 -302
  78. package/main/nn_responses_trainer.sesi +0 -269
  79. package/main/nn_sentences_trainer.sesi +0 -330
  80. package/main/orchestrator.sesi +0 -15
  81. package/main/personas.json +0 -124
  82. package/main/personas_classifier_weights.json +0 -45
  83. package/main/playground.sesi +0 -3
  84. package/main/predictive_typing.sesi +0 -127
  85. package/main/query_brain.sesi +0 -45
  86. package/main/response_classifier_weights.json +0 -45
  87. package/main/retro_chat.html +0 -239
  88. package/main/retro_chat_generator.sesi +0 -745
  89. package/main/sesi_ai.sesi +0 -158
  90. package/main/sesi_db_chatbot.sesi +0 -280
  91. package/main/setup_swarm.sesi +0 -5
  92. package/main/start.sesi +0 -13
  93. package/main/terminal.log +0 -56
  94. package/main/terminal_chat.py +0 -385
  95. package/main/unified_sesi_ai.sesi +0 -334
  96. package/main/varied_responses.json +0 -304
package/bin/sesi.js CHANGED
@@ -1,57 +1,215 @@
1
1
  #!/usr/bin/env node
2
2
  require('@dotenvx/dotenvx').config();
3
- const { runSesiFile } = require('../dist/index.js');
3
+ const { runSesiFile, runSesi } = require('../dist/index.js');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
 
7
7
  const args = process.argv.slice(2);
8
8
 
9
- if (args.length === 0) {
10
- console.log(`
11
- Sesi Programming Language v1.2.2
9
+ const argsHeader = `
10
+ Sesi Programming Language v1.3.2
12
11
 
13
12
  Usage:
14
- sesi <file> Run a Sesi program
15
- sesi -help <query> Ask for help from our Sesi Co-Pilot
16
- sesi --help <query>
17
- sesi -h <query>
13
+ sesi <file> [options] <args> Run a Sesi program
14
+ sesi -e "code" Evaluate Sesi code directly
15
+ sesi -h <query> Ask for help from our Sesi Co-Pilot
16
+ sesi -v Show version
17
+ sesi -enc <file> -p <password> Encrypt a file
18
+ sesi -dec <file> -p <password> Decrypt a file
19
+ sesi -r <file> Show the raw parser output
18
20
 
19
21
  Options:
20
- --version Show version
22
+ -l, --local Disable safe mode (careful!)
23
+ -a, --allowed-paths <p> Comma-separated list of allowed directories
24
+ -e, --eval "<code_to_run>" Evaluate Sesi code directly
25
+ -enc, --encrypt <file> Encrypt a file
26
+ -dec, --decrypt <file> Decrypt a file
27
+ -p, --password <pass> Password for encryption/decryption
28
+ -v, --version Show version
29
+ -h, --help Show this help
30
+ -r, --raw Show the raw parser output
21
31
 
22
32
  Examples:
23
- sesi main/start.sesi
24
33
  sesi examples/01_hello.sesi
25
- sesi -help "how do I parse a json string?"
26
- `);
27
- process.exit(0);
34
+ sesi main/test_args.sesi arg1 arg2
35
+ sesi -e "print 'hello'"
36
+ sesi -h "how do I use memory?"
37
+ sesi -r examples/01_hello.sesi
38
+ sesi -enc secret.sesi -p mypassword
39
+ sesi -dec secret.sesi -p mypassword
40
+ `;
41
+
42
+ function parseArgs(args) {
43
+ const options = {
44
+ file: null,
45
+ eval: null,
46
+ helpQuery: null,
47
+ helpFile: null,
48
+ encryptFile: null,
49
+ decryptFile: null,
50
+ password: null,
51
+ sesiOptions: {
52
+ safeMode: true,
53
+ allowedPaths: [process.cwd()],
54
+ raw: false,
55
+ args: []
56
+ }
57
+ };
58
+
59
+ for (let i = 0; i < args.length; i++) {
60
+ const arg = args[i];
61
+ const isHelpFlag = arg === '--help' || arg === '-help' || arg === '-h';
62
+
63
+ if (arg === '-v' || arg === '--version') {
64
+ console.log('Sesi v1.3.2');
65
+ process.exit(0);
66
+ } else if (isHelpFlag && i === 0 && !options.file && !options.eval) {
67
+ if (args[i + 1] && !args[i + 1].startsWith('-')) {
68
+ options.helpQuery = args.slice(i + 1).join(' ').trim();
69
+ break;
70
+ } else {
71
+ console.log(argsHeader);
72
+ process.exit(0);
73
+ }
74
+ } else if (isHelpFlag && options.file) {
75
+ options.helpFile = options.file;
76
+ options.helpQuery = args[i + 1] && !args[i + 1].startsWith('-')
77
+ ? args.slice(i + 1).join(' ').trim()
78
+ : 'Help me understand this file.';
79
+ break;
80
+ } else if (arg === '-e' || arg === '--eval') {
81
+ options.eval = args[++i];
82
+ } else if (arg === '-enc' || arg === '--encrypt') {
83
+ options.encryptFile = args[++i];
84
+ } else if (arg === '-dec' || arg === '--decrypt') {
85
+ options.decryptFile = args[++i];
86
+ } else if (arg === '-p' || arg === '--password') {
87
+ options.password = args[++i];
88
+ } else if (arg === '-l' || arg === '--local') {
89
+ options.sesiOptions.safeMode = false;
90
+ options.sesiOptions.allowLocalFs = true;
91
+ } else if (arg === '-a' || arg === '--allowed-paths') {
92
+ const paths = args[++i].split(',');
93
+ options.sesiOptions.allowedPaths.push(...paths.map(p => path.resolve(p)));
94
+ } else if (!arg.startsWith('-') && !options.file && !options.eval && !options.encryptFile && !options.decryptFile) {
95
+ options.file = arg;
96
+ } else if (arg == '-r' || arg == '--raw') {
97
+ options.sesiOptions.raw = true;
98
+ }
99
+ }
100
+
101
+ if (options.file && !options.helpQuery) {
102
+ const fileIndex = args.indexOf(options.file);
103
+ if (fileIndex !== -1) {
104
+ options.sesiOptions.args = args.slice(fileIndex + 1);
105
+ }
106
+ } else if (options.eval) {
107
+ const evalIndex = args.findIndex(arg => arg === '-e' || arg === '--eval');
108
+ if (evalIndex !== -1) {
109
+ options.sesiOptions.args = args.slice(evalIndex + 2);
110
+ }
111
+ }
112
+
113
+ return options;
28
114
  }
29
115
 
30
- if (args[0] === '--help' || args[0] === '-help' || args[0] === '-h') {
31
- let queryText = args.slice(1).join(' ').trim();
32
- if (!queryText) {
33
- queryText = "how do I parse a json string?";
116
+ const parsed = parseArgs(args);
117
+
118
+ async function main() {
119
+ if (!parsed.file && !parsed.eval && !parsed.helpQuery && !parsed.encryptFile && !parsed.decryptFile) {
120
+ console.log(argsHeader);
121
+ process.exit(0);
122
+ }
123
+
124
+ if (parsed.encryptFile || parsed.decryptFile) {
125
+ const password = parsed.password || process.env.SESI_PASSWORD;
126
+ if (!password) {
127
+ console.error('Error: Password is required for encryption/decryption. Use -p <password> or set the SESI_PASSWORD environment variable.');
128
+ process.exit(1);
129
+ }
130
+ const crypto = require('crypto');
131
+ const targetFile = parsed.encryptFile || parsed.decryptFile;
132
+ const isEncrypt = !!parsed.encryptFile;
133
+
134
+ if (!fs.existsSync(targetFile)) {
135
+ console.error(`Error: File not found: ${targetFile}`);
136
+ process.exit(1);
137
+ }
138
+
139
+ const content = fs.readFileSync(targetFile, 'utf-8');
140
+ try {
141
+ const algorithm = 'aes-256-cbc';
142
+ const key = crypto.createHash('sha256').update(String(password)).digest();
143
+
144
+ if (isEncrypt) {
145
+ const iv = crypto.randomBytes(16);
146
+ const cipher = crypto.createCipheriv(algorithm, key, iv);
147
+ let encrypted = cipher.update(content, 'utf8', 'hex');
148
+ encrypted += cipher.final('hex');
149
+ const finalOutput = iv.toString('hex') + ':' + encrypted;
150
+ fs.writeFileSync(targetFile, finalOutput, 'utf-8');
151
+ console.log(`Successfully encrypted ${targetFile}`);
152
+ } else {
153
+ const parts = content.split(':');
154
+ if (parts.length !== 2) throw new Error('Invalid encrypted format');
155
+ const iv = Buffer.from(parts[0], 'hex');
156
+ const decipher = crypto.createDecipheriv(algorithm, key, iv);
157
+ let decrypted = decipher.update(parts[1], 'hex', 'utf8');
158
+ decrypted += decipher.final('utf8');
159
+ fs.writeFileSync(targetFile, decrypted, 'utf-8');
160
+ console.log(`Successfully decrypted ${targetFile}`);
161
+ }
162
+ } catch (e) {
163
+ console.error(`Error during ${isEncrypt ? 'encryption' : 'decryption'}:`, e.message);
164
+ process.exit(1);
165
+ }
166
+ return;
34
167
  }
35
- fs.writeFileSync('query.txt', queryText, 'utf-8');
36
-
37
- const copilotPath = path.join(__dirname, '../main/sesi_db_chatbot.sesi');
38
- runSesiFile(copilotPath).catch((error) => {
39
- console.error('Fatal error in Sesi Co-Pilot:', error.message);
40
- process.exit(1);
41
- });
42
- } else if (args[0] === '--version') {
43
- console.log('Sesi v1.2.2');
44
- process.exit(0);
45
- } else {
46
- const filePath = args[0];
47
-
48
- if (!fs.existsSync(filePath)) {
49
- console.error(`Error: File not found: ${filePath}`);
50
- process.exit(1);
168
+
169
+ if (parsed.helpQuery) {
170
+ fs.writeFileSync('query.txt', parsed.helpQuery, 'utf-8');
171
+ if (parsed.helpFile) {
172
+ const resolvedFile = path.resolve(parsed.helpFile);
173
+ const fileContext = fs.readFileSync(resolvedFile, 'utf-8');
174
+ fs.writeFileSync('help_context.txt', `File: ${resolvedFile}\n\n${fileContext}`, 'utf-8');
175
+ } else if (fs.existsSync('help_context.txt')) {
176
+ fs.unlinkSync('help_context.txt');
177
+ }
178
+ const copilotPath = path.join(__dirname, '../chatbot/sesi_db_chatbot.sesi');
179
+ await runSesiFile(copilotPath).catch((error) => {
180
+ console.error('Fatal error in Sesi Co-Pilot:', error.message);
181
+ process.exit(1);
182
+ });
183
+ } else if (parsed.eval) {
184
+ await runSesi(parsed.eval, process.cwd(), parsed.sesiOptions).catch((error) => {
185
+ console.error('Fatal error:', error.message);
186
+ process.exit(1);
187
+ });
188
+ } else if (parsed.file === '-') {
189
+ let input = '';
190
+ process.stdin.on('data', data => { input += data; });
191
+ process.stdin.on('end', async () => {
192
+ await runSesi(input, process.cwd(), parsed.sesiOptions).catch((error) => {
193
+ console.error('Fatal error:', error.message);
194
+ process.exit(1);
195
+ });
196
+ });
197
+ } else if (parsed.file) {
198
+ if (!fs.existsSync(parsed.file)) {
199
+ console.error(`Error: File not found: ${parsed.file}`);
200
+ process.exit(1);
201
+ }
202
+ await runSesiFile(parsed.file, parsed.sesiOptions).catch((error) => {
203
+ console.error('Fatal error:', error.message);
204
+ process.exit(1);
205
+ });
206
+ } else if (parsed.raw) {
207
+ const content = fs.readFileSync(parsed.file, 'utf-8');
208
+ await runSesi(content, process.cwd(), { ...parsed.sesiOptions, raw: true }).catch((error) => {
209
+ console.error('Fatal error:', error.message);
210
+ process.exit(1);
211
+ });
51
212
  }
213
+ }
52
214
 
53
- runSesiFile(filePath).catch((error) => {
54
- console.error('Fatal error:', error.message);
55
- process.exit(1);
56
- });
57
- }
215
+ main();