@trading-boy/cli 1.11.0 → 2.0.0

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 (83) hide show
  1. package/README.md +50 -22
  2. package/dist/api-client.d.ts +4 -7
  3. package/dist/api-client.js +8 -13
  4. package/dist/cli.bundle.js +1977 -33976
  5. package/dist/credentials.js +1 -1
  6. package/dist/index.d.ts +0 -28
  7. package/dist/index.js +0 -24
  8. package/dist/logger.d.ts +8 -0
  9. package/dist/logger.js +12 -0
  10. package/dist/utils.js +3 -3
  11. package/package.json +20 -5
  12. package/dist/cli.d.ts +0 -5
  13. package/dist/cli.js +0 -157
  14. package/dist/commands/agent-cmd.d.ts +0 -9
  15. package/dist/commands/agent-cmd.js +0 -572
  16. package/dist/commands/audit.d.ts +0 -18
  17. package/dist/commands/audit.js +0 -73
  18. package/dist/commands/behavioral.d.ts +0 -73
  19. package/dist/commands/behavioral.js +0 -349
  20. package/dist/commands/benchmark-cmd.d.ts +0 -3
  21. package/dist/commands/benchmark-cmd.js +0 -191
  22. package/dist/commands/billing.d.ts +0 -12
  23. package/dist/commands/billing.js +0 -142
  24. package/dist/commands/catalysts.d.ts +0 -17
  25. package/dist/commands/catalysts.js +0 -151
  26. package/dist/commands/coaching-cmd.d.ts +0 -16
  27. package/dist/commands/coaching-cmd.js +0 -222
  28. package/dist/commands/config-cmd.d.ts +0 -30
  29. package/dist/commands/config-cmd.js +0 -515
  30. package/dist/commands/connect-chatgpt.d.ts +0 -5
  31. package/dist/commands/connect-chatgpt.js +0 -293
  32. package/dist/commands/connect-claude.d.ts +0 -5
  33. package/dist/commands/connect-claude.js +0 -280
  34. package/dist/commands/context.d.ts +0 -41
  35. package/dist/commands/context.js +0 -405
  36. package/dist/commands/cron-cmd.d.ts +0 -3
  37. package/dist/commands/cron-cmd.js +0 -305
  38. package/dist/commands/decisions.d.ts +0 -57
  39. package/dist/commands/decisions.js +0 -364
  40. package/dist/commands/edge-cmd.d.ts +0 -78
  41. package/dist/commands/edge-cmd.js +0 -183
  42. package/dist/commands/edge-guard-cmd.d.ts +0 -36
  43. package/dist/commands/edge-guard-cmd.js +0 -169
  44. package/dist/commands/events.d.ts +0 -3
  45. package/dist/commands/events.js +0 -117
  46. package/dist/commands/infra.d.ts +0 -24
  47. package/dist/commands/infra.js +0 -137
  48. package/dist/commands/journal.d.ts +0 -3
  49. package/dist/commands/journal.js +0 -302
  50. package/dist/commands/login.d.ts +0 -18
  51. package/dist/commands/login.js +0 -127
  52. package/dist/commands/logout.d.ts +0 -8
  53. package/dist/commands/logout.js +0 -108
  54. package/dist/commands/narratives.d.ts +0 -3
  55. package/dist/commands/narratives.js +0 -259
  56. package/dist/commands/onboarding.d.ts +0 -7
  57. package/dist/commands/onboarding.js +0 -298
  58. package/dist/commands/query.d.ts +0 -32
  59. package/dist/commands/query.js +0 -135
  60. package/dist/commands/replay-cmd.d.ts +0 -43
  61. package/dist/commands/replay-cmd.js +0 -184
  62. package/dist/commands/review.d.ts +0 -3
  63. package/dist/commands/review.js +0 -443
  64. package/dist/commands/risk.d.ts +0 -47
  65. package/dist/commands/risk.js +0 -158
  66. package/dist/commands/social.d.ts +0 -43
  67. package/dist/commands/social.js +0 -318
  68. package/dist/commands/soul-wizard.d.ts +0 -29
  69. package/dist/commands/soul-wizard.js +0 -155
  70. package/dist/commands/strategy-cmd.d.ts +0 -44
  71. package/dist/commands/strategy-cmd.js +0 -340
  72. package/dist/commands/subscribe.d.ts +0 -78
  73. package/dist/commands/subscribe.js +0 -552
  74. package/dist/commands/suggestions-cmd.d.ts +0 -24
  75. package/dist/commands/suggestions-cmd.js +0 -148
  76. package/dist/commands/thesis-cmd.d.ts +0 -3
  77. package/dist/commands/thesis-cmd.js +0 -129
  78. package/dist/commands/trader.d.ts +0 -30
  79. package/dist/commands/trader.js +0 -971
  80. package/dist/commands/watch.d.ts +0 -16
  81. package/dist/commands/watch.js +0 -104
  82. package/dist/commands/whoami.d.ts +0 -14
  83. package/dist/commands/whoami.js +0 -105
@@ -1,16 +0,0 @@
1
- import { Command } from 'commander';
2
- export interface WatchState {
3
- timer: ReturnType<typeof setInterval> | null;
4
- running: boolean;
5
- }
6
- /**
7
- * Start a watch loop that polls and re-renders at the given interval.
8
- * Returns a WatchState with a cleanup handle.
9
- */
10
- export declare function startWatchLoop(symbol: string, intervalSeconds: number, renderFn?: (symbol: string) => Promise<unknown>): WatchState;
11
- /**
12
- * Stop the watch loop and clean up resources.
13
- */
14
- export declare function stopWatchLoop(state: WatchState): void;
15
- export declare function registerWatchCommand(program: Command): void;
16
- //# sourceMappingURL=watch.d.ts.map
@@ -1,104 +0,0 @@
1
- import { Option } from 'commander';
2
- import chalk from 'chalk';
3
- import { createLogger } from '@trading-boy/core';
4
- import { formatContextOutput } from './context.js';
5
- import { apiRequest } from '../api-client.js';
6
- // ─── Logger ───
7
- const logger = createLogger('cli-watch');
8
- // ─── Default intervals ───
9
- const DEFAULT_INTERVAL_SECONDS = 10;
10
- const DEFAULT_CONTEXT_INTERVAL_SECONDS = 60;
11
- /**
12
- * Render a single watch cycle via remote API.
13
- */
14
- async function renderCycleRemote(symbol) {
15
- try {
16
- const pkg = await apiRequest(`/api/v1/tokens/${encodeURIComponent(symbol.toUpperCase())}/context`);
17
- process.stdout.write('\x1B[2J\x1B[0f');
18
- console.log(formatContextOutput(pkg));
19
- console.log(chalk.dim(` Watching ${symbol.toUpperCase()} — refreshing every few seconds. Press Ctrl+C to stop.`));
20
- console.log(chalk.dim(` Last updated: ${new Date().toLocaleString()}`));
21
- console.log('');
22
- return pkg;
23
- }
24
- catch (error) {
25
- const message = error instanceof Error ? error.message : String(error);
26
- logger.error({ error: message }, 'Watch cycle failed');
27
- console.error(chalk.red(`Error: ${message}`));
28
- return null;
29
- }
30
- }
31
- /**
32
- * Start a watch loop that polls and re-renders at the given interval.
33
- * Returns a WatchState with a cleanup handle.
34
- */
35
- export function startWatchLoop(symbol, intervalSeconds, renderFn) {
36
- const state = { timer: null, running: true };
37
- const render = renderFn ?? renderCycleRemote;
38
- // Initial render
39
- void render(symbol);
40
- // Set up polling interval
41
- state.timer = setInterval(() => {
42
- if (state.running) {
43
- void render(symbol);
44
- }
45
- }, intervalSeconds * 1000);
46
- return state;
47
- }
48
- /**
49
- * Stop the watch loop and clean up resources.
50
- */
51
- export function stopWatchLoop(state) {
52
- state.running = false;
53
- if (state.timer) {
54
- clearInterval(state.timer);
55
- state.timer = null;
56
- }
57
- }
58
- // ─── Command Registration ───
59
- export function registerWatchCommand(program) {
60
- program
61
- .command('watch <symbol>')
62
- .description('Watch token data with periodic refresh')
63
- .option('-i, --interval <seconds>', 'Refresh interval in seconds', (v) => parseInt(v, 10))
64
- .option('-c, --context', 'Watch full ContextPackage (default interval: 60s)')
65
- .addOption(new Option('--format <format>', 'Output format').choices(['text', 'json']).default('text'))
66
- .action(async (symbol, options) => {
67
- const useContext = options.context === true;
68
- const defaultInterval = useContext ? DEFAULT_CONTEXT_INTERVAL_SECONDS : DEFAULT_INTERVAL_SECONDS;
69
- const intervalSeconds = options.interval ?? defaultInterval;
70
- if (intervalSeconds < 1) {
71
- console.error(chalk.red('Error: Interval must be at least 1 second'));
72
- process.exitCode = 1;
73
- return;
74
- }
75
- const mode = useContext ? 'context' : 'query';
76
- const isJson = options.format === 'json';
77
- logger.info({ symbol, intervalSeconds, mode }, 'Starting watch mode');
78
- const renderFn = isJson
79
- ? async (sym) => {
80
- try {
81
- const pkg = await apiRequest(`/api/v1/tokens/${encodeURIComponent(sym.toUpperCase())}/context`);
82
- console.log(JSON.stringify({ watchedAt: new Date().toISOString(), symbol: sym.toUpperCase(), ...pkg }, null, 2));
83
- return pkg;
84
- }
85
- catch (error) {
86
- console.log(JSON.stringify({ error: error instanceof Error ? error.message : String(error), timestamp: new Date().toISOString() }));
87
- return null;
88
- }
89
- }
90
- : renderCycleRemote;
91
- const state = startWatchLoop(symbol, intervalSeconds, renderFn);
92
- // Clean exit on SIGINT (Ctrl+C)
93
- const cleanup = () => {
94
- logger.info('Watch mode stopped by user');
95
- stopWatchLoop(state);
96
- console.log('');
97
- console.log(chalk.dim(' Watch mode stopped.'));
98
- process.exit(0);
99
- };
100
- process.on('SIGINT', cleanup);
101
- process.on('SIGTERM', cleanup);
102
- });
103
- }
104
- //# sourceMappingURL=watch.js.map
@@ -1,14 +0,0 @@
1
- import { Command } from 'commander';
2
- export interface WhoamiResult {
3
- authenticated: boolean;
4
- email?: string;
5
- plan?: string;
6
- keyId?: string;
7
- redactedKey?: string;
8
- storageMethod?: string;
9
- storedAt?: string;
10
- }
11
- export declare function executeWhoami(): Promise<WhoamiResult>;
12
- export declare function formatWhoamiOutput(result: WhoamiResult): string;
13
- export declare function registerWhoamiCommand(program: Command): void;
14
- //# sourceMappingURL=whoami.d.ts.map
@@ -1,105 +0,0 @@
1
- import { Option } from 'commander';
2
- import chalk from 'chalk';
3
- import { createLogger } from '@trading-boy/core';
4
- import { loadCredentials, redactApiKey } from '../credentials.js';
5
- import { getApiBase } from '../api-client.js';
6
- const logger = createLogger('cli-whoami');
7
- // ─── Whoami Logic ───
8
- export async function executeWhoami() {
9
- // Check env var first (matches resolveApiKey priority)
10
- const envKey = process.env.TRADING_BOY_API_KEY;
11
- if (envKey) {
12
- return {
13
- authenticated: true,
14
- redactedKey: redactApiKey(envKey),
15
- storageMethod: 'TRADING_BOY_API_KEY env var',
16
- };
17
- }
18
- const creds = await loadCredentials();
19
- if (!creds) {
20
- return { authenticated: false };
21
- }
22
- return {
23
- authenticated: true,
24
- email: creds.email,
25
- plan: creds.plan,
26
- keyId: creds.keyId,
27
- redactedKey: redactApiKey(creds.apiKey),
28
- storageMethod: creds.storageMethod,
29
- storedAt: creds.storedAt,
30
- };
31
- }
32
- // ─── Formatter ───
33
- export function formatWhoamiOutput(result) {
34
- const lines = [];
35
- lines.push('');
36
- if (!result.authenticated) {
37
- lines.push(chalk.dim(' Not authenticated. Run `trading-boy login` or `trading-boy subscribe` to get started.'));
38
- lines.push('');
39
- return lines.join('\n');
40
- }
41
- lines.push(chalk.bold.cyan(' Authenticated'));
42
- lines.push(chalk.gray(' ' + '─'.repeat(40)));
43
- lines.push('');
44
- if (result.email) {
45
- lines.push(` ${chalk.gray('Account:')} ${result.email}`);
46
- }
47
- if (result.plan) {
48
- lines.push(` ${chalk.gray('Plan:')} ${result.plan}`);
49
- }
50
- if (result.keyId) {
51
- lines.push(` ${chalk.gray('Key ID:')} ${result.keyId}`);
52
- }
53
- if (result.redactedKey) {
54
- lines.push(` ${chalk.gray('Key:')} ${result.redactedKey}`);
55
- }
56
- if (result.storageMethod) {
57
- lines.push(` ${chalk.gray('Storage:')} ${result.storageMethod}`);
58
- }
59
- if (result.storedAt) {
60
- const date = new Date(result.storedAt).toLocaleString();
61
- lines.push(` ${chalk.gray('Since:')} ${date}`);
62
- }
63
- lines.push(` ${chalk.gray('API:')} ${getApiBase()}`);
64
- lines.push('');
65
- return lines.join('\n');
66
- }
67
- // ─── Command Registration ───
68
- export function registerWhoamiCommand(program) {
69
- program
70
- .command('whoami')
71
- .description('Show current authentication status')
72
- .addOption(new Option('--format <format>', 'Output format').choices(['text', 'json']).default('text'))
73
- .addOption(new Option('--show-key', 'Show full API key (for Telegram setup)'))
74
- .action(async (options) => {
75
- try {
76
- const result = await executeWhoami();
77
- // Show full key if requested
78
- if (options.showKey && result.authenticated) {
79
- const envKey = process.env.TRADING_BOY_API_KEY;
80
- if (envKey) {
81
- console.log(envKey);
82
- return;
83
- }
84
- const creds = await loadCredentials();
85
- if (creds) {
86
- console.log(creds.apiKey);
87
- return;
88
- }
89
- }
90
- if (options.format === 'json') {
91
- console.log(JSON.stringify({ ...result, apiUrl: getApiBase() }, null, 2));
92
- }
93
- else {
94
- console.log(formatWhoamiOutput(result));
95
- }
96
- }
97
- catch (error) {
98
- const message = error instanceof Error ? error.message : String(error);
99
- logger.error({ error: message }, 'Whoami failed');
100
- console.error(chalk.red(` Error: ${message}`));
101
- process.exitCode = 1;
102
- }
103
- });
104
- }
105
- //# sourceMappingURL=whoami.js.map