@kibibot/cli 1.0.11 → 1.0.13
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/dist/commands/about.js +13 -1
- package/dist/commands/login.js +24 -14
- package/dist/index.js +33 -1
- package/package.json +2 -3
package/dist/commands/about.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { readFileSync, existsSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
3
3
|
import { join, dirname } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { homedir } from 'node:os';
|
|
5
6
|
function getVersion() {
|
|
6
7
|
try {
|
|
7
8
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -47,5 +48,16 @@ export function registerAbout(program) {
|
|
|
47
48
|
}
|
|
48
49
|
console.log(chalk.cyan(` ╚${'═'.repeat(W)}╝`));
|
|
49
50
|
console.log();
|
|
51
|
+
// Mark as welcomed
|
|
52
|
+
try {
|
|
53
|
+
const kibiDir = join(homedir(), '.kibi');
|
|
54
|
+
const marker = join(kibiDir, '.welcomed');
|
|
55
|
+
if (!existsSync(marker)) {
|
|
56
|
+
if (!existsSync(kibiDir))
|
|
57
|
+
mkdirSync(kibiDir, { recursive: true });
|
|
58
|
+
writeFileSync(marker, new Date().toISOString());
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch { }
|
|
50
62
|
});
|
|
51
63
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -27,8 +27,10 @@ export function registerLogin(program) {
|
|
|
27
27
|
}
|
|
28
28
|
let apiKey = opts.apiKey;
|
|
29
29
|
if (!apiKey) {
|
|
30
|
-
// Interactive prompt with masked input
|
|
31
|
-
|
|
30
|
+
// Interactive prompt with masked input (first 6 chars visible)
|
|
31
|
+
const VISIBLE_PREFIX = 6;
|
|
32
|
+
const prompt = 'Enter your API key: ';
|
|
33
|
+
process.stdout.write(prompt);
|
|
32
34
|
apiKey = await new Promise((resolve) => {
|
|
33
35
|
let input = '';
|
|
34
36
|
const stdin = process.stdin;
|
|
@@ -38,10 +40,19 @@ export function registerLogin(program) {
|
|
|
38
40
|
}
|
|
39
41
|
stdin.resume();
|
|
40
42
|
stdin.setEncoding('utf8');
|
|
43
|
+
function redraw() {
|
|
44
|
+
// Clear current line and rewrite
|
|
45
|
+
process.stdout.write(`\r${prompt}`);
|
|
46
|
+
if (input.length <= VISIBLE_PREFIX) {
|
|
47
|
+
process.stdout.write(input);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
process.stdout.write(input.slice(0, VISIBLE_PREFIX) + '*'.repeat(input.length - VISIBLE_PREFIX));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
41
53
|
const onData = (ch) => {
|
|
42
54
|
const c = ch.toString();
|
|
43
55
|
if (c === '\n' || c === '\r') {
|
|
44
|
-
// Enter
|
|
45
56
|
stdin.removeListener('data', onData);
|
|
46
57
|
if (stdin.isTTY)
|
|
47
58
|
stdin.setRawMode(wasRaw ?? false);
|
|
@@ -50,25 +61,24 @@ export function registerLogin(program) {
|
|
|
50
61
|
resolve(input.trim());
|
|
51
62
|
}
|
|
52
63
|
else if (c === '\u0003') {
|
|
53
|
-
// Ctrl+C
|
|
54
64
|
process.stdout.write('\n');
|
|
55
65
|
process.exit(0);
|
|
56
66
|
}
|
|
57
67
|
else if (c === '\u007f' || c === '\b') {
|
|
58
|
-
// Backspace
|
|
59
68
|
if (input.length > 0) {
|
|
60
69
|
input = input.slice(0, -1);
|
|
61
|
-
|
|
70
|
+
// Clear to end of line then redraw
|
|
71
|
+
process.stdout.write(`\r${prompt}${' '.repeat(input.length + 1)}`);
|
|
72
|
+
redraw();
|
|
62
73
|
}
|
|
63
74
|
}
|
|
64
|
-
else
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
process.stdout.write('*'.repeat(c.length));
|
|
75
|
+
else {
|
|
76
|
+
// Single char or pasted text
|
|
77
|
+
for (const char of c) {
|
|
78
|
+
if (char >= ' ')
|
|
79
|
+
input += char;
|
|
80
|
+
}
|
|
81
|
+
redraw();
|
|
72
82
|
}
|
|
73
83
|
};
|
|
74
84
|
stdin.on('data', onData);
|
package/dist/index.js
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* @package @kibibot/cli
|
|
6
6
|
*/
|
|
7
7
|
import { Command } from 'commander';
|
|
8
|
-
import { readFileSync } from 'node:fs';
|
|
8
|
+
import { readFileSync, existsSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
10
|
import { dirname, join } from 'node:path';
|
|
11
|
+
import { homedir } from 'node:os';
|
|
11
12
|
import { enableDebug } from './lib/api.js';
|
|
12
13
|
import { registerLogin } from './commands/login.js';
|
|
13
14
|
import { registerWhoami } from './commands/whoami.js';
|
|
@@ -37,6 +38,37 @@ program
|
|
|
37
38
|
enableDebug();
|
|
38
39
|
}
|
|
39
40
|
});
|
|
41
|
+
// Show about box on first run (skip if user is running 'kibi about' directly)
|
|
42
|
+
const welcomeMarker = join(homedir(), '.kibi', '.welcomed');
|
|
43
|
+
const isAboutCommand = process.argv[2] === 'about';
|
|
44
|
+
if (!existsSync(welcomeMarker) && !isAboutCommand) {
|
|
45
|
+
try {
|
|
46
|
+
const W = 43;
|
|
47
|
+
const pad = (t) => t + ' '.repeat(Math.max(0, W - t.length));
|
|
48
|
+
const lines = [
|
|
49
|
+
'', ' K I B I B O T', '',
|
|
50
|
+
' Deploy tokens. Earn fees.', ' Power your AI agent.', '',
|
|
51
|
+
` Version ${pkg.version}`,
|
|
52
|
+
' Website kibi.bot',
|
|
53
|
+
' Docs kibi.bot/docs/agent',
|
|
54
|
+
' GitHub github.com/KibiAgent',
|
|
55
|
+
'', ' Base · BSC · Solana', '',
|
|
56
|
+
];
|
|
57
|
+
console.log();
|
|
58
|
+
console.log(` \x1b[36m╔${'═'.repeat(W)}╗\x1b[0m`);
|
|
59
|
+
for (const l of lines)
|
|
60
|
+
console.log(` \x1b[36m║\x1b[0m${pad(l)}\x1b[36m║\x1b[0m`);
|
|
61
|
+
console.log(` \x1b[36m╚${'═'.repeat(W)}╝\x1b[0m`);
|
|
62
|
+
console.log();
|
|
63
|
+
const kibiDir = join(homedir(), '.kibi');
|
|
64
|
+
if (!existsSync(kibiDir))
|
|
65
|
+
mkdirSync(kibiDir, { recursive: true });
|
|
66
|
+
writeFileSync(welcomeMarker, new Date().toISOString());
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// best-effort
|
|
70
|
+
}
|
|
71
|
+
}
|
|
40
72
|
// Register all commands
|
|
41
73
|
registerLogin(program);
|
|
42
74
|
registerWhoami(program);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kibibot/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "KibiBot CLI — deploy tokens, check balances, and manage your AI agent from the terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "tsc",
|
|
18
18
|
"dev": "tsc --watch",
|
|
19
|
-
"prepublishOnly": "npm run build"
|
|
20
|
-
"postinstall": "node scripts/postinstall.js 2>/dev/null || true"
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
21
20
|
},
|
|
22
21
|
"engines": {
|
|
23
22
|
"node": ">=18.0.0"
|