@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.
- package/.agents/rules/sesi-must-read.md +116 -0
- package/.agents/workflows/create-sesi-script.md +44 -0
- package/.agents/workflows/fix-sesi-script.md +14 -0
- package/.github/prompts/MakeInSesi.prompt.md +79 -0
- package/README.md +163 -51
- package/bin/sesi.js +196 -38
- package/chatbot/chatbot.html +488 -0
- package/{main → chatbot}/chatbot.sesi +1 -2
- package/chatbot/chatbot_server.py +105 -0
- package/chatbot/sesi_db_chatbot.sesi +278 -0
- package/dist/ai-runtime.js +2 -2
- package/dist/builtins.d.ts.map +1 -1
- package/dist/builtins.js +199 -5
- package/dist/builtins.js.map +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +90 -6
- package/dist/index.js.map +1 -1
- package/dist/interpreter.d.ts +21 -2
- package/dist/interpreter.d.ts.map +1 -1
- package/dist/interpreter.js +201 -92
- package/dist/interpreter.js.map +1 -1
- package/dist/lexer.d.ts.map +1 -1
- package/dist/lexer.js +8 -4
- package/dist/lexer.js.map +1 -1
- package/dist/parser.d.ts +1 -0
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +21 -12
- package/dist/parser.js.map +1 -1
- package/dist/sesi.bundled.js +2526 -1487
- package/dist/types.d.ts +14 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +33 -1
- package/dist/types.js.map +1 -1
- package/docs/ARCHITECTURE.md +21 -13
- package/docs/BUILTINS.md +136 -19
- package/docs/CLI.md +200 -0
- package/docs/COMPARISON.md +16 -13
- package/docs/IMAGE_GENERATION.md +13 -14
- package/docs/IMPLEMENTATION_SUMMARY.md +174 -110
- package/docs/QUICKSTART.md +173 -39
- package/docs/README.md +202 -54
- package/docs/{SYSTEMS_REASONING.md → REASONING.md} +115 -120
- package/docs/ROADMAP.md +51 -47
- package/docs/SKILLS.md +73 -98
- package/docs/SPECIFICATION.md +59 -40
- package/examples/03_functions.sesi +30 -1
- package/examples/07_prompts.sesi +27 -3
- package/examples/08_model_call.sesi +6 -4
- package/examples/09_structured_output.sesi +19 -3
- package/examples/10_code_generation.sesi +6 -4
- package/examples/11_memory_conversation.sesi +47 -15
- package/examples/12_classification.sesi +62 -7
- package/examples/13_data_pipeline.sesi +55 -28
- package/examples/14_folder_explainer.sesi +52 -51
- package/examples/15_image_generation.sesi +15 -14
- package/examples/16_modules.sesi +27 -27
- package/examples/19_search_web.sesi +18 -2
- package/examples/20_model_aliases.sesi +22 -0
- package/examples/21_custom_tools.sesi +27 -0
- package/examples/22_reasoning_plus_custom_tools.sesi +19 -0
- package/main/tests/test-args.sesi +7 -0
- package/main/tests/test_args.sesi +7 -0
- package/main/tests/test_general_modules.sesi +127 -0
- package/main/tests/test_grounding.sesi +2 -0
- package/package.json +26 -22
- package/docs/DISTRIBUTED_SYSTEMS.md +0 -71
- package/docs/sesi_ai_chronicles.md +0 -209
- package/main/conversational_classifier_weights.json +0 -45
- package/main/conversational_sentences.json +0 -304
- package/main/epochs.sesi +0 -94
- package/main/gpu_orchestrator.sesi +0 -36
- package/main/hardware_diagnostics.sesi +0 -118
- package/main/inference.sesi +0 -54
- package/main/native_chatbot.sesi +0 -180
- package/main/native_synthesizer.sesi +0 -83
- package/main/nn_personas_trainer.sesi +0 -302
- package/main/nn_responses_trainer.sesi +0 -269
- package/main/nn_sentences_trainer.sesi +0 -330
- package/main/orchestrator.sesi +0 -15
- package/main/personas.json +0 -124
- package/main/personas_classifier_weights.json +0 -45
- package/main/playground.sesi +0 -3
- package/main/predictive_typing.sesi +0 -127
- package/main/query_brain.sesi +0 -45
- package/main/response_classifier_weights.json +0 -45
- package/main/retro_chat.html +0 -239
- package/main/retro_chat_generator.sesi +0 -745
- package/main/sesi_ai.sesi +0 -158
- package/main/sesi_db_chatbot.sesi +0 -280
- package/main/setup_swarm.sesi +0 -5
- package/main/start.sesi +0 -13
- package/main/terminal.log +0 -56
- package/main/terminal_chat.py +0 -385
- package/main/unified_sesi_ai.sesi +0 -334
- 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
|
-
|
|
10
|
-
|
|
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>
|
|
15
|
-
sesi -
|
|
16
|
-
sesi
|
|
17
|
-
sesi -
|
|
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
|
-
--
|
|
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
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} else if (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
54
|
-
console.error('Fatal error:', error.message);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
215
|
+
main();
|