@nolimitcli/cli 2.0.0 → 2.0.1
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/README.md +51 -9
- package/dist/index.js +101 -95
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,25 +1,67 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @nolimitcli/cli
|
|
2
2
|
|
|
3
3
|
No subscription. Just code.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npx @
|
|
8
|
+
npx @nolimitcli/cli
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Or install globally:
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
|
|
15
|
-
nolimit
|
|
16
|
-
|
|
14
|
+
npm install -g @nolimitcli/cli
|
|
15
|
+
nolimit
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Just run the command and start chatting:
|
|
21
|
+
|
|
17
22
|
```
|
|
23
|
+
┌─────────────────────────────┐
|
|
24
|
+
│ NoLimit v2.0.0 │
|
|
25
|
+
│ No subscription. Just code. │
|
|
26
|
+
└─────────────────────────────┘
|
|
27
|
+
|
|
28
|
+
Balance: 2K tokens
|
|
29
|
+
|
|
30
|
+
Commands: /earn · /balance · /help · /quit
|
|
31
|
+
─────────────────────────────────
|
|
32
|
+
|
|
33
|
+
› Write a function to reverse a string
|
|
34
|
+
|
|
35
|
+
function reverse(str) {
|
|
36
|
+
return str.split('').reverse().join('');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
─ 89 tokens used
|
|
40
|
+
|
|
41
|
+
›
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Commands
|
|
45
|
+
|
|
46
|
+
| Command | Description |
|
|
47
|
+
|---------|-------------|
|
|
48
|
+
| `/earn` | Watch an ad to earn 8K tokens |
|
|
49
|
+
| `/balance` | Check your token balance |
|
|
50
|
+
| `/clear` | Clear the screen |
|
|
51
|
+
| `/help` | Show all commands |
|
|
52
|
+
| `/quit` | Exit |
|
|
18
53
|
|
|
19
54
|
## How it works
|
|
20
55
|
|
|
21
|
-
1.
|
|
22
|
-
2.
|
|
23
|
-
3.
|
|
56
|
+
1. First run auto-authenticates (2K welcome tokens)
|
|
57
|
+
2. Type anything to chat with AI
|
|
58
|
+
3. When tokens run low, type `/earn`
|
|
59
|
+
4. Watch a 30-second ad in your browser
|
|
60
|
+
5. Continue chatting
|
|
24
61
|
|
|
25
62
|
No subscription. No credit card. Just code.
|
|
63
|
+
|
|
64
|
+
## Links
|
|
65
|
+
|
|
66
|
+
- [nolimit.dev](https://nolimit.dev)
|
|
67
|
+
- [GitHub](https://github.com/buzzernetwork/nolimit)
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import ora from 'ora';
|
|
|
5
5
|
import open from 'open';
|
|
6
6
|
import * as readline from 'readline';
|
|
7
7
|
const API_BASE = 'https://nolimit-production-2589.up.railway.app';
|
|
8
|
-
const VERSION = '2.0.
|
|
8
|
+
const VERSION = '2.0.1';
|
|
9
9
|
// Persistent config storage
|
|
10
10
|
const config = new Conf({
|
|
11
11
|
projectName: 'nolimit',
|
|
@@ -164,123 +164,129 @@ async function main() {
|
|
|
164
164
|
});
|
|
165
165
|
const prompt = () => {
|
|
166
166
|
rl.question(chalk.green('› '), async (input) => {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
// Handle commands
|
|
173
|
-
if (trimmed.startsWith('/')) {
|
|
174
|
-
const cmd = trimmed.toLowerCase();
|
|
175
|
-
if (cmd === '/quit' || cmd === '/exit' || cmd === '/q') {
|
|
176
|
-
console.log(chalk.dim('\n Goodbye.\n'));
|
|
177
|
-
rl.close();
|
|
178
|
-
process.exit(0);
|
|
179
|
-
}
|
|
180
|
-
if (cmd === '/help' || cmd === '/h') {
|
|
181
|
-
console.log();
|
|
182
|
-
console.log(chalk.dim(' Commands:'));
|
|
183
|
-
console.log(chalk.cyan(' /earn') + chalk.dim(' Watch an ad to earn tokens'));
|
|
184
|
-
console.log(chalk.cyan(' /balance') + chalk.dim(' Check your token balance'));
|
|
185
|
-
console.log(chalk.cyan(' /clear') + chalk.dim(' Clear the screen'));
|
|
186
|
-
console.log(chalk.cyan(' /quit') + chalk.dim(' Exit NoLimit'));
|
|
187
|
-
console.log();
|
|
167
|
+
try {
|
|
168
|
+
const trimmed = input.trim();
|
|
169
|
+
if (!trimmed) {
|
|
188
170
|
prompt();
|
|
189
171
|
return;
|
|
190
172
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
|
|
173
|
+
// Handle commands
|
|
174
|
+
if (trimmed.startsWith('/')) {
|
|
175
|
+
const cmd = trimmed.toLowerCase();
|
|
176
|
+
if (cmd === '/quit' || cmd === '/exit' || cmd === '/q') {
|
|
177
|
+
console.log(chalk.dim('\n Goodbye.\n'));
|
|
178
|
+
rl.close();
|
|
179
|
+
process.exit(0);
|
|
197
180
|
}
|
|
198
|
-
|
|
199
|
-
prompt();
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
if (cmd === '/balance' || cmd === '/b') {
|
|
203
|
-
const data = await getBalance(apiKey);
|
|
204
|
-
if (data) {
|
|
205
|
-
balance = data.balance;
|
|
181
|
+
if (cmd === '/help' || cmd === '/h') {
|
|
206
182
|
console.log();
|
|
207
|
-
console.log(chalk.dim('
|
|
208
|
-
console.log(chalk.
|
|
209
|
-
console.log(chalk.
|
|
183
|
+
console.log(chalk.dim(' Commands:'));
|
|
184
|
+
console.log(chalk.cyan(' /earn') + chalk.dim(' Watch an ad to earn tokens'));
|
|
185
|
+
console.log(chalk.cyan(' /balance') + chalk.dim(' Check your token balance'));
|
|
186
|
+
console.log(chalk.cyan(' /clear') + chalk.dim(' Clear the screen'));
|
|
187
|
+
console.log(chalk.cyan(' /quit') + chalk.dim(' Exit NoLimit'));
|
|
210
188
|
console.log();
|
|
189
|
+
prompt();
|
|
190
|
+
return;
|
|
211
191
|
}
|
|
192
|
+
if (cmd === '/earn' || cmd === '/e') {
|
|
193
|
+
console.log();
|
|
194
|
+
const success = await watchAd(apiKey);
|
|
195
|
+
if (success) {
|
|
196
|
+
const newData = await getBalance(apiKey);
|
|
197
|
+
balance = newData?.balance || balance;
|
|
198
|
+
}
|
|
199
|
+
console.log();
|
|
200
|
+
prompt();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (cmd === '/balance' || cmd === '/b') {
|
|
204
|
+
const data = await getBalance(apiKey);
|
|
205
|
+
if (data) {
|
|
206
|
+
balance = data.balance;
|
|
207
|
+
console.log();
|
|
208
|
+
console.log(chalk.dim(' Balance: ') + chalk.bold.white(formatTokens(data.balance)) + chalk.dim(' tokens'));
|
|
209
|
+
console.log(chalk.dim(' Earned: ') + formatTokens(data.totalEarned));
|
|
210
|
+
console.log(chalk.dim(' Spent: ') + formatTokens(data.totalSpent));
|
|
211
|
+
console.log();
|
|
212
|
+
}
|
|
213
|
+
prompt();
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (cmd === '/clear' || cmd === '/c') {
|
|
217
|
+
showWelcome(balance);
|
|
218
|
+
prompt();
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
console.log(chalk.dim(`\n Unknown command: ${trimmed}\n`));
|
|
212
222
|
prompt();
|
|
213
223
|
return;
|
|
214
224
|
}
|
|
215
|
-
|
|
216
|
-
|
|
225
|
+
// Check if we have enough tokens
|
|
226
|
+
if (balance < 100) {
|
|
227
|
+
console.log();
|
|
228
|
+
console.log(chalk.yellow(' Low tokens.') + chalk.dim(' Watch an ad to continue.'));
|
|
229
|
+
console.log();
|
|
230
|
+
const watch = await new Promise((resolve) => {
|
|
231
|
+
rl.question(chalk.dim(' Watch now? ') + chalk.cyan('[Y/n] '), (answer) => {
|
|
232
|
+
resolve(answer.toLowerCase() !== 'n');
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
if (watch) {
|
|
236
|
+
const success = await watchAd(apiKey);
|
|
237
|
+
if (success) {
|
|
238
|
+
const newData = await getBalance(apiKey);
|
|
239
|
+
balance = newData?.balance || balance;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
console.log();
|
|
217
243
|
prompt();
|
|
218
244
|
return;
|
|
219
245
|
}
|
|
220
|
-
|
|
221
|
-
prompt();
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
// Check if we have enough tokens
|
|
225
|
-
if (balance < 100) {
|
|
226
|
-
console.log();
|
|
227
|
-
console.log(chalk.yellow(' Low tokens.') + chalk.dim(' Watch an ad to continue.'));
|
|
246
|
+
// Generate response
|
|
228
247
|
console.log();
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
248
|
+
const spinner = ora({ text: chalk.dim('Thinking...'), spinner: 'dots' }).start();
|
|
249
|
+
const result = await generate(apiKey, trimmed);
|
|
250
|
+
if (!result) {
|
|
251
|
+
spinner.fail(chalk.red('Failed to generate response'));
|
|
252
|
+
console.log();
|
|
253
|
+
prompt();
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (result.text === '__INSUFFICIENT_TOKENS__') {
|
|
257
|
+
spinner.stop();
|
|
258
|
+
console.log(chalk.yellow(' Insufficient tokens.') + chalk.dim(' Watch an ad to continue.'));
|
|
259
|
+
console.log();
|
|
260
|
+
const watch = await new Promise((resolve) => {
|
|
261
|
+
rl.question(chalk.dim(' Watch now? ') + chalk.cyan('[Y/n] '), (answer) => {
|
|
262
|
+
resolve(answer.toLowerCase() !== 'n');
|
|
263
|
+
});
|
|
232
264
|
});
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
265
|
+
if (watch) {
|
|
266
|
+
const success = await watchAd(apiKey);
|
|
267
|
+
if (success) {
|
|
268
|
+
const newData = await getBalance(apiKey);
|
|
269
|
+
balance = newData?.balance || balance;
|
|
270
|
+
}
|
|
239
271
|
}
|
|
272
|
+
console.log();
|
|
273
|
+
prompt();
|
|
274
|
+
return;
|
|
240
275
|
}
|
|
276
|
+
spinner.stop();
|
|
277
|
+
// Show response
|
|
278
|
+
console.log(chalk.white(result.text));
|
|
241
279
|
console.log();
|
|
242
|
-
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
// Generate response
|
|
246
|
-
console.log();
|
|
247
|
-
const spinner = ora({ text: chalk.dim('Thinking...'), spinner: 'dots' }).start();
|
|
248
|
-
const result = await generate(apiKey, trimmed);
|
|
249
|
-
if (!result) {
|
|
250
|
-
spinner.fail(chalk.red('Failed to generate response'));
|
|
280
|
+
console.log(chalk.dim(` ─ ${formatTokens(result.tokensUsed)} tokens used`));
|
|
251
281
|
console.log();
|
|
282
|
+
// Update balance
|
|
283
|
+
balance = Math.max(0, balance - result.tokensUsed);
|
|
252
284
|
prompt();
|
|
253
|
-
return;
|
|
254
285
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
console.log(chalk.yellow(' Insufficient tokens.') + chalk.dim(' Watch an ad to continue.'));
|
|
258
|
-
console.log();
|
|
259
|
-
const watch = await new Promise((resolve) => {
|
|
260
|
-
rl.question(chalk.dim(' Watch now? ') + chalk.cyan('[Y/n] '), (answer) => {
|
|
261
|
-
resolve(answer.toLowerCase() !== 'n');
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
if (watch) {
|
|
265
|
-
const success = await watchAd(apiKey);
|
|
266
|
-
if (success) {
|
|
267
|
-
const newData = await getBalance(apiKey);
|
|
268
|
-
balance = newData?.balance || balance;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
console.log();
|
|
286
|
+
catch (error) {
|
|
287
|
+
console.log(chalk.red('\n Error occurred. Please try again.\n'));
|
|
272
288
|
prompt();
|
|
273
|
-
return;
|
|
274
289
|
}
|
|
275
|
-
spinner.stop();
|
|
276
|
-
// Show response
|
|
277
|
-
console.log(chalk.white(result.text));
|
|
278
|
-
console.log();
|
|
279
|
-
console.log(chalk.dim(` ─ ${formatTokens(result.tokensUsed)} tokens used`));
|
|
280
|
-
console.log();
|
|
281
|
-
// Update balance
|
|
282
|
-
balance = Math.max(0, balance - result.tokensUsed);
|
|
283
|
-
prompt();
|
|
284
290
|
});
|
|
285
291
|
};
|
|
286
292
|
// Handle Ctrl+C gracefully
|