@spfunctions/cli 1.7.7 → 1.7.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.
@@ -2,8 +2,7 @@
2
2
  * sf query "iran oil"
3
3
  *
4
4
  * LLM-enhanced prediction market knowledge search. No auth required.
5
- * Searches Kalshi, Polymarket, and SimpleFunctions content.
6
- * Returns structured answer with markets, thesis, content, key factors.
5
+ * Searches Kalshi, Polymarket, X, traditional markets, and SimpleFunctions content.
7
6
  *
8
7
  * Usage:
9
8
  * sf query "iran oil" — Formatted output
@@ -3,8 +3,7 @@
3
3
  * sf query "iran oil"
4
4
  *
5
5
  * LLM-enhanced prediction market knowledge search. No auth required.
6
- * Searches Kalshi, Polymarket, and SimpleFunctions content.
7
- * Returns structured answer with markets, thesis, content, key factors.
6
+ * Searches Kalshi, Polymarket, X, traditional markets, and SimpleFunctions content.
8
7
  *
9
8
  * Usage:
10
9
  * sf query "iran oil" — Formatted output
@@ -49,59 +48,78 @@ async function queryCommand(q, opts) {
49
48
  }
50
49
  console.log();
51
50
  }
52
- // Markets — show each venue separately
53
- const formatMarket = (m) => {
54
- const venue = m.venue === 'kalshi' ? '\x1b[36mK\x1b[39m' : '\x1b[35mP\x1b[39m';
55
- const vol = m.volume > 1_000_000 ? `${(m.volume / 1_000_000).toFixed(1)}M` :
56
- m.volume > 1_000 ? `${(m.volume / 1_000).toFixed(0)}K` :
57
- String(Math.round(m.volume));
58
- const ticker = m.ticker ? ` ${m.ticker}` : '';
59
- console.log(` ${venue} ${String(m.price).padStart(3)}¢ vol ${vol.padStart(6)} ${m.title.slice(0, 55)}${ticker}`);
60
- };
51
+ // Markets — each venue separately
61
52
  const kalshiList = data.kalshi || [];
62
53
  const polyList = data.polymarket || [];
63
- const hasMarkets = kalshiList.length > 0 || polyList.length > 0;
64
- if (hasMarkets) {
54
+ if (kalshiList.length > 0 || polyList.length > 0) {
65
55
  console.log(' \x1b[1mMarkets\x1b[22m');
66
- if (kalshiList.length > 0) {
67
- for (const m of kalshiList.slice(0, 8))
68
- formatMarket(m);
56
+ for (const m of kalshiList.slice(0, 8)) {
57
+ const vol = fmtVol(m.volume);
58
+ console.log(` \x1b[36mK\x1b[39m ${String(m.price).padStart(3)}¢ vol ${vol.padStart(6)} ${m.title.slice(0, 55)}`);
69
59
  }
70
- if (polyList.length > 0) {
71
- if (kalshiList.length > 0)
72
- console.log(); // separator between venues
73
- for (const m of polyList.slice(0, 8))
74
- formatMarket(m);
60
+ if (kalshiList.length > 0 && polyList.length > 0)
61
+ console.log();
62
+ for (const m of polyList.slice(0, 8)) {
63
+ const vol = fmtVol(m.volume);
64
+ console.log(` \x1b[35mP\x1b[39m ${String(m.price).padStart(3)}¢ vol ${vol.padStart(6)} ${m.title.slice(0, 55)}`);
65
+ }
66
+ console.log();
67
+ }
68
+ // X posts
69
+ const xList = data.x || [];
70
+ if (xList.length > 0) {
71
+ console.log(' \x1b[1mX signals\x1b[22m');
72
+ for (const p of xList.slice(0, 5)) {
73
+ const engagement = `${fmtNum(p.likes)}♥ ${fmtNum(p.retweets)}⟲`;
74
+ console.log(` @${p.author} ${engagement} ${p.text.slice(0, 80)}`);
75
+ }
76
+ console.log();
77
+ }
78
+ // Traditional markets
79
+ const tradList = data.traditional || [];
80
+ if (tradList.length > 0) {
81
+ console.log(' \x1b[1mTraditional\x1b[22m');
82
+ for (const m of tradList) {
83
+ const sign = m.change1d >= 0 ? '+' : '';
84
+ console.log(` ${m.symbol.padEnd(5)} $${m.price} ${sign}${m.change1d} (${sign}${m.changePct}%) ${m.name}`);
75
85
  }
76
86
  console.log();
77
87
  }
78
88
  // Theses
79
89
  if (data.theses?.length > 0) {
80
- console.log(` \x1b[1mTheses\x1b[22m`);
90
+ console.log(' \x1b[1mTheses\x1b[22m');
81
91
  for (const t of data.theses.slice(0, 3)) {
82
92
  console.log(` ${t.confidence || '?'}% ${String(t.edges || 0).padStart(2)} edges ${t.title.slice(0, 50)}`);
83
93
  }
84
94
  console.log();
85
95
  }
86
- else if (data.thesis) {
87
- // Backward compat
88
- const t = data.thesis;
89
- console.log(` \x1b[1mThesis\x1b[22m`);
90
- console.log(` ${t.confidence}% confidence ${t.edges} edges /thesis/${t.slug}`);
91
- console.log();
92
- }
93
96
  // Content
94
97
  if (data.content?.length > 0) {
95
98
  console.log(' \x1b[1mContent\x1b[22m');
96
99
  for (const c of data.content.slice(0, 5)) {
97
100
  const type = c.type.padEnd(9);
98
- console.log(` \x1b[2m${type}\x1b[22m ${c.title.slice(0, 60)}`);
101
+ console.log(` \x1b[2m${type}\x1b[22m ${c.title.slice(0, 50)} \x1b[2m${c.url}\x1b[22m`);
99
102
  }
100
103
  console.log();
101
104
  }
102
- // Sources
103
- if (data.sources?.length > 0) {
104
- console.log(` \x1b[2mSources: ${data.sources.join(', ')}\x1b[22m`);
105
- console.log();
106
- }
105
+ // Meta
106
+ const meta = data.meta || {};
107
+ const sources = meta.sources || data.sources || [];
108
+ const latency = meta.latencyMs ? `${(meta.latencyMs / 1000).toFixed(1)}s` : '';
109
+ console.log(` \x1b[2mSources: ${sources.join(', ')}${latency ? ` (${latency})` : ''}\x1b[22m`);
110
+ console.log();
111
+ }
112
+ function fmtVol(v) {
113
+ if (v > 1_000_000)
114
+ return `${(v / 1_000_000).toFixed(1)}M`;
115
+ if (v > 1_000)
116
+ return `${(v / 1_000).toFixed(0)}K`;
117
+ return String(Math.round(v));
118
+ }
119
+ function fmtNum(n) {
120
+ if (n > 1_000_000)
121
+ return `${(n / 1_000_000).toFixed(1)}M`;
122
+ if (n > 1_000)
123
+ return `${(n / 1_000).toFixed(1)}K`;
124
+ return String(n);
107
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spfunctions/cli",
3
- "version": "1.7.7",
3
+ "version": "1.7.8",
4
4
  "description": "Prediction market intelligence CLI. Causal thesis model, 24/7 Kalshi/Polymarket scan, live orderbook, edge detection. Interactive agent mode with tool calling.",
5
5
  "bin": {
6
6
  "sf": "./dist/index.js"