@lanonasis/cli 1.5.2 → 2.0.1
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 +12 -3
- package/dist/core/achievements.d.ts +102 -0
- package/dist/core/achievements.js +425 -0
- package/dist/core/architecture.d.ts +145 -0
- package/dist/core/architecture.js +355 -0
- package/dist/core/dashboard.d.ts +71 -0
- package/dist/core/dashboard.js +569 -0
- package/dist/core/error-handler.d.ts +97 -0
- package/dist/core/error-handler.js +380 -0
- package/dist/core/power-mode.d.ts +118 -0
- package/dist/core/power-mode.js +460 -0
- package/dist/core/progress.d.ts +160 -0
- package/dist/core/progress.js +428 -0
- package/dist/core/welcome.d.ts +40 -0
- package/dist/core/welcome.js +466 -0
- package/dist/enhanced-cli.d.ts +15 -0
- package/dist/enhanced-cli.js +296 -0
- package/dist/index-simple.js +11 -3
- package/dist/utils/mcp-client.js +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Architecture for Enhanced CLI Experience
|
|
3
|
+
* Implements the layered architecture for state management, interaction, and presentation
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
// State Management Layer
|
|
8
|
+
export class StateManager extends EventEmitter {
|
|
9
|
+
navigationStack = [];
|
|
10
|
+
userContext;
|
|
11
|
+
sessionMemory;
|
|
12
|
+
preferences;
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.userContext = this.initializeUserContext();
|
|
16
|
+
this.sessionMemory = this.initializeSessionMemory();
|
|
17
|
+
this.preferences = this.loadPreferences();
|
|
18
|
+
}
|
|
19
|
+
initializeUserContext() {
|
|
20
|
+
return {
|
|
21
|
+
preferences: this.loadPreferences(),
|
|
22
|
+
sessionStarted: new Date(),
|
|
23
|
+
history: []
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
initializeSessionMemory() {
|
|
27
|
+
return {
|
|
28
|
+
recentCommands: [],
|
|
29
|
+
recentMemories: [],
|
|
30
|
+
searchHistory: [],
|
|
31
|
+
clipboardHistory: [],
|
|
32
|
+
undoStack: []
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
loadPreferences() {
|
|
36
|
+
// Load from config file or use defaults
|
|
37
|
+
return {
|
|
38
|
+
theme: 'default',
|
|
39
|
+
outputFormat: 'table',
|
|
40
|
+
verbosity: 'normal',
|
|
41
|
+
expertMode: false,
|
|
42
|
+
shortcuts: true,
|
|
43
|
+
animations: true,
|
|
44
|
+
autoComplete: true,
|
|
45
|
+
confirmDestructive: true
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Navigation methods
|
|
49
|
+
pushNavigation(state) {
|
|
50
|
+
this.navigationStack.push(state);
|
|
51
|
+
this.emit('navigation:push', state);
|
|
52
|
+
this.renderBreadcrumb();
|
|
53
|
+
}
|
|
54
|
+
popNavigation() {
|
|
55
|
+
if (this.navigationStack.length > 1) {
|
|
56
|
+
const state = this.navigationStack.pop();
|
|
57
|
+
this.emit('navigation:pop', state);
|
|
58
|
+
this.renderBreadcrumb();
|
|
59
|
+
return state;
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
getCurrentNavigation() {
|
|
64
|
+
return this.navigationStack[this.navigationStack.length - 1];
|
|
65
|
+
}
|
|
66
|
+
renderBreadcrumb() {
|
|
67
|
+
if (this.navigationStack.length > 0) {
|
|
68
|
+
const path = this.navigationStack.map(s => s.name).join(' > ');
|
|
69
|
+
console.log(chalk.dim(path));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Context methods
|
|
73
|
+
updateUserContext(updates) {
|
|
74
|
+
this.userContext = { ...this.userContext, ...updates };
|
|
75
|
+
this.emit('context:update', this.userContext);
|
|
76
|
+
}
|
|
77
|
+
getUserContext() {
|
|
78
|
+
return this.userContext;
|
|
79
|
+
}
|
|
80
|
+
// Session memory methods
|
|
81
|
+
addToHistory(command) {
|
|
82
|
+
this.sessionMemory.recentCommands.push(command);
|
|
83
|
+
if (this.sessionMemory.recentCommands.length > 100) {
|
|
84
|
+
this.sessionMemory.recentCommands.shift();
|
|
85
|
+
}
|
|
86
|
+
this.userContext.history.push(command);
|
|
87
|
+
}
|
|
88
|
+
getRecentCommands(limit = 10) {
|
|
89
|
+
return this.sessionMemory.recentCommands.slice(-limit);
|
|
90
|
+
}
|
|
91
|
+
// Preferences methods
|
|
92
|
+
updatePreference(key, value) {
|
|
93
|
+
this.preferences[key] = value;
|
|
94
|
+
this.savePreferences();
|
|
95
|
+
this.emit('preferences:update', { key, value });
|
|
96
|
+
}
|
|
97
|
+
getPreferences() {
|
|
98
|
+
return this.preferences;
|
|
99
|
+
}
|
|
100
|
+
savePreferences() {
|
|
101
|
+
// Save to config file
|
|
102
|
+
// Implementation would write to ~/.onasis/preferences.json
|
|
103
|
+
}
|
|
104
|
+
// Undo/Redo functionality
|
|
105
|
+
pushToUndoStack(action) {
|
|
106
|
+
this.sessionMemory.undoStack.push(action);
|
|
107
|
+
if (this.sessionMemory.undoStack.length > 50) {
|
|
108
|
+
this.sessionMemory.undoStack.shift();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
popFromUndoStack() {
|
|
112
|
+
return this.sessionMemory.undoStack.pop();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Interaction Engine
|
|
116
|
+
export class InteractionEngine {
|
|
117
|
+
stateManager;
|
|
118
|
+
promptSystem;
|
|
119
|
+
validationEngine;
|
|
120
|
+
feedbackLoop;
|
|
121
|
+
helpSystem;
|
|
122
|
+
constructor(stateManager) {
|
|
123
|
+
this.stateManager = stateManager;
|
|
124
|
+
this.promptSystem = new AdaptivePromptSystem(stateManager);
|
|
125
|
+
this.validationEngine = new ContextualValidator();
|
|
126
|
+
this.feedbackLoop = new RealTimeFeedback();
|
|
127
|
+
this.helpSystem = new InlineHelpProvider(stateManager);
|
|
128
|
+
}
|
|
129
|
+
async prompt(config) {
|
|
130
|
+
return this.promptSystem.prompt(config);
|
|
131
|
+
}
|
|
132
|
+
validate(value, rules) {
|
|
133
|
+
return this.validationEngine.validate(value, rules);
|
|
134
|
+
}
|
|
135
|
+
showFeedback(message, type) {
|
|
136
|
+
this.feedbackLoop.show(message, type);
|
|
137
|
+
}
|
|
138
|
+
getContextualHelp() {
|
|
139
|
+
return this.helpSystem.getHelp();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Adaptive Prompt System
|
|
143
|
+
export class AdaptivePromptSystem {
|
|
144
|
+
stateManager;
|
|
145
|
+
constructor(stateManager) {
|
|
146
|
+
this.stateManager = stateManager;
|
|
147
|
+
}
|
|
148
|
+
async prompt(config) {
|
|
149
|
+
const preferences = this.stateManager.getPreferences();
|
|
150
|
+
// Adapt prompt based on user preferences and context
|
|
151
|
+
if (preferences.expertMode) {
|
|
152
|
+
return this.expertPrompt(config);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
return this.guidedPrompt(config);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
async expertPrompt(config) {
|
|
159
|
+
// Minimal, streamlined prompt for expert users
|
|
160
|
+
// Implementation would use minimal UI elements
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
async guidedPrompt(config) {
|
|
164
|
+
// Rich, guided prompt with helpful hints
|
|
165
|
+
// Implementation would use enhanced UI elements
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Contextual Validator
|
|
170
|
+
export class ContextualValidator {
|
|
171
|
+
validate(value, rules) {
|
|
172
|
+
const errors = [];
|
|
173
|
+
const warnings = [];
|
|
174
|
+
const suggestions = [];
|
|
175
|
+
for (const rule of rules) {
|
|
176
|
+
const result = rule.validate(value);
|
|
177
|
+
if (!result.valid) {
|
|
178
|
+
if (result.severity === 'error') {
|
|
179
|
+
errors.push(result.message);
|
|
180
|
+
}
|
|
181
|
+
else if (result.severity === 'warning') {
|
|
182
|
+
warnings.push(result.message);
|
|
183
|
+
}
|
|
184
|
+
if (result.suggestion) {
|
|
185
|
+
suggestions.push(result.suggestion);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
valid: errors.length === 0,
|
|
191
|
+
errors,
|
|
192
|
+
warnings,
|
|
193
|
+
suggestions
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Real-time Feedback System
|
|
198
|
+
export class RealTimeFeedback {
|
|
199
|
+
icons = {
|
|
200
|
+
success: chalk.green('✓'),
|
|
201
|
+
error: chalk.red('✖'),
|
|
202
|
+
warning: chalk.yellow('⚠'),
|
|
203
|
+
info: chalk.cyan('ℹ'),
|
|
204
|
+
loading: chalk.blue('◐')
|
|
205
|
+
};
|
|
206
|
+
show(message, type) {
|
|
207
|
+
const icon = this.icons[type];
|
|
208
|
+
const colorFn = this.getColorFunction(type);
|
|
209
|
+
console.log(`${icon} ${colorFn(message)}`);
|
|
210
|
+
}
|
|
211
|
+
getColorFunction(type) {
|
|
212
|
+
switch (type) {
|
|
213
|
+
case 'success': return chalk.green;
|
|
214
|
+
case 'error': return chalk.red;
|
|
215
|
+
case 'warning': return chalk.yellow;
|
|
216
|
+
case 'info': return chalk.cyan;
|
|
217
|
+
default: return chalk.white;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
// Inline Help Provider
|
|
222
|
+
export class InlineHelpProvider {
|
|
223
|
+
stateManager;
|
|
224
|
+
constructor(stateManager) {
|
|
225
|
+
this.stateManager = stateManager;
|
|
226
|
+
}
|
|
227
|
+
getHelp() {
|
|
228
|
+
const currentState = this.stateManager.getCurrentNavigation();
|
|
229
|
+
const context = this.stateManager.getUserContext();
|
|
230
|
+
// Return contextual help based on current state
|
|
231
|
+
return this.generateHelpText(currentState, context);
|
|
232
|
+
}
|
|
233
|
+
generateHelpText(state, context) {
|
|
234
|
+
if (!state) {
|
|
235
|
+
return 'Type "help" for available commands';
|
|
236
|
+
}
|
|
237
|
+
// Generate context-specific help
|
|
238
|
+
const helps = {
|
|
239
|
+
'home': 'Main dashboard - choose an action or type a command',
|
|
240
|
+
'memory:create': 'Creating a new memory - provide title and content',
|
|
241
|
+
'memory:search': 'Search memories - use natural language or keywords',
|
|
242
|
+
'settings': 'Configure your preferences and authentication'
|
|
243
|
+
};
|
|
244
|
+
return helps[state.name] || 'Type "?" for help, "←" to go back';
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// Presentation Layer
|
|
248
|
+
export class PresentationLayer {
|
|
249
|
+
themeEngine;
|
|
250
|
+
layoutManager;
|
|
251
|
+
animationController;
|
|
252
|
+
constructor() {
|
|
253
|
+
this.themeEngine = new AdaptiveThemeEngine();
|
|
254
|
+
this.layoutManager = new ResponsiveLayoutManager();
|
|
255
|
+
this.animationController = new SubtleAnimationController();
|
|
256
|
+
}
|
|
257
|
+
applyTheme(theme) {
|
|
258
|
+
this.themeEngine.setTheme(theme);
|
|
259
|
+
}
|
|
260
|
+
renderLayout(content, layout) {
|
|
261
|
+
this.layoutManager.render(content, layout);
|
|
262
|
+
}
|
|
263
|
+
animate(element, animation) {
|
|
264
|
+
this.animationController.animate(element, animation);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
// Theme Engine
|
|
268
|
+
export class AdaptiveThemeEngine {
|
|
269
|
+
currentTheme = 'default';
|
|
270
|
+
themes = {
|
|
271
|
+
default: {
|
|
272
|
+
primary: chalk.blue.bold,
|
|
273
|
+
secondary: chalk.gray,
|
|
274
|
+
success: chalk.green,
|
|
275
|
+
warning: chalk.yellow,
|
|
276
|
+
error: chalk.red,
|
|
277
|
+
info: chalk.cyan,
|
|
278
|
+
accent: chalk.magenta,
|
|
279
|
+
muted: chalk.dim,
|
|
280
|
+
highlight: chalk.white.bold
|
|
281
|
+
},
|
|
282
|
+
dark: {
|
|
283
|
+
primary: chalk.cyanBright.bold,
|
|
284
|
+
secondary: chalk.gray,
|
|
285
|
+
success: chalk.greenBright,
|
|
286
|
+
warning: chalk.yellowBright,
|
|
287
|
+
error: chalk.redBright,
|
|
288
|
+
info: chalk.blueBright,
|
|
289
|
+
accent: chalk.magentaBright,
|
|
290
|
+
muted: chalk.dim,
|
|
291
|
+
highlight: chalk.whiteBright.bold
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
setTheme(theme) {
|
|
295
|
+
if (theme in this.themes) {
|
|
296
|
+
this.currentTheme = theme;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
getColors() {
|
|
300
|
+
return this.themes[this.currentTheme];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// Layout Manager
|
|
304
|
+
export class ResponsiveLayoutManager {
|
|
305
|
+
render(content, layout) {
|
|
306
|
+
// Implement different layout strategies
|
|
307
|
+
switch (layout) {
|
|
308
|
+
case 'card':
|
|
309
|
+
this.renderCard(content);
|
|
310
|
+
break;
|
|
311
|
+
case 'table':
|
|
312
|
+
this.renderTable(content);
|
|
313
|
+
break;
|
|
314
|
+
case 'dashboard':
|
|
315
|
+
this.renderDashboard(content);
|
|
316
|
+
break;
|
|
317
|
+
default:
|
|
318
|
+
console.log(content);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
renderCard(content) {
|
|
322
|
+
// Render content in card layout
|
|
323
|
+
console.log('╭─────────────────────────────────────────╮');
|
|
324
|
+
console.log(`│ ${content.title || ''}`.padEnd(42) + '│');
|
|
325
|
+
console.log('├─────────────────────────────────────────┤');
|
|
326
|
+
console.log(`│ ${content.body || ''}`.padEnd(42) + '│');
|
|
327
|
+
console.log('╰─────────────────────────────────────────╯');
|
|
328
|
+
}
|
|
329
|
+
renderTable(content) {
|
|
330
|
+
// Render content in table layout
|
|
331
|
+
// Implementation here
|
|
332
|
+
}
|
|
333
|
+
renderDashboard(content) {
|
|
334
|
+
// Render dashboard layout
|
|
335
|
+
// Implementation here
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
// Animation Controller
|
|
339
|
+
export class SubtleAnimationController {
|
|
340
|
+
animate(element, animation) {
|
|
341
|
+
// Implement subtle animations for CLI
|
|
342
|
+
// This would handle progress bars, spinners, etc.
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
// Factory to create the complete architecture
|
|
346
|
+
export function createCLIArchitecture() {
|
|
347
|
+
const stateManager = new StateManager();
|
|
348
|
+
const interactionEngine = new InteractionEngine(stateManager);
|
|
349
|
+
const presentationLayer = new PresentationLayer();
|
|
350
|
+
return {
|
|
351
|
+
stateManager,
|
|
352
|
+
interactionEngine,
|
|
353
|
+
presentationLayer
|
|
354
|
+
};
|
|
355
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Dashboard Command Center
|
|
3
|
+
* The central hub for all CLI operations after authentication
|
|
4
|
+
*/
|
|
5
|
+
import { StateManager } from './architecture.js';
|
|
6
|
+
export interface DashboardStats {
|
|
7
|
+
totalMemories: number;
|
|
8
|
+
totalTopics: number;
|
|
9
|
+
apiKeys: number;
|
|
10
|
+
recentActivity: ActivityItem[];
|
|
11
|
+
}
|
|
12
|
+
export interface ActivityItem {
|
|
13
|
+
action: string;
|
|
14
|
+
target: string;
|
|
15
|
+
timestamp: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class DashboardCommandCenter {
|
|
18
|
+
private stateManager;
|
|
19
|
+
private stats;
|
|
20
|
+
constructor(stateManager: StateManager);
|
|
21
|
+
show(): Promise<void>;
|
|
22
|
+
private render;
|
|
23
|
+
private renderHeader;
|
|
24
|
+
private renderStatsAndActivity;
|
|
25
|
+
private renderQuickStats;
|
|
26
|
+
private renderRecentActivity;
|
|
27
|
+
private renderMainMenu;
|
|
28
|
+
private renderFooter;
|
|
29
|
+
private handleUserInput;
|
|
30
|
+
private processInput;
|
|
31
|
+
private handleNumberedOption;
|
|
32
|
+
private createMemory;
|
|
33
|
+
private searchMemories;
|
|
34
|
+
private browseTopics;
|
|
35
|
+
private viewAnalytics;
|
|
36
|
+
private manageApiKeys;
|
|
37
|
+
private openSettings;
|
|
38
|
+
private showHelp;
|
|
39
|
+
private interpretSmartCommand;
|
|
40
|
+
private loadStats;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Interactive Memory Creator
|
|
44
|
+
*/
|
|
45
|
+
export declare class InteractiveMemoryCreator {
|
|
46
|
+
private stateManager;
|
|
47
|
+
constructor(stateManager: StateManager);
|
|
48
|
+
create(): Promise<void>;
|
|
49
|
+
createQuick(content: string): Promise<void>;
|
|
50
|
+
private analyzeContent;
|
|
51
|
+
private showPreview;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Interactive Search Experience
|
|
55
|
+
*/
|
|
56
|
+
export declare class InteractiveSearch {
|
|
57
|
+
private stateManager;
|
|
58
|
+
constructor(stateManager: StateManager);
|
|
59
|
+
search(initialQuery?: string): Promise<void>;
|
|
60
|
+
private displayResults;
|
|
61
|
+
private simulateDelay;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Analytics View
|
|
65
|
+
*/
|
|
66
|
+
export declare class AnalyticsView {
|
|
67
|
+
private stateManager;
|
|
68
|
+
constructor(stateManager: StateManager);
|
|
69
|
+
show(): Promise<void>;
|
|
70
|
+
private renderChart;
|
|
71
|
+
}
|