@lanonasis/cli 1.2.0 ā 1.2.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.
- package/README.md +30 -4
- package/dist/commands/api-keys.d.ts +3 -0
- package/dist/commands/api-keys.js +812 -0
- package/dist/commands/mcp.js +2 -2
- package/dist/commands/memory.js +22 -20
- package/dist/index-simple.js +522 -189
- package/dist/index.js +320 -23
- package/dist/utils/api.d.ts +12 -2
- package/dist/utils/api.js +17 -0
- package/dist/utils/formatting.d.ts +2 -0
- package/dist/utils/formatting.js +13 -0
- package/dist/utils/mcp-client.js +13 -7
- package/package.json +8 -3
package/dist/index-simple.js
CHANGED
|
@@ -1,215 +1,548 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
};
|
|
11
28
|
const program = new Command();
|
|
29
|
+
// CLI Configuration
|
|
30
|
+
const cliConfig = new CLIConfig();
|
|
12
31
|
program
|
|
13
32
|
.name('lanonasis')
|
|
14
|
-
.
|
|
15
|
-
.
|
|
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)
|
|
16
178
|
program
|
|
17
179
|
.command('init')
|
|
18
|
-
.description('Initialize
|
|
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')
|
|
19
271
|
.action(() => {
|
|
20
|
-
console.log('
|
|
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');
|
|
272
|
+
console.log(colors.info('Opening dashboard logs...'));
|
|
273
|
+
console.log(colors.success('Dashboard logs: https://app.netlify.com/sites/lanonasis-dashboard/logs'));
|
|
37
274
|
});
|
|
38
|
-
|
|
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
|
|
39
282
|
.command('status')
|
|
40
|
-
.description('
|
|
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')
|
|
41
295
|
.action(() => {
|
|
42
|
-
console.log('
|
|
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');
|
|
296
|
+
console.log(colors.warning('ā” Triggering documentation rebuild...'));
|
|
297
|
+
console.log(colors.success('Documentation rebuild initiated via webhook'));
|
|
51
298
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
console.log('
|
|
66
|
-
console.log('
|
|
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');
|
|
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')}`);
|
|
73
314
|
});
|
|
74
|
-
|
|
75
|
-
.command('
|
|
76
|
-
.description('
|
|
77
|
-
.
|
|
78
|
-
.
|
|
79
|
-
.
|
|
80
|
-
console.log('
|
|
81
|
-
console.log('
|
|
82
|
-
console.log('
|
|
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');
|
|
315
|
+
sdkCmd
|
|
316
|
+
.command('versions')
|
|
317
|
+
.description('List all available SDK versions')
|
|
318
|
+
.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)')}`);
|
|
87
324
|
});
|
|
88
|
-
|
|
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
|
|
332
|
+
.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')
|
|
346
|
+
.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')}`);
|
|
391
|
+
});
|
|
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
|
+
}
|
|
414
|
+
}
|
|
415
|
+
console.log();
|
|
416
|
+
console.log(colors.info('š” All services are operational and healthy'));
|
|
417
|
+
});
|
|
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
|
|
89
425
|
.command('list')
|
|
90
|
-
.description('List all
|
|
91
|
-
.
|
|
92
|
-
.
|
|
93
|
-
.
|
|
94
|
-
console.log('
|
|
95
|
-
console.log('
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
console.log('');
|
|
99
|
-
console.log('
|
|
100
|
-
console.log(' lanonasis config set api-url https://your-service.com');
|
|
101
|
-
console.log(' lanonasis auth login');
|
|
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`);
|
|
102
436
|
});
|
|
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`));
|
|
443
|
+
});
|
|
444
|
+
// Global commands that don't require auth
|
|
103
445
|
program
|
|
104
|
-
.command('
|
|
105
|
-
.description('
|
|
106
|
-
.
|
|
107
|
-
.
|
|
108
|
-
.
|
|
109
|
-
.
|
|
110
|
-
console.log(
|
|
111
|
-
console.log('
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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);
|
|
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
|
+
}
|
|
137
460
|
}
|
|
138
461
|
});
|
|
462
|
+
// Health command using the healthCheck function
|
|
139
463
|
program
|
|
140
|
-
.command('
|
|
141
|
-
.
|
|
142
|
-
.
|
|
143
|
-
.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
console.log('
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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);
|
|
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);
|
|
163
478
|
}
|
|
164
479
|
});
|
|
165
|
-
// Help command
|
|
166
480
|
program
|
|
167
|
-
.command('
|
|
168
|
-
.description('
|
|
481
|
+
.command('docs')
|
|
482
|
+
.description('Open documentation in browser')
|
|
169
483
|
.action(() => {
|
|
170
|
-
|
|
171
|
-
console.log(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
+
}
|
|
210
527
|
});
|
|
211
|
-
//
|
|
212
|
-
|
|
213
|
-
|
|
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
|
+
}
|
|
214
547
|
}
|
|
215
|
-
|
|
548
|
+
main();
|