nlos 1.5.0 → 1.7.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 +193 -1
  2. package/package.json +1 -1
package/bin/nlos.js CHANGED
@@ -477,6 +477,186 @@ function payload(options = {}) {
477
477
  }
478
478
  }
479
479
 
480
+ function clean(options = {}) {
481
+ const { local = false, all = false } = options;
482
+
483
+ log('blue', 'Cleaning NL-OS...\n');
484
+
485
+ // Remove Ollama model
486
+ log('yellow', 'Removing Ollama model...');
487
+ try {
488
+ execSync('ollama rm nlos-kernel:latest', { stdio: 'pipe' });
489
+ log('green', ' [removed] nlos-kernel:latest');
490
+ } catch {
491
+ log('cyan', ' [skip] nlos-kernel:latest not found');
492
+ }
493
+
494
+ // Clean local workspace files if --local or --all
495
+ if (local || all) {
496
+ const targetDir = process.cwd();
497
+ const localFiles = [
498
+ 'KERNEL.md',
499
+ 'memory.md',
500
+ 'AGENTS.md',
501
+ 'axioms.yaml',
502
+ 'personalities.md',
503
+ '.nlos.yaml',
504
+ ];
505
+ const localDirs = ['commands'];
506
+
507
+ log('yellow', 'Removing local workspace files...');
508
+ for (const file of localFiles) {
509
+ const filePath = path.join(targetDir, file);
510
+ if (fs.existsSync(filePath)) {
511
+ fs.unlinkSync(filePath);
512
+ log('green', ` [removed] ${file}`);
513
+ }
514
+ }
515
+ for (const dir of localDirs) {
516
+ const dirPath = path.join(targetDir, dir);
517
+ if (fs.existsSync(dirPath)) {
518
+ fs.rmSync(dirPath, { recursive: true });
519
+ log('green', ` [removed] ${dir}/`);
520
+ }
521
+ }
522
+ }
523
+
524
+ // Uninstall global package if --all
525
+ if (all) {
526
+ log('yellow', 'Uninstalling global package...');
527
+ console.log();
528
+ log('cyan', 'Run this command to complete uninstall:');
529
+ console.log(` npm uninstall -g nlos\n`);
530
+ log('yellow', '(Cannot self-uninstall while running)');
531
+ }
532
+
533
+ console.log();
534
+ log('green', 'Clean complete!\n');
535
+
536
+ if (!local && !all) {
537
+ console.log(`${colors.yellow}Options:${colors.reset}`);
538
+ console.log(` nlos clean --local Also remove local workspace files`);
539
+ console.log(` nlos clean --all Remove everything (local + instructions for global)`);
540
+ }
541
+ }
542
+
543
+ function init(options = {}) {
544
+ const targetDir = process.cwd();
545
+
546
+ log('blue', `Initializing NL-OS workspace in ${targetDir}...\n`);
547
+
548
+ // Files to copy from package to local workspace
549
+ const filesToCopy = [
550
+ { src: 'memory.md', dest: 'memory.md', desc: 'Directive stack (customize this!)' },
551
+ { src: 'KERNEL.md', dest: 'KERNEL.md', desc: 'Kernel entry point' },
552
+ { src: 'AGENTS.md', dest: 'AGENTS.md', desc: 'Agent rules and invariants' },
553
+ { src: 'axioms.yaml', dest: 'axioms.yaml', desc: 'Canonical definitions' },
554
+ { src: 'personalities.md', dest: 'personalities.md', desc: 'Voice presets' },
555
+ ];
556
+
557
+ const commandsToCopy = [
558
+ 'hype.md',
559
+ 'note.md',
560
+ 'assume.md',
561
+ ];
562
+
563
+ // Create directories
564
+ const commandsDir = path.join(targetDir, 'commands');
565
+ if (!fs.existsSync(commandsDir)) {
566
+ fs.mkdirSync(commandsDir, { recursive: true });
567
+ }
568
+
569
+ // Copy kernel files
570
+ log('yellow', 'Copying kernel files:');
571
+ for (const { src, dest, desc } of filesToCopy) {
572
+ const srcPath = path.join(PACKAGE_ROOT, src);
573
+ const destPath = path.join(targetDir, dest);
574
+
575
+ if (fs.existsSync(destPath)) {
576
+ log('cyan', ` [skip] ${dest} (already exists)`);
577
+ } else if (fs.existsSync(srcPath)) {
578
+ fs.copyFileSync(srcPath, destPath);
579
+ log('green', ` [created] ${dest} - ${desc}`);
580
+ } else {
581
+ log('red', ` [missing] ${src} not found in package`);
582
+ }
583
+ }
584
+
585
+ // Copy command files
586
+ console.log();
587
+ log('yellow', 'Copying command files:');
588
+ for (const cmd of commandsToCopy) {
589
+ const srcPath = path.join(PACKAGE_ROOT, '.cursor', 'commands', cmd);
590
+ const destPath = path.join(commandsDir, cmd);
591
+
592
+ if (fs.existsSync(destPath)) {
593
+ log('cyan', ` [skip] commands/${cmd} (already exists)`);
594
+ } else if (fs.existsSync(srcPath)) {
595
+ fs.copyFileSync(srcPath, destPath);
596
+ log('green', ` [created] commands/${cmd}`);
597
+ } else {
598
+ log('red', ` [missing] ${cmd} not found in package`);
599
+ }
600
+ }
601
+
602
+ // Create .nlos config file
603
+ const configPath = path.join(targetDir, '.nlos.yaml');
604
+ if (!fs.existsSync(configPath)) {
605
+ const config = `# NL-OS Workspace Configuration
606
+ # Generated: ${new Date().toISOString().split('T')[0]}
607
+
608
+ workspace:
609
+ name: "${path.basename(targetDir)}"
610
+ initialized: true
611
+
612
+ kernel:
613
+ # Use local files (set to false to use global package)
614
+ use_local: true
615
+
616
+ # Default model for this workspace
617
+ default_model: qwen2.5:3b
618
+
619
+ # Tier: minimal, mandatory, full
620
+ default_tier: minimal
621
+
622
+ # Add workspace-specific settings below
623
+ `;
624
+ fs.writeFileSync(configPath, config);
625
+ log('green', ` [created] .nlos.yaml - workspace config`);
626
+ }
627
+
628
+ // Create .gitignore addition
629
+ const gitignorePath = path.join(targetDir, '.gitignore');
630
+ const gitignoreContent = `# NL-OS
631
+ .nlos-cache/
632
+ `;
633
+ if (!fs.existsSync(gitignorePath)) {
634
+ fs.writeFileSync(gitignorePath, gitignoreContent);
635
+ log('green', ` [created] .gitignore`);
636
+ }
637
+
638
+ console.log();
639
+ log('green', 'Workspace initialized!\n');
640
+
641
+ console.log(`${colors.yellow}Next steps:${colors.reset}`);
642
+ console.log(` 1. Edit ${colors.cyan}memory.md${colors.reset} to customize your directives`);
643
+ console.log(` 2. Add commands to ${colors.cyan}commands/${colors.reset}`);
644
+ console.log(` 3. Run ${colors.cyan}nlos chat --minimal${colors.reset} to start\n`);
645
+
646
+ console.log(`${colors.yellow}Files created:${colors.reset}`);
647
+ console.log(` ${targetDir}/`);
648
+ console.log(` ├── KERNEL.md # Entry point`);
649
+ console.log(` ├── memory.md # Your directives (edit this!)`);
650
+ console.log(` ├── AGENTS.md # Agent rules`);
651
+ console.log(` ├── axioms.yaml # Definitions`);
652
+ console.log(` ├── personalities.md # Voice presets`);
653
+ console.log(` ├── commands/ # Your commands`);
654
+ console.log(` │ ├── hype.md`);
655
+ console.log(` │ ├── note.md`);
656
+ console.log(` │ └── assume.md`);
657
+ console.log(` └── .nlos.yaml # Workspace config`);
658
+ }
659
+
480
660
  function showHelp() {
481
661
  console.log(`
482
662
  ${colors.cyan}NL-OS${colors.reset} - Natural Language Operating System
@@ -485,7 +665,9 @@ ${colors.yellow}Usage:${colors.reset}
485
665
  nlos <command> [options]
486
666
 
487
667
  ${colors.yellow}Commands:${colors.reset}
668
+ init Initialize NL-OS workspace in current directory
488
669
  chat Interactive NL-OS chat session (recommended)
670
+ clean Remove Ollama model and optionally local files
489
671
  boot Boot NL-OS and verify kernel loads
490
672
  payload Generate portable kernel payloads
491
673
  verify Verify kernel files exist
@@ -507,7 +689,7 @@ ${colors.yellow}Payload Options:${colors.reset}
507
689
  --all Generate all variants
508
690
 
509
691
  ${colors.yellow}Examples:${colors.reset}
510
- nlos chat # Start interactive chat (recommended)
692
+ nlos init # Initialize workspace with kernel files
511
693
  nlos chat --minimal # Use minimal kernel for small models (3B)
512
694
  nlos chat --model llama3.1:8b # Chat with specific model
513
695
  nlos chat --profile quality --full # Quality mode with full kernel
@@ -551,6 +733,8 @@ function parseArgs(args) {
551
733
  options.dryRun = true;
552
734
  } else if (arg === '--all') {
553
735
  options.all = true;
736
+ } else if (arg === '--local') {
737
+ options.local = true;
554
738
  }
555
739
 
556
740
  i++;
@@ -565,6 +749,14 @@ const command = args[0];
565
749
  const options = parseArgs(args.slice(1));
566
750
 
567
751
  switch (command) {
752
+ case 'init':
753
+ init(options);
754
+ break;
755
+
756
+ case 'clean':
757
+ clean(options);
758
+ break;
759
+
568
760
  case 'chat':
569
761
  chat(options);
570
762
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nlos",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Natural Language Operating System - A model-agnostic kernel for any LLM",
5
5
  "main": "bin/nlos.js",
6
6
  "bin": {