@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.
- package/README.md +357 -80
- package/dist/commands/auth.js +151 -1
- package/dist/commands/mcp.js +37 -30
- package/dist/commands/memory.js +78 -53
- package/dist/index-simple.js +189 -522
- package/dist/index.js +221 -327
- package/dist/utils/api.d.ts +2 -12
- package/dist/utils/api.js +0 -17
- package/dist/utils/completions.d.ts +28 -0
- package/dist/utils/completions.js +276 -0
- package/dist/utils/config.d.ts +2 -0
- package/dist/utils/config.js +13 -0
- package/dist/utils/formatting.d.ts +0 -2
- package/dist/utils/formatting.js +0 -13
- package/dist/utils/mcp-client.d.ts +6 -49
- package/dist/utils/mcp-client.js +82 -161
- package/dist/utils/mcp-client.test.d.ts +1 -0
- package/dist/utils/mcp-client.test.js +125 -0
- package/dist/utils/output.d.ts +23 -0
- package/dist/utils/output.js +97 -0
- package/dist/utils/websocket-mcp-client.d.ts +60 -0
- package/dist/utils/websocket-mcp-client.js +182 -0
- package/dist/utils/websocket-mcp-client.test.d.ts +1 -0
- package/dist/utils/websocket-mcp-client.test.js +126 -0
- package/package.json +10 -17
- package/dist/commands/api-keys.d.ts +0 -3
- package/dist/commands/api-keys.js +0 -812
- package/dist/mcp-server.d.ts +0 -2
- package/dist/mcp-server.js +0 -519
package/dist/index.js
CHANGED
|
@@ -9,35 +9,26 @@ import { topicCommands } from './commands/topics.js';
|
|
|
9
9
|
import { configCommands } from './commands/config.js';
|
|
10
10
|
import { orgCommands } from './commands/organization.js';
|
|
11
11
|
import { mcpCommands } from './commands/mcp.js';
|
|
12
|
-
import apiKeysCommand from './commands/api-keys.js';
|
|
13
12
|
import { CLIConfig } from './utils/config.js';
|
|
14
13
|
import { getMCPClient } from './utils/mcp-client.js';
|
|
14
|
+
import { TabCompletions } from './utils/completions.js';
|
|
15
|
+
import { output } from './utils/output.js';
|
|
15
16
|
// Load environment variables
|
|
16
17
|
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
|
-
};
|
|
28
18
|
const program = new Command();
|
|
29
19
|
// CLI Configuration
|
|
30
20
|
const cliConfig = new CLIConfig();
|
|
31
21
|
program
|
|
32
22
|
.name('lanonasis')
|
|
33
|
-
.alias('
|
|
34
|
-
.
|
|
35
|
-
.
|
|
36
|
-
.
|
|
37
|
-
.option('-
|
|
38
|
-
.option('--api-url <url>', 'override API URL')
|
|
23
|
+
.alias('onasis')
|
|
24
|
+
.description('Lanonasis Unified CLI - Enterprise AI Infrastructure & Memory as a Service')
|
|
25
|
+
.version('1.5.0')
|
|
26
|
+
.option('-v, --verbose', 'enable verbose logging')
|
|
27
|
+
.option('--api-url <url>', 'override API URL (default: https://api.lanonasis.com)')
|
|
39
28
|
.option('--output <format>', 'output format (json, table, yaml)', 'table')
|
|
40
29
|
.option('--no-mcp', 'disable MCP and use direct API')
|
|
30
|
+
.option('--api-key <key>', 'use API key authentication (bypasses interactive login)')
|
|
31
|
+
.option('--silent', 'suppress non-essential output (implied with --output json)')
|
|
41
32
|
.hook('preAction', async (thisCommand, actionCommand) => {
|
|
42
33
|
const opts = thisCommand.opts();
|
|
43
34
|
if (opts.verbose) {
|
|
@@ -46,130 +37,87 @@ program
|
|
|
46
37
|
if (opts.apiUrl) {
|
|
47
38
|
process.env.MEMORY_API_URL = opts.apiUrl;
|
|
48
39
|
}
|
|
40
|
+
if (opts.apiKey) {
|
|
41
|
+
process.env.LANONASIS_API_KEY = opts.apiKey;
|
|
42
|
+
}
|
|
49
43
|
process.env.CLI_OUTPUT_FORMAT = opts.output;
|
|
44
|
+
// Configure output manager
|
|
45
|
+
output.setOptions({
|
|
46
|
+
format: opts.output,
|
|
47
|
+
silent: opts.silent,
|
|
48
|
+
json: opts.output === 'json'
|
|
49
|
+
});
|
|
50
50
|
// Auto-initialize MCP unless disabled
|
|
51
|
-
if (opts.mcp !== false && !['init', 'auth', 'login', 'mcp', '
|
|
51
|
+
if (opts.mcp !== false && !['init', 'auth', 'login', 'mcp', 'help'].includes(actionCommand.name())) {
|
|
52
52
|
try {
|
|
53
53
|
const client = getMCPClient();
|
|
54
54
|
if (!client.isConnectedToServer()) {
|
|
55
|
-
const useRemote = await cliConfig.isAuthenticated();
|
|
55
|
+
const useRemote = await cliConfig.isAuthenticated() || !!opts.apiKey;
|
|
56
56
|
await client.connect({ useRemote });
|
|
57
|
-
if (process.env.CLI_VERBOSE === 'true') {
|
|
58
|
-
|
|
57
|
+
if (process.env.CLI_VERBOSE === 'true' && !output.isSilent()) {
|
|
58
|
+
output.log(chalk.gray(`MCP connected (${useRemote ? 'remote' : 'local'})`));
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
catch
|
|
63
|
-
if (process.env.CLI_VERBOSE === 'true') {
|
|
64
|
-
|
|
65
|
-
console.log(colors.muted(`Error: ${error instanceof Error ? error.message : String(error)}`));
|
|
62
|
+
catch {
|
|
63
|
+
if (process.env.CLI_VERBOSE === 'true' && !output.isSilent()) {
|
|
64
|
+
output.log(chalk.yellow('MCP auto-connect failed, using direct API'));
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
});
|
|
70
|
-
//
|
|
69
|
+
// Global error handler
|
|
71
70
|
process.on('uncaughtException', (error) => {
|
|
72
|
-
|
|
73
|
-
if (process.env.CLI_VERBOSE === 'true') {
|
|
74
|
-
console.error(
|
|
71
|
+
output.error(chalk.red('ā Unexpected error:'), error.message);
|
|
72
|
+
if (process.env.CLI_VERBOSE === 'true' && !output.isJsonOutput()) {
|
|
73
|
+
console.error(error.stack);
|
|
75
74
|
}
|
|
76
75
|
process.exit(1);
|
|
77
76
|
});
|
|
78
77
|
process.on('unhandledRejection', (reason, promise) => {
|
|
79
|
-
|
|
80
|
-
if (process.env.CLI_VERBOSE === 'true') {
|
|
81
|
-
console.error(
|
|
78
|
+
output.error(chalk.red('ā Unhandled promise rejection:'), reason);
|
|
79
|
+
if (process.env.CLI_VERBOSE === 'true' && !output.isJsonOutput()) {
|
|
80
|
+
console.error(promise);
|
|
82
81
|
}
|
|
83
82
|
process.exit(1);
|
|
84
83
|
});
|
|
85
|
-
//
|
|
84
|
+
// Welcome message for first-time users
|
|
86
85
|
const showWelcome = () => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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'));
|
|
86
|
+
if (!output.isSilent()) {
|
|
87
|
+
console.log(chalk.blue.bold('š Lanonasis CLI - Enterprise AI Infrastructure'));
|
|
88
|
+
console.log(chalk.gray('Memory as a Service, AI Orchestration & Multi-tenant Infrastructure'));
|
|
89
|
+
console.log();
|
|
90
|
+
console.log(chalk.yellow('Quick Start:'));
|
|
91
|
+
console.log(chalk.white(' lanonasis login # Interactive authentication'));
|
|
92
|
+
console.log(chalk.white(' onasis -h # Show short help'));
|
|
93
|
+
console.log(chalk.white(' lanonasis --help # Show detailed help'));
|
|
94
|
+
console.log();
|
|
95
|
+
console.log(chalk.yellow('API Key Usage (for AI agents):'));
|
|
96
|
+
console.log(chalk.white(' npx -y @lanonasis/cli --api-key=<key> memory list'));
|
|
97
|
+
console.log(chalk.white(' export LANONASIS_API_KEY=<key> && lanonasis memory search "query"'));
|
|
98
|
+
console.log();
|
|
99
|
+
console.log(chalk.gray('Documentation: https://docs.lanonasis.com/cli'));
|
|
162
100
|
}
|
|
163
|
-
console.log();
|
|
164
|
-
console.log(colors.info('š” For detailed diagnostics, run: lanonasis status --verbose'));
|
|
165
101
|
};
|
|
166
102
|
// Check if user is authenticated for protected commands
|
|
167
103
|
const requireAuth = (command) => {
|
|
168
|
-
command.hook('preAction', async () => {
|
|
104
|
+
command.hook('preAction', async (thisCommand) => {
|
|
105
|
+
const opts = thisCommand.opts();
|
|
106
|
+
const hasApiKey = opts.apiKey || process.env.LANONASIS_API_KEY;
|
|
169
107
|
const isAuthenticated = await cliConfig.isAuthenticated();
|
|
170
|
-
if (!isAuthenticated) {
|
|
171
|
-
|
|
172
|
-
|
|
108
|
+
if (!isAuthenticated && !hasApiKey) {
|
|
109
|
+
if (output.isJsonOutput()) {
|
|
110
|
+
output.error('Authentication required');
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
console.error(chalk.red('ā Authentication required'));
|
|
114
|
+
console.log();
|
|
115
|
+
console.log(chalk.yellow('Choose authentication method:'));
|
|
116
|
+
console.log(chalk.white(' 1. Interactive login:'), chalk.gray('lanonasis login'));
|
|
117
|
+
console.log(chalk.white(' 2. API Key:'), chalk.gray('lanonasis --api-key=<key> <command>'));
|
|
118
|
+
console.log(chalk.white(' 3. Environment:'), chalk.gray('export LANONASIS_API_KEY=<key>'));
|
|
119
|
+
console.log();
|
|
120
|
+
}
|
|
173
121
|
process.exit(1);
|
|
174
122
|
}
|
|
175
123
|
});
|
|
@@ -245,201 +193,95 @@ const orgCmd = program
|
|
|
245
193
|
.description('Organization management');
|
|
246
194
|
requireAuth(orgCmd);
|
|
247
195
|
orgCommands(orgCmd);
|
|
248
|
-
//
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
.
|
|
254
|
-
.
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
.
|
|
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')
|
|
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)')}`);
|
|
324
|
-
});
|
|
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')}`);
|
|
196
|
+
// List connections and functions (prioritize memory services)
|
|
197
|
+
program
|
|
198
|
+
.command('list')
|
|
199
|
+
.alias('ls')
|
|
200
|
+
.description('List available connections and functions')
|
|
201
|
+
.option('--type <type>', 'filter by type (memory, api, mcp, all)', 'all')
|
|
202
|
+
.action(async (options) => {
|
|
203
|
+
const config = new CLIConfig();
|
|
204
|
+
await config.init();
|
|
205
|
+
const isAuth = await config.isAuthenticated();
|
|
206
|
+
console.log(chalk.blue.bold('š Available Connections & Functions'));
|
|
385
207
|
console.log();
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
console.log(colors.error('ā Unhealthy'));
|
|
413
|
-
}
|
|
208
|
+
if (!isAuth) {
|
|
209
|
+
console.log(chalk.yellow('ā ļø Authentication required for full functionality'));
|
|
210
|
+
console.log(chalk.gray('Run: lanonasis login'));
|
|
211
|
+
console.log();
|
|
212
|
+
}
|
|
213
|
+
// Memory Services (Priority)
|
|
214
|
+
if (options.type === 'all' || options.type === 'memory') {
|
|
215
|
+
console.log(chalk.green.bold('š§ Memory Services') + chalk.gray(' (Primary)'));
|
|
216
|
+
console.log(' ⢠Memory CRUD Operations');
|
|
217
|
+
console.log(' - memory create Create new memory entry');
|
|
218
|
+
console.log(' - memory search Semantic search memories');
|
|
219
|
+
console.log(' - memory list List all memories');
|
|
220
|
+
console.log(' - memory get Get specific memory');
|
|
221
|
+
console.log(' - memory update Update memory content');
|
|
222
|
+
console.log(' - memory delete Delete memory entry');
|
|
223
|
+
console.log(' ⢠Vector Embeddings & AI');
|
|
224
|
+
console.log(' - Automatic embedding generation');
|
|
225
|
+
console.log(' - Semantic similarity search');
|
|
226
|
+
console.log(' - OpenAI text-embedding-ada-002');
|
|
227
|
+
console.log(' ⢠Organization & Topics');
|
|
228
|
+
console.log(' - topic create Create memory topics');
|
|
229
|
+
console.log(' - topic list List all topics');
|
|
230
|
+
console.log(' - Memory type classification');
|
|
231
|
+
console.log();
|
|
414
232
|
}
|
|
233
|
+
// API Connections
|
|
234
|
+
if (options.type === 'all' || options.type === 'api') {
|
|
235
|
+
console.log(chalk.blue.bold('š API Connections'));
|
|
236
|
+
console.log(' ⢠Core Gateway API');
|
|
237
|
+
console.log(' - https://api.lanonasis.com/v1');
|
|
238
|
+
console.log(' - Authentication: JWT + API Keys');
|
|
239
|
+
console.log(' - Project scope: maas');
|
|
240
|
+
console.log(' ⢠Supabase Backend');
|
|
241
|
+
console.log(' - PostgreSQL + pgvector');
|
|
242
|
+
console.log(' - Row Level Security (RLS)');
|
|
243
|
+
console.log(' - Real-time subscriptions');
|
|
244
|
+
console.log(' ⢠OpenAI Integration');
|
|
245
|
+
console.log(' - Embeddings generation');
|
|
246
|
+
console.log(' - Text processing');
|
|
247
|
+
console.log();
|
|
248
|
+
}
|
|
249
|
+
// MCP Tools
|
|
250
|
+
if (options.type === 'all' || options.type === 'mcp') {
|
|
251
|
+
console.log(chalk.magenta.bold('š¤ MCP (Model Context Protocol)'));
|
|
252
|
+
console.log(' ⢠AI Agent Interface');
|
|
253
|
+
console.log(' - mcp start Start MCP server');
|
|
254
|
+
console.log(' - mcp status Check MCP status');
|
|
255
|
+
console.log(' - mcp connect Connect to remote MCP');
|
|
256
|
+
console.log(' ⢠Tool Registry');
|
|
257
|
+
console.log(' - Memory operations for AI agents');
|
|
258
|
+
console.log(' - File system operations');
|
|
259
|
+
console.log(' - External API integrations');
|
|
260
|
+
console.log(' ⢠Usage Examples');
|
|
261
|
+
console.log(' - Claude Code integration');
|
|
262
|
+
console.log(' - VS Code extensions');
|
|
263
|
+
console.log(' - Cursor IDE support');
|
|
264
|
+
console.log();
|
|
265
|
+
}
|
|
266
|
+
// Available Commands Summary
|
|
267
|
+
console.log(chalk.yellow.bold('š Quick Command Reference'));
|
|
268
|
+
console.log(' Authentication:');
|
|
269
|
+
console.log(' lanonasis login Interactive login');
|
|
270
|
+
console.log(' lanonasis --api-key=<key> API key authentication');
|
|
271
|
+
console.log(' Memory (Primary):');
|
|
272
|
+
console.log(' lanonasis memory create -t "Title" -c "Content"');
|
|
273
|
+
console.log(' lanonasis memory search "query"');
|
|
274
|
+
console.log(' lanonasis memory list --type project');
|
|
275
|
+
console.log(' MCP for AI Agents:');
|
|
276
|
+
console.log(' npx -y @lanonasis/cli --api-key=<key> memory list');
|
|
277
|
+
console.log(' lanonasis mcp start');
|
|
415
278
|
console.log();
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
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`);
|
|
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`));
|
|
279
|
+
if (isAuth) {
|
|
280
|
+
console.log(chalk.green('ā All functions available (authenticated)'));
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
console.log(chalk.gray('ā¹ļø Login for full access to memory services'));
|
|
284
|
+
}
|
|
443
285
|
});
|
|
444
286
|
// Global commands that don't require auth
|
|
445
287
|
program
|
|
@@ -459,29 +301,11 @@ program
|
|
|
459
301
|
}
|
|
460
302
|
}
|
|
461
303
|
});
|
|
462
|
-
// Health command using the healthCheck function
|
|
463
|
-
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);
|
|
478
|
-
}
|
|
479
|
-
});
|
|
480
304
|
program
|
|
481
305
|
.command('docs')
|
|
482
306
|
.description('Open documentation in browser')
|
|
483
307
|
.action(() => {
|
|
484
|
-
const url = 'https://
|
|
308
|
+
const url = 'https://docs.lanonasis.com/cli';
|
|
485
309
|
console.log(chalk.blue(`Opening documentation: ${url}`));
|
|
486
310
|
// Try to open in browser
|
|
487
311
|
import('open').then(open => {
|
|
@@ -493,9 +317,79 @@ program
|
|
|
493
317
|
console.log(chalk.white(`Please visit: ${url}`));
|
|
494
318
|
});
|
|
495
319
|
});
|
|
320
|
+
// Completion commands
|
|
321
|
+
program
|
|
322
|
+
.command('completion')
|
|
323
|
+
.description('Generate shell completion scripts')
|
|
324
|
+
.option('--shell <shell>', 'shell type (bash, zsh)', 'bash')
|
|
325
|
+
.action(async (options) => {
|
|
326
|
+
const completions = new TabCompletions();
|
|
327
|
+
switch (options.shell) {
|
|
328
|
+
case 'bash':
|
|
329
|
+
console.log(completions.generateBashCompletion());
|
|
330
|
+
break;
|
|
331
|
+
case 'zsh':
|
|
332
|
+
console.log(completions.generateZshCompletion());
|
|
333
|
+
break;
|
|
334
|
+
default:
|
|
335
|
+
console.error(chalk.red('Unsupported shell. Use: bash, zsh'));
|
|
336
|
+
process.exit(1);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
program
|
|
340
|
+
.command('install-completion')
|
|
341
|
+
.description('Install shell completions for current user')
|
|
342
|
+
.option('--shell <shell>', 'shell type (bash, zsh)', 'bash')
|
|
343
|
+
.action(async (options) => {
|
|
344
|
+
const completions = new TabCompletions();
|
|
345
|
+
const shell = options.shell;
|
|
346
|
+
try {
|
|
347
|
+
let completionScript;
|
|
348
|
+
let installPath;
|
|
349
|
+
switch (shell) {
|
|
350
|
+
case 'bash':
|
|
351
|
+
completionScript = completions.generateBashCompletion();
|
|
352
|
+
installPath = `${process.env.HOME}/.bash_completion.d/lanonasis`;
|
|
353
|
+
break;
|
|
354
|
+
case 'zsh':
|
|
355
|
+
completionScript = completions.generateZshCompletion();
|
|
356
|
+
installPath = `${process.env.HOME}/.local/share/zsh/site-functions/_lanonasis`;
|
|
357
|
+
break;
|
|
358
|
+
default:
|
|
359
|
+
console.error(chalk.red('Unsupported shell. Use: bash, zsh'));
|
|
360
|
+
process.exit(1);
|
|
361
|
+
}
|
|
362
|
+
// Write completion script
|
|
363
|
+
const { promises: fs } = await import('fs');
|
|
364
|
+
const path = await import('path');
|
|
365
|
+
await fs.mkdir(path.dirname(installPath), { recursive: true });
|
|
366
|
+
await fs.writeFile(installPath, completionScript);
|
|
367
|
+
console.log(chalk.green('ā Shell completions installed'));
|
|
368
|
+
console.log(`Location: ${installPath}`);
|
|
369
|
+
console.log();
|
|
370
|
+
console.log(chalk.yellow('To activate completions:'));
|
|
371
|
+
switch (shell) {
|
|
372
|
+
case 'bash':
|
|
373
|
+
console.log(chalk.white(' source ~/.bash_completion.d/lanonasis'));
|
|
374
|
+
console.log(chalk.gray(' # Or restart your terminal'));
|
|
375
|
+
break;
|
|
376
|
+
case 'zsh':
|
|
377
|
+
console.log(chalk.white(' # Add to ~/.zshrc:'));
|
|
378
|
+
console.log(chalk.white(' fpath=(~/.local/share/zsh/site-functions $fpath)'));
|
|
379
|
+
console.log(chalk.white(' autoload -U compinit && compinit'));
|
|
380
|
+
console.log(chalk.gray(' # Then restart your terminal'));
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
catch (error) {
|
|
385
|
+
console.error(chalk.red('ā Failed to install completions:'), error instanceof Error ? error.message : error);
|
|
386
|
+
process.exit(1);
|
|
387
|
+
}
|
|
388
|
+
});
|
|
496
389
|
// Help customization
|
|
497
390
|
program.configureHelp({
|
|
498
391
|
formatHelp: (cmd, helper) => {
|
|
392
|
+
// Get terminal width for formatting (currently using default helper formatting)
|
|
499
393
|
let help = chalk.blue.bold('š§ Memory as a Service CLI\n\n');
|
|
500
394
|
help += helper.commandUsage(cmd) + '\n\n';
|
|
501
395
|
if (cmd.description()) {
|
|
@@ -521,7 +415,7 @@ program.configureHelp({
|
|
|
521
415
|
help += '\n';
|
|
522
416
|
}
|
|
523
417
|
help += chalk.gray('For more help on a specific command, run: memory <command> --help\n');
|
|
524
|
-
help += chalk.gray('Documentation: https://
|
|
418
|
+
help += chalk.gray('Documentation: https://docs.seyederick.com/memory-service\n');
|
|
525
419
|
return help;
|
|
526
420
|
}
|
|
527
421
|
});
|