suparank 1.2.8 → 1.2.9
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/suparank.js +26 -12
- package/package.json +1 -1
package/bin/suparank.js
CHANGED
|
@@ -22,7 +22,7 @@ const CONFIG_FILE = path.join(SUPARANK_DIR, 'config.json')
|
|
|
22
22
|
const CREDENTIALS_FILE = path.join(SUPARANK_DIR, 'credentials.json')
|
|
23
23
|
const SESSION_FILE = path.join(SUPARANK_DIR, 'session.json')
|
|
24
24
|
|
|
25
|
-
// Colors for terminal output
|
|
25
|
+
// Colors for terminal output (only used in interactive commands)
|
|
26
26
|
const colors = {
|
|
27
27
|
reset: '\x1b[0m',
|
|
28
28
|
bright: '\x1b[1m',
|
|
@@ -34,14 +34,27 @@ const colors = {
|
|
|
34
34
|
cyan: '\x1b[36m'
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// Check if running in MCP mode (no command argument = MCP server)
|
|
38
|
+
const isMCPMode = !process.argv[2] || !['setup', 'test', 'session', 'clear', 'help', '--help', '-h'].includes(process.argv[2])
|
|
39
|
+
|
|
37
40
|
function log(message, color = 'reset') {
|
|
38
|
-
|
|
41
|
+
// In MCP mode, use stderr to avoid breaking JSON protocol
|
|
42
|
+
// In interactive mode (setup, test, etc), use stdout for user-friendly output
|
|
43
|
+
if (isMCPMode) {
|
|
44
|
+
console.error(`[suparank] ${message}`)
|
|
45
|
+
} else {
|
|
46
|
+
console.log(`${colors[color]}${message}${colors.reset}`)
|
|
47
|
+
}
|
|
39
48
|
}
|
|
40
49
|
|
|
41
50
|
function logHeader(message) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
if (isMCPMode) {
|
|
52
|
+
console.error(`[suparank] === ${message} ===`)
|
|
53
|
+
} else {
|
|
54
|
+
console.log()
|
|
55
|
+
log(`=== ${message} ===`, 'bright')
|
|
56
|
+
console.log()
|
|
57
|
+
}
|
|
45
58
|
}
|
|
46
59
|
|
|
47
60
|
function ensureDir() {
|
|
@@ -335,10 +348,9 @@ function runMCP() {
|
|
|
335
348
|
const config = loadConfig()
|
|
336
349
|
|
|
337
350
|
if (!config) {
|
|
338
|
-
|
|
339
|
-
console.
|
|
340
|
-
|
|
341
|
-
return
|
|
351
|
+
// No config - exit with error (user needs to run setup first)
|
|
352
|
+
console.error('[suparank] No configuration found. Run: npx suparank setup')
|
|
353
|
+
process.exit(1)
|
|
342
354
|
}
|
|
343
355
|
|
|
344
356
|
// Find the MCP client script (modular version)
|
|
@@ -359,13 +371,15 @@ function runMCP() {
|
|
|
359
371
|
}
|
|
360
372
|
|
|
361
373
|
if (!mcpClientPath) {
|
|
362
|
-
|
|
374
|
+
console.error('[suparank] Error: mcp-client not found')
|
|
363
375
|
process.exit(1)
|
|
364
376
|
}
|
|
365
377
|
|
|
366
378
|
// Launch MCP client with config
|
|
379
|
+
// Use 'pipe' for stdin/stdout to properly handle MCP protocol
|
|
380
|
+
// stderr is inherited for logging
|
|
367
381
|
const child = spawn('node', [mcpClientPath, config.project_slug, config.api_key], {
|
|
368
|
-
stdio: 'inherit',
|
|
382
|
+
stdio: ['inherit', 'inherit', 'inherit'],
|
|
369
383
|
env: {
|
|
370
384
|
...process.env,
|
|
371
385
|
SUPARANK_API_URL: config.api_url
|
|
@@ -373,7 +387,7 @@ function runMCP() {
|
|
|
373
387
|
})
|
|
374
388
|
|
|
375
389
|
child.on('error', (err) => {
|
|
376
|
-
console.error('Failed to start MCP client:', err.message)
|
|
390
|
+
console.error('[suparank] Failed to start MCP client:', err.message)
|
|
377
391
|
process.exit(1)
|
|
378
392
|
})
|
|
379
393
|
|