@lanonasis/cli 1.0.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 ADDED
@@ -0,0 +1,217 @@
1
+ # Lanonasis CLI - Enterprise Infrastructure Management
2
+
3
+ 🚀 **Professional CLI for Lanonasis Platform Services**
4
+
5
+ The Lanonasis CLI provides a powerful command-line interface for interacting with the entire Lanonasis ecosystem, including Memory as a Service (MaaS), infrastructure management, and multi-service orchestration. Manage your memories, search through knowledge bases, organize your thoughts, and control your infrastructure - all from the terminal.
6
+
7
+ ## ⚡ Quick Start
8
+
9
+ ```bash
10
+ # Install globally
11
+ npm install -g @lanonasis/cli
12
+
13
+ # Or use with npx (no installation needed)
14
+ npx -y @lanonasis/cli init
15
+
16
+ # Initialize Lanonasis services
17
+ lanonasis init
18
+
19
+ # Configure your services
20
+ lanonasis config set api-url https://your-lanonasis-service.com
21
+
22
+ # Authenticate
23
+ lanonasis auth login
24
+
25
+ # Memory operations (also available as 'memory' and 'maas' commands)
26
+ lanonasis memory create -t "My First Memory" -c "This is the content of my memory"
27
+ lanonasis memory search "search query"
28
+ lanonasis memory list
29
+
30
+ # Infrastructure management (future services)
31
+ lanonasis deploy status
32
+ lanonasis services list
33
+ ```
34
+
35
+ ## 🚀 Installation
36
+
37
+ ### Global Installation (Recommended)
38
+ ```bash
39
+ npm install -g @lanonasis/cli
40
+ ```
41
+
42
+ ### NPX Usage (No Installation)
43
+ ```bash
44
+ npx -y @lanonasis/cli --help
45
+ npx -y @lanonasis/cli init
46
+ ```
47
+
48
+ ### Local Installation
49
+ ```bash
50
+ npm install @lanonasis/cli
51
+ npx lanonasis --help
52
+ ```
53
+
54
+ ## 📋 Available Commands
55
+
56
+ ### 🔧 Setup & Configuration
57
+ - `lanonasis init` - Initialize CLI and show setup instructions
58
+ - `lanonasis config set <key> <value>` - Set configuration values
59
+ - `lanonasis config get <key>` - Get configuration value
60
+ - `lanonasis config list` - List all configuration options
61
+ - `lanonasis status` - Show CLI status and configuration
62
+
63
+ ### 🔐 Authentication
64
+ - `lanonasis auth login` - Authenticate with your services
65
+ - `lanonasis auth logout` - Sign out
66
+ - `lanonasis auth status` - Check authentication status
67
+
68
+ ### 📝 Memory Operations
69
+ - `lanonasis create -t "Title" -c "Content" [--type <type>]` - Create new memory
70
+ - `lanonasis search <query> [-l <limit>]` - Search memories
71
+ - `lanonasis list [-l <limit>] [--type <type>]` - List memories
72
+ - `lanonasis help` - Show detailed help
73
+
74
+ #### Alternative Commands (Backwards Compatibility)
75
+ - `memory <command>` - Direct memory operations
76
+ - `maas <command>` - Memory as a Service operations
77
+
78
+ ## 🧠 Memory Types
79
+
80
+ The CLI supports the following memory types:
81
+ - **conversation** - Chat and dialogue context
82
+ - **knowledge** - Educational and reference content
83
+ - **project** - Project-specific documentation
84
+ - **context** - General contextual information
85
+ - **reference** - Quick reference materials
86
+
87
+ ## ⚙️ Configuration
88
+
89
+ Configure your CLI to connect to your Lanonasis services:
90
+
91
+ ```bash
92
+ # Set your service endpoint
93
+ lanonasis config set api-url https://your-lanonasis-service.com
94
+
95
+ # View current configuration
96
+ lanonasis config list
97
+ ```
98
+
99
+ ## 🔒 Authentication
100
+
101
+ Authenticate with your Lanonasis platform:
102
+
103
+ ```bash
104
+ # Login to your service
105
+ lanonasis auth login
106
+
107
+ # Check authentication status
108
+ lanonasis auth status
109
+
110
+ # Logout
111
+ lanonasis auth logout
112
+ ```
113
+
114
+ ## 📖 Usage Examples
115
+
116
+ ```bash
117
+ # Create different types of memories
118
+ lanonasis create -t "Meeting Notes" -c "Project kickoff discussion" --type project
119
+ lanonasis create -t "API Reference" -c "POST /api/memories endpoint" --type reference
120
+ lanonasis create -t "Learning Notes" -c "Vector embeddings concepts" --type knowledge
121
+
122
+ # Using npx (no installation)
123
+ npx -y @lanonasis/cli create -t "Quick Note" -c "NPX usage example"
124
+
125
+ # Search with different options
126
+ lanonasis search "API endpoints" -l 5
127
+ lanonasis search "project meeting"
128
+
129
+ # List with filters
130
+ lanonasis list --type project -l 10
131
+ lanonasis list -l 20
132
+
133
+ # Alternative command usage
134
+ memory search "my query" # Direct memory command
135
+ maas list --type knowledge # MaaS command
136
+ ```
137
+
138
+ ## 🌐 MaaS Service Integration
139
+
140
+ This CLI is designed to work with Memory as a Service platforms that provide:
141
+ - RESTful API endpoints
142
+ - JWT or API key authentication
143
+ - Vector-based memory search
144
+ - Multi-tenant memory storage
145
+
146
+ ### Setting up your MaaS Service
147
+
148
+ 1. **Deploy** a MaaS service using the provided backend
149
+ 2. **Configure** the CLI with your service endpoint
150
+ 3. **Authenticate** using your service credentials
151
+ 4. **Start** managing your memories!
152
+
153
+ ## 🛠️ Development
154
+
155
+ ### Prerequisites
156
+ - Node.js 18+
157
+ - npm or yarn
158
+
159
+ ### Local Development
160
+ ```bash
161
+ git clone <repository-url>
162
+ cd memory-cli
163
+ npm install
164
+
165
+ # Development mode
166
+ npm run dev
167
+
168
+ # Build
169
+ npm run build
170
+
171
+ # Test locally
172
+ node dist/index-simple.js help
173
+ ```
174
+
175
+ ## 📦 What's Included
176
+
177
+ - **Full CLI Interface** - Complete command-line tool
178
+ - **Memory Management** - Create, search, list memories
179
+ - **Type System** - Organized memory categorization
180
+ - **Authentication** - Secure service integration
181
+ - **Configuration** - Flexible service setup
182
+ - **Help System** - Comprehensive documentation
183
+
184
+ ## 🔗 Related Projects
185
+
186
+ - **Memory Service Backend** - Full MaaS API server
187
+ - **Memory SDK** - JavaScript/TypeScript SDK for developers
188
+ - **Memory Visualizer** - Interactive memory exploration
189
+
190
+ ## 📄 License
191
+
192
+ MIT License - see LICENSE file for details
193
+
194
+ ## 🤝 Contributing
195
+
196
+ 1. Fork the repository
197
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
198
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
199
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
200
+ 5. Open a Pull Request
201
+
202
+ ## 🐛 Support
203
+
204
+ - **Issues**: [GitHub Issues](https://github.com/seyederick/memory-cli/issues)
205
+ - **Documentation**: [CLI Documentation](https://github.com/seyederick/memory-cli)
206
+
207
+ ## 🎯 Use Cases
208
+
209
+ - **Personal Knowledge Management** - Organize your thoughts and notes
210
+ - **Team Knowledge Sharing** - Collaborative memory management
211
+ - **Project Documentation** - Context-aware project memories
212
+ - **Research Organization** - Academic and research note-taking
213
+ - **API Integration** - Programmatic memory management
214
+
215
+ ---
216
+
217
+ **Built with ❤️ for the Memory as a Service ecosystem**
@@ -0,0 +1 @@
1
+ export declare function loginCommand(options: any): Promise<void>;
@@ -0,0 +1,130 @@
1
+ import chalk from 'chalk';
2
+ import inquirer from 'inquirer';
3
+ import ora from 'ora';
4
+ import { apiClient } from '../utils/api.js';
5
+ import { CLIConfig } from '../utils/config.js';
6
+ export async function loginCommand(options) {
7
+ const config = new CLIConfig();
8
+ await config.init();
9
+ console.log(chalk.blue.bold('🔐 Login to MaaS (Supabase Auth)'));
10
+ console.log();
11
+ let { email, password } = options;
12
+ // Get credentials if not provided
13
+ if (!email || !password) {
14
+ const answers = await inquirer.prompt([
15
+ {
16
+ type: 'input',
17
+ name: 'email',
18
+ message: 'Email:',
19
+ default: email,
20
+ validate: (input) => {
21
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
22
+ return emailRegex.test(input) || 'Please enter a valid email address';
23
+ }
24
+ },
25
+ {
26
+ type: 'password',
27
+ name: 'password',
28
+ message: 'Password:',
29
+ mask: '*',
30
+ validate: (input) => input.length > 0 || 'Password is required'
31
+ }
32
+ ]);
33
+ email = answers.email;
34
+ password = answers.password;
35
+ }
36
+ const spinner = ora('Authenticating...').start();
37
+ try {
38
+ const response = await apiClient.login(email, password);
39
+ // Store token and user info
40
+ await config.setToken(response.token);
41
+ spinner.succeed('Login successful');
42
+ console.log();
43
+ console.log(chalk.green('✓ Authenticated successfully'));
44
+ console.log(`Welcome, ${response.user.email}!`);
45
+ if (response.user.organization_id) {
46
+ console.log(`Organization: ${response.user.organization_id}`);
47
+ }
48
+ console.log(`Plan: ${response.user.plan || 'free'}`);
49
+ }
50
+ catch (error) {
51
+ spinner.fail('Login failed');
52
+ if (error.response?.status === 401) {
53
+ console.error(chalk.red('✖ Invalid email or password'));
54
+ // Ask if they want to register
55
+ const answer = await inquirer.prompt([
56
+ {
57
+ type: 'confirm',
58
+ name: 'register',
59
+ message: 'Would you like to create a new account?',
60
+ default: false
61
+ }
62
+ ]);
63
+ if (answer.register) {
64
+ await registerFlow(email);
65
+ }
66
+ }
67
+ else {
68
+ console.error(chalk.red('✖ Login failed:'), error.message);
69
+ }
70
+ process.exit(1);
71
+ }
72
+ }
73
+ async function registerFlow(defaultEmail) {
74
+ console.log();
75
+ console.log(chalk.blue.bold('📝 Create New Account'));
76
+ console.log();
77
+ const answers = await inquirer.prompt([
78
+ {
79
+ type: 'input',
80
+ name: 'email',
81
+ message: 'Email:',
82
+ default: defaultEmail,
83
+ validate: (input) => {
84
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
85
+ return emailRegex.test(input) || 'Please enter a valid email address';
86
+ }
87
+ },
88
+ {
89
+ type: 'password',
90
+ name: 'password',
91
+ message: 'Password (min 8 characters):',
92
+ mask: '*',
93
+ validate: (input) => input.length >= 8 || 'Password must be at least 8 characters'
94
+ },
95
+ {
96
+ type: 'password',
97
+ name: 'confirmPassword',
98
+ message: 'Confirm password:',
99
+ mask: '*',
100
+ validate: (input, answers) => {
101
+ return input === answers.password || 'Passwords do not match';
102
+ }
103
+ },
104
+ {
105
+ type: 'input',
106
+ name: 'organizationName',
107
+ message: 'Organization name (optional):',
108
+ default: ''
109
+ }
110
+ ]);
111
+ const spinner = ora('Creating account...').start();
112
+ try {
113
+ const response = await apiClient.register(answers.email, answers.password, answers.organizationName || undefined);
114
+ const config = new CLIConfig();
115
+ await config.setToken(response.token);
116
+ spinner.succeed('Account created successfully');
117
+ console.log();
118
+ console.log(chalk.green('✓ Account created and authenticated'));
119
+ console.log(`Welcome to MaaS, ${response.user.email}!`);
120
+ if (answers.organizationName) {
121
+ console.log(`Organization: ${answers.organizationName}`);
122
+ }
123
+ console.log(`Plan: ${response.user.plan || 'free'}`);
124
+ }
125
+ catch (error) {
126
+ spinner.fail('Registration failed');
127
+ console.error(chalk.red('✖ Registration failed:'), error.message);
128
+ process.exit(1);
129
+ }
130
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function configCommands(program: Command): void;
@@ -0,0 +1,122 @@
1
+ import chalk from 'chalk';
2
+ import inquirer from 'inquirer';
3
+ import { CLIConfig } from '../utils/config.js';
4
+ import { apiClient } from '../utils/api.js';
5
+ export function configCommands(program) {
6
+ // Show current configuration
7
+ program
8
+ .command('show')
9
+ .description('Show current configuration')
10
+ .action(async () => {
11
+ const config = new CLIConfig();
12
+ await config.init();
13
+ console.log(chalk.blue.bold('⚙️ Current Configuration'));
14
+ console.log();
15
+ console.log(chalk.green('API URL:'), config.getApiUrl());
16
+ console.log(chalk.green('Config Path:'), config.getConfigPath());
17
+ const isAuth = await config.isAuthenticated();
18
+ console.log(chalk.green('Authenticated:'), isAuth ? chalk.green('Yes') : chalk.red('No'));
19
+ if (isAuth) {
20
+ const user = await config.getCurrentUser();
21
+ if (user) {
22
+ console.log(chalk.green('User:'), user.email);
23
+ console.log(chalk.green('Organization:'), user.organization_id);
24
+ console.log(chalk.green('Role:'), user.role);
25
+ console.log(chalk.green('Plan:'), user.plan);
26
+ }
27
+ }
28
+ });
29
+ // Set API URL
30
+ program
31
+ .command('set-url')
32
+ .description('Set API URL')
33
+ .argument('[url]', 'API URL')
34
+ .action(async (url) => {
35
+ const config = new CLIConfig();
36
+ await config.init();
37
+ if (!url) {
38
+ const answer = await inquirer.prompt([
39
+ {
40
+ type: 'input',
41
+ name: 'url',
42
+ message: 'API URL:',
43
+ default: config.getApiUrl(),
44
+ validate: (input) => {
45
+ try {
46
+ new URL(input);
47
+ return true;
48
+ }
49
+ catch {
50
+ return 'Please enter a valid URL';
51
+ }
52
+ }
53
+ }
54
+ ]);
55
+ url = answer.url;
56
+ }
57
+ await config.setApiUrl(url);
58
+ console.log(chalk.green('✓ API URL updated:'), url);
59
+ });
60
+ // Test connection
61
+ program
62
+ .command('test')
63
+ .description('Test connection to API')
64
+ .action(async () => {
65
+ const config = new CLIConfig();
66
+ await config.init();
67
+ console.log(chalk.blue('🔌 Testing connection...'));
68
+ console.log(chalk.gray(`API URL: ${config.getApiUrl()}`));
69
+ console.log();
70
+ try {
71
+ const health = await apiClient.getHealth();
72
+ console.log(chalk.green('✓ Connection successful'));
73
+ console.log(`Status: ${health.status}`);
74
+ console.log(`Version: ${health.version}`);
75
+ console.log(`Uptime: ${Math.round(health.uptime)}s`);
76
+ if (health.dependencies) {
77
+ console.log();
78
+ console.log(chalk.yellow('Dependencies:'));
79
+ Object.entries(health.dependencies).forEach(([name, info]) => {
80
+ const status = info.status === 'healthy' ? chalk.green('✓') : chalk.red('✖');
81
+ console.log(` ${status} ${name}: ${info.status} (${info.response_time}ms)`);
82
+ });
83
+ }
84
+ }
85
+ catch (error) {
86
+ console.log(chalk.red('✖ Connection failed'));
87
+ if (error.code === 'ECONNREFUSED') {
88
+ console.error(chalk.red('Cannot connect to API server'));
89
+ console.log(chalk.yellow('Make sure the API server is running'));
90
+ }
91
+ else {
92
+ console.error(chalk.red('Error:'), error.message);
93
+ }
94
+ process.exit(1);
95
+ }
96
+ });
97
+ // Reset configuration
98
+ program
99
+ .command('reset')
100
+ .description('Reset all configuration')
101
+ .option('-f, --force', 'skip confirmation')
102
+ .action(async (options) => {
103
+ if (!options.force) {
104
+ const answer = await inquirer.prompt([
105
+ {
106
+ type: 'confirm',
107
+ name: 'confirm',
108
+ message: 'Are you sure you want to reset all configuration? This will log you out.',
109
+ default: false
110
+ }
111
+ ]);
112
+ if (!answer.confirm) {
113
+ console.log(chalk.yellow('Reset cancelled'));
114
+ return;
115
+ }
116
+ }
117
+ const config = new CLIConfig();
118
+ await config.clear();
119
+ console.log(chalk.green('✓ Configuration reset'));
120
+ console.log(chalk.yellow('Run'), chalk.white('memory init'), chalk.yellow('to reconfigure'));
121
+ });
122
+ }
@@ -0,0 +1 @@
1
+ export declare function initCommand(options: any): Promise<void>;
@@ -0,0 +1,52 @@
1
+ import chalk from 'chalk';
2
+ import inquirer from 'inquirer';
3
+ import { CLIConfig } from '../utils/config.js';
4
+ export async function initCommand(options) {
5
+ const config = new CLIConfig();
6
+ console.log(chalk.blue.bold('🚀 Initializing MaaS CLI'));
7
+ console.log();
8
+ // Check if config already exists
9
+ const configExists = await config.exists();
10
+ if (configExists && !options.force) {
11
+ const answer = await inquirer.prompt([
12
+ {
13
+ type: 'confirm',
14
+ name: 'overwrite',
15
+ message: 'Configuration already exists. Overwrite?',
16
+ default: false
17
+ }
18
+ ]);
19
+ if (!answer.overwrite) {
20
+ console.log(chalk.yellow('Initialization cancelled'));
21
+ return;
22
+ }
23
+ }
24
+ // Get configuration
25
+ const answers = await inquirer.prompt([
26
+ {
27
+ type: 'input',
28
+ name: 'apiUrl',
29
+ message: 'API URL:',
30
+ default: 'http://localhost:3000/api/v1',
31
+ validate: (input) => {
32
+ try {
33
+ new URL(input);
34
+ return true;
35
+ }
36
+ catch {
37
+ return 'Please enter a valid URL';
38
+ }
39
+ }
40
+ }
41
+ ]);
42
+ // Initialize config
43
+ await config.init();
44
+ await config.setApiUrl(answers.apiUrl);
45
+ console.log();
46
+ console.log(chalk.green('✓ CLI initialized successfully'));
47
+ console.log(chalk.gray(`Configuration saved to: ${config.getConfigPath()}`));
48
+ console.log();
49
+ console.log(chalk.yellow('Next steps:'));
50
+ console.log(chalk.white(' memory login # Authenticate with your account'));
51
+ console.log(chalk.white(' memory --help # Show available commands'));
52
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function memoryCommands(program: Command): void;