tmpa-cli 1.0.4 → 1.0.5
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/bin/index.js +48 -31
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -8,6 +8,20 @@ const { execSync } = require('child_process');
|
|
|
8
8
|
|
|
9
9
|
const CONFIG_FILE = path.join(os.homedir(), '.tmpa_config.json');
|
|
10
10
|
|
|
11
|
+
// Color Palette (TrueColor / ANSI Escape Codes)
|
|
12
|
+
const COLOR = {
|
|
13
|
+
reset: '\x1b[0m',
|
|
14
|
+
dim: '\x1b[2m',
|
|
15
|
+
bold: '\x1b[1m',
|
|
16
|
+
cyan: '\x1b[36m',
|
|
17
|
+
blue: '\x1b[38;2;59;130;246m', // #3B82F6
|
|
18
|
+
purple: '\x1b[38;2;168;85;247m', // #A855F7
|
|
19
|
+
green: '\x1b[38;2;34;197;94m', // #22C55E
|
|
20
|
+
yellow: '\x1b[38;2;234;179;8m', // #EAB308
|
|
21
|
+
red: '\x1b[38;2;239;68;68m', // #EF4444
|
|
22
|
+
gray: '\x1b[38;2;100;116;139m' // #64748B
|
|
23
|
+
};
|
|
24
|
+
|
|
11
25
|
function loadConfig() {
|
|
12
26
|
if (fs.existsSync(CONFIG_FILE)) {
|
|
13
27
|
try {
|
|
@@ -29,18 +43,21 @@ function saveConfig(config) {
|
|
|
29
43
|
|
|
30
44
|
function showBanner() {
|
|
31
45
|
console.clear();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
██║
|
|
37
|
-
██║
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
|
|
47
|
+
// ASCII Art Banner with Blue-to-Purple Gradient Effect
|
|
48
|
+
const line1 = `${COLOR.blue} ████████╗███╗ ███╗██████╗ █████╗ ${COLOR.reset}`;
|
|
49
|
+
const line2 = `${COLOR.blue} ╚══██╔══╝████╗ ████║██╔══██╗██╔══██╗${COLOR.reset}`;
|
|
50
|
+
const line3 = `${COLOR.blue} ██║ ██╔████╔██║██████╔╝███████║${COLOR.reset}`;
|
|
51
|
+
const line4 = `${COLOR.purple} ██║ ██║╚██╔╝██║██╔═══╝ ██╔══██║${COLOR.reset}`;
|
|
52
|
+
const line5 = `${COLOR.purple} ██║ ██║ ╚═╝ ██║██║ ██║ ██║${COLOR.reset}`;
|
|
53
|
+
const line6 = `${COLOR.purple} ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝${COLOR.reset}`;
|
|
54
|
+
|
|
55
|
+
console.log(`\n${line1}\n${line2}\n${line3}\n${line4}\n${line5}\n${line6}`);
|
|
56
|
+
console.log(`${COLOR.gray}───────────────────────────────────────────────────${COLOR.reset}`);
|
|
57
|
+
console.log(` ${COLOR.green}The Multi Platform AI [Interactive Mode]${COLOR.reset}`);
|
|
58
|
+
console.log(` ${COLOR.gray}/config${COLOR.reset} : Set API Key | ${COLOR.gray}/connect${COLOR.reset} : Connect Web`);
|
|
59
|
+
console.log(` ${COLOR.gray}/uninstall${COLOR.reset} : Remove CLI | ${COLOR.gray}/exit${COLOR.reset} : Exit Session`);
|
|
60
|
+
console.log(`${COLOR.gray}───────────────────────────────────────────────────${COLOR.reset}\n`);
|
|
44
61
|
}
|
|
45
62
|
|
|
46
63
|
const rl = readline.createInterface({
|
|
@@ -51,12 +68,12 @@ const rl = readline.createInterface({
|
|
|
51
68
|
let config = loadConfig();
|
|
52
69
|
|
|
53
70
|
function askConfig(callback) {
|
|
54
|
-
rl.question(
|
|
55
|
-
rl.question(
|
|
71
|
+
rl.question(`${COLOR.yellow}[>] Enter API Key:${COLOR.reset} `, (apiKey) => {
|
|
72
|
+
rl.question(`${COLOR.yellow}[>] Enter Endpoint URL (Press Enter for Default Gemini):${COLOR.reset} `, (endpoint) => {
|
|
56
73
|
config.apiKey = apiKey.trim();
|
|
57
74
|
config.endpoint = endpoint.trim() || 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent';
|
|
58
75
|
saveConfig(config);
|
|
59
|
-
console.log(
|
|
76
|
+
console.log(`${COLOR.green}[+] Configuration saved successfully!${COLOR.reset}\n`);
|
|
60
77
|
if (callback) callback();
|
|
61
78
|
});
|
|
62
79
|
});
|
|
@@ -64,7 +81,7 @@ function askConfig(callback) {
|
|
|
64
81
|
|
|
65
82
|
async function handleChat(prompt) {
|
|
66
83
|
if (!config.apiKey) {
|
|
67
|
-
console.log(
|
|
84
|
+
console.log(`${COLOR.yellow}[!] API Key is not set.${COLOR.reset}`);
|
|
68
85
|
return askConfig(() => startPrompt());
|
|
69
86
|
}
|
|
70
87
|
|
|
@@ -72,7 +89,7 @@ async function handleChat(prompt) {
|
|
|
72
89
|
config.endpoint = 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent';
|
|
73
90
|
}
|
|
74
91
|
|
|
75
|
-
console.log(
|
|
92
|
+
console.log(`${COLOR.yellow}TMPA CLI processing...${COLOR.reset}`);
|
|
76
93
|
|
|
77
94
|
try {
|
|
78
95
|
const url = config.endpoint.includes('googleapis.com')
|
|
@@ -90,7 +107,7 @@ async function handleChat(prompt) {
|
|
|
90
107
|
});
|
|
91
108
|
|
|
92
109
|
const data = await response.json();
|
|
93
|
-
let reply = '
|
|
110
|
+
let reply = 'No response from server.';
|
|
94
111
|
|
|
95
112
|
if (data.candidates && data.candidates[0]?.content?.parts[0]?.text) {
|
|
96
113
|
reply = data.candidates[0].content.parts[0].text;
|
|
@@ -100,43 +117,43 @@ async function handleChat(prompt) {
|
|
|
100
117
|
reply = data.message;
|
|
101
118
|
}
|
|
102
119
|
|
|
103
|
-
console.log(`\n
|
|
120
|
+
console.log(`\n${COLOR.blue}TMPA CLI :${COLOR.reset} ${reply}\n`);
|
|
104
121
|
} catch (error) {
|
|
105
|
-
console.log(`\n
|
|
122
|
+
console.log(`\n${COLOR.red}[x] Error: ${error.message}${COLOR.reset}\n`);
|
|
106
123
|
}
|
|
107
124
|
|
|
108
125
|
startPrompt();
|
|
109
126
|
}
|
|
110
127
|
|
|
111
128
|
function handleUninstall() {
|
|
112
|
-
rl.question(
|
|
113
|
-
if (answer.toLowerCase() === 'y' || answer.toLowerCase() === '
|
|
114
|
-
console.log(
|
|
129
|
+
rl.question(`${COLOR.red}[!] Are you sure you want to uninstall TMPA CLI? (y/N):${COLOR.reset} `, (answer) => {
|
|
130
|
+
if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
|
|
131
|
+
console.log(`\n${COLOR.yellow}[...] Removing TMPA CLI and cleaning configuration...${COLOR.reset}`);
|
|
115
132
|
try {
|
|
116
133
|
if (fs.existsSync(CONFIG_FILE)) {
|
|
117
134
|
fs.unlinkSync(CONFIG_FILE);
|
|
118
135
|
}
|
|
119
|
-
console.log(
|
|
136
|
+
console.log(`${COLOR.green}[+] Local configuration cleared.${COLOR.reset}`);
|
|
120
137
|
execSync('npm uninstall -g tmpa-cli', { stdio: 'inherit' });
|
|
121
|
-
console.log(
|
|
138
|
+
console.log(`\n${COLOR.green}[+] TMPA CLI uninstalled successfully. Goodbye!${COLOR.reset}\n`);
|
|
122
139
|
process.exit(0);
|
|
123
140
|
} catch (err) {
|
|
124
|
-
console.log(
|
|
141
|
+
console.log(`\n${COLOR.red}[x] Failed to uninstall automatically. Run: npm uninstall -g tmpa-cli manually.${COLOR.reset}\n`);
|
|
125
142
|
process.exit(0);
|
|
126
143
|
}
|
|
127
144
|
} else {
|
|
128
|
-
console.log(
|
|
145
|
+
console.log(`${COLOR.gray}Uninstall process cancelled.${COLOR.reset}\n`);
|
|
129
146
|
startPrompt();
|
|
130
147
|
}
|
|
131
148
|
});
|
|
132
149
|
}
|
|
133
150
|
|
|
134
151
|
function startPrompt() {
|
|
135
|
-
rl.question(
|
|
152
|
+
rl.question(`${COLOR.cyan}TMPA >${COLOR.reset} `, (input) => {
|
|
136
153
|
const cmd = input.trim();
|
|
137
154
|
|
|
138
155
|
if (cmd === '/exit') {
|
|
139
|
-
console.log(
|
|
156
|
+
console.log(`${COLOR.gray}Goodbye!${COLOR.reset}`);
|
|
140
157
|
process.exit(0);
|
|
141
158
|
} else if (cmd === '/clear') {
|
|
142
159
|
showBanner();
|
|
@@ -144,7 +161,7 @@ function startPrompt() {
|
|
|
144
161
|
} else if (cmd === '/config') {
|
|
145
162
|
askConfig(() => startPrompt());
|
|
146
163
|
} else if (cmd === '/connect') {
|
|
147
|
-
console.log(
|
|
164
|
+
console.log(`\n${COLOR.purple}[!] [COMING SOON] Web integration & auth login features will be available in the next release.${COLOR.reset}\n`);
|
|
148
165
|
startPrompt();
|
|
149
166
|
} else if (cmd === '/uninstall') {
|
|
150
167
|
handleUninstall();
|
|
@@ -156,7 +173,7 @@ function startPrompt() {
|
|
|
156
173
|
});
|
|
157
174
|
}
|
|
158
175
|
|
|
159
|
-
//
|
|
176
|
+
// Program Entry Point
|
|
160
177
|
showBanner();
|
|
161
178
|
if (!config.apiKey) {
|
|
162
179
|
askConfig(() => startPrompt());
|