npm-noxyai 1.0.1 → 1.0.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 (2) hide show
  1. package/index.js +18 -115
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,30 +1,3 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require('fs');
4
- const os = require('os');
5
- const path = require('path');
6
-
7
- // Change this to http://localhost:3000 if you are testing locally first
8
- const BASE_URL = 'https://noxyai.com';
9
- const CONFIG_FILE = path.join(os.homedir(), '.noxyai.json');
10
-
11
- const args = process.argv.slice(2);
12
- const command = args[0];
13
-
14
- // Helper: Save token to ~/.noxyai.json
15
- function saveToken(token) {
16
- fs.writeFileSync(CONFIG_FILE, JSON.stringify({ token }));
17
- }
18
-
19
- // Helper: Read token
20
- function getToken() {
21
- if (fs.existsSync(CONFIG_FILE)) {
22
- const config = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
23
- return config.token;
24
- }
25
- return null;
26
- }
27
-
28
1
  // --- COMMAND: login ---
29
2
  async function login() {
30
3
  console.log('Initializing login...');
@@ -38,7 +11,6 @@ async function login() {
38
11
  console.log('=============================================\n');
39
12
  console.log('Waiting for confirmation...');
40
13
 
41
- // Poll the server to see if the user clicked "Authorize"
42
14
  const pollInterval = setInterval(async () => {
43
15
  const pollRes = await fetch(`${BASE_URL}/api/cli/poll`, {
44
16
  method: 'POST',
@@ -51,8 +23,24 @@ async function login() {
51
23
  if (data.status === 'success') {
52
24
  clearInterval(pollInterval);
53
25
  saveToken(data.token);
54
- console.log('\n✅ Login successful! You are now connected to NoxyAI.');
55
- console.log('Try running: noxyai chat "Hello, world!"');
26
+
27
+ // ASCII ART SUCCESS MESSAGE
28
+ console.clear();
29
+ console.log(`\n\x1b[36m
30
+ ___ ___ ___ ___ ___
31
+ /\\__\\ /\\ \\ |\\__\\ |\\__\\ /\\ \\ ___
32
+ /::| | /::\\ \\ |:| | |:| | /::\\ \\ /\\ \\
33
+ /:|:| | /:/\\:\\ \\ |:| | |:| | /:/\\:\\ \\ \\:\\ \\
34
+ /:/|:| |__ /:/ \\:\\ \\ |:|__|__ |:|__|__ /::\\~\\:\\ \\ /::\\__\\
35
+ /:/ |:| /\\__\\ /:/__/ \\:\\__\\ ____/::::\\__\\ /::::\\__\\ /:/\\:\\ \\:\\__\\ __/:/\\/__/
36
+ \\/__|:|/:/ / \\:\\ \\ /:/ / \\::::/~~/~ /:/~~/~ \\/__\\:\\/:/ / /\\/:/ /
37
+ |:/:/ / \\:\\ /:/ / ~~|:|~~| /:/ / \\::/ / \\::/__/
38
+ |::/ / \\:\\/:/ / |:| | \\/__/ /:/ / \\:\\__\\
39
+ /:/ / \\::/ / |:| | /:/ / \\/__/
40
+ \\/__/ \\/__/ \\|__| \\/__/
41
+ \x1b[0m`);
42
+ console.log('\n✅ Login successful! Terminal connected.');
43
+ console.log('Try running: noxyai chat "Hello, world!"\n');
56
44
  process.exit(0);
57
45
  } else if (data.error) {
58
46
  clearInterval(pollInterval);
@@ -66,88 +54,3 @@ async function login() {
66
54
  }
67
55
  }
68
56
 
69
- // --- COMMAND: chat ---
70
- async function chat(prompt) {
71
- const token = getToken();
72
- if (!token) {
73
- console.error('❌ You are not logged in. Please run: noxyai login');
74
- process.exit(1);
75
- }
76
-
77
- if (!prompt) {
78
- console.error('❌ Please provide a prompt. Example: noxyai chat "Write a python script"');
79
- process.exit(1);
80
- }
81
-
82
- // Defaulting to auto model, but you can add CLI flags (e.g. --model deepseek) later
83
- const model = 'auto';
84
-
85
- try {
86
- const res = await fetch(`${BASE_URL}/api/cli/execute`, {
87
- method: 'POST',
88
- headers: {
89
- 'Content-Type': 'application/json',
90
- 'Authorization': `Bearer ${token}`
91
- },
92
- body: JSON.stringify({ prompt, model })
93
- });
94
-
95
- if (!res.ok) {
96
- const errorText = await res.text();
97
- console.error(`\n❌ API Error: ${errorText}`);
98
- process.exit(1);
99
- }
100
-
101
- console.log(`\n🤖 NoxyAI (${model}):\n`);
102
-
103
- // Parse the Server-Sent Events (SSE) stream
104
- const reader = res.body.getReader();
105
- const decoder = new TextDecoder('utf-8');
106
-
107
- while (true) {
108
- const { done, value } = await reader.read();
109
- if (done) break;
110
-
111
- const chunk = decoder.decode(value, { stream: true });
112
- const lines = chunk.split('\n');
113
-
114
- for (const line of lines) {
115
- if (line.startsWith('data: ')) {
116
- const data = line.slice(6).trim();
117
- if (data === '[DONE]') {
118
- console.log('\n'); // Add final newline
119
- process.exit(0);
120
- }
121
- try {
122
- const parsed = JSON.parse(data);
123
- if (parsed.text) {
124
- process.stdout.write(parsed.text); // Print exactly as it streams
125
- }
126
- } catch (e) {
127
- // Ignore parse errors on partial chunks
128
- }
129
- }
130
- }
131
- }
132
- } catch (error) {
133
- console.error('\n❌ Connection error:', error.message);
134
- }
135
- }
136
-
137
- // --- ROUTER ---
138
- if (command === 'login') {
139
- login();
140
- } else if (command === 'chat') {
141
- const prompt = args.slice(1).join(' '); // Capture everything after "chat"
142
- chat(prompt);
143
- } else {
144
- console.log(`
145
- Usage:
146
- noxyai login - Authenticate your terminal
147
- noxyai chat <prompt> - Chat with NoxyAI
148
-
149
- Example:
150
- noxyai chat "How do I reverse a string in JS?"
151
- `);
152
- }
153
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-noxyai",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {