enton-cli 0.1.0 → 0.1.2

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.
@@ -10,6 +10,7 @@ exports.interactiveMode = interactiveMode;
10
10
  const chalk_1 = __importDefault(require("chalk"));
11
11
  const ora_1 = __importDefault(require("ora"));
12
12
  const inquirer_1 = __importDefault(require("inquirer"));
13
+ const open_1 = __importDefault(require("open"));
13
14
  const client_1 = require("../api/client");
14
15
  const manager_1 = require("../config/manager");
15
16
  async function interactiveMode(options) {
@@ -104,6 +105,16 @@ async function handleCommand(command, client) {
104
105
  case 'clear':
105
106
  console.clear();
106
107
  break;
108
+ case 'login':
109
+ await handleLogin();
110
+ break;
111
+ case 'logout':
112
+ await handleLogout();
113
+ break;
114
+ case 'key':
115
+ case 'apikey':
116
+ await showApiKeyHelp();
117
+ break;
107
118
  case 'history':
108
119
  console.log(chalk_1.default.dim('Command history not yet implemented'));
109
120
  break;
@@ -118,26 +129,114 @@ async function handleCommand(command, client) {
118
129
  function showHelp() {
119
130
  console.log(`
120
131
  ${chalk_1.default.bold('Available Commands:')}
121
- ${chalk_1.default.cyan('/help')} - Show this help message
122
- ${chalk_1.default.cyan('/clear')} - Clear the screen
132
+ ${chalk_1.default.cyan('/login')} - Login to ENTON (opens browser)
133
+ ${chalk_1.default.cyan('/logout')} - Logout and clear API key
134
+ ${chalk_1.default.cyan('/key')} - Show API key setup help
123
135
  ${chalk_1.default.cyan('/status')} - Show connection status
124
- ${chalk_1.default.cyan('/history')} - Show command history
136
+ ${chalk_1.default.cyan('/clear')} - Clear the screen
137
+ ${chalk_1.default.cyan('/help')} - Show this help message
125
138
 
126
139
  ${chalk_1.default.bold('Query Examples:')}
127
- ${chalk_1.default.dim('What is the price of AAPL?')}
128
- ${chalk_1.default.dim('Get me news about Tesla')}
129
- ${chalk_1.default.dim('Analyze NVDA stock')}
130
- ${chalk_1.default.dim('Show my portfolio')}
131
- ${chalk_1.default.dim('Buy 10 shares of MSFT')}
140
+ ${chalk_1.default.dim('price of AAPL')}
141
+ ${chalk_1.default.dim('news about Tesla')}
142
+ ${chalk_1.default.dim('analyze NVDA')}
143
+ ${chalk_1.default.dim('show my portfolio')}
144
+ ${chalk_1.default.dim('buy 10 shares of MSFT')}
132
145
 
133
146
  ${chalk_1.default.bold('Exit:')}
134
147
  Type ${chalk_1.default.cyan('exit')}, ${chalk_1.default.cyan('quit')}, or ${chalk_1.default.cyan('q')}
135
148
  `);
136
149
  }
150
+ async function handleLogin() {
151
+ console.log(chalk_1.default.bold('\nšŸ” Login to ENTON\n'));
152
+ const config = (0, manager_1.getConfig)();
153
+ const developerUrl = `${config.apiUrl}/developer`;
154
+ console.log(chalk_1.default.dim('Opening browser to get your API key...\n'));
155
+ try {
156
+ await (0, open_1.default)(developerUrl);
157
+ console.log(chalk_1.default.cyan(`If browser doesn't open, visit:\n${developerUrl}\n`));
158
+ }
159
+ catch {
160
+ console.log(chalk_1.default.cyan(`Open this URL in your browser:\n${developerUrl}\n`));
161
+ }
162
+ console.log(chalk_1.default.bold('Steps:'));
163
+ console.log(' 1. Sign in if prompted');
164
+ console.log(' 2. Click "Create API Key"');
165
+ console.log(' 3. Copy your key (starts with ent_live_ or ent_test_)\n');
166
+ const { apiKey } = await inquirer_1.default.prompt([
167
+ {
168
+ type: 'password',
169
+ name: 'apiKey',
170
+ message: 'Paste your API key:',
171
+ mask: '*',
172
+ validate: (input) => {
173
+ if (!input)
174
+ return 'API key is required';
175
+ if (!input.startsWith('ent_'))
176
+ return 'API key should start with ent_live_ or ent_test_';
177
+ return true;
178
+ }
179
+ }
180
+ ]);
181
+ const spinner = (0, ora_1.default)('Verifying API key...').start();
182
+ try {
183
+ // Save the key
184
+ await (0, manager_1.saveApiKey)(apiKey);
185
+ // Test it
186
+ const client = new client_1.EntonAPIClient(config.apiUrl, apiKey);
187
+ await client.query('hello', { stream: false });
188
+ spinner.succeed(chalk_1.default.green('Successfully logged in!'));
189
+ console.log(chalk_1.default.dim('\nYour API key is saved. You can now use ENTON.\n'));
190
+ }
191
+ catch (error) {
192
+ spinner.fail(chalk_1.default.red('Login failed'));
193
+ console.log(chalk_1.default.dim(` ${error.message}\n`));
194
+ console.log(chalk_1.default.dim('Make sure you copied the full API key from enton.ai/developer\n'));
195
+ }
196
+ }
197
+ async function handleLogout() {
198
+ const { confirm } = await inquirer_1.default.prompt([
199
+ {
200
+ type: 'confirm',
201
+ name: 'confirm',
202
+ message: 'Are you sure you want to logout?',
203
+ default: false
204
+ }
205
+ ]);
206
+ if (confirm) {
207
+ await (0, manager_1.deleteApiKey)();
208
+ console.log(chalk_1.default.green('\nāœ… Logged out successfully\n'));
209
+ }
210
+ }
211
+ async function showApiKeyHelp() {
212
+ const config = (0, manager_1.getConfig)();
213
+ console.log(`
214
+ ${chalk_1.default.bold('šŸ”‘ API Key Setup')}
215
+
216
+ ${chalk_1.default.bold('Option 1: Interactive login')}
217
+ Type ${chalk_1.default.cyan('/login')} to open browser and authenticate
218
+
219
+ ${chalk_1.default.bold('Option 2: Environment variable')}
220
+ ${chalk_1.default.dim('export ENTON_API_KEY=ent_live_xxxxxxxxxxxxx')}
221
+
222
+ ${chalk_1.default.bold('Option 3: Config file')}
223
+ Your config is stored at: ${chalk_1.default.cyan('~/.enton/config.json')}
224
+
225
+ ${chalk_1.default.bold('Get your API key:')}
226
+ Visit ${chalk_1.default.cyan(`${config.apiUrl}/developer`)} to create API keys
227
+
228
+ ${chalk_1.default.bold('Current status:')}
229
+ ${config.apiKey ? chalk_1.default.green('āœ… API key configured') : chalk_1.default.yellow('āš ļø No API key set')}
230
+ `);
231
+ }
137
232
  async function showStatus(client) {
233
+ const config = (0, manager_1.getConfig)();
138
234
  console.log(`
139
235
  ${chalk_1.default.bold('Connection Status:')}
140
- API URL: ${chalk_1.default.cyan(client.baseUrl)}
141
- Auth: ${client.isAuthenticated() ? chalk_1.default.green('āœ… Connected') : chalk_1.default.yellow('āš ļø Not authenticated')}
236
+ API URL: ${chalk_1.default.cyan(client.baseUrl)}
237
+ API Key: ${config.apiKey ? chalk_1.default.green('āœ… ' + config.apiKey.substring(0, 12) + '...') : chalk_1.default.yellow('āš ļø Not set')}
238
+ Auth: ${client.isAuthenticated() ? chalk_1.default.green('āœ… Authenticated') : chalk_1.default.yellow('āš ļø Not authenticated')}
239
+
240
+ ${chalk_1.default.dim('Use /login to authenticate or /key for help')}
142
241
  `);
143
242
  }
package/dist/index.js CHANGED
@@ -9,6 +9,39 @@
9
9
  * enton auth login # Authenticate with ENTON
10
10
  * enton watch AAPL,TSLA # Watch mode for real-time prices
11
11
  */
12
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
25
+ }) : function(o, v) {
26
+ o["default"] = v;
27
+ });
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
12
45
  var __importDefault = (this && this.__importDefault) || function (mod) {
13
46
  return (mod && mod.__esModule) ? mod : { "default": mod };
14
47
  };
@@ -21,6 +54,12 @@ const watch_1 = require("./commands/watch");
21
54
  const config_1 = require("./commands/config");
22
55
  const manager_1 = require("./config/manager");
23
56
  const chalk_1 = __importDefault(require("chalk"));
57
+ const fs = __importStar(require("fs"));
58
+ const path = __importStar(require("path"));
59
+ // Get version from package.json
60
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
61
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
62
+ const VERSION = packageJson.version;
24
63
  const program = new commander_1.Command();
25
64
  // ASCII art banner
26
65
  const banner = `
@@ -31,7 +70,7 @@ ${chalk_1.default.cyan('ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•
31
70
  program
32
71
  .name('enton')
33
72
  .description('AI-powered financial assistant - like Claude Code, but for finance')
34
- .version('0.1.0')
73
+ .version(VERSION)
35
74
  .option('-j, --json', 'Output response as JSON')
36
75
  .option('-q, --quiet', 'Minimal output (no banner)')
37
76
  .argument('[query...]', 'Direct query to ENTON')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "enton-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "ENTON - AI-powered financial assistant CLI. Like Claude Code, but for finance.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",