@lanonasis/cli 3.6.5 → 3.6.7
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/dist/commands/api-keys.d.ts +2 -1
- package/dist/commands/api-keys.js +73 -78
- package/dist/commands/auth.js +160 -167
- package/dist/commands/completion.js +31 -39
- package/dist/commands/config.js +162 -201
- package/dist/commands/enhanced-memory.js +11 -17
- package/dist/commands/guide.js +79 -88
- package/dist/commands/init.js +14 -20
- package/dist/commands/mcp.d.ts +10 -0
- package/dist/commands/mcp.js +167 -156
- package/dist/commands/memory.js +77 -83
- package/dist/commands/organization.js +15 -21
- package/dist/commands/topics.js +52 -58
- package/dist/core/achievements.js +19 -26
- package/dist/core/architecture.js +42 -59
- package/dist/core/dashboard.js +71 -81
- package/dist/core/error-handler.js +30 -39
- package/dist/core/power-mode.js +46 -53
- package/dist/core/progress.js +35 -44
- package/dist/core/welcome.js +56 -64
- package/dist/enhanced-cli.js +49 -58
- package/dist/index-simple.js +75 -113
- package/dist/index.js +64 -69
- package/dist/mcp/access-control.js +13 -17
- package/dist/mcp/client/enhanced-client.js +16 -23
- package/dist/mcp/enhanced-server.js +10 -14
- package/dist/mcp/logger.js +3 -7
- package/dist/mcp/memory-state.js +13 -17
- package/dist/mcp/schemas/tool-schemas.d.ts +16 -16
- package/dist/mcp/schemas/tool-schemas.js +122 -126
- package/dist/mcp/server/lanonasis-server.js +66 -57
- package/dist/mcp/transports/transport-manager.js +18 -25
- package/dist/mcp/vector-store.js +6 -10
- package/dist/mcp-server.js +23 -27
- package/dist/utils/api.js +19 -26
- package/dist/utils/config.d.ts +2 -1
- package/dist/utils/config.js +65 -78
- package/dist/utils/formatting.js +6 -14
- package/dist/utils/mcp-client.js +76 -117
- package/package.json +36 -5
package/dist/commands/config.js
CHANGED
|
@@ -1,90 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.configCommands = configCommands;
|
|
40
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
42
|
-
const path = __importStar(require("path"));
|
|
43
|
-
const config_js_1 = require("../utils/config.js");
|
|
44
|
-
const api_js_1 = require("../utils/api.js");
|
|
45
|
-
function configCommands(program) {
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { CLIConfig } from '../utils/config.js';
|
|
5
|
+
import { apiClient } from '../utils/api.js';
|
|
6
|
+
export function configCommands(program) {
|
|
46
7
|
// Generic config set command
|
|
47
8
|
program
|
|
48
9
|
.command('set <key> <value>')
|
|
49
10
|
.description('Set configuration value')
|
|
50
11
|
.action(async (key, value) => {
|
|
51
|
-
const config = new
|
|
12
|
+
const config = new CLIConfig();
|
|
52
13
|
await config.init();
|
|
53
14
|
// Handle special cases
|
|
54
15
|
switch (key) {
|
|
55
16
|
case 'api-url':
|
|
56
17
|
await config.setApiUrl(value);
|
|
57
|
-
console.log(
|
|
18
|
+
console.log(chalk.green('✓ API URL updated:'), value);
|
|
58
19
|
break;
|
|
59
20
|
case 'ai-integration':
|
|
60
21
|
if (value === 'claude-mcp') {
|
|
61
22
|
config.set('mcpEnabled', true);
|
|
62
23
|
config.set('aiIntegration', 'claude-mcp');
|
|
63
|
-
console.log(
|
|
64
|
-
console.log(
|
|
65
|
-
console.log(
|
|
24
|
+
console.log(chalk.green('✓ AI integration set to Claude MCP'));
|
|
25
|
+
console.log(chalk.cyan(' MCP will be automatically initialized for memory operations'));
|
|
26
|
+
console.log(chalk.cyan(' Run "lanonasis mcp-server init" to test the connection'));
|
|
66
27
|
}
|
|
67
28
|
else {
|
|
68
|
-
console.log(
|
|
69
|
-
console.log(
|
|
29
|
+
console.log(chalk.yellow('⚠️ Unknown AI integration:'), value);
|
|
30
|
+
console.log(chalk.gray(' Currently supported: claude-mcp'));
|
|
70
31
|
}
|
|
71
32
|
break;
|
|
72
33
|
case 'mcp-use-remote':
|
|
73
34
|
config.set('mcpUseRemote', value === 'true');
|
|
74
|
-
console.log(
|
|
35
|
+
console.log(chalk.green('✓ MCP remote mode:'), value === 'true' ? 'enabled' : 'disabled');
|
|
75
36
|
break;
|
|
76
37
|
case 'mcp-server-path':
|
|
77
38
|
config.set('mcpServerPath', value);
|
|
78
|
-
console.log(
|
|
39
|
+
console.log(chalk.green('✓ MCP server path updated:'), value);
|
|
79
40
|
break;
|
|
80
41
|
case 'mcp-server-url':
|
|
81
42
|
config.set('mcpServerUrl', value);
|
|
82
|
-
console.log(
|
|
43
|
+
console.log(chalk.green('✓ MCP server URL updated:'), value);
|
|
83
44
|
break;
|
|
84
45
|
default:
|
|
85
46
|
// Generic config set
|
|
86
47
|
config.set(key, value);
|
|
87
|
-
console.log(
|
|
48
|
+
console.log(chalk.green(`✓ ${key} set to:`), value);
|
|
88
49
|
}
|
|
89
50
|
});
|
|
90
51
|
// Generic config get command
|
|
@@ -92,14 +53,14 @@ function configCommands(program) {
|
|
|
92
53
|
.command('get <key>')
|
|
93
54
|
.description('Get configuration value')
|
|
94
55
|
.action(async (key) => {
|
|
95
|
-
const config = new
|
|
56
|
+
const config = new CLIConfig();
|
|
96
57
|
await config.init();
|
|
97
58
|
const value = config.get(key);
|
|
98
59
|
if (value !== undefined) {
|
|
99
|
-
console.log(
|
|
60
|
+
console.log(chalk.green(`${key}:`), value);
|
|
100
61
|
}
|
|
101
62
|
else {
|
|
102
|
-
console.log(
|
|
63
|
+
console.log(chalk.yellow(`⚠️ ${key} is not set`));
|
|
103
64
|
}
|
|
104
65
|
});
|
|
105
66
|
// Show current configuration
|
|
@@ -107,21 +68,21 @@ function configCommands(program) {
|
|
|
107
68
|
.command('show')
|
|
108
69
|
.description('Show current configuration')
|
|
109
70
|
.action(async () => {
|
|
110
|
-
const config = new
|
|
71
|
+
const config = new CLIConfig();
|
|
111
72
|
await config.init();
|
|
112
|
-
console.log(
|
|
73
|
+
console.log(chalk.blue.bold('⚙️ Current Configuration'));
|
|
113
74
|
console.log();
|
|
114
|
-
console.log(
|
|
115
|
-
console.log(
|
|
75
|
+
console.log(chalk.green('API URL:'), config.getApiUrl());
|
|
76
|
+
console.log(chalk.green('Config Path:'), config.getConfigPath());
|
|
116
77
|
const isAuth = await config.isAuthenticated();
|
|
117
|
-
console.log(
|
|
78
|
+
console.log(chalk.green('Authenticated:'), isAuth ? chalk.green('Yes') : chalk.red('No'));
|
|
118
79
|
if (isAuth) {
|
|
119
80
|
const user = await config.getCurrentUser();
|
|
120
81
|
if (user) {
|
|
121
|
-
console.log(
|
|
122
|
-
console.log(
|
|
123
|
-
console.log(
|
|
124
|
-
console.log(
|
|
82
|
+
console.log(chalk.green('User:'), user.email);
|
|
83
|
+
console.log(chalk.green('Organization:'), user.organization_id);
|
|
84
|
+
console.log(chalk.green('Role:'), user.role);
|
|
85
|
+
console.log(chalk.green('Plan:'), user.plan);
|
|
125
86
|
}
|
|
126
87
|
}
|
|
127
88
|
});
|
|
@@ -130,9 +91,9 @@ function configCommands(program) {
|
|
|
130
91
|
.command('list')
|
|
131
92
|
.description('List all configuration options')
|
|
132
93
|
.action(async () => {
|
|
133
|
-
const config = new
|
|
94
|
+
const config = new CLIConfig();
|
|
134
95
|
await config.init();
|
|
135
|
-
console.log(
|
|
96
|
+
console.log(chalk.blue.bold('📋 Configuration Options'));
|
|
136
97
|
console.log();
|
|
137
98
|
const configOptions = [
|
|
138
99
|
{ key: 'api-url', description: 'API endpoint URL', current: config.getApiUrl() },
|
|
@@ -143,10 +104,10 @@ function configCommands(program) {
|
|
|
143
104
|
{ key: 'mcpEnabled', description: 'MCP integration enabled', current: config.get('mcpEnabled') || false }
|
|
144
105
|
];
|
|
145
106
|
configOptions.forEach(opt => {
|
|
146
|
-
console.log(
|
|
107
|
+
console.log(chalk.green(opt.key.padEnd(20)), chalk.gray(opt.description.padEnd(30)), chalk.yellow(String(opt.current)));
|
|
147
108
|
});
|
|
148
109
|
console.log();
|
|
149
|
-
console.log(
|
|
110
|
+
console.log(chalk.gray('Use "lanonasis config set <key> <value>" to update any option'));
|
|
150
111
|
});
|
|
151
112
|
// Set API URL
|
|
152
113
|
program
|
|
@@ -154,10 +115,10 @@ function configCommands(program) {
|
|
|
154
115
|
.description('Set API URL')
|
|
155
116
|
.argument('[url]', 'API URL')
|
|
156
117
|
.action(async (url) => {
|
|
157
|
-
const config = new
|
|
118
|
+
const config = new CLIConfig();
|
|
158
119
|
await config.init();
|
|
159
120
|
if (!url) {
|
|
160
|
-
const answer = await
|
|
121
|
+
const answer = await inquirer.prompt([
|
|
161
122
|
{
|
|
162
123
|
type: 'input',
|
|
163
124
|
name: 'url',
|
|
@@ -177,43 +138,43 @@ function configCommands(program) {
|
|
|
177
138
|
url = answer.url;
|
|
178
139
|
}
|
|
179
140
|
await config.setApiUrl(url);
|
|
180
|
-
console.log(
|
|
141
|
+
console.log(chalk.green('✓ API URL updated:'), url);
|
|
181
142
|
});
|
|
182
143
|
// Test connection
|
|
183
144
|
program
|
|
184
145
|
.command('test')
|
|
185
146
|
.description('Test connection to API')
|
|
186
147
|
.action(async () => {
|
|
187
|
-
const config = new
|
|
148
|
+
const config = new CLIConfig();
|
|
188
149
|
await config.init();
|
|
189
|
-
console.log(
|
|
190
|
-
console.log(
|
|
150
|
+
console.log(chalk.blue('🔌 Testing connection...'));
|
|
151
|
+
console.log(chalk.gray(`API URL: ${config.getApiUrl()}`));
|
|
191
152
|
console.log();
|
|
192
153
|
try {
|
|
193
|
-
const health = await
|
|
194
|
-
console.log(
|
|
154
|
+
const health = await apiClient.getHealth();
|
|
155
|
+
console.log(chalk.green('✓ Connection successful'));
|
|
195
156
|
console.log(`Status: ${health.status}`);
|
|
196
157
|
console.log(`Version: ${health.version}`);
|
|
197
158
|
if (health.dependencies) {
|
|
198
159
|
console.log();
|
|
199
|
-
console.log(
|
|
160
|
+
console.log(chalk.yellow('Dependencies:'));
|
|
200
161
|
Object.entries(health.dependencies).forEach(([name, info]) => {
|
|
201
|
-
const status = info.status === 'healthy' ?
|
|
162
|
+
const status = info.status === 'healthy' ? chalk.green('✓') : chalk.red('✖');
|
|
202
163
|
const responseTime = info.response_time || info.latency_ms || 0;
|
|
203
164
|
console.log(` ${status} ${name}: ${info.status} (${responseTime}ms)`);
|
|
204
165
|
});
|
|
205
166
|
}
|
|
206
167
|
}
|
|
207
168
|
catch (error) {
|
|
208
|
-
console.log(
|
|
169
|
+
console.log(chalk.red('✖ Connection failed'));
|
|
209
170
|
const errorCode = error && typeof error === 'object' && 'code' in error ? error.code : null;
|
|
210
171
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
211
172
|
if (errorCode === 'ECONNREFUSED') {
|
|
212
|
-
console.error(
|
|
213
|
-
console.log(
|
|
173
|
+
console.error(chalk.red('Cannot connect to API server'));
|
|
174
|
+
console.log(chalk.yellow('Make sure the API server is running'));
|
|
214
175
|
}
|
|
215
176
|
else {
|
|
216
|
-
console.error(
|
|
177
|
+
console.error(chalk.red('Error:'), errorMessage);
|
|
217
178
|
}
|
|
218
179
|
process.exit(1);
|
|
219
180
|
}
|
|
@@ -224,17 +185,17 @@ function configCommands(program) {
|
|
|
224
185
|
.description('Discover service endpoints')
|
|
225
186
|
.option('-v, --verbose', 'show detailed discovery information')
|
|
226
187
|
.action(async (options) => {
|
|
227
|
-
const config = new
|
|
188
|
+
const config = new CLIConfig();
|
|
228
189
|
await config.init();
|
|
229
|
-
console.log(
|
|
190
|
+
console.log(chalk.blue('🔍 Discovering service endpoints...'));
|
|
230
191
|
console.log();
|
|
231
192
|
try {
|
|
232
193
|
await config.discoverServices(options.verbose);
|
|
233
194
|
const services = config.get('discoveredServices');
|
|
234
195
|
if (services) {
|
|
235
|
-
console.log(
|
|
196
|
+
console.log(chalk.green('✓ Service discovery completed'));
|
|
236
197
|
console.log();
|
|
237
|
-
console.log(
|
|
198
|
+
console.log(chalk.yellow('Discovered endpoints:'));
|
|
238
199
|
console.log(` Auth: ${services.auth_base}`);
|
|
239
200
|
console.log(` Memory: ${services.memory_base}`);
|
|
240
201
|
console.log(` MCP HTTP: ${services.mcp_base}`);
|
|
@@ -244,33 +205,33 @@ function configCommands(program) {
|
|
|
244
205
|
}
|
|
245
206
|
}
|
|
246
207
|
catch {
|
|
247
|
-
console.log(
|
|
248
|
-
console.log(
|
|
208
|
+
console.log(chalk.red('✖ Service discovery failed'));
|
|
209
|
+
console.log(chalk.gray('Using fallback endpoints'));
|
|
249
210
|
}
|
|
250
211
|
});
|
|
251
212
|
program
|
|
252
213
|
.command('endpoints')
|
|
253
214
|
.description('Show current service endpoints')
|
|
254
215
|
.action(async () => {
|
|
255
|
-
const config = new
|
|
216
|
+
const config = new CLIConfig();
|
|
256
217
|
await config.init();
|
|
257
218
|
const services = config.get('discoveredServices');
|
|
258
219
|
const hasManualOverrides = config.hasManualEndpointOverrides();
|
|
259
220
|
const lastDiscovery = config.get('lastServiceDiscovery');
|
|
260
221
|
const lastManualUpdate = config.get('lastManualEndpointUpdate');
|
|
261
|
-
console.log(
|
|
222
|
+
console.log(chalk.blue.bold('🌐 Service Endpoints'));
|
|
262
223
|
console.log();
|
|
263
224
|
if (services) {
|
|
264
|
-
console.log(
|
|
265
|
-
console.log(` Auth Base: ${
|
|
266
|
-
console.log(` Memory Base: ${
|
|
267
|
-
console.log(` MCP HTTP: ${
|
|
268
|
-
console.log(` MCP WebSocket: ${
|
|
269
|
-
console.log(` MCP SSE: ${
|
|
270
|
-
console.log(` Project Scope: ${
|
|
225
|
+
console.log(chalk.yellow('Current endpoints:'));
|
|
226
|
+
console.log(` Auth Base: ${chalk.white(services.auth_base)}`);
|
|
227
|
+
console.log(` Memory Base: ${chalk.white(services.memory_base)}`);
|
|
228
|
+
console.log(` MCP HTTP: ${chalk.white(services.mcp_base)}`);
|
|
229
|
+
console.log(` MCP WebSocket: ${chalk.white(services.mcp_ws_base)}`);
|
|
230
|
+
console.log(` MCP SSE: ${chalk.white(services.mcp_sse_base)}`);
|
|
231
|
+
console.log(` Project Scope: ${chalk.white(services.project_scope)}`);
|
|
271
232
|
console.log();
|
|
272
233
|
if (hasManualOverrides) {
|
|
273
|
-
console.log(
|
|
234
|
+
console.log(chalk.cyan('📝 Manual overrides are active'));
|
|
274
235
|
if (lastManualUpdate) {
|
|
275
236
|
const updateDate = new Date(lastManualUpdate);
|
|
276
237
|
console.log(` Last updated: ${updateDate.toLocaleString()}`);
|
|
@@ -278,30 +239,30 @@ function configCommands(program) {
|
|
|
278
239
|
}
|
|
279
240
|
else if (lastDiscovery) {
|
|
280
241
|
const discoveryDate = new Date(lastDiscovery);
|
|
281
|
-
console.log(
|
|
242
|
+
console.log(chalk.green('🔍 Endpoints from service discovery'));
|
|
282
243
|
console.log(` Last discovered: ${discoveryDate.toLocaleString()}`);
|
|
283
244
|
}
|
|
284
245
|
else {
|
|
285
|
-
console.log(
|
|
246
|
+
console.log(chalk.gray('📋 Using fallback endpoints'));
|
|
286
247
|
}
|
|
287
248
|
}
|
|
288
249
|
else {
|
|
289
|
-
console.log(
|
|
290
|
-
console.log(
|
|
250
|
+
console.log(chalk.yellow('⚠️ No endpoints configured'));
|
|
251
|
+
console.log(chalk.gray('Run: lanonasis config discover'));
|
|
291
252
|
}
|
|
292
253
|
});
|
|
293
254
|
program
|
|
294
255
|
.command('set-endpoint <type> <url>')
|
|
295
256
|
.description('Set manual endpoint override (auth|memory|mcp-http|mcp-ws|mcp-sse)')
|
|
296
257
|
.action(async (type, url) => {
|
|
297
|
-
const config = new
|
|
258
|
+
const config = new CLIConfig();
|
|
298
259
|
await config.init();
|
|
299
260
|
// Validate URL format
|
|
300
261
|
try {
|
|
301
262
|
new URL(url);
|
|
302
263
|
}
|
|
303
264
|
catch {
|
|
304
|
-
console.log(
|
|
265
|
+
console.log(chalk.red('✖ Invalid URL format'));
|
|
305
266
|
process.exit(1);
|
|
306
267
|
}
|
|
307
268
|
// Map type to config key
|
|
@@ -314,29 +275,29 @@ function configCommands(program) {
|
|
|
314
275
|
};
|
|
315
276
|
const configKey = endpointMap[type];
|
|
316
277
|
if (!configKey) {
|
|
317
|
-
console.log(
|
|
318
|
-
console.log(
|
|
278
|
+
console.log(chalk.red('✖ Invalid endpoint type'));
|
|
279
|
+
console.log(chalk.gray('Valid types: auth, memory, mcp-http, mcp-ws, mcp-sse'));
|
|
319
280
|
process.exit(1);
|
|
320
281
|
}
|
|
321
282
|
// Set the manual override
|
|
322
283
|
const overrides = { [configKey]: url };
|
|
323
284
|
await config.setManualEndpoints(overrides);
|
|
324
|
-
console.log(
|
|
325
|
-
console.log(
|
|
285
|
+
console.log(chalk.green(`✓ ${type} endpoint set to:`), url);
|
|
286
|
+
console.log(chalk.cyan('💡 Use "lanonasis config clear-overrides" to remove manual overrides'));
|
|
326
287
|
});
|
|
327
288
|
program
|
|
328
289
|
.command('clear-overrides')
|
|
329
290
|
.description('Clear manual endpoint overrides and rediscover services')
|
|
330
291
|
.action(async () => {
|
|
331
|
-
const config = new
|
|
292
|
+
const config = new CLIConfig();
|
|
332
293
|
await config.init();
|
|
333
294
|
if (!config.hasManualEndpointOverrides()) {
|
|
334
|
-
console.log(
|
|
295
|
+
console.log(chalk.yellow('⚠️ No manual overrides to clear'));
|
|
335
296
|
return;
|
|
336
297
|
}
|
|
337
298
|
await config.clearManualEndpointOverrides();
|
|
338
|
-
console.log(
|
|
339
|
-
console.log(
|
|
299
|
+
console.log(chalk.green('✓ Manual endpoint overrides cleared'));
|
|
300
|
+
console.log(chalk.cyan('✓ Service endpoints rediscovered'));
|
|
340
301
|
});
|
|
341
302
|
// Validate configuration
|
|
342
303
|
program
|
|
@@ -345,10 +306,10 @@ function configCommands(program) {
|
|
|
345
306
|
.option('-v, --verbose', 'show detailed validation information')
|
|
346
307
|
.option('--repair', 'automatically repair common issues')
|
|
347
308
|
.action(async (options) => {
|
|
348
|
-
const config = new
|
|
309
|
+
const config = new CLIConfig();
|
|
349
310
|
await config.init();
|
|
350
|
-
console.log(
|
|
351
|
-
console.log(
|
|
311
|
+
console.log(chalk.blue.bold('🔍 Configuration Validation'));
|
|
312
|
+
console.log(chalk.cyan('━'.repeat(50)));
|
|
352
313
|
console.log();
|
|
353
314
|
const validation = {
|
|
354
315
|
configExists: false,
|
|
@@ -363,101 +324,101 @@ function configCommands(program) {
|
|
|
363
324
|
repairs: []
|
|
364
325
|
};
|
|
365
326
|
// Step 1: Check config file existence and readability
|
|
366
|
-
console.log(
|
|
327
|
+
console.log(chalk.cyan('1. Configuration File'));
|
|
367
328
|
try {
|
|
368
329
|
validation.configExists = await config.exists();
|
|
369
330
|
if (validation.configExists) {
|
|
370
|
-
console.log(
|
|
331
|
+
console.log(chalk.green(' ✓ Config file exists at'), config.getConfigPath());
|
|
371
332
|
// Try to read the config
|
|
372
333
|
await config.load();
|
|
373
334
|
validation.configReadable = true;
|
|
374
|
-
console.log(
|
|
335
|
+
console.log(chalk.green(' ✓ Config file is readable'));
|
|
375
336
|
// Check config version
|
|
376
337
|
validation.configVersion = config.get('version');
|
|
377
338
|
if (validation.configVersion) {
|
|
378
|
-
console.log(
|
|
339
|
+
console.log(chalk.green(' ✓ Config version:'), validation.configVersion);
|
|
379
340
|
}
|
|
380
341
|
else {
|
|
381
|
-
console.log(
|
|
342
|
+
console.log(chalk.yellow(' ⚠ Config version missing (legacy config)'));
|
|
382
343
|
validation.issues.push('Config version missing');
|
|
383
344
|
if (options.repair) {
|
|
384
345
|
await config.save(); // This will add the version
|
|
385
346
|
validation.repairs.push('Added config version');
|
|
386
|
-
console.log(
|
|
347
|
+
console.log(chalk.cyan(' → Repaired: Added config version'));
|
|
387
348
|
}
|
|
388
349
|
}
|
|
389
350
|
validation.configFormat = true;
|
|
390
351
|
}
|
|
391
352
|
else {
|
|
392
|
-
console.log(
|
|
353
|
+
console.log(chalk.red(' ✖ Config file not found'));
|
|
393
354
|
validation.issues.push('Config file does not exist');
|
|
394
355
|
if (options.repair) {
|
|
395
356
|
await config.save(); // Create empty config
|
|
396
357
|
validation.repairs.push('Created config file');
|
|
397
|
-
console.log(
|
|
358
|
+
console.log(chalk.cyan(' → Repaired: Created config file'));
|
|
398
359
|
}
|
|
399
360
|
}
|
|
400
361
|
}
|
|
401
362
|
catch (error) {
|
|
402
|
-
console.log(
|
|
403
|
-
console.log(
|
|
363
|
+
console.log(chalk.red(' ✖ Config file is corrupted or unreadable'));
|
|
364
|
+
console.log(chalk.gray(` Error: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
404
365
|
validation.issues.push('Config file is corrupted');
|
|
405
366
|
if (options.repair) {
|
|
406
367
|
try {
|
|
407
368
|
// Try to backup the corrupted config
|
|
408
369
|
const backupPath = await config.backupConfig();
|
|
409
|
-
console.log(
|
|
370
|
+
console.log(chalk.cyan(` → Backed up corrupted config to: ${backupPath}`));
|
|
410
371
|
// Create new config
|
|
411
372
|
await config.clear();
|
|
412
373
|
await config.save();
|
|
413
374
|
validation.repairs.push('Recreated corrupted config file');
|
|
414
|
-
console.log(
|
|
375
|
+
console.log(chalk.cyan(' → Repaired: Recreated config file'));
|
|
415
376
|
}
|
|
416
377
|
catch {
|
|
417
|
-
console.log(
|
|
378
|
+
console.log(chalk.red(' ✖ Could not repair corrupted config'));
|
|
418
379
|
}
|
|
419
380
|
}
|
|
420
381
|
}
|
|
421
382
|
// Step 2: Validate authentication configuration
|
|
422
|
-
console.log(
|
|
383
|
+
console.log(chalk.cyan('\n2. Authentication Configuration'));
|
|
423
384
|
const token = config.getToken();
|
|
424
385
|
const vendorKey = config.getVendorKey();
|
|
425
386
|
const authMethod = config.get('authMethod');
|
|
426
387
|
if (!token && !vendorKey) {
|
|
427
|
-
console.log(
|
|
388
|
+
console.log(chalk.yellow(' ⚠ No authentication credentials configured'));
|
|
428
389
|
validation.issues.push('No authentication credentials');
|
|
429
390
|
}
|
|
430
391
|
else {
|
|
431
|
-
console.log(
|
|
392
|
+
console.log(chalk.green(' ✓ Authentication credentials found'));
|
|
432
393
|
// Validate auth method consistency
|
|
433
394
|
if (vendorKey && authMethod !== 'vendor_key') {
|
|
434
|
-
console.log(
|
|
395
|
+
console.log(chalk.yellow(' ⚠ Auth method mismatch (has vendor key but method is not vendor_key)'));
|
|
435
396
|
validation.issues.push('Auth method mismatch');
|
|
436
397
|
if (options.repair) {
|
|
437
398
|
config.set('authMethod', 'vendor_key');
|
|
438
399
|
await config.save();
|
|
439
400
|
validation.repairs.push('Fixed auth method for vendor key');
|
|
440
|
-
console.log(
|
|
401
|
+
console.log(chalk.cyan(' → Repaired: Set auth method to vendor_key'));
|
|
441
402
|
}
|
|
442
403
|
}
|
|
443
404
|
else if (token && !vendorKey && authMethod !== 'jwt' && authMethod !== 'oauth') {
|
|
444
|
-
console.log(
|
|
405
|
+
console.log(chalk.yellow(' ⚠ Auth method mismatch (has token but method is not jwt/oauth)'));
|
|
445
406
|
validation.issues.push('Auth method mismatch');
|
|
446
407
|
if (options.repair) {
|
|
447
408
|
config.set('authMethod', 'jwt');
|
|
448
409
|
await config.save();
|
|
449
410
|
validation.repairs.push('Fixed auth method for token');
|
|
450
|
-
console.log(
|
|
411
|
+
console.log(chalk.cyan(' → Repaired: Set auth method to jwt'));
|
|
451
412
|
}
|
|
452
413
|
}
|
|
453
414
|
// Validate vendor key presence if present
|
|
454
415
|
if (vendorKey) {
|
|
455
416
|
const formatValidation = config.validateVendorKeyFormat(vendorKey);
|
|
456
417
|
if (formatValidation === true) {
|
|
457
|
-
console.log(
|
|
418
|
+
console.log(chalk.green(' ✓ Vendor key is set'));
|
|
458
419
|
}
|
|
459
420
|
else {
|
|
460
|
-
console.log(
|
|
421
|
+
console.log(chalk.red(` ✖ Vendor key issue: ${formatValidation}`));
|
|
461
422
|
validation.issues.push('Vendor key missing or invalid');
|
|
462
423
|
}
|
|
463
424
|
}
|
|
@@ -466,28 +427,28 @@ function configCommands(program) {
|
|
|
466
427
|
const isValid = await config.validateStoredCredentials();
|
|
467
428
|
validation.authenticationValid = isValid;
|
|
468
429
|
if (isValid) {
|
|
469
|
-
console.log(
|
|
430
|
+
console.log(chalk.green(' ✓ Authentication credentials are valid'));
|
|
470
431
|
}
|
|
471
432
|
else {
|
|
472
|
-
console.log(
|
|
433
|
+
console.log(chalk.red(' ✖ Authentication credentials are invalid'));
|
|
473
434
|
validation.issues.push('Invalid authentication credentials');
|
|
474
435
|
}
|
|
475
436
|
}
|
|
476
437
|
catch (error) {
|
|
477
|
-
console.log(
|
|
438
|
+
console.log(chalk.yellow(' ⚠ Could not validate authentication credentials'));
|
|
478
439
|
if (options.verbose) {
|
|
479
|
-
console.log(
|
|
440
|
+
console.log(chalk.gray(` Error: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
480
441
|
}
|
|
481
442
|
}
|
|
482
443
|
}
|
|
483
444
|
// Step 3: Validate service endpoints
|
|
484
|
-
console.log(
|
|
445
|
+
console.log(chalk.cyan('\n3. Service Endpoints'));
|
|
485
446
|
try {
|
|
486
447
|
await config.discoverServices(options.verbose);
|
|
487
448
|
const services = config.get('discoveredServices');
|
|
488
449
|
if (services) {
|
|
489
450
|
validation.endpointsValid = true;
|
|
490
|
-
console.log(
|
|
451
|
+
console.log(chalk.green(' ✓ Service endpoints are configured'));
|
|
491
452
|
// Validate endpoint URLs
|
|
492
453
|
const endpoints = [
|
|
493
454
|
{ name: 'Auth', url: services.auth_base },
|
|
@@ -501,32 +462,32 @@ function configCommands(program) {
|
|
|
501
462
|
try {
|
|
502
463
|
new URL(endpoint.url);
|
|
503
464
|
if (options.verbose) {
|
|
504
|
-
console.log(
|
|
465
|
+
console.log(chalk.green(` ✓ ${endpoint.name}: ${endpoint.url}`));
|
|
505
466
|
}
|
|
506
467
|
}
|
|
507
468
|
catch {
|
|
508
|
-
console.log(
|
|
469
|
+
console.log(chalk.red(` ✖ Invalid ${endpoint.name} URL: ${endpoint.url}`));
|
|
509
470
|
validation.issues.push(`Invalid ${endpoint.name} URL`);
|
|
510
471
|
}
|
|
511
472
|
}
|
|
512
473
|
}
|
|
513
474
|
// Check for manual overrides
|
|
514
475
|
if (config.hasManualEndpointOverrides()) {
|
|
515
|
-
console.log(
|
|
476
|
+
console.log(chalk.cyan(' ℹ Manual endpoint overrides are active'));
|
|
516
477
|
const lastUpdate = config.get('lastManualEndpointUpdate');
|
|
517
478
|
if (lastUpdate && options.verbose) {
|
|
518
479
|
const updateDate = new Date(lastUpdate);
|
|
519
|
-
console.log(
|
|
480
|
+
console.log(chalk.gray(` Last updated: ${updateDate.toLocaleString()}`));
|
|
520
481
|
}
|
|
521
482
|
}
|
|
522
483
|
}
|
|
523
484
|
else {
|
|
524
|
-
console.log(
|
|
485
|
+
console.log(chalk.red(' ✖ Service endpoints are not configured'));
|
|
525
486
|
validation.issues.push('Service endpoints not configured');
|
|
526
487
|
}
|
|
527
488
|
}
|
|
528
489
|
catch {
|
|
529
|
-
console.log(
|
|
490
|
+
console.log(chalk.red(' ✖ Service endpoint discovery failed'));
|
|
530
491
|
validation.issues.push('Service endpoint discovery failed');
|
|
531
492
|
if (options.repair) {
|
|
532
493
|
// Set fallback endpoints
|
|
@@ -538,52 +499,52 @@ function configCommands(program) {
|
|
|
538
499
|
mcp_sse_base: 'https://mcp.lanonasis.com/api/v1/events'
|
|
539
500
|
});
|
|
540
501
|
validation.repairs.push('Set fallback service endpoints');
|
|
541
|
-
console.log(
|
|
502
|
+
console.log(chalk.cyan(' → Repaired: Set fallback service endpoints'));
|
|
542
503
|
}
|
|
543
504
|
}
|
|
544
505
|
// Step 4: Validate MCP configuration
|
|
545
|
-
console.log(
|
|
506
|
+
console.log(chalk.cyan('\n4. MCP Configuration'));
|
|
546
507
|
const mcpPreference = config.get('mcpPreference');
|
|
547
508
|
// const mcpServerPath = config.get<string>('mcpServerPath');
|
|
548
509
|
const mcpServerUrl = config.get('mcpServerUrl');
|
|
549
510
|
if (mcpPreference) {
|
|
550
511
|
if (['local', 'remote', 'auto'].includes(mcpPreference)) {
|
|
551
|
-
console.log(
|
|
512
|
+
console.log(chalk.green(` ✓ MCP preference: ${mcpPreference}`));
|
|
552
513
|
validation.mcpConfigValid = true;
|
|
553
514
|
}
|
|
554
515
|
else {
|
|
555
|
-
console.log(
|
|
516
|
+
console.log(chalk.red(` ✖ Invalid MCP preference: ${mcpPreference}`));
|
|
556
517
|
validation.issues.push('Invalid MCP preference');
|
|
557
518
|
if (options.repair) {
|
|
558
519
|
config.set('mcpPreference', 'auto');
|
|
559
520
|
await config.save();
|
|
560
521
|
validation.repairs.push('Reset MCP preference to auto');
|
|
561
|
-
console.log(
|
|
522
|
+
console.log(chalk.cyan(' → Repaired: Reset MCP preference to auto'));
|
|
562
523
|
}
|
|
563
524
|
}
|
|
564
525
|
}
|
|
565
526
|
else {
|
|
566
|
-
console.log(
|
|
527
|
+
console.log(chalk.yellow(' ⚠ MCP preference not set (using default: auto)'));
|
|
567
528
|
if (options.repair) {
|
|
568
529
|
config.set('mcpPreference', 'auto');
|
|
569
530
|
await config.save();
|
|
570
531
|
validation.repairs.push('Set default MCP preference');
|
|
571
|
-
console.log(
|
|
532
|
+
console.log(chalk.cyan(' → Repaired: Set MCP preference to auto'));
|
|
572
533
|
}
|
|
573
534
|
}
|
|
574
535
|
// Validate MCP URLs if present
|
|
575
536
|
if (mcpServerUrl) {
|
|
576
537
|
try {
|
|
577
538
|
new URL(mcpServerUrl);
|
|
578
|
-
console.log(
|
|
539
|
+
console.log(chalk.green(' ✓ MCP server URL is valid'));
|
|
579
540
|
}
|
|
580
541
|
catch {
|
|
581
|
-
console.log(
|
|
542
|
+
console.log(chalk.red(` ✖ Invalid MCP server URL: ${mcpServerUrl}`));
|
|
582
543
|
validation.issues.push('Invalid MCP server URL');
|
|
583
544
|
}
|
|
584
545
|
}
|
|
585
546
|
// Step 5: Check for configuration backup
|
|
586
|
-
console.log(
|
|
547
|
+
console.log(chalk.cyan('\n5. Configuration Backup'));
|
|
587
548
|
try {
|
|
588
549
|
const configDir = path.dirname(config.getConfigPath());
|
|
589
550
|
const fs = await import('fs/promises');
|
|
@@ -591,44 +552,44 @@ function configCommands(program) {
|
|
|
591
552
|
const backupFiles = files.filter(f => f.startsWith('config.backup.'));
|
|
592
553
|
if (backupFiles.length > 0) {
|
|
593
554
|
validation.backupExists = true;
|
|
594
|
-
console.log(
|
|
555
|
+
console.log(chalk.green(` ✓ Found ${backupFiles.length} configuration backup(s)`));
|
|
595
556
|
if (options.verbose) {
|
|
596
557
|
const latestBackup = backupFiles.sort().reverse()[0];
|
|
597
|
-
console.log(
|
|
558
|
+
console.log(chalk.gray(` Latest backup: ${latestBackup}`));
|
|
598
559
|
}
|
|
599
560
|
}
|
|
600
561
|
else {
|
|
601
|
-
console.log(
|
|
562
|
+
console.log(chalk.yellow(' ⚠ No configuration backups found'));
|
|
602
563
|
if (options.repair) {
|
|
603
564
|
const backupPath = await config.backupConfig();
|
|
604
565
|
validation.repairs.push('Created configuration backup');
|
|
605
|
-
console.log(
|
|
566
|
+
console.log(chalk.cyan(` → Repaired: Created backup at ${path.basename(backupPath)}`));
|
|
606
567
|
}
|
|
607
568
|
}
|
|
608
569
|
}
|
|
609
570
|
catch (error) {
|
|
610
|
-
console.log(
|
|
571
|
+
console.log(chalk.yellow(' ⚠ Could not check for backups'));
|
|
611
572
|
if (options.verbose) {
|
|
612
|
-
console.log(
|
|
573
|
+
console.log(chalk.gray(` Error: ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
613
574
|
}
|
|
614
575
|
}
|
|
615
576
|
// Summary and recommendations
|
|
616
|
-
console.log(
|
|
617
|
-
console.log(
|
|
577
|
+
console.log(chalk.blue.bold('\n📋 Configuration Validation Summary'));
|
|
578
|
+
console.log(chalk.cyan('━'.repeat(50)));
|
|
618
579
|
if (validation.issues.length === 0) {
|
|
619
|
-
console.log(
|
|
620
|
-
console.log(
|
|
580
|
+
console.log(chalk.green('✅ Configuration validation passed!'));
|
|
581
|
+
console.log(chalk.cyan(' Your configuration is valid and healthy.'));
|
|
621
582
|
}
|
|
622
583
|
else {
|
|
623
|
-
console.log(
|
|
584
|
+
console.log(chalk.red(`❌ Found ${validation.issues.length} issue(s):`));
|
|
624
585
|
validation.issues.forEach(issue => {
|
|
625
|
-
console.log(
|
|
586
|
+
console.log(chalk.red(` • ${issue}`));
|
|
626
587
|
});
|
|
627
588
|
}
|
|
628
589
|
if (validation.repairs.length > 0) {
|
|
629
|
-
console.log(
|
|
590
|
+
console.log(chalk.yellow(`\n🔧 Applied ${validation.repairs.length} repair(s):`));
|
|
630
591
|
validation.repairs.forEach(repair => {
|
|
631
|
-
console.log(
|
|
592
|
+
console.log(chalk.cyan(` • ${repair}`));
|
|
632
593
|
});
|
|
633
594
|
}
|
|
634
595
|
// Recommendations
|
|
@@ -646,9 +607,9 @@ function configCommands(program) {
|
|
|
646
607
|
recommendations.push('Run: lanonasis config validate --repair (to create backup)');
|
|
647
608
|
}
|
|
648
609
|
if (recommendations.length > 0) {
|
|
649
|
-
console.log(
|
|
610
|
+
console.log(chalk.yellow('\n💡 Recommended actions:'));
|
|
650
611
|
recommendations.forEach(rec => {
|
|
651
|
-
console.log(
|
|
612
|
+
console.log(chalk.cyan(` • ${rec}`));
|
|
652
613
|
});
|
|
653
614
|
}
|
|
654
615
|
});
|
|
@@ -657,16 +618,16 @@ function configCommands(program) {
|
|
|
657
618
|
.command('backup')
|
|
658
619
|
.description('Create a backup of current configuration')
|
|
659
620
|
.action(async () => {
|
|
660
|
-
const config = new
|
|
621
|
+
const config = new CLIConfig();
|
|
661
622
|
await config.init();
|
|
662
623
|
try {
|
|
663
624
|
const backupPath = await config.backupConfig();
|
|
664
|
-
console.log(
|
|
665
|
-
console.log(
|
|
625
|
+
console.log(chalk.green('✓ Configuration backed up to:'));
|
|
626
|
+
console.log(chalk.cyan(` ${backupPath}`));
|
|
666
627
|
}
|
|
667
628
|
catch (error) {
|
|
668
|
-
console.log(
|
|
669
|
-
console.log(
|
|
629
|
+
console.log(chalk.red('✖ Failed to create backup:'));
|
|
630
|
+
console.log(chalk.gray(` ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
670
631
|
process.exit(1);
|
|
671
632
|
}
|
|
672
633
|
});
|
|
@@ -676,7 +637,7 @@ function configCommands(program) {
|
|
|
676
637
|
.description('Restore configuration from backup')
|
|
677
638
|
.argument('[backup-file]', 'specific backup file to restore from')
|
|
678
639
|
.action(async (backupFile) => {
|
|
679
|
-
const config = new
|
|
640
|
+
const config = new CLIConfig();
|
|
680
641
|
await config.init();
|
|
681
642
|
try {
|
|
682
643
|
const configDir = path.dirname(config.getConfigPath());
|
|
@@ -691,17 +652,17 @@ function configCommands(program) {
|
|
|
691
652
|
const files = await fs.readdir(configDir);
|
|
692
653
|
const backupFiles = files.filter(f => f.startsWith('config.backup.')).sort().reverse();
|
|
693
654
|
if (backupFiles.length === 0) {
|
|
694
|
-
console.log(
|
|
695
|
-
console.log(
|
|
655
|
+
console.log(chalk.red('✖ No backup files found'));
|
|
656
|
+
console.log(chalk.gray(' Run: lanonasis config backup'));
|
|
696
657
|
process.exit(1);
|
|
697
658
|
}
|
|
698
659
|
backupPath = path.join(configDir, backupFiles[0]);
|
|
699
|
-
console.log(
|
|
660
|
+
console.log(chalk.cyan(`Using latest backup: ${backupFiles[0]}`));
|
|
700
661
|
}
|
|
701
662
|
// Verify backup file exists
|
|
702
663
|
await fs.access(backupPath);
|
|
703
664
|
// Confirm restoration
|
|
704
|
-
const answer = await
|
|
665
|
+
const answer = await inquirer.prompt([
|
|
705
666
|
{
|
|
706
667
|
type: 'confirm',
|
|
707
668
|
name: 'confirm',
|
|
@@ -710,20 +671,20 @@ function configCommands(program) {
|
|
|
710
671
|
}
|
|
711
672
|
]);
|
|
712
673
|
if (!answer.confirm) {
|
|
713
|
-
console.log(
|
|
674
|
+
console.log(chalk.yellow('Restore cancelled'));
|
|
714
675
|
return;
|
|
715
676
|
}
|
|
716
677
|
// Create backup of current config before restoring
|
|
717
678
|
const currentBackupPath = await config.backupConfig();
|
|
718
|
-
console.log(
|
|
679
|
+
console.log(chalk.cyan(`Current config backed up to: ${path.basename(currentBackupPath)}`));
|
|
719
680
|
// Restore from backup
|
|
720
681
|
await fs.copyFile(backupPath, config.getConfigPath());
|
|
721
|
-
console.log(
|
|
722
|
-
console.log(
|
|
682
|
+
console.log(chalk.green('✓ Configuration restored from backup'));
|
|
683
|
+
console.log(chalk.cyan(' You may need to re-authenticate if credentials were changed'));
|
|
723
684
|
}
|
|
724
685
|
catch (error) {
|
|
725
|
-
console.log(
|
|
726
|
-
console.log(
|
|
686
|
+
console.log(chalk.red('✖ Failed to restore from backup:'));
|
|
687
|
+
console.log(chalk.gray(` ${error instanceof Error ? error.message : 'Unknown error'}`));
|
|
727
688
|
process.exit(1);
|
|
728
689
|
}
|
|
729
690
|
});
|
|
@@ -734,7 +695,7 @@ function configCommands(program) {
|
|
|
734
695
|
.option('-f, --force', 'skip confirmation')
|
|
735
696
|
.action(async (options) => {
|
|
736
697
|
if (!options.force) {
|
|
737
|
-
const answer = await
|
|
698
|
+
const answer = await inquirer.prompt([
|
|
738
699
|
{
|
|
739
700
|
type: 'confirm',
|
|
740
701
|
name: 'confirm',
|
|
@@ -743,21 +704,21 @@ function configCommands(program) {
|
|
|
743
704
|
}
|
|
744
705
|
]);
|
|
745
706
|
if (!answer.confirm) {
|
|
746
|
-
console.log(
|
|
707
|
+
console.log(chalk.yellow('Reset cancelled'));
|
|
747
708
|
return;
|
|
748
709
|
}
|
|
749
710
|
}
|
|
750
|
-
const config = new
|
|
711
|
+
const config = new CLIConfig();
|
|
751
712
|
// Create backup before reset
|
|
752
713
|
try {
|
|
753
714
|
const backupPath = await config.backupConfig();
|
|
754
|
-
console.log(
|
|
715
|
+
console.log(chalk.cyan(`Configuration backed up to: ${path.basename(backupPath)}`));
|
|
755
716
|
}
|
|
756
717
|
catch {
|
|
757
718
|
// Ignore backup errors during reset
|
|
758
719
|
}
|
|
759
720
|
await config.clear();
|
|
760
|
-
console.log(
|
|
761
|
-
console.log(
|
|
721
|
+
console.log(chalk.green('✓ Configuration reset'));
|
|
722
|
+
console.log(chalk.yellow('Run'), chalk.white('lanonasis auth login'), chalk.yellow('to reconfigure'));
|
|
762
723
|
});
|
|
763
724
|
}
|