@invizi/cli 0.1.6 → 0.1.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.
@@ -1,3 +1,4 @@
1
+ import { parseArgs } from 'node:util';
1
2
  import { loadConfig } from '../config.js';
2
3
  const HLP_API = 'https://api.hyperliquid.xyz/info';
3
4
  const MAX_FILLS_PER_REQUEST = 2000;
@@ -171,6 +172,8 @@ function formatTable(stats, address, days) {
171
172
  lines.push(` Best: ${best.coin} ${formatUsd(best.netPnl)}`);
172
173
  if (worst.netPnl < 0)
173
174
  lines.push(` Worst: ${worst.coin} ${formatUsd(worst.netPnl)}`);
175
+ lines.push('');
176
+ lines.push(` Fetched: ${new Date().toISOString().replace('T', ' ').slice(0, 19)} UTC`);
174
177
  return lines.join('\n');
175
178
  }
176
179
  function formatCoinDetail(fills, coin) {
@@ -194,20 +197,55 @@ function formatCoinDetail(fills, coin) {
194
197
  }
195
198
  return lines.join('\n');
196
199
  }
200
+ function showHelp() {
201
+ console.log(`
202
+ invizi trades — Analyze past trades from Hyperliquid
203
+
204
+ Usage:
205
+ invizi trades [address] [options]
206
+
207
+ Options:
208
+ --days <n> Only show trades from the last N days
209
+ --coin <COIN> Show per-fill detail for a specific coin
210
+ --json Output as JSON (for piping to AI tools)
211
+ --help Show this help
212
+
213
+ Examples:
214
+ invizi trades P&L by coin (connected address)
215
+ invizi trades --days 30 Last 30 days only
216
+ invizi trades --coin SOL SOL fill-by-fill detail
217
+ invizi trades 0xABC...123 Analyze any public address
218
+ invizi trades --days 7 --json JSON output for AI tools
219
+
220
+ Data is read from the public Hyperliquid blockchain. No auth required.
221
+ `);
222
+ }
197
223
  export async function trades(args) {
224
+ const { values, positionals } = parseArgs({
225
+ args,
226
+ options: {
227
+ days: { type: 'string', short: 'd' },
228
+ coin: { type: 'string', short: 'c' },
229
+ json: { type: 'boolean', default: false },
230
+ help: { type: 'boolean', short: 'h', default: false },
231
+ },
232
+ allowPositionals: true,
233
+ strict: false,
234
+ });
235
+ if (values.help) {
236
+ showHelp();
237
+ return 0;
238
+ }
198
239
  const config = loadConfig();
199
- const address = args.find(a => /^0x[0-9a-fA-F]{40}$/.test(a)) || config.address;
240
+ const address = positionals.find(a => /^0x[0-9a-fA-F]{40}$/.test(a)) || config.address;
200
241
  if (!address) {
201
242
  console.error('No address found. Run: invizi connect <address>');
202
243
  console.error('Or pass directly: invizi trades 0x...');
203
244
  return 1;
204
245
  }
205
- // Parse flags
206
- const daysIdx = args.indexOf('--days');
207
- const days = daysIdx !== -1 ? parseInt(args[daysIdx + 1], 10) : null;
208
- const coinIdx = args.indexOf('--coin');
209
- const coinFilter = coinIdx !== -1 ? args[coinIdx + 1]?.toUpperCase() : null;
210
- const jsonMode = args.includes('--json');
246
+ const days = typeof values.days === 'string' ? parseInt(values.days, 10) : null;
247
+ const coinFilter = typeof values.coin === 'string' ? values.coin.toUpperCase() : null;
248
+ const jsonMode = values.json === true;
211
249
  // Calculate start time
212
250
  const now = Date.now();
213
251
  const startTime = days ? now - days * 24 * 60 * 60 * 1000 : 0;
package/dist/config.js CHANGED
@@ -22,8 +22,8 @@ export function loadConfig(configPath = getConfigPath()) {
22
22
  }
23
23
  }
24
24
  export function saveConfig(config, configPath = getConfigPath()) {
25
- mkdirSync(dirname(configPath), { recursive: true });
26
- writeFileSync(configPath, JSON.stringify(config, null, 2));
25
+ mkdirSync(dirname(configPath), { recursive: true, mode: 0o700 });
26
+ writeFileSync(configPath, JSON.stringify(config, null, 2), { mode: 0o600 });
27
27
  }
28
28
  export function resolveApiUrl(config, env = process.env) {
29
29
  return config.apiUrl || env.INVIZI_API_URL || env.INVIZI_SERVER || DEFAULT_API_URL;
package/dist/invizi.js CHANGED
@@ -8,17 +8,22 @@ function showLocalHelp() {
8
8
  console.log(`
9
9
  Invizi CLI
10
10
 
11
- Commands:
12
- invizi auth login Login via Auth0 device flow
13
- invizi auth status Show current auth identity
14
- invizi auth logout Clear local Auth0 session
15
- invizi connect <address> Connect a wallet address (auto-detects exchange)
16
- invizi trades Analyze past trades (P&L by coin)
17
- invizi setup Install skills into your AI tool
11
+ Data:
12
+ invizi context Market regime, macro, yields, options, HLP
13
+ invizi context -c SOL + coin data, flow, positions, trade history
14
+ invizi scout <COIN> Quick coin scan (price, funding, RSI, OBI)
15
+ invizi market BTC/ETH/SOL prices, fear/greed, funding extremes
16
+ invizi trades Analyze past trades P&L by coin (local)
17
+
18
+ Account:
19
+ invizi auth login Login
20
+ invizi auth status Show current identity
21
+ invizi connect <address> Connect a wallet address
22
+
23
+ Setup:
24
+ invizi setup Configure API + install AI skills
18
25
  invizi config Show current config
19
26
  invizi version Show CLI version
20
-
21
- Run invizi --help after login for the remote command list.
22
27
  `);
23
28
  }
24
29
  async function executeProtocol(args, authHeader) {
@@ -76,13 +81,12 @@ async function showRemoteHelp(authHeader) {
76
81
  console.log('No commands available for this user.');
77
82
  return;
78
83
  }
79
- console.log('Invizi Remote Commands\n');
80
84
  for (const cmd of commands) {
81
85
  const name = Array.isArray(cmd.tokens) ? cmd.tokens.join(' ') : cmd.id || '(unknown)';
82
86
  const desc = cmd.description || '';
83
- console.log(` ${name.padEnd(20)} ${desc}`);
87
+ console.log(` invizi ${name.padEnd(22)} ${desc}`);
84
88
  }
85
- console.log('\nUse: invizi <command> --help (if supported)');
89
+ console.log('');
86
90
  }
87
91
  async function executeRemote(args, options = {}) {
88
92
  const authHeader = await getAuthorizationHeader();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invizi/cli",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Invizi CLI",
5
5
  "type": "module",
6
6
  "bin": {