tmpa-cli 1.0.13 → 1.0.14
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 +57 -36
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -79,7 +79,7 @@ ${C.c3} ██║ ██║╚██╔╝██║██╔═══╝ █
|
|
|
79
79
|
${C.c4} ██║ ██║ ╚═╝ ██║██║ ██║ ██║${C.reset}
|
|
80
80
|
${C.c4} ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝${C.reset}
|
|
81
81
|
${C.darkGray}────────────────────────────────────────────────────────────${C.reset}
|
|
82
|
-
${C.reset}The Multi Platform AI ${C.green}[Interactive Mode +
|
|
82
|
+
${C.reset}The Multi Platform AI ${C.green}[Interactive Mode + Multi-Location Scanner]${C.reset}
|
|
83
83
|
${C.gray}/config | /models | /skill | /mcp | /connect | /scan | /exit${C.reset}
|
|
84
84
|
${C.darkGray}────────────────────────────────────────────────────────────${C.reset}
|
|
85
85
|
`);
|
|
@@ -89,7 +89,6 @@ ${C.darkGray}──────────────────────
|
|
|
89
89
|
function getActiveToolsContext() {
|
|
90
90
|
let contextParts = [];
|
|
91
91
|
|
|
92
|
-
// Skills Context
|
|
93
92
|
const activeSkills = Object.keys(registry.skills || {});
|
|
94
93
|
if (activeSkills.length > 0) {
|
|
95
94
|
contextParts.push("AVAILABLE SKILLS:");
|
|
@@ -99,7 +98,6 @@ function getActiveToolsContext() {
|
|
|
99
98
|
});
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
// MCP Context
|
|
103
101
|
const activeMCP = Object.keys(registry.mcp || {});
|
|
104
102
|
if (activeMCP.length > 0) {
|
|
105
103
|
contextParts.push("AVAILABLE MCP SERVERS:");
|
|
@@ -120,7 +118,7 @@ function listSkills() {
|
|
|
120
118
|
console.log(`\n${C.cyan}=== Registered Skills ===${C.reset}`);
|
|
121
119
|
const keys = Object.keys(registry.skills || {});
|
|
122
120
|
if (keys.length === 0) {
|
|
123
|
-
console.log(`${C.gray}Belum ada skill yang terhubung. Gunakan ${C.yellow}/connect skill <path>${C.gray} untuk
|
|
121
|
+
console.log(`${C.gray}Belum ada skill yang terhubung. Gunakan ${C.yellow}/connect skill <path>${C.gray} atau ${C.yellow}/scan${C.gray} untuk memindai.${C.reset}\n`);
|
|
124
122
|
return;
|
|
125
123
|
}
|
|
126
124
|
keys.forEach((name, i) => {
|
|
@@ -134,7 +132,7 @@ function listMCP() {
|
|
|
134
132
|
console.log(`\n${C.cyan}=== Registered MCP (Model Context Protocol) Servers ===${C.reset}`);
|
|
135
133
|
const keys = Object.keys(registry.mcp || {});
|
|
136
134
|
if (keys.length === 0) {
|
|
137
|
-
console.log(`${C.gray}Belum ada MCP server terhubung. Gunakan ${C.yellow}/connect mcp <target>${C.gray} untuk
|
|
135
|
+
console.log(`${C.gray}Belum ada MCP server terhubung. Gunakan ${C.yellow}/connect mcp <target>${C.gray} atau ${C.yellow}/scan${C.gray} untuk memindai.${C.reset}\n`);
|
|
138
136
|
return;
|
|
139
137
|
}
|
|
140
138
|
keys.forEach((name, i) => {
|
|
@@ -184,36 +182,65 @@ function connectResource(inputArgs) {
|
|
|
184
182
|
}
|
|
185
183
|
}
|
|
186
184
|
|
|
185
|
+
// Deep Multi-Location Scanner Function
|
|
187
186
|
function scanResources() {
|
|
188
|
-
console.log(`${C.yellow}[...] Memindai folder
|
|
187
|
+
console.log(`${C.yellow}[...] Memindai folder internal & lokasi umum pengguna (Gemini/Claude/System)...${C.reset}`);
|
|
189
188
|
registry = loadRegistry();
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
189
|
+
registry.skills = registry.skills || {};
|
|
190
|
+
registry.mcp = registry.mcp || {};
|
|
191
|
+
|
|
192
|
+
const home = os.homedir();
|
|
193
|
+
const searchTargets = [
|
|
194
|
+
// Folder Internal TMPA
|
|
195
|
+
{ type: 'skill', dir: SKILLS_DIR },
|
|
196
|
+
{ type: 'mcp', dir: MCP_DIR },
|
|
197
|
+
|
|
198
|
+
// Folder Umum Pengguna (Direct Home Directory)
|
|
199
|
+
{ type: 'skill', dir: path.join(home, 'skills') },
|
|
200
|
+
{ type: 'mcp', dir: path.join(home, 'mcp') },
|
|
201
|
+
{ type: 'mcp', dir: path.join(home, '.mcp') },
|
|
202
|
+
|
|
203
|
+
// Folder Konfigurasi Gemini CLI & Claude Desktop
|
|
204
|
+
{ type: 'skill', dir: path.join(home, '.gemini', 'skills') },
|
|
205
|
+
{ type: 'mcp', dir: path.join(home, '.gemini', 'mcp') },
|
|
206
|
+
{ type: 'skill', dir: path.join(home, '.config', 'gemini', 'skills') },
|
|
207
|
+
{ type: 'mcp', dir: path.join(home, '.config', 'gemini', 'mcp') },
|
|
208
|
+
{ type: 'mcp', dir: path.join(home, '.claude', 'mcp') },
|
|
209
|
+
{ type: 'mcp', dir: path.join(home, '.config', 'claude', 'mcp') }
|
|
210
|
+
];
|
|
211
|
+
|
|
212
|
+
let addedCount = 0;
|
|
213
|
+
|
|
214
|
+
searchTargets.forEach(({ type, dir }) => {
|
|
215
|
+
if (fs.existsSync(dir)) {
|
|
216
|
+
try {
|
|
217
|
+
const items = fs.readdirSync(dir);
|
|
218
|
+
items.forEach(item => {
|
|
219
|
+
const fullPath = path.join(dir, item);
|
|
220
|
+
const name = path.basename(item, path.extname(item));
|
|
221
|
+
|
|
222
|
+
if (type === 'skill') {
|
|
223
|
+
if (!registry.skills[name]) {
|
|
224
|
+
registry.skills[name] = { path: fullPath, connectedAt: new Date().toISOString(), status: 'Active' };
|
|
225
|
+
console.log(`${C.green}[+] Terdeteksi Skill: ${name}${C.reset} ${C.gray}(${fullPath})${C.reset}`);
|
|
226
|
+
addedCount++;
|
|
227
|
+
}
|
|
228
|
+
} else if (type === 'mcp') {
|
|
229
|
+
if (!registry.mcp[name]) {
|
|
230
|
+
registry.mcp[name] = { target: fullPath, type: 'local', connectedAt: new Date().toISOString(), status: 'Connected' };
|
|
231
|
+
console.log(`${C.green}[+] Terdeteksi MCP: ${name}${C.reset} ${C.gray}(${fullPath})${C.reset}`);
|
|
232
|
+
addedCount++;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
} catch (e) {
|
|
237
|
+
// Skip folder jika permission terikat
|
|
211
238
|
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
239
|
+
}
|
|
240
|
+
});
|
|
214
241
|
|
|
215
242
|
saveRegistry(registry);
|
|
216
|
-
console.log(`${C.green}[+] Pemindaian selesai
|
|
243
|
+
console.log(`${C.green}[+] Pemindaian selesai. Total item baru terdeteksi: ${addedCount}${C.reset}\n`);
|
|
217
244
|
}
|
|
218
245
|
|
|
219
246
|
function askConfig(callback) {
|
|
@@ -382,7 +409,6 @@ async function handleChat(prompt) {
|
|
|
382
409
|
let headers = { 'Content-Type': 'application/json' };
|
|
383
410
|
let bodyData = {};
|
|
384
411
|
|
|
385
|
-
// Combine User Prompt + Active Tools Context
|
|
386
412
|
const toolsContext = getActiveToolsContext();
|
|
387
413
|
const fullPrompt = prompt + toolsContext;
|
|
388
414
|
|
|
@@ -423,11 +449,6 @@ async function handleChat(prompt) {
|
|
|
423
449
|
|
|
424
450
|
console.log(`\n${C.c1}TMPA CLI (${config.model || 'AI'}) :${C.reset} ${aiResponse}\n`);
|
|
425
451
|
|
|
426
|
-
// Check if AI requested execution of a local tool/skill
|
|
427
|
-
if (aiResponse.includes('[EXEC_TOOL:')) {
|
|
428
|
-
console.log(`${C.cyan}[+] Detected Tool Execution Request from AI...${C.reset}`);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
452
|
} catch (error) {
|
|
432
453
|
console.log(`\n${C.red}[x] Fetch Error: ${error.message}${C.reset}\n`);
|
|
433
454
|
}
|