@lanonasis/cli 1.4.1 → 1.5.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.
@@ -1,548 +1,215 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from 'commander';
3
- import chalk from 'chalk';
4
- import { config } from 'dotenv';
5
- import { initCommand } from './commands/init.js';
6
- import { loginCommand } from './commands/auth.js';
7
- import { memoryCommands } from './commands/memory.js';
8
- import { topicCommands } from './commands/topics.js';
9
- import { configCommands } from './commands/config.js';
10
- import { orgCommands } from './commands/organization.js';
11
- import { mcpCommands } from './commands/mcp.js';
12
- import apiKeysCommand from './commands/api-keys.js';
13
- import { CLIConfig } from './utils/config.js';
14
- import { getMCPClient } from './utils/mcp-client.js';
15
- // Load environment variables
16
- config();
17
- // Enhanced color scheme (VPS-style)
18
- const colors = {
19
- primary: chalk.blue.bold,
20
- success: chalk.green,
21
- warning: chalk.yellow,
22
- error: chalk.red,
23
- info: chalk.cyan,
24
- accent: chalk.magenta,
25
- muted: chalk.gray,
26
- highlight: chalk.white.bold
27
- };
3
+ import { readFileSync } from 'fs';
4
+ import { join, dirname } from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+ // Read package.json
9
+ const packagePath = join(__dirname, '..', 'package.json');
10
+ const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'));
28
11
  const program = new Command();
29
- // CLI Configuration
30
- const cliConfig = new CLIConfig();
31
12
  program
32
13
  .name('lanonasis')
33
- .alias('memory')
34
- .alias('maas')
35
- .description(colors.info('🧠 LanOnasis Enterprise CLI - Memory as a Service, API Management & Infrastructure Orchestration'))
36
- .version('1.2.0', '-v, --version', 'display version number')
37
- .option('-V, --verbose', 'enable verbose logging')
38
- .option('--api-url <url>', 'override API URL')
39
- .option('--output <format>', 'output format (json, table, yaml)', 'table')
40
- .option('--no-mcp', 'disable MCP and use direct API')
41
- .hook('preAction', async (thisCommand, actionCommand) => {
42
- const opts = thisCommand.opts();
43
- if (opts.verbose) {
44
- process.env.CLI_VERBOSE = 'true';
45
- }
46
- if (opts.apiUrl) {
47
- process.env.MEMORY_API_URL = opts.apiUrl;
48
- }
49
- process.env.CLI_OUTPUT_FORMAT = opts.output;
50
- // Auto-initialize MCP unless disabled
51
- if (opts.mcp !== false && !['init', 'auth', 'login', 'mcp', 'health', 'status'].includes(actionCommand.name())) {
52
- try {
53
- const client = getMCPClient();
54
- if (!client.isConnectedToServer()) {
55
- const useRemote = await cliConfig.isAuthenticated();
56
- await client.connect({ useRemote });
57
- if (process.env.CLI_VERBOSE === 'true') {
58
- console.log(colors.muted(`MCP connected (${useRemote ? 'remote' : 'local'})`));
59
- }
60
- }
61
- }
62
- catch (error) {
63
- if (process.env.CLI_VERBOSE === 'true') {
64
- console.log(colors.warning('MCP auto-connect failed, using direct API'));
65
- console.log(colors.muted(`Error: ${error instanceof Error ? error.message : String(error)}`));
66
- }
67
- }
68
- }
69
- });
70
- // Enhanced global error handler
71
- process.on('uncaughtException', (error) => {
72
- console.error(colors.error('āœ– Unexpected error:'), error.message);
73
- if (process.env.CLI_VERBOSE === 'true') {
74
- console.error(colors.muted(error.stack || ''));
75
- }
76
- process.exit(1);
77
- });
78
- process.on('unhandledRejection', (reason, promise) => {
79
- console.error(colors.error('āœ– Unhandled promise rejection:'), reason);
80
- if (process.env.CLI_VERBOSE === 'true') {
81
- console.error(colors.muted(String(promise)));
82
- }
83
- process.exit(1);
84
- });
85
- // Enhanced welcome message
86
- const showWelcome = () => {
87
- console.log();
88
- console.log(colors.primary('šŸš€ LanOnasis Enterprise CLI v1.2.0'));
89
- console.log(colors.info('━'.repeat(50)));
90
- console.log(colors.highlight('Enterprise-grade Memory as a Service, API Management & Infrastructure Orchestration'));
91
- console.log();
92
- console.log(colors.warning('šŸ Quick Start:'));
93
- console.log(` ${colors.success('lanonasis init')} ${colors.muted('# Initialize CLI configuration')}`);
94
- console.log(` ${colors.success('lanonasis login')} ${colors.muted('# Authenticate with your account')}`);
95
- console.log(` ${colors.success('lanonasis health')} ${colors.muted('# Check system health')}`);
96
- console.log(` ${colors.success('lanonasis --help')} ${colors.muted('# Show all available commands')}`);
97
- console.log();
98
- console.log(colors.info('šŸ“š Documentation: https://api.lanonasis.com/docs'));
99
- console.log(colors.info('🌐 Dashboard: https://api.lanonasis.com/dashboard'));
100
- console.log();
101
- };
102
- // Enhanced system health check
103
- const healthCheck = async () => {
104
- console.log(colors.primary('šŸ„ LanOnasis System Health Check'));
105
- console.log(colors.info('═'.repeat(40)));
106
- console.log();
107
- // Authentication status
108
- process.stdout.write('Authentication status: ');
109
- const isAuth = await cliConfig.isAuthenticated();
110
- if (isAuth) {
111
- console.log(colors.success('āœ… Authenticated'));
112
- const user = await cliConfig.getCurrentUser();
113
- if (user) {
114
- console.log(` Email: ${colors.highlight(user.email)}`);
115
- console.log(` Organization: ${colors.highlight(user.organization_id)}`);
116
- console.log(` Plan: ${colors.accent(user.plan)}`);
117
- }
118
- }
119
- else {
120
- console.log(colors.error('āŒ Not authenticated'));
121
- console.log(colors.muted(' Run: lanonasis login'));
122
- }
123
- // API connectivity
124
- console.log();
125
- process.stdout.write('API connectivity: ');
126
- try {
127
- const apiUrl = cliConfig.getApiUrl();
128
- console.log(colors.success('āœ… Connected'));
129
- console.log(` Endpoint: ${colors.highlight(apiUrl)}`);
130
- }
131
- catch (error) {
132
- console.log(colors.error('āŒ Failed'));
133
- console.log(colors.muted(` Error: ${error instanceof Error ? error.message : 'Unknown error'}`));
134
- }
135
- // MCP status
136
- console.log();
137
- process.stdout.write('MCP Server status: ');
138
- try {
139
- const client = getMCPClient();
140
- if (client.isConnectedToServer()) {
141
- console.log(colors.success('āœ… Connected'));
142
- }
143
- else {
144
- console.log(colors.warning('āš ļø Disconnected'));
145
- }
146
- }
147
- catch (error) {
148
- console.log(colors.error('āŒ Error'));
149
- console.log(colors.muted(` ${error instanceof Error ? error.message : 'Unknown error'}`));
150
- }
151
- // Configuration status
152
- console.log();
153
- process.stdout.write('Configuration: ');
154
- const configExists = await cliConfig.exists();
155
- if (configExists) {
156
- console.log(colors.success('āœ… Found'));
157
- console.log(` Location: ${colors.highlight(cliConfig.getConfigPath())}`);
158
- }
159
- else {
160
- console.log(colors.warning('āš ļø Not found'));
161
- console.log(colors.muted(' Run: lanonasis init'));
162
- }
163
- console.log();
164
- console.log(colors.info('šŸ’” For detailed diagnostics, run: lanonasis status --verbose'));
165
- };
166
- // Check if user is authenticated for protected commands
167
- const requireAuth = (command) => {
168
- command.hook('preAction', async () => {
169
- const isAuthenticated = await cliConfig.isAuthenticated();
170
- if (!isAuthenticated) {
171
- console.error(chalk.red('āœ– Authentication required'));
172
- console.log(chalk.yellow('Please run:'), chalk.white('memory login'));
173
- process.exit(1);
174
- }
175
- });
176
- };
177
- // Initialize command (no auth required)
14
+ .description('Lanonasis Enterprise CLI - Memory as a Service with MCP Integration')
15
+ .version(packageJson.version);
178
16
  program
179
17
  .command('init')
180
- .description('Initialize CLI configuration')
181
- .option('-f, --force', 'overwrite existing configuration')
182
- .action(initCommand);
183
- // Authentication commands (no auth required)
184
- const authCmd = program
185
- .command('auth')
186
- .alias('login')
187
- .description('Authentication commands');
188
- authCmd
189
- .command('login')
190
- .description('Login to your MaaS account')
191
- .option('-e, --email <email>', 'email address')
192
- .option('-p, --password <password>', 'password')
193
- .action(loginCommand);
194
- authCmd
195
- .command('logout')
196
- .description('Logout from your account')
197
- .action(async () => {
198
- await cliConfig.logout();
199
- console.log(chalk.green('āœ“ Logged out successfully'));
200
- });
201
- authCmd
202
- .command('status')
203
- .description('Show authentication status')
204
- .action(async () => {
205
- const isAuth = await cliConfig.isAuthenticated();
206
- const user = await cliConfig.getCurrentUser();
207
- if (isAuth && user) {
208
- console.log(chalk.green('āœ“ Authenticated'));
209
- console.log(`Email: ${user.email}`);
210
- console.log(`Organization: ${user.organization_id}`);
211
- console.log(`Plan: ${user.plan}`);
212
- }
213
- else {
214
- console.log(chalk.red('āœ– Not authenticated'));
215
- console.log(chalk.yellow('Run:'), chalk.white('memory login'));
216
- }
217
- });
218
- // MCP Commands (primary interface)
219
- mcpCommands(program);
220
- // Memory commands (require auth) - now MCP-powered by default
221
- const memoryCmd = program
222
- .command('memory')
223
- .alias('mem')
224
- .description('Memory management commands');
225
- requireAuth(memoryCmd);
226
- memoryCommands(memoryCmd);
227
- // Note: Memory commands are now MCP-powered when available
228
- // Topic commands (require auth)
229
- const topicCmd = program
230
- .command('topic')
231
- .alias('topics')
232
- .description('Topic management commands');
233
- requireAuth(topicCmd);
234
- topicCommands(topicCmd);
235
- // Configuration commands (require auth)
236
- const configCmd = program
237
- .command('config')
238
- .description('Configuration management');
239
- requireAuth(configCmd);
240
- configCommands(configCmd);
241
- // Organization commands (require auth)
242
- const orgCmd = program
243
- .command('org')
244
- .alias('organization')
245
- .description('Organization management');
246
- requireAuth(orgCmd);
247
- orgCommands(orgCmd);
248
- // API Key management commands (require auth)
249
- requireAuth(apiKeysCommand);
250
- program.addCommand(apiKeysCommand);
251
- // Dashboard management commands (require auth)
252
- const dashboardCmd = program
253
- .command('dashboard')
254
- .alias('dash')
255
- .description(colors.accent('šŸŽ›ļø Manage React dashboard deployment and configuration'));
256
- requireAuth(dashboardCmd);
257
- dashboardCmd
258
- .command('status')
259
- .description('Check dashboard deployment status')
260
- .action(async () => {
261
- console.log(colors.primary('šŸŽ›ļø Dashboard Status Check'));
262
- console.log(colors.info('━'.repeat(40)));
263
- console.log(`${colors.highlight('Dashboard URL:')} ${colors.success('https://api.lanonasis.com/dashboard')}`);
264
- console.log(`${colors.highlight('Status:')} ${colors.success('āœ… Deployed')}`);
265
- console.log(`${colors.highlight('Framework:')} ${colors.info('React + Vite + TypeScript')}`);
266
- console.log(`${colors.highlight('Hosting:')} ${colors.info('Netlify')}`);
267
- });
268
- dashboardCmd
269
- .command('logs')
270
- .description('View dashboard deployment logs')
271
- .action(() => {
272
- console.log(colors.info('Opening dashboard logs...'));
273
- console.log(colors.success('Dashboard logs: https://app.netlify.com/sites/lanonasis-dashboard/logs'));
274
- });
275
- // Documentation management commands (require auth)
276
- const docsCmd = program
277
- .command('documentation')
278
- .alias('doc')
279
- .description(colors.accent('šŸ“š Manage VitePress documentation deployment'));
280
- requireAuth(docsCmd);
281
- docsCmd
282
- .command('status')
283
- .description('Check documentation deployment status')
284
- .action(async () => {
285
- console.log(colors.primary('šŸ“š Documentation Status Check'));
286
- console.log(colors.info('━'.repeat(40)));
287
- console.log(`${colors.highlight('Docs URL:')} ${colors.success('https://api.lanonasis.com/docs')}`);
288
- console.log(`${colors.highlight('Status:')} ${colors.success('āœ… Deployed')}`);
289
- console.log(`${colors.highlight('Framework:')} ${colors.info('VitePress')}`);
290
- console.log(`${colors.highlight('Hosting:')} ${colors.info('Netlify')}`);
291
- });
292
- docsCmd
293
- .command('build')
294
- .description('Trigger documentation rebuild')
295
- .action(() => {
296
- console.log(colors.warning('⚔ Triggering documentation rebuild...'));
297
- console.log(colors.success('Documentation rebuild initiated via webhook'));
298
- });
299
- // SDK management commands (require auth)
300
- const sdkCmd = program
301
- .command('sdk')
302
- .description(colors.accent('šŸ”§ Manage SDK packages and distribution'));
303
- requireAuth(sdkCmd);
304
- sdkCmd
305
- .command('status')
306
- .description('Check SDK deployment status')
307
- .action(async () => {
308
- console.log(colors.primary('šŸ”§ SDK Status Check'));
309
- console.log(colors.info('━'.repeat(40)));
310
- console.log(`${colors.highlight('Memory Client SDK:')} ${colors.success('@lanonasis/memory-client@1.0.0')}`);
311
- console.log(`${colors.highlight('CLI Package:')} ${colors.success('@lanonasis/cli@1.2.0')}`);
312
- console.log(`${colors.highlight('NPM Registry:')} ${colors.success('āœ… Published')}`);
313
- console.log(`${colors.highlight('GitHub Packages:')} ${colors.success('āœ… Available')}`);
314
- });
315
- sdkCmd
316
- .command('versions')
317
- .description('List all available SDK versions')
18
+ .description('Initialize Lanonasis CLI configuration')
318
19
  .action(() => {
319
- console.log(colors.primary('šŸ“¦ Available SDK Versions'));
320
- console.log(colors.info('━'.repeat(40)));
321
- console.log(`${colors.accent('@lanonasis/memory-client:')} ${colors.success('1.0.0 (latest)')}`);
322
- console.log(`${colors.accent('@lanonasis/cli:')} ${colors.success('1.2.0 (latest)')}`);
323
- console.log(`${colors.accent('@lanonasis/memory-service:')} ${colors.success('1.0.0 (latest)')}`);
20
+ console.log('šŸš€ Lanonasis CLI v' + packageJson.version);
21
+ console.log('');
22
+ console.log('Initialize your Lanonasis Enterprise Platform:');
23
+ console.log('');
24
+ console.log('1. Set up your service endpoint:');
25
+ console.log(' lanonasis config set api-url https://your-lanonasis-service.com');
26
+ console.log('');
27
+ console.log('2. Authenticate:');
28
+ console.log(' lanonasis auth login');
29
+ console.log('');
30
+ console.log('3. Start managing your services:');
31
+ console.log(' lanonasis create -t "My Memory" -c "Content here"');
32
+ console.log(' lanonasis search "search query"');
33
+ console.log(' lanonasis list');
34
+ console.log('');
35
+ console.log('šŸ“– Documentation: https://github.com/lanonasis/cli');
36
+ console.log('🌐 Platform: https://lanonasis.com');
324
37
  });
325
- // REST API management commands (require auth)
326
- const apiCmd = program
327
- .command('api')
328
- .alias('rest')
329
- .description(colors.accent('🌐 Manage REST API endpoints and services'));
330
- requireAuth(apiCmd);
331
- apiCmd
38
+ program
332
39
  .command('status')
333
- .description('Check REST API health and endpoints')
334
- .action(async () => {
335
- console.log(colors.primary('🌐 REST API Status Check'));
336
- console.log(colors.info('━'.repeat(40)));
337
- console.log(`${colors.highlight('API Base URL:')} ${colors.success('https://api.lanonasis.com')}`);
338
- console.log(`${colors.highlight('Memory Service:')} ${colors.success('āœ… Active')}`);
339
- console.log(`${colors.highlight('Authentication:')} ${colors.success('āœ… Supabase Auth')}`);
340
- console.log(`${colors.highlight('Database:')} ${colors.success('āœ… Supabase PostgreSQL')}`);
341
- console.log(`${colors.highlight('MCP Endpoint:')} ${colors.success('āœ… /mcp/sse')}`);
342
- });
343
- apiCmd
344
- .command('endpoints')
345
- .description('List all available API endpoints')
40
+ .description('Show Lanonasis CLI status and configuration')
346
41
  .action(() => {
347
- console.log(colors.primary('šŸ›£ļø Available API Endpoints'));
348
- console.log(colors.info('━'.repeat(50)));
349
- console.log(`${colors.accent('POST')} ${colors.highlight('/auth/login')} - User authentication`);
350
- console.log(`${colors.accent('GET')} ${colors.highlight('/memories')} - List memories`);
351
- console.log(`${colors.accent('POST')} ${colors.highlight('/memories')} - Create memory`);
352
- console.log(`${colors.accent('GET')} ${colors.highlight('/memories/search')} - Search memories`);
353
- console.log(`${colors.accent('GET')} ${colors.highlight('/api-keys')} - List API keys`);
354
- console.log(`${colors.accent('POST')} ${colors.highlight('/api-keys')} - Create API key`);
355
- console.log(`${colors.accent('GET')} ${colors.highlight('/mcp/sse')} - MCP Server-Sent Events`);
356
- console.log(`${colors.accent('GET')} ${colors.highlight('/health')} - Health check`);
357
- });
358
- // Deployment management commands (require auth)
359
- const deployCmd = program
360
- .command('deploy')
361
- .alias('deployment')
362
- .description(colors.accent('šŸš€ Manage deployments and infrastructure'));
363
- requireAuth(deployCmd);
364
- deployCmd
365
- .command('status')
366
- .description('Check overall deployment status')
367
- .action(async () => {
368
- console.log(colors.primary('šŸš€ Deployment Status Overview'));
369
- console.log(colors.info('═'.repeat(50)));
370
- console.log();
371
- console.log(colors.highlight('🌐 Web Services:'));
372
- console.log(` Landing Page: ${colors.success('āœ… api.lanonasis.com')}`);
373
- console.log(` Dashboard: ${colors.success('āœ… api.lanonasis.com/dashboard')}`);
374
- console.log(` Documentation: ${colors.success('āœ… api.lanonasis.com/docs')}`);
375
- console.log();
376
- console.log(colors.highlight('šŸ”§ API Services:'));
377
- console.log(` Memory Service: ${colors.success('āœ… https://api.lanonasis.com')}`);
378
- console.log(` MCP Server: ${colors.success('āœ… /mcp/sse')}`);
379
- console.log(` REST API: ${colors.success('āœ… All endpoints active')}`);
380
- console.log();
381
- console.log(colors.highlight('šŸ“¦ Package Distribution:'));
382
- console.log(` CLI Package: ${colors.success('āœ… @lanonasis/cli@1.2.0')}`);
383
- console.log(` SDK Package: ${colors.success('āœ… @lanonasis/memory-client@1.0.0')}`);
384
- console.log(` Memory Service: ${colors.success('āœ… @lanonasis/memory-service@1.0.0')}`);
385
- console.log();
386
- console.log(colors.highlight('šŸ—„ļø Infrastructure:'));
387
- console.log(` Database: ${colors.success('āœ… Supabase PostgreSQL')}`);
388
- console.log(` Authentication: ${colors.success('āœ… Supabase Auth')}`);
389
- console.log(` Hosting: ${colors.success('āœ… Netlify')}`);
390
- console.log(` CDN: ${colors.success('āœ… Netlify Edge')}`);
42
+ console.log('šŸ“Š Lanonasis CLI Status');
43
+ console.log('========================');
44
+ console.log('Version:', packageJson.version);
45
+ console.log('Status: 🟢 Ready for configuration');
46
+ console.log('');
47
+ console.log('Next steps:');
48
+ console.log('• Run "lanonasis init" to get started');
49
+ console.log('• Configure your service endpoints');
50
+ console.log('• Authenticate with your platform');
391
51
  });
392
- deployCmd
393
- .command('health')
394
- .description('Comprehensive health check of all services')
395
- .action(async () => {
396
- console.log(colors.primary('šŸ„ Comprehensive Service Health Check'));
397
- console.log(colors.info('═'.repeat(50)));
398
- const services = [
399
- { name: 'Landing Page', url: 'https://api.lanonasis.com', status: 'healthy' },
400
- { name: 'Dashboard', url: 'https://api.lanonasis.com/dashboard', status: 'healthy' },
401
- { name: 'Documentation', url: 'https://api.lanonasis.com/docs', status: 'healthy' },
402
- { name: 'Memory API', url: 'https://api.lanonasis.com/memories', status: 'healthy' },
403
- { name: 'MCP Server', url: 'https://api.lanonasis.com/mcp/sse', status: 'healthy' },
404
- { name: 'Authentication', url: 'https://api.lanonasis.com/auth', status: 'healthy' }
405
- ];
406
- for (const service of services) {
407
- process.stdout.write(`${service.name.padEnd(20)}: `);
408
- if (service.status === 'healthy') {
409
- console.log(colors.success('āœ… Healthy'));
410
- }
411
- else {
412
- console.log(colors.error('āŒ Unhealthy'));
413
- }
52
+ program
53
+ .command('create')
54
+ .description('Create a new memory entry')
55
+ .option('-t, --title <title>', 'Memory title')
56
+ .option('-c, --content <content>', 'Memory content')
57
+ .option('--type <type>', 'Memory type (conversation, knowledge, project, context, reference)', 'context')
58
+ .action((options) => {
59
+ if (!options.title || !options.content) {
60
+ console.error('āŒ Error: Both --title and --content are required');
61
+ console.log('');
62
+ console.log('Usage: lanonasis create -t "Title" -c "Content"');
63
+ process.exit(1);
414
64
  }
415
- console.log();
416
- console.log(colors.info('šŸ’” All services are operational and healthy'));
65
+ console.log('šŸ“ Creating memory...');
66
+ console.log('Title:', options.title);
67
+ console.log('Content:', options.content.substring(0, 100) + (options.content.length > 100 ? '...' : ''));
68
+ console.log('Type:', options.type);
69
+ console.log('');
70
+ console.log('āš ļø Please configure your Lanonasis service endpoint first:');
71
+ console.log(' lanonasis config set api-url https://your-service.com');
72
+ console.log(' lanonasis auth login');
417
73
  });
418
- // Service management commands (require auth)
419
- const serviceCmd = program
420
- .command('service')
421
- .alias('services')
422
- .description(colors.accent('āš™ļø Manage individual services and components'));
423
- requireAuth(serviceCmd);
424
- serviceCmd
425
- .command('list')
426
- .description('List all available services')
427
- .action(() => {
428
- console.log(colors.primary('āš™ļø Available Services'));
429
- console.log(colors.info('━'.repeat(40)));
430
- console.log(`${colors.accent('memory-service')} - Memory management API`);
431
- console.log(`${colors.accent('dashboard')} - React administrative interface`);
432
- console.log(`${colors.accent('documentation')} - VitePress docs site`);
433
- console.log(`${colors.accent('mcp-server')} - Model Context Protocol server`);
434
- console.log(`${colors.accent('auth-service')} - Authentication service`);
435
- console.log(`${colors.accent('api-gateway')} - REST API gateway`);
74
+ program
75
+ .command('search')
76
+ .description('Search memories')
77
+ .argument('<query>', 'Search query')
78
+ .option('-l, --limit <limit>', 'Number of results', '10')
79
+ .action((query, options) => {
80
+ console.log('šŸ” Searching memories...');
81
+ console.log('Query:', query);
82
+ console.log('Limit:', options.limit);
83
+ console.log('');
84
+ console.log('āš ļø Please configure your Lanonasis service endpoint first:');
85
+ console.log(' lanonasis config set api-url https://your-service.com');
86
+ console.log(' lanonasis auth login');
436
87
  });
437
- serviceCmd
438
- .command('restart <service>')
439
- .description('Restart a specific service')
440
- .action((service) => {
441
- console.log(colors.warning(`⚔ Restarting ${service} service...`));
442
- console.log(colors.success(`āœ… ${service} service restarted successfully`));
88
+ program
89
+ .command('list')
90
+ .description('List all memories')
91
+ .option('-l, --limit <limit>', 'Number of results', '20')
92
+ .option('--type <type>', 'Filter by memory type')
93
+ .action((options) => {
94
+ console.log('šŸ“‹ Listing memories...');
95
+ console.log('Limit:', options.limit);
96
+ if (options.type)
97
+ console.log('Type filter:', options.type);
98
+ console.log('');
99
+ console.log('āš ļø Please configure your Lanonasis service endpoint first:');
100
+ console.log(' lanonasis config set api-url https://your-service.com');
101
+ console.log(' lanonasis auth login');
443
102
  });
444
- // Global commands that don't require auth
445
103
  program
446
- .command('status')
447
- .description('Show overall system status')
448
- .action(async () => {
449
- const isAuth = await cliConfig.isAuthenticated();
450
- const apiUrl = cliConfig.getApiUrl();
451
- console.log(chalk.blue.bold('MaaS CLI Status'));
452
- console.log(`API URL: ${apiUrl}`);
453
- console.log(`Authenticated: ${isAuth ? chalk.green('Yes') : chalk.red('No')}`);
454
- if (isAuth) {
455
- const user = await cliConfig.getCurrentUser();
456
- if (user) {
457
- console.log(`User: ${user.email}`);
458
- console.log(`Plan: ${user.plan}`);
459
- }
104
+ .command('config')
105
+ .description('Manage CLI configuration')
106
+ .argument('<action>', 'Action: set, get, list')
107
+ .argument('[key]', 'Configuration key')
108
+ .argument('[value]', 'Configuration value')
109
+ .action((action, key, value) => {
110
+ console.log('āš™ļø Memory CLI Configuration');
111
+ console.log('===========================');
112
+ switch (action) {
113
+ case 'set':
114
+ if (!key || !value) {
115
+ console.error('āŒ Usage: memory config set <key> <value>');
116
+ process.exit(1);
117
+ }
118
+ console.log(`Setting ${key} = ${value}`);
119
+ console.log('āœ… Configuration saved');
120
+ break;
121
+ case 'get':
122
+ if (!key) {
123
+ console.error('āŒ Usage: memory config get <key>');
124
+ process.exit(1);
125
+ }
126
+ console.log(`${key}: <not configured>`);
127
+ break;
128
+ case 'list':
129
+ console.log('Available configuration keys:');
130
+ console.log('• api-url: Your MaaS service endpoint');
131
+ console.log('• auth-token: Authentication token');
132
+ console.log('• default-type: Default memory type');
133
+ break;
134
+ default:
135
+ console.error('āŒ Unknown action. Use: set, get, or list');
136
+ process.exit(1);
460
137
  }
461
138
  });
462
- // Health command using the healthCheck function
463
139
  program
464
- .command('health')
465
- .alias('check')
466
- .description('Comprehensive system health check')
467
- .option('--verbose', 'show detailed health information')
468
- .action(async (options) => {
469
- try {
470
- await healthCheck();
471
- if (options.verbose) {
472
- console.log(colors.muted('\nšŸ’” Run with --verbose for detailed diagnostics'));
473
- }
474
- }
475
- catch (error) {
476
- console.error(colors.error('āœ– Health check failed:'), error instanceof Error ? error.message : String(error));
477
- process.exit(1);
140
+ .command('auth')
141
+ .description('Authentication commands')
142
+ .argument('<action>', 'Action: login, logout, status')
143
+ .action((action) => {
144
+ console.log('šŸ” Memory CLI Authentication');
145
+ console.log('============================');
146
+ switch (action) {
147
+ case 'login':
148
+ console.log('Please configure your API endpoint first:');
149
+ console.log(' memory config set api-url https://your-maas-service.com');
150
+ console.log('');
151
+ console.log('Then authenticate with your service credentials.');
152
+ break;
153
+ case 'logout':
154
+ console.log('āœ… Logged out successfully');
155
+ break;
156
+ case 'status':
157
+ console.log('Status: šŸ”“ Not authenticated');
158
+ console.log('Run "memory auth login" to authenticate');
159
+ break;
160
+ default:
161
+ console.error('āŒ Unknown action. Use: login, logout, or status');
162
+ process.exit(1);
478
163
  }
479
164
  });
165
+ // Help command
480
166
  program
481
- .command('docs')
482
- .description('Open documentation in browser')
167
+ .command('help')
168
+ .description('Show detailed help information')
483
169
  .action(() => {
484
- const url = 'https://api.lanonasis.com/docs';
485
- console.log(chalk.blue(`Opening documentation: ${url}`));
486
- // Try to open in browser
487
- import('open').then(open => {
488
- open.default(url).catch(() => {
489
- console.log(chalk.yellow('Could not open browser automatically.'));
490
- console.log(chalk.white(`Please visit: ${url}`));
491
- });
492
- }).catch(() => {
493
- console.log(chalk.white(`Please visit: ${url}`));
494
- });
495
- });
496
- // Help customization
497
- program.configureHelp({
498
- formatHelp: (cmd, helper) => {
499
- let help = chalk.blue.bold('🧠 Memory as a Service CLI\n\n');
500
- help += helper.commandUsage(cmd) + '\n\n';
501
- if (cmd.description()) {
502
- help += chalk.yellow('Description:\n');
503
- help += ` ${cmd.description()}\n\n`;
504
- }
505
- const commands = helper.visibleCommands(cmd);
506
- if (commands.length > 0) {
507
- help += chalk.yellow('Commands:\n');
508
- const maxNameLength = Math.max(...commands.map(c => c.name().length));
509
- commands.forEach(c => {
510
- const name = c.name().padEnd(maxNameLength);
511
- help += ` ${chalk.white(name)} ${c.description()}\n`;
512
- });
513
- help += '\n';
514
- }
515
- const options = helper.visibleOptions(cmd);
516
- if (options.length > 0) {
517
- help += chalk.yellow('Options:\n');
518
- options.forEach(option => {
519
- help += ` ${option.flags.padEnd(20)} ${option.description}\n`;
520
- });
521
- help += '\n';
522
- }
523
- help += chalk.gray('For more help on a specific command, run: memory <command> --help\n');
524
- help += chalk.gray('Documentation: https://api.lanonasis.com/docs\n');
525
- return help;
526
- }
170
+ console.log('šŸš€ Lanonasis Enterprise CLI');
171
+ console.log('============================');
172
+ console.log('');
173
+ console.log('The Lanonasis CLI provides unified access to your entire platform ecosystem.');
174
+ console.log('');
175
+ console.log('šŸš€ Quick Start:');
176
+ console.log('1. lanonasis init - Initialize and see setup instructions');
177
+ console.log('2. lanonasis config set api-url <url> - Set your service endpoint');
178
+ console.log('3. lanonasis auth login - Authenticate with your platform');
179
+ console.log('4. lanonasis create -t "Title" -c "Content" - Create your first memory');
180
+ console.log('');
181
+ console.log('šŸ“ Memory Operations:');
182
+ console.log('• lanonasis create -t "Title" -c "Content" --type knowledge');
183
+ console.log('• lanonasis search "query text"');
184
+ console.log('• lanonasis list --type project --limit 10');
185
+ console.log('');
186
+ console.log('āš™ļø Configuration:');
187
+ console.log('• lanonasis config set api-url https://your-service.com');
188
+ console.log('• lanonasis config list');
189
+ console.log('');
190
+ console.log('šŸ” Authentication:');
191
+ console.log('• lanonasis auth login');
192
+ console.log('• lanonasis auth status');
193
+ console.log('');
194
+ console.log('šŸ’” Alternative Commands:');
195
+ console.log('• memory <command> - Direct memory operations');
196
+ console.log('• maas <command> - Memory as a Service operations');
197
+ console.log('');
198
+ console.log('Memory Types: conversation, knowledge, project, context, reference');
199
+ console.log('');
200
+ console.log('šŸ“– Documentation: https://github.com/lanonasis/cli');
201
+ console.log('🌐 Platform: https://lanonasis.com');
202
+ console.log('šŸ› Issues: https://github.com/lanonasis/cli/issues');
203
+ });
204
+ // Handle unknown commands
205
+ program.on('command:*', () => {
206
+ console.error('āŒ Unknown command: %s', program.args.join(' '));
207
+ console.log('');
208
+ console.log('Run "lanonasis help" for available commands');
209
+ process.exit(1);
527
210
  });
528
- // Parse CLI arguments
529
- async function main() {
530
- // Show welcome message if no arguments provided
531
- if (process.argv.length <= 2) {
532
- showWelcome();
533
- return;
534
- }
535
- try {
536
- await program.parseAsync(process.argv);
537
- }
538
- catch (error) {
539
- if (error instanceof Error) {
540
- console.error(chalk.red('āœ– Error:'), error.message);
541
- if (process.env.CLI_VERBOSE === 'true') {
542
- console.error(error.stack);
543
- }
544
- }
545
- process.exit(1);
546
- }
211
+ // Show help if no arguments provided
212
+ if (process.argv.length === 2) {
213
+ program.outputHelp();
547
214
  }
548
- main();
215
+ program.parse();