nlos 1.1.0 → 1.2.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 (2) hide show
  1. package/bin/nlos.js +37 -8
  2. package/package.json +1 -1
package/bin/nlos.js CHANGED
@@ -276,16 +276,15 @@ function chat(options = {}) {
276
276
  log('yellow', 'Building kernel payload...');
277
277
  const payload = generatePayload(full ? 'full' : 'mandatory', 'markdown');
278
278
 
279
- // Write to temp file (ollama --system has length limits, file is safer)
280
- const tempPayloadPath = path.join(PACKAGE_ROOT, 'portable', '.kernel-payload-session.md');
281
- fs.mkdirSync(path.dirname(tempPayloadPath), { recursive: true });
282
- fs.writeFileSync(tempPayloadPath, payload);
279
+ // Escape the payload for Modelfile SYSTEM directive
280
+ // Replace """ with escaped version and handle multiline
281
+ const escapedPayload = payload.replace(/"""/g, '\\"\\"\\"');
283
282
 
284
283
  const tokenEstimate = full ? '~15,500' : '~10,600';
285
284
  log('green', `Kernel payload ready (${tokenEstimate} tokens)`);
286
285
  console.log();
287
286
 
288
- // Check if model exists locally
287
+ // Check if base model exists locally
289
288
  try {
290
289
  execSync(`ollama list | grep -q "${selectedModel.split(':')[0]}"`, { stdio: 'pipe' });
291
290
  } catch {
@@ -298,12 +297,42 @@ function chat(options = {}) {
298
297
  }
299
298
  }
300
299
 
301
- log('green', `Launching interactive session with ${selectedModel}...`);
300
+ // Create a temporary Modelfile with the kernel as system prompt
301
+ log('yellow', 'Creating NL-OS model variant...');
302
+ const modelfilePath = path.join(PACKAGE_ROOT, 'portable', '.Modelfile.nlos');
303
+ const nlosModelName = 'nlos-kernel:latest';
304
+
305
+ const modelfileContent = `FROM ${selectedModel}
306
+ SYSTEM """${payload}"""
307
+ `;
308
+
309
+ fs.mkdirSync(path.dirname(modelfilePath), { recursive: true });
310
+ fs.writeFileSync(modelfilePath, modelfileContent);
311
+
312
+ // Create the nlos model variant
313
+ try {
314
+ execSync(`ollama create ${nlosModelName} -f "${modelfilePath}"`, {
315
+ stdio: 'pipe',
316
+ cwd: PACKAGE_ROOT
317
+ });
318
+ log('green', `Created model: ${nlosModelName}`);
319
+ } catch (error) {
320
+ log('red', `Failed to create model: ${error.message}`);
321
+ log('yellow', 'Falling back to manual system prompt...');
322
+
323
+ // Fallback: just run the base model and tell user to paste
324
+ console.log('\nCould not create kernel model. Run manually:');
325
+ console.log(` ollama run ${selectedModel}`);
326
+ console.log(' Then paste the kernel from: portable/kernel-payload.md\n');
327
+ process.exit(1);
328
+ }
329
+
330
+ log('green', `Launching interactive session...`);
302
331
  log('cyan', '─'.repeat(60));
303
332
  console.log();
304
333
 
305
- // Spawn interactive ollama session with system prompt from file
306
- const child = spawn('ollama', ['run', selectedModel, '--system', payload], {
334
+ // Spawn interactive ollama session with the nlos model
335
+ const child = spawn('ollama', ['run', nlosModelName], {
307
336
  stdio: 'inherit',
308
337
  });
309
338
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nlos",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Natural Language Operating System - A model-agnostic kernel for any LLM",
5
5
  "main": "bin/nlos.js",
6
6
  "bin": {