tmpa-cli 1.0.5 → 1.0.6
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 +42 -42
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -8,18 +8,19 @@ const { execSync } = require('child_process');
|
|
|
8
8
|
|
|
9
9
|
const CONFIG_FILE = path.join(os.homedir(), '.tmpa_config.json');
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
const
|
|
11
|
+
// Exact RGB Gradient Colors (Cyan -> Light Blue -> Deep Blue -> Purple)
|
|
12
|
+
const C = {
|
|
13
13
|
reset: '\x1b[0m',
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
yellow: '\x1b[38;2;234;179;8m',
|
|
21
|
-
red: '\x1b[38;2;239;68;68m',
|
|
22
|
-
gray: '\x1b[38;2;
|
|
14
|
+
c1: '\x1b[38;2;0;210;255m', // Bright Cyan
|
|
15
|
+
c2: '\x1b[38;2;30;144;255m', // Light Blue
|
|
16
|
+
c3: '\x1b[38;2;99;102;241m', // Indigo Blue
|
|
17
|
+
c4: '\x1b[38;2;168;85;247m', // Purple
|
|
18
|
+
green: '\x1b[38;2;34;197;94m',
|
|
19
|
+
cyan: '\x1b[38;2;6x;182;212m',
|
|
20
|
+
yellow: '\x1b[38;2;234;179;8m',
|
|
21
|
+
red: '\x1b[38;2;239;68;68m',
|
|
22
|
+
gray: '\x1b[38;2;148;163;184m',
|
|
23
|
+
darkGray: '\x1b[38;2;71;85;105m'
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
function loadConfig() {
|
|
@@ -44,20 +45,19 @@ function saveConfig(config) {
|
|
|
44
45
|
function showBanner() {
|
|
45
46
|
console.clear();
|
|
46
47
|
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
console.log(`${COLOR.gray}───────────────────────────────────────────────────${COLOR.reset}\n`);
|
|
48
|
+
// Exact Banner matching the image structure
|
|
49
|
+
console.log(`
|
|
50
|
+
${C.c1}████████╗███╗ ███╗██████╗ █████╗ ${C.reset}
|
|
51
|
+
${C.c2}╚══██╔══╝████╗ ████║██╔══██╗██╔══██╗${C.reset}
|
|
52
|
+
${C.c2} ██║ ██╔████╔██║██████╔╝███████║${C.reset}
|
|
53
|
+
${C.c3} ██║ ██║╚██╔╝██║██╔═══╝ ██╔══██║${C.reset}
|
|
54
|
+
${C.c4} ██║ ██║ ╚═╝ ██║██║ ██║ ██║${C.reset}
|
|
55
|
+
${C.c4} ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝${C.reset}
|
|
56
|
+
${C.darkGray}────────────────────────────────────────────────────────────${C.reset}
|
|
57
|
+
${C.reset}The Multi Platform AI ${C.green}[Interactive Mode]${C.reset}
|
|
58
|
+
${C.gray}/config : Set API | /connect : Web Integration | /uninstall : Remove | /exit : Exit${C.reset}
|
|
59
|
+
${C.darkGray}────────────────────────────────────────────────────────────${C.reset}
|
|
60
|
+
`);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const rl = readline.createInterface({
|
|
@@ -68,12 +68,12 @@ const rl = readline.createInterface({
|
|
|
68
68
|
let config = loadConfig();
|
|
69
69
|
|
|
70
70
|
function askConfig(callback) {
|
|
71
|
-
rl.question(`${
|
|
72
|
-
rl.question(`${
|
|
71
|
+
rl.question(`${C.yellow}[>] Enter API Key:${C.reset} `, (apiKey) => {
|
|
72
|
+
rl.question(`${C.yellow}[>] Enter Endpoint URL (Press Enter for Default Gemini):${C.reset} `, (endpoint) => {
|
|
73
73
|
config.apiKey = apiKey.trim();
|
|
74
74
|
config.endpoint = endpoint.trim() || 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent';
|
|
75
75
|
saveConfig(config);
|
|
76
|
-
console.log(`${
|
|
76
|
+
console.log(`${C.green}[+] Configuration saved successfully!${C.reset}\n`);
|
|
77
77
|
if (callback) callback();
|
|
78
78
|
});
|
|
79
79
|
});
|
|
@@ -81,7 +81,7 @@ function askConfig(callback) {
|
|
|
81
81
|
|
|
82
82
|
async function handleChat(prompt) {
|
|
83
83
|
if (!config.apiKey) {
|
|
84
|
-
console.log(`${
|
|
84
|
+
console.log(`${C.yellow}[!] API Key is not set.${C.reset}`);
|
|
85
85
|
return askConfig(() => startPrompt());
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -89,7 +89,7 @@ async function handleChat(prompt) {
|
|
|
89
89
|
config.endpoint = 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent';
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
console.log(`${
|
|
92
|
+
console.log(`${C.yellow}TMPA CLI processing...${C.reset}`);
|
|
93
93
|
|
|
94
94
|
try {
|
|
95
95
|
const url = config.endpoint.includes('googleapis.com')
|
|
@@ -117,43 +117,43 @@ async function handleChat(prompt) {
|
|
|
117
117
|
reply = data.message;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
console.log(`\n${
|
|
120
|
+
console.log(`\n${C.c1}TMPA CLI :${C.reset} ${reply}\n`);
|
|
121
121
|
} catch (error) {
|
|
122
|
-
console.log(`\n${
|
|
122
|
+
console.log(`\n${C.red}[x] Error: ${error.message}${C.reset}\n`);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
startPrompt();
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
function handleUninstall() {
|
|
129
|
-
rl.question(`${
|
|
129
|
+
rl.question(`${C.red}[!] Are you sure you want to uninstall TMPA CLI? (y/N):${C.reset} `, (answer) => {
|
|
130
130
|
if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
|
|
131
|
-
console.log(`\n${
|
|
131
|
+
console.log(`\n${C.yellow}[...] Removing TMPA CLI and cleaning configuration...${C.reset}`);
|
|
132
132
|
try {
|
|
133
133
|
if (fs.existsSync(CONFIG_FILE)) {
|
|
134
134
|
fs.unlinkSync(CONFIG_FILE);
|
|
135
135
|
}
|
|
136
|
-
console.log(`${
|
|
136
|
+
console.log(`${C.green}[+] Local configuration cleared.${C.reset}`);
|
|
137
137
|
execSync('npm uninstall -g tmpa-cli', { stdio: 'inherit' });
|
|
138
|
-
console.log(`\n${
|
|
138
|
+
console.log(`\n${C.green}[+] TMPA CLI uninstalled successfully. Goodbye!${C.reset}\n`);
|
|
139
139
|
process.exit(0);
|
|
140
140
|
} catch (err) {
|
|
141
|
-
console.log(`\n${
|
|
141
|
+
console.log(`\n${C.red}[x] Failed to uninstall automatically. Run: npm uninstall -g tmpa-cli manually.${C.reset}\n`);
|
|
142
142
|
process.exit(0);
|
|
143
143
|
}
|
|
144
144
|
} else {
|
|
145
|
-
console.log(`${
|
|
145
|
+
console.log(`${C.gray}Uninstall process cancelled.${C.reset}\n`);
|
|
146
146
|
startPrompt();
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
function startPrompt() {
|
|
152
|
-
rl.question(`${
|
|
152
|
+
rl.question(`${C.c1}TMPA >${C.reset} `, (input) => {
|
|
153
153
|
const cmd = input.trim();
|
|
154
154
|
|
|
155
155
|
if (cmd === '/exit') {
|
|
156
|
-
console.log(`${
|
|
156
|
+
console.log(`${C.gray}Goodbye!${C.reset}`);
|
|
157
157
|
process.exit(0);
|
|
158
158
|
} else if (cmd === '/clear') {
|
|
159
159
|
showBanner();
|
|
@@ -161,7 +161,7 @@ function startPrompt() {
|
|
|
161
161
|
} else if (cmd === '/config') {
|
|
162
162
|
askConfig(() => startPrompt());
|
|
163
163
|
} else if (cmd === '/connect') {
|
|
164
|
-
console.log(`\n${
|
|
164
|
+
console.log(`\n${C.c4}[!] [COMING SOON] Web integration & auth login features will be available in the next release.${C.reset}\n`);
|
|
165
165
|
startPrompt();
|
|
166
166
|
} else if (cmd === '/uninstall') {
|
|
167
167
|
handleUninstall();
|
|
@@ -173,7 +173,7 @@ function startPrompt() {
|
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
// Program
|
|
176
|
+
// Program Execution
|
|
177
177
|
showBanner();
|
|
178
178
|
if (!config.apiKey) {
|
|
179
179
|
askConfig(() => startPrompt());
|