@kibibot/cli 1.0.10 → 1.0.12
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/login.js +24 -14
- package/dist/index.js +32 -1
- package/package.json +4 -4
- package/scripts/postinstall.js +34 -0
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,36 @@ program
|
|
|
37
38
|
enableDebug();
|
|
38
39
|
}
|
|
39
40
|
});
|
|
41
|
+
// Show about box on first run
|
|
42
|
+
const welcomeMarker = join(homedir(), '.kibi', '.welcomed');
|
|
43
|
+
if (!existsSync(welcomeMarker)) {
|
|
44
|
+
try {
|
|
45
|
+
const W = 43;
|
|
46
|
+
const pad = (t) => t + ' '.repeat(Math.max(0, W - t.length));
|
|
47
|
+
const lines = [
|
|
48
|
+
'', ' K I B I B O T', '',
|
|
49
|
+
' Deploy tokens. Earn fees.', ' Power your AI agent.', '',
|
|
50
|
+
` Version ${pkg.version}`,
|
|
51
|
+
' Website kibi.bot',
|
|
52
|
+
' Docs kibi.bot/docs/agent',
|
|
53
|
+
' GitHub github.com/KibiAgent',
|
|
54
|
+
'', ' Base · BSC · Solana', '',
|
|
55
|
+
];
|
|
56
|
+
console.log();
|
|
57
|
+
console.log(` \x1b[36m╔${'═'.repeat(W)}╗\x1b[0m`);
|
|
58
|
+
for (const l of lines)
|
|
59
|
+
console.log(` \x1b[36m║\x1b[0m${pad(l)}\x1b[36m║\x1b[0m`);
|
|
60
|
+
console.log(` \x1b[36m╚${'═'.repeat(W)}╝\x1b[0m`);
|
|
61
|
+
console.log();
|
|
62
|
+
const kibiDir = join(homedir(), '.kibi');
|
|
63
|
+
if (!existsSync(kibiDir))
|
|
64
|
+
mkdirSync(kibiDir, { recursive: true });
|
|
65
|
+
writeFileSync(welcomeMarker, new Date().toISOString());
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// best-effort
|
|
69
|
+
}
|
|
70
|
+
}
|
|
40
71
|
// Register all commands
|
|
41
72
|
registerLogin(program);
|
|
42
73
|
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.12",
|
|
4
4
|
"description": "KibiBot CLI — deploy tokens, check balances, and manage your AI agent from the terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|
|
13
|
-
"bin"
|
|
13
|
+
"bin",
|
|
14
|
+
"scripts"
|
|
14
15
|
],
|
|
15
16
|
"scripts": {
|
|
16
17
|
"build": "tsc",
|
|
17
18
|
"dev": "tsc --watch",
|
|
18
|
-
"prepublishOnly": "npm run build"
|
|
19
|
-
"postinstall": "node dist/index.js about 2>/dev/null || true"
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=18.0.0"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const W = 43;
|
|
3
|
+
function pad(text) {
|
|
4
|
+
return text + ' '.repeat(Math.max(0, W - text.length));
|
|
5
|
+
}
|
|
6
|
+
let version = 'unknown';
|
|
7
|
+
try {
|
|
8
|
+
const pkg = require('../package.json');
|
|
9
|
+
version = pkg.version || 'unknown';
|
|
10
|
+
} catch {}
|
|
11
|
+
|
|
12
|
+
const lines = [
|
|
13
|
+
'',
|
|
14
|
+
' K I B I B O T',
|
|
15
|
+
'',
|
|
16
|
+
' Deploy tokens. Earn fees.',
|
|
17
|
+
' Power your AI agent.',
|
|
18
|
+
'',
|
|
19
|
+
` Version ${version}`,
|
|
20
|
+
' Website kibi.bot',
|
|
21
|
+
' Docs kibi.bot/docs/agent',
|
|
22
|
+
' GitHub github.com/KibiAgent',
|
|
23
|
+
'',
|
|
24
|
+
' Base · BSC · Solana',
|
|
25
|
+
'',
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
console.log();
|
|
29
|
+
console.log(` \x1b[36m╔${'═'.repeat(W)}╗\x1b[0m`);
|
|
30
|
+
for (const line of lines) {
|
|
31
|
+
console.log(` \x1b[36m║\x1b[0m${pad(line)}\x1b[36m║\x1b[0m`);
|
|
32
|
+
}
|
|
33
|
+
console.log(` \x1b[36m╚${'═'.repeat(W)}╝\x1b[0m`);
|
|
34
|
+
console.log();
|