@lanonasis/cli 1.5.1 → 1.5.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.
@@ -0,0 +1,196 @@
1
+ #compdef lanonasis onasis memory maas
2
+
3
+ # Lanonasis/Onasis CLI Zsh Completion
4
+ # Installation: Place in your $fpath (e.g., ~/.zsh/completions/) and run 'compinit'
5
+
6
+ _lanonasis() {
7
+ local context curcontext="$curcontext" state line
8
+ typeset -A opt_args
9
+
10
+ _arguments -C \
11
+ '1: :_lanonasis_commands' \
12
+ '*:: :->args' \
13
+ '--help[Show help information]' \
14
+ '--version[Show version information]' \
15
+ '--verbose[Enable verbose logging]' \
16
+ '--output[Output format]:format:(table json yaml csv)' \
17
+ '--api-url[Override API URL]:url:' \
18
+ '--no-mcp[Disable MCP and use direct API]'
19
+
20
+ case $state in
21
+ args)
22
+ case $words[1] in
23
+ auth|login)
24
+ _lanonasis_auth_commands
25
+ ;;
26
+ memory|mem)
27
+ _lanonasis_memory_commands
28
+ ;;
29
+ topic|topics)
30
+ _lanonasis_topic_commands
31
+ ;;
32
+ config)
33
+ _lanonasis_config_commands
34
+ ;;
35
+ api-keys)
36
+ _lanonasis_apikeys_commands
37
+ ;;
38
+ mcp)
39
+ _lanonasis_mcp_commands
40
+ ;;
41
+ dashboard)
42
+ _lanonasis_dashboard_commands
43
+ ;;
44
+ deploy|deployment)
45
+ _lanonasis_deploy_commands
46
+ ;;
47
+ service|services)
48
+ _lanonasis_service_commands
49
+ ;;
50
+ esac
51
+ ;;
52
+ esac
53
+ }
54
+
55
+ _lanonasis_commands() {
56
+ local commands; commands=(
57
+ 'init:Initialize CLI configuration'
58
+ 'login:Authenticate with your account'
59
+ 'auth:Authentication commands'
60
+ 'logout:Logout from your account'
61
+ 'status:Show system status'
62
+ 'health:Comprehensive health check'
63
+ 'docs:Open documentation'
64
+ 'memory:Memory management commands'
65
+ 'mem:Memory management (alias)'
66
+ 'topic:Topic management commands'
67
+ 'topics:Topic management (alias)'
68
+ 'config:Configuration management'
69
+ 'org:Organization management'
70
+ 'organization:Organization management (alias)'
71
+ 'api-keys:API key management'
72
+ 'mcp:Model Context Protocol commands'
73
+ 'dashboard:Dashboard management'
74
+ 'documentation:Documentation management'
75
+ 'sdk:SDK management'
76
+ 'api:REST API management'
77
+ 'rest:REST API management (alias)'
78
+ 'deploy:Deployment management'
79
+ 'deployment:Deployment management (alias)'
80
+ 'service:Service management'
81
+ 'services:Service management (alias)'
82
+ )
83
+ _describe 'commands' commands
84
+ }
85
+
86
+ _lanonasis_auth_commands() {
87
+ local subcommands; subcommands=(
88
+ 'login:Login to your account'
89
+ 'logout:Logout from your account'
90
+ 'status:Show authentication status'
91
+ 'vendor-key:Authenticate with vendor key'
92
+ 'oauth:Browser-based OAuth authentication'
93
+ )
94
+ _describe 'auth commands' subcommands
95
+ }
96
+
97
+ _lanonasis_memory_commands() {
98
+ local subcommands; subcommands=(
99
+ 'list:List memories'
100
+ 'create:Create a new memory'
101
+ 'get:Get a specific memory'
102
+ 'update:Update an existing memory'
103
+ 'delete:Delete a memory'
104
+ 'search:Search memories'
105
+ 'stats:Show memory statistics'
106
+ 'bulk-delete:Delete multiple memories'
107
+ 'export:Export memories'
108
+ 'import:Import memories'
109
+ )
110
+ _describe 'memory commands' subcommands
111
+
112
+ # Add memory type completion for relevant commands
113
+ if [[ "$words[2]" == "create" || "$words[2]" == "update" || "$words[2]" == "list" ]]; then
114
+ _arguments \
115
+ '--memory-type[Memory type]:type:(context project knowledge reference personal workflow)' \
116
+ '--tags[Tags]:tags:' \
117
+ '--topic-id[Topic ID]:topic:'
118
+ fi
119
+ }
120
+
121
+ _lanonasis_topic_commands() {
122
+ local subcommands; subcommands=(
123
+ 'list:List topics'
124
+ 'create:Create a new topic'
125
+ 'get:Get a specific topic'
126
+ 'update:Update an existing topic'
127
+ 'delete:Delete a topic'
128
+ )
129
+ _describe 'topic commands' subcommands
130
+ }
131
+
132
+ _lanonasis_config_commands() {
133
+ local subcommands; subcommands=(
134
+ 'get:Get configuration value'
135
+ 'set:Set configuration value'
136
+ 'list:List all configuration'
137
+ 'reset:Reset configuration'
138
+ )
139
+ _describe 'config commands' subcommands
140
+ }
141
+
142
+ _lanonasis_apikeys_commands() {
143
+ local subcommands; subcommands=(
144
+ 'list:List API keys'
145
+ 'create:Create a new API key'
146
+ 'revoke:Revoke an API key'
147
+ 'rotate:Rotate an API key'
148
+ )
149
+ _describe 'api-keys commands' subcommands
150
+ }
151
+
152
+ _lanonasis_mcp_commands() {
153
+ local subcommands; subcommands=(
154
+ 'status:Show MCP server status'
155
+ 'connect:Connect to MCP server'
156
+ 'disconnect:Disconnect from MCP server'
157
+ 'servers:List MCP servers'
158
+ 'tools:List available tools'
159
+ 'resources:List available resources'
160
+ )
161
+ _describe 'mcp commands' subcommands
162
+ }
163
+
164
+ _lanonasis_dashboard_commands() {
165
+ local subcommands; subcommands=(
166
+ 'status:Check dashboard status'
167
+ 'logs:View dashboard logs'
168
+ 'open:Open dashboard in browser'
169
+ )
170
+ _describe 'dashboard commands' subcommands
171
+ }
172
+
173
+ _lanonasis_deploy_commands() {
174
+ local subcommands; subcommands=(
175
+ 'status:Show deployment status'
176
+ 'health:Check deployment health'
177
+ 'list:List deployments'
178
+ )
179
+ _describe 'deploy commands' subcommands
180
+ }
181
+
182
+ _lanonasis_service_commands() {
183
+ local subcommands; subcommands=(
184
+ 'list:List services'
185
+ 'status:Show service status'
186
+ 'restart:Restart a service'
187
+ 'logs:View service logs'
188
+ )
189
+ _describe 'service commands' subcommands
190
+ }
191
+
192
+ # Initialize completion for all aliases
193
+ compdef _lanonasis lanonasis
194
+ compdef _lanonasis onasis
195
+ compdef _lanonasis memory
196
+ compdef _lanonasis maas
@@ -10,8 +10,15 @@ import { configCommands } from './commands/config.js';
10
10
  import { orgCommands } from './commands/organization.js';
11
11
  import { mcpCommands } from './commands/mcp.js';
12
12
  import apiKeysCommand from './commands/api-keys.js';
13
+ import { completionCommand, installCompletionsCommand } from './commands/completion.js';
14
+ import { guideCommand, quickStartCommand } from './commands/guide.js';
13
15
  import { CLIConfig } from './utils/config.js';
14
16
  import { getMCPClient } from './utils/mcp-client.js';
17
+ import * as fs from 'fs';
18
+ import * as path from 'path';
19
+ import { fileURLToPath } from 'url';
20
+ const __filename = fileURLToPath(import.meta.url);
21
+ const __dirname = path.dirname(__filename);
15
22
  // Load environment variables
16
23
  config();
17
24
  // Enhanced color scheme (VPS-style)
@@ -28,16 +35,21 @@ const colors = {
28
35
  const program = new Command();
29
36
  // CLI Configuration
30
37
  const cliConfig = new CLIConfig();
38
+ // Detect which command was used to invoke the CLI
39
+ const invocationName = process.argv[1] ? path.basename(process.argv[1]) : 'lanonasis';
40
+ const isOnasisInvocation = invocationName === 'onasis';
31
41
  program
32
- .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.4.2', '-v, --version', 'display version number')
42
+ .name(isOnasisInvocation ? 'onasis' : 'lanonasis')
43
+ .alias(isOnasisInvocation ? 'lanonasis' : 'memory')
44
+ .alias(isOnasisInvocation ? 'memory' : 'maas')
45
+ .description(colors.info(`🧠 ${isOnasisInvocation ? 'Onasis-Core Golden Contract CLI' : 'LanOnasis Enterprise CLI'} - Memory as a Service, API Management & Infrastructure Orchestration`))
46
+ .version('1.5.2', '-v, --version', 'display version number')
37
47
  .option('-V, --verbose', 'enable verbose logging')
38
48
  .option('--api-url <url>', 'override API URL')
39
49
  .option('--output <format>', 'output format (json, table, yaml)', 'table')
40
50
  .option('--no-mcp', 'disable MCP and use direct API')
51
+ .option('--completion [shell]', 'generate shell completion script')
52
+ .option('--completion-data', 'output completion data as JSON')
41
53
  .hook('preAction', async (thisCommand, actionCommand) => {
42
54
  const opts = thisCommand.opts();
43
55
  if (opts.verbose) {
@@ -84,16 +96,31 @@ process.on('unhandledRejection', (reason, promise) => {
84
96
  });
85
97
  // Enhanced welcome message
86
98
  const showWelcome = () => {
99
+ const cmdName = isOnasisInvocation ? 'onasis' : 'lanonasis';
100
+ const title = isOnasisInvocation ? 'Onasis-Core Golden Contract CLI' : 'LanOnasis Enterprise CLI';
87
101
  console.log();
88
- console.log(colors.primary('🚀 LanOnasis Enterprise CLI v1.4.2'));
102
+ console.log(colors.primary(`🚀 ${title} v1.5.2`));
89
103
  console.log(colors.info('━'.repeat(50)));
90
104
  console.log(colors.highlight('Enterprise-grade Memory as a Service, API Management & Infrastructure Orchestration'));
105
+ if (isOnasisInvocation) {
106
+ console.log(colors.accent('✓ Golden Contract Compliant - Service Discovery Enabled'));
107
+ }
91
108
  console.log();
92
109
  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')}`);
110
+ console.log(` ${colors.success(`${cmdName} init`)} ${colors.muted('# Initialize CLI configuration')}`);
111
+ console.log(` ${colors.success(`${cmdName} login`)} ${colors.muted('# Authenticate with your account')}`);
112
+ console.log(` ${colors.success(`${cmdName} health`)} ${colors.muted('# Check system health')}`);
113
+ console.log(` ${colors.success(`${cmdName} --help`)} ${colors.muted('# Show all available commands')}`);
114
+ console.log();
115
+ if (isOnasisInvocation) {
116
+ console.log(colors.info('🔑 Golden Contract Authentication:'));
117
+ console.log(` ${colors.success(`${cmdName} login --vendor-key pk_xxx.sk_xxx`)} ${colors.muted('# Vendor key auth')}`);
118
+ console.log(` ${colors.success(`${cmdName} login --oauth`)} ${colors.muted('# Browser OAuth')}`);
119
+ console.log();
120
+ }
121
+ console.log(colors.info('🔧 Shell Completions:'));
122
+ console.log(` ${colors.success(`${cmdName} completion`)} ${colors.muted('# Installation guide')}`);
123
+ console.log(` ${colors.success(`source <(${cmdName} --completion bash)`)} ${colors.muted('# Bash completions')}`);
97
124
  console.log();
98
125
  console.log(colors.info('📚 Documentation: https://docs.lanonasis.com/memory-services'));
99
126
  console.log(colors.info('🌐 Dashboard: https://api.lanonasis.com/dashboard'));
@@ -190,6 +217,8 @@ authCmd
190
217
  .description('Login to your MaaS account')
191
218
  .option('-e, --email <email>', 'email address')
192
219
  .option('-p, --password <password>', 'password')
220
+ .option('--vendor-key <key>', 'vendor key (pk_xxx.sk_xxx format)')
221
+ .option('--oauth', 'use OAuth browser flow')
193
222
  .action(loginCommand);
194
223
  authCmd
195
224
  .command('logout')
@@ -493,6 +522,53 @@ program
493
522
  console.log(chalk.white(`Please visit: ${url}`));
494
523
  });
495
524
  });
525
+ // Completion commands
526
+ program
527
+ .command('completion')
528
+ .description('Generate shell completion scripts')
529
+ .argument('[shell]', 'shell type (bash, zsh, fish)')
530
+ .action(async (shell) => {
531
+ if (!shell) {
532
+ await installCompletionsCommand();
533
+ return;
534
+ }
535
+ const completionsDir = path.join(__dirname, 'completions');
536
+ let scriptPath;
537
+ switch (shell.toLowerCase()) {
538
+ case 'bash':
539
+ scriptPath = path.join(completionsDir, 'bash-completion.sh');
540
+ break;
541
+ case 'zsh':
542
+ scriptPath = path.join(completionsDir, 'zsh-completion.zsh');
543
+ break;
544
+ case 'fish':
545
+ scriptPath = path.join(completionsDir, 'fish-completion.fish');
546
+ break;
547
+ default:
548
+ console.error(colors.error(`Unsupported shell: ${shell}`));
549
+ console.log(colors.info('Supported shells: bash, zsh, fish'));
550
+ process.exit(1);
551
+ }
552
+ try {
553
+ const script = fs.readFileSync(scriptPath, 'utf8');
554
+ console.log(script);
555
+ }
556
+ catch (error) {
557
+ console.error(colors.error('Failed to read completion script:'), error instanceof Error ? error.message : String(error));
558
+ process.exit(1);
559
+ }
560
+ });
561
+ // User guidance commands
562
+ program
563
+ .command('guide')
564
+ .alias('setup')
565
+ .description('Interactive setup guide for new users')
566
+ .action(guideCommand);
567
+ program
568
+ .command('quickstart')
569
+ .alias('quick')
570
+ .description('Show essential commands for quick start')
571
+ .action(quickStartCommand);
496
572
  // Help customization
497
573
  program.configureHelp({
498
574
  formatHelp: (cmd, helper) => {
@@ -520,13 +596,54 @@ program.configureHelp({
520
596
  });
521
597
  help += '\n';
522
598
  }
523
- help += chalk.gray('For more help on a specific command, run: memory <command> --help\n');
599
+ const cmdName = isOnasisInvocation ? 'onasis' : program.name();
600
+ help += chalk.gray(`For more help on a specific command, run: ${cmdName} <command> --help\n`);
524
601
  help += chalk.gray('Documentation: https://api.lanonasis.com/docs\n');
602
+ if (isOnasisInvocation) {
603
+ help += chalk.gray('Golden Contract: Onasis-Core v0.1 Compliant\n');
604
+ }
525
605
  return help;
526
606
  }
527
607
  });
528
608
  // Parse CLI arguments
529
609
  async function main() {
610
+ // Check for special flags first
611
+ if (process.argv.includes('--completion-data')) {
612
+ await completionCommand();
613
+ return;
614
+ }
615
+ if (process.argv.includes('--completion')) {
616
+ const shellIndex = process.argv.indexOf('--completion');
617
+ const shell = process.argv[shellIndex + 1];
618
+ if (shell && !shell.startsWith('-')) {
619
+ // Shell completion script request
620
+ const completionsDir = path.join(__dirname, 'completions');
621
+ let scriptPath;
622
+ switch (shell.toLowerCase()) {
623
+ case 'bash':
624
+ scriptPath = path.join(completionsDir, 'bash-completion.sh');
625
+ break;
626
+ case 'zsh':
627
+ scriptPath = path.join(completionsDir, 'zsh-completion.zsh');
628
+ break;
629
+ case 'fish':
630
+ scriptPath = path.join(completionsDir, 'fish-completion.fish');
631
+ break;
632
+ default:
633
+ console.error(colors.error(`Unsupported shell: ${shell}`));
634
+ process.exit(1);
635
+ }
636
+ try {
637
+ const script = fs.readFileSync(scriptPath, 'utf8');
638
+ console.log(script);
639
+ return;
640
+ }
641
+ catch (error) {
642
+ console.error(colors.error('Failed to read completion script'));
643
+ process.exit(1);
644
+ }
645
+ }
646
+ }
530
647
  // Show welcome message if no arguments provided
531
648
  if (process.argv.length <= 2) {
532
649
  showWelcome();
@@ -1,2 +1,38 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ /**
3
+ * CLI-Embedded MCP Server
4
+ * Uses the same configuration and authentication as @lanonasis/cli v1.5.2+
5
+ * Can run standalone or be invoked by CLI commands
6
+ */
7
+ interface MCPServerOptions {
8
+ mode?: 'stdio' | 'http';
9
+ port?: number;
10
+ verbose?: boolean;
11
+ useRemote?: boolean;
12
+ }
13
+ export declare class CLIMCPServer {
14
+ private config;
15
+ constructor();
16
+ /**
17
+ * Start MCP server using CLI configuration
18
+ */
19
+ start(options?: MCPServerOptions): Promise<void>;
20
+ /**
21
+ * Start local MCP server using CLI auth config
22
+ */
23
+ private startLocalMCP;
24
+ /**
25
+ * Connect to remote MCP server
26
+ */
27
+ private startRemoteMCP;
28
+ /**
29
+ * Check if MCP server is available and configured
30
+ */
31
+ checkStatus(): Promise<{
32
+ available: boolean;
33
+ configured: boolean;
34
+ authMethod: string;
35
+ mode: 'local' | 'remote' | 'auto';
36
+ }>;
37
+ }
38
+ export default CLIMCPServer;