sigrank-mcp 0.6.6 → 0.6.8

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.
Files changed (2) hide show
  1. package/cli.mjs +20 -27
  2. package/package.json +1 -1
package/cli.mjs CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  import { callTool, DEFAULT_API_BASE } from './tools.mjs'
24
24
  import { execSync } from 'child_process'
25
- import { existsSync, readFileSync } from 'fs'
25
+ import { existsSync, readFileSync, writeFileSync } from 'fs'
26
26
  import os from 'os'
27
27
  import path from 'path'
28
28
 
@@ -441,7 +441,7 @@ function tokscalePillars() {
441
441
  const claude = entries.filter(e =>
442
442
  e.client === 'claude' &&
443
443
  e.model !== '<synthetic>' && e.model !== 'unknown' &&
444
- e.provider !== 'unknown'
444
+ (e.input > 0 || e.output > 0)
445
445
  )
446
446
  const p = claude.reduce((acc, e) => ({
447
447
  input: acc.input + (e.input ?? 0),
@@ -477,34 +477,27 @@ function appPillars() {
477
477
  }
478
478
 
479
479
  function tokenDashPillars() {
480
- // query token-dashboard SQLite directly
481
480
  const dbPath = path.join(os.homedir(), '.claude', 'token-dashboard.db')
482
481
  if (!existsSync(dbPath)) return null
483
482
  try {
484
- const claudeFilter = `(model LIKE '%claude%' OR model LIKE '%fable%' OR model LIKE '%sonnet%' OR model LIKE '%opus%' OR model LIKE '%haiku%')`
485
- const now = new Date()
486
- const result = {}
487
- for (const [win, days] of [['7d', 7], ['30d', 30], ['90d', 90]]) {
488
- const since = new Date(now - days * 86400000).toISOString()
489
- const cmd = `python3 -c "
490
- import sqlite3, json
491
- db = sqlite3.connect('${dbPath}')
492
- r = db.execute('''SELECT SUM(input_tokens),SUM(output_tokens),SUM(cache_create_5m_tokens+cache_create_1h_tokens),SUM(cache_read_tokens) FROM messages WHERE timestamp>=? AND ${claudeFilter}''',(('${since}',))).fetchone()
493
- print(json.dumps({'input':r[0] or 0,'output':r[1] or 0,'cacheCreate':r[2] or 0,'cacheRead':r[3] or 0}))
494
- "`
495
- const raw = execSync(cmd, { timeout: 10000, stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim()
496
- result[win] = JSON.parse(raw)
497
- }
498
- // all-time
499
- const cmd = `python3 -c "
500
- import sqlite3, json
501
- db = sqlite3.connect('${dbPath}')
502
- r = db.execute('SELECT SUM(input_tokens),SUM(output_tokens),SUM(cache_create_5m_tokens+cache_create_1h_tokens),SUM(cache_read_tokens) FROM messages WHERE ${claudeFilter}').fetchone()
503
- print(json.dumps({'input':r[0] or 0,'output':r[1] or 0,'cacheCreate':r[2] or 0,'cacheRead':r[3] or 0}))
504
- "`
505
- const raw = execSync(cmd, { timeout: 10000, stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim()
506
- result['all'] = JSON.parse(raw)
507
- return result
483
+ const tmpScript = path.join(os.tmpdir(), 'sigrank_td_query.py')
484
+ writeFileSync(tmpScript, `
485
+ import sqlite3, json, sys
486
+ from datetime import datetime, timezone, timedelta
487
+ db = sqlite3.connect(sys.argv[1])
488
+ cf = "(model LIKE '%claude%' OR model LIKE '%fable%' OR model LIKE '%sonnet%' OR model LIKE '%opus%' OR model LIKE '%haiku%')"
489
+ out = {}
490
+ for win, days in [('7d',7),('30d',30),('90d',90)]:
491
+ since = (datetime.now(timezone.utc) - timedelta(days=days)).isoformat()
492
+ r = db.execute(f"SELECT SUM(input_tokens),SUM(output_tokens),SUM(cache_create_5m_tokens+cache_create_1h_tokens),SUM(cache_read_tokens) FROM messages WHERE timestamp>=? AND {cf}",(since,)).fetchone()
493
+ out[win] = {'input':r[0] or 0,'output':r[1] or 0,'cacheCreate':r[2] or 0,'cacheRead':r[3] or 0}
494
+ r = db.execute(f"SELECT SUM(input_tokens),SUM(output_tokens),SUM(cache_create_5m_tokens+cache_create_1h_tokens),SUM(cache_read_tokens) FROM messages WHERE {cf}").fetchone()
495
+ out['all'] = {'input':r[0] or 0,'output':r[1] or 0,'cacheCreate':r[2] or 0,'cacheRead':r[3] or 0}
496
+ print(json.dumps(out))
497
+ `)
498
+ const raw = execSync(`python3 "${tmpScript}" "${dbPath}"`,
499
+ { timeout: 15000, stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim()
500
+ return JSON.parse(raw)
508
501
  } catch {
509
502
  return null
510
503
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sigrank-mcp",
3
- "version": "0.6.6",
3
+ "version": "0.6.8",
4
4
  "description": "SigRank MCP server — the yield cascade + live leaderboard as MCP tools any agent can call",
5
5
  "type": "module",
6
6
  "bin": {