@memograph/cli 0.1.4

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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +402 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +97 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/core/detect.d.ts +30 -0
  8. package/dist/core/detect.d.ts.map +1 -0
  9. package/dist/core/detect.js +212 -0
  10. package/dist/core/detect.js.map +1 -0
  11. package/dist/core/extract.d.ts +6 -0
  12. package/dist/core/extract.d.ts.map +1 -0
  13. package/dist/core/extract.js +104 -0
  14. package/dist/core/extract.js.map +1 -0
  15. package/dist/core/inspect.d.ts +7 -0
  16. package/dist/core/inspect.d.ts.map +1 -0
  17. package/dist/core/inspect.js +98 -0
  18. package/dist/core/inspect.js.map +1 -0
  19. package/dist/core/llm/client.d.ts +55 -0
  20. package/dist/core/llm/client.d.ts.map +1 -0
  21. package/dist/core/llm/client.js +199 -0
  22. package/dist/core/llm/client.js.map +1 -0
  23. package/dist/core/llm/detect-llm.d.ts +28 -0
  24. package/dist/core/llm/detect-llm.d.ts.map +1 -0
  25. package/dist/core/llm/detect-llm.js +212 -0
  26. package/dist/core/llm/detect-llm.js.map +1 -0
  27. package/dist/core/llm/extract-llm.d.ts +27 -0
  28. package/dist/core/llm/extract-llm.d.ts.map +1 -0
  29. package/dist/core/llm/extract-llm.js +151 -0
  30. package/dist/core/llm/extract-llm.js.map +1 -0
  31. package/dist/core/llm/prompts.d.ts +28 -0
  32. package/dist/core/llm/prompts.d.ts.map +1 -0
  33. package/dist/core/llm/prompts.js +172 -0
  34. package/dist/core/llm/prompts.js.map +1 -0
  35. package/dist/core/llm/providers.d.ts +34 -0
  36. package/dist/core/llm/providers.d.ts.map +1 -0
  37. package/dist/core/llm/providers.js +169 -0
  38. package/dist/core/llm/providers.js.map +1 -0
  39. package/dist/core/load.d.ts +10 -0
  40. package/dist/core/load.d.ts.map +1 -0
  41. package/dist/core/load.js +106 -0
  42. package/dist/core/load.js.map +1 -0
  43. package/dist/core/normalize.d.ts +30 -0
  44. package/dist/core/normalize.d.ts.map +1 -0
  45. package/dist/core/normalize.js +63 -0
  46. package/dist/core/normalize.js.map +1 -0
  47. package/dist/core/render.d.ts +10 -0
  48. package/dist/core/render.d.ts.map +1 -0
  49. package/dist/core/render.js +60 -0
  50. package/dist/core/render.js.map +1 -0
  51. package/dist/core/score.d.ts +27 -0
  52. package/dist/core/score.d.ts.map +1 -0
  53. package/dist/core/score.js +59 -0
  54. package/dist/core/score.js.map +1 -0
  55. package/dist/core/types.d.ts +162 -0
  56. package/dist/core/types.d.ts.map +1 -0
  57. package/dist/core/types.js +6 -0
  58. package/dist/core/types.js.map +1 -0
  59. package/dist/interactive/index.d.ts +67 -0
  60. package/dist/interactive/index.d.ts.map +1 -0
  61. package/dist/interactive/index.js +794 -0
  62. package/dist/interactive/index.js.map +1 -0
  63. package/dist/interactive/settings.d.ts +36 -0
  64. package/dist/interactive/settings.d.ts.map +1 -0
  65. package/dist/interactive/settings.js +174 -0
  66. package/dist/interactive/settings.js.map +1 -0
  67. package/dist/interactive/wizard.d.ts +10 -0
  68. package/dist/interactive/wizard.d.ts.map +1 -0
  69. package/dist/interactive/wizard.js +249 -0
  70. package/dist/interactive/wizard.js.map +1 -0
  71. package/package.json +49 -0
@@ -0,0 +1,10 @@
1
+ import { InspectResult } from './types.js';
2
+ /**
3
+ * Render inspection result as human-readable text
4
+ */
5
+ export declare function renderTextReport(result: InspectResult): string;
6
+ /**
7
+ * Render inspection result as JSON
8
+ */
9
+ export declare function renderJsonReport(result: InspectResult): string;
10
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/core/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAoD9D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE9D"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderTextReport = renderTextReport;
4
+ exports.renderJsonReport = renderJsonReport;
5
+ /**
6
+ * Render inspection result as human-readable text
7
+ */
8
+ function renderTextReport(result) {
9
+ const lines = [];
10
+ // Header
11
+ lines.push('=== Memograph Inspect Report ===');
12
+ lines.push(`Drift Score: ${result.drift_score}/100 (raw: ${result.raw_score})`);
13
+ lines.push(`Token Waste: ${result.token_waste_pct}%`);
14
+ lines.push('');
15
+ // Critical Events
16
+ if (result.events.length > 0) {
17
+ lines.push('Critical Events:');
18
+ for (const event of result.events) {
19
+ const idxList = event.evidence.msg_idxs.join(',');
20
+ lines.push(`- [${event.type}] sev=${event.severity} conf=${event.confidence.toFixed(2)} idx=${idxList}`);
21
+ lines.push(` ${event.summary}`);
22
+ }
23
+ }
24
+ else {
25
+ lines.push('Critical Events: None detected');
26
+ }
27
+ lines.push('');
28
+ // Should-have-been memory
29
+ if (result.should_have_been_memory.length > 0) {
30
+ lines.push('Should-have-been memory (top):');
31
+ for (const fact of result.should_have_been_memory) {
32
+ lines.push(`- ${fact.fact_key}="${fact.fact_value}" @${fact.msg_idx} (conf ${fact.confidence.toFixed(2)})`);
33
+ }
34
+ }
35
+ else {
36
+ lines.push('Should-have-been memory: None extracted');
37
+ }
38
+ lines.push('');
39
+ // Timings
40
+ lines.push('Timings (ms):');
41
+ lines.push(`- extract_facts: ${result.timings_ms.extract_facts}`);
42
+ if (result.timings_ms.drift_detection !== undefined) {
43
+ lines.push(`- drift_detection: ${result.timings_ms.drift_detection}`);
44
+ }
45
+ else {
46
+ // Legacy/Heuristic mode timings
47
+ lines.push(`- repetition: ${result.timings_ms.repetition}`);
48
+ lines.push(`- session_reset: ${result.timings_ms.session_reset}`);
49
+ lines.push(`- contradictions: ${result.timings_ms.contradictions}`);
50
+ lines.push(`- pref_forgotten: ${result.timings_ms.pref_forgotten}`);
51
+ }
52
+ return lines.join('\n');
53
+ }
54
+ /**
55
+ * Render inspection result as JSON
56
+ */
57
+ function renderJsonReport(result) {
58
+ return JSON.stringify(result, null, 2);
59
+ }
60
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/core/render.ts"],"names":[],"mappings":";;AAKA,4CAoDC;AAKD,4CAEC;AA9DD;;GAEG;AACH,SAAgB,gBAAgB,CAAC,MAAqB;IACpD,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,SAAS;IACT,KAAK,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAC/C,KAAK,CAAC,IAAI,CAAC,gBAAgB,MAAM,CAAC,WAAW,cAAc,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC;IAChF,KAAK,CAAC,IAAI,CAAC,gBAAgB,MAAM,CAAC,eAAe,GAAG,CAAC,CAAC;IACtD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,kBAAkB;IAClB,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC/B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClC,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClD,KAAK,CAAC,IAAI,CACR,MAAM,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,QAAQ,SAAS,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,OAAO,EAAE,CAC7F,CAAC;YACF,KAAK,CAAC,IAAI,CA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AAC,IAAI,CAAC,qBAAqB,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;QACpE,KAAK,CAAC,IAAI,CAAC,qBAAqB,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,MAAqB;IACpD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { DriftEvent, TranscriptMessage } from './types.js';
2
+ /**
3
+ * Configurable weights for drift scoring
4
+ */
5
+ export declare const DEFAULT_WEIGHTS: {
6
+ preference_forgotten: number;
7
+ repetition_cluster: number;
8
+ session_reset: number;
9
+ contradiction: number;
10
+ };
11
+ /**
12
+ * Calculate drift score from events
13
+ */
14
+ export declare function calculateDriftScore(events: DriftEvent[], weights?: {
15
+ preference_forgotten: number;
16
+ repetition_cluster: number;
17
+ session_reset: number;
18
+ contradiction: number;
19
+ }): {
20
+ drift_score: number;
21
+ raw_score: number;
22
+ };
23
+ /**
24
+ * Calculate token waste percentage
25
+ */
26
+ export declare function calculateTokenWaste(messages: TranscriptMessage[], events: DriftEvent[]): number;
27
+ //# sourceMappingURL=score.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"score.d.ts","sourceRoot":"","sources":["../../src/core/score.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;CAK3B,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO;;;;;CAAkB,GACxB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAY5C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,MAAM,EAAE,UAAU,EAAE,GACnB,MAAM,CAiCR"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_WEIGHTS = void 0;
4
+ exports.calculateDriftScore = calculateDriftScore;
5
+ exports.calculateTokenWaste = calculateTokenWaste;
6
+ /**
7
+ * Configurable weights for drift scoring
8
+ */
9
+ exports.DEFAULT_WEIGHTS = {
10
+ preference_forgotten: 15,
11
+ repetition_cluster: 10,
12
+ session_reset: 20,
13
+ contradiction: 10,
14
+ };
15
+ /**
16
+ * Calculate drift score from events
17
+ */
18
+ function calculateDriftScore(events, weights = exports.DEFAULT_WEIGHTS) {
19
+ let raw_score = 0;
20
+ for (const event of events) {
21
+ const weight = weights[event.type] || 0;
22
+ raw_score += weight;
23
+ }
24
+ // Clamp to 0-100 range
25
+ const drift_score = Math.max(0, Math.min(100, raw_score));
26
+ return { drift_score, raw_score };
27
+ }
28
+ /**
29
+ * Calculate token waste percentage
30
+ */
31
+ function calculateTokenWaste(messages, events) {
32
+ // Find all repetition cluster events
33
+ const repetitionEvents = events.filter(e => e.type === 'repetition_cluster');
34
+ if (repetitionEvents.length === 0) {
35
+ return 0;
36
+ }
37
+ // Collect all message indices involved in repetitions
38
+ const wasteIndices = new Set();
39
+ for (const event of repetitionEvents) {
40
+ for (const idx of event.evidence.msg_idxs) {
41
+ wasteIndices.add(idx);
42
+ }
43
+ }
44
+ // Calculate waste tokens (from user messages in clusters)
45
+ let wasteTokens = 0;
46
+ for (const idx of wasteIndices) {
47
+ const msg = messages.find(m => m.idx === idx);
48
+ if (msg && msg.role === 'user') {
49
+ wasteTokens += msg.tokens || 0;
50
+ }
51
+ }
52
+ // Calculate total tokens
53
+ const totalTokens = messages.reduce((sum, msg) => sum + (msg.tokens || 0), 0);
54
+ if (totalTokens === 0) {
55
+ return 0;
56
+ }
57
+ return (wasteTokens / totalTokens) * 100;
58
+ }
59
+ //# sourceMappingURL=score.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"score.js","sourceRoot":"","sources":["../../src/core/score.ts"],"names":[],"mappings":";;;AAeA,kDAeC;AAKD,kDAoCC;AArED;;GAEG;AACU,QAAA,eAAe,GAAG;IAC7B,oBAAoB,EAAE,EAAE;IACxB,kBAAkB,EAAE,EAAE;IACtB,aAAa,EAAE,EAAE;IACjB,aAAa,EAAE,EAAE;CAClB,CAAC;AAEF;;GAEG;AACH,SAAgB,mBAAmB,CACjC,MAAoB,EACpB,OAAO,GAAG,uBAAe;IAEzB,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,IAA4B,CAAC,IAAI,CAAC,CAAC;QAChE,SAAS,IAAI,MAAM,CAAC;IACtB,CAAC;IAED,uBAAuB;IACvB,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;IAE1D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CACjC,QAA6B,EAC7B,MAAoB;IAEpB,qCAAqC;IACrC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,oBAAoB,CAAC,CAAC;IAE7E,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,CAAC,CAAC;IACX,CAAC;IAED,sDAAsD;IACtD,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IACvC,KAAK,MAAM,KAAK,IAAI,gBAAgB,EAAE,CAAC;QACrC,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC1C,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,0DAA0D;IAC1D,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;QAC9C,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC/B,WAAW,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,yBAAyB;IACzB,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAE9E,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC,GAAG,GAAG,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Core type definitions for Memograph CLI
3
+ */
4
+ import type { LLMProvider } from './llm/providers.js';
5
+ /**
6
+ * A single message in a conversation transcript
7
+ */
8
+ export interface TranscriptMessage {
9
+ /** Message index (0-based) */
10
+ idx: number;
11
+ /** Role of the message sender */
12
+ role: 'system' | 'user' | 'assistant' | 'tool';
13
+ /** Message content (text) */
14
+ content: string;
15
+ /** Optional ISO timestamp */
16
+ ts?: string;
17
+ /** Optional token count (estimated if missing) */
18
+ tokens?: number;
19
+ /** Optional session boundary marker */
20
+ session_id?: string;
21
+ /** Optional additional metadata */
22
+ metadata?: Record<string, unknown>;
23
+ }
24
+ /**
25
+ * Complete conversation transcript
26
+ */
27
+ export interface Transcript {
28
+ /** Schema version for forward compatibility */
29
+ schema_version: string;
30
+ /** Array of messages in conversation order */
31
+ messages: TranscriptMessage[];
32
+ /** Optional raw transcript content for non-JSON inputs */
33
+ raw_text?: string;
34
+ }
35
+ /**
36
+ * A fact extracted from the conversation
37
+ */
38
+ export interface ExtractedFact {
39
+ /** Fact category and key (e.g., "identity:name", "pref:language") */
40
+ fact_key: string;
41
+ /** Fact value */
42
+ fact_value: string;
43
+ /** Message index where fact was found */
44
+ msg_idx: number;
45
+ /** Confidence score (0-1) */
46
+ confidence: number;
47
+ }
48
+ /**
49
+ * Evidence for a drift event
50
+ */
51
+ export interface EventEvidence {
52
+ /** Message indices involved */
53
+ msg_idxs: number[];
54
+ /** Text snippets from messages */
55
+ snippets: string[];
56
+ /** Optional fact key involved */
57
+ fact_key?: string;
58
+ /** Optional additional context */
59
+ context?: Record<string, unknown>;
60
+ }
61
+ /**
62
+ * Base drift event
63
+ */
64
+ export interface BaseDriftEvent {
65
+ /** Event type discriminator */
66
+ type: string;
67
+ /** Severity (1-5, higher is worse) */
68
+ severity: number;
69
+ /** Confidence (0-1) */
70
+ confidence: number;
71
+ /** Supporting evidence */
72
+ evidence: EventEvidence;
73
+ /** Human-readable summary */
74
+ summary: string;
75
+ }
76
+ /**
77
+ * Repetition cluster event - user forced to repeat themselves
78
+ */
79
+ export interface RepetitionCluster extends BaseDriftEvent {
80
+ type: 'repetition_cluster';
81
+ /** Number of similar messages */
82
+ cluster_size: number;
83
+ }
84
+ /**
85
+ * Session reset event - assistant implies starting over
86
+ */
87
+ export interface SessionReset extends BaseDriftEvent {
88
+ type: 'session_reset';
89
+ /** Reset phrase that triggered detection */
90
+ reset_phrase: string;
91
+ }
92
+ /**
93
+ * Preference forgotten event - user restates preference
94
+ */
95
+ export interface PreferenceForgotten extends BaseDriftEvent {
96
+ type: 'preference_forgotten';
97
+ /** Preference that was forgotten */
98
+ preference_key: string;
99
+ /** Preference value */
100
+ preference_value: string;
101
+ }
102
+ /**
103
+ * Contradiction event - conflicting facts detected
104
+ */
105
+ export interface Contradiction extends BaseDriftEvent {
106
+ type: 'contradiction';
107
+ /** Old fact value */
108
+ old_value: string;
109
+ /** New (conflicting) fact value */
110
+ new_value: string;
111
+ }
112
+ /**
113
+ * Union of all drift event types
114
+ */
115
+ export type DriftEvent = RepetitionCluster | SessionReset | PreferenceForgotten | Contradiction;
116
+ /**
117
+ * Timing measurements for inspection phases
118
+ * Note: In LLM-only mode, individual detection types are not timed separately
119
+ * All drift detection is combined into drift_detection timing
120
+ */
121
+ export interface Timings {
122
+ extract_facts: number;
123
+ repetition: number;
124
+ session_reset: number;
125
+ contradictions: number;
126
+ pref_forgotten: number;
127
+ drift_detection?: number;
128
+ }
129
+ /**
130
+ * Complete inspection result
131
+ */
132
+ export interface InspectResult {
133
+ /** Drift score (0-100, higher is worse) */
134
+ drift_score: number;
135
+ /** Raw score before clamping */
136
+ raw_score: number;
137
+ /** Token waste percentage */
138
+ token_waste_pct: number;
139
+ /** Detected drift events */
140
+ events: DriftEvent[];
141
+ /** Facts that should have been remembered */
142
+ should_have_been_memory: ExtractedFact[];
143
+ /** Timing measurements (ms) */
144
+ timings_ms: Timings;
145
+ }
146
+ /**
147
+ * Configuration options for inspection (LLM-only)
148
+ */
149
+ export interface InspectConfig {
150
+ /** Maximum number of messages to process */
151
+ max_messages?: number;
152
+ /** LLM configuration (required for LLM-based analysis) */
153
+ llm?: {
154
+ provider?: LLMProvider;
155
+ apiKey?: string;
156
+ model?: string;
157
+ temperature?: number;
158
+ maxTokens?: number;
159
+ baseUrl?: string;
160
+ };
161
+ }
162
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC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C;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,4BAA4B;IAC5B,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,6CAA6C;IAC7C,uBAAuB,EAAE,aAAa,EAAE,CAAC;IACzC,+BAA+B;IAC/B,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,GAAG,CAAC,EAAE;QACJ,QAAQ,CAAC,EAAE,WAAW,CAAC;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Core type definitions for Memograph CLI
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Interactive CLI menu system for Memograph
3
+ * Uses Node.js built-in readline with arrow key navigation
4
+ */
5
+ import * as readline from 'readline';
6
+ import type { LLMProvider } from '../core/llm/providers.js';
7
+ export interface Settings {
8
+ llm: {
9
+ provider: LLMProvider;
10
+ model: string;
11
+ apiKey: string;
12
+ temperature: number;
13
+ maxTokens: number;
14
+ baseUrl?: string;
15
+ };
16
+ }
17
+ /**
18
+ * Ensure stdout is fully flushed before reading input
19
+ */
20
+ export declare function flushStdout(): Promise<void>;
21
+ /**
22
+ * Drain stdout completely and wait for all writes to finish
23
+ */
24
+ export declare function drainStdout(): Promise<void>;
25
+ /**
26
+ * Create a readline interface
27
+ */
28
+ export declare function createRL(): readline.Interface;
29
+ /**
30
+ * Create a readline interface optimized for interactive terminals
31
+ */
32
+ export declare function createTerminalRL(): readline.Interface;
33
+ /**
34
+ * Wait for Enter (return to menu) or Ctrl+C (exit)
35
+ * Used for the final analysis prompt to avoid readline issues
36
+ */
37
+ export declare function waitForEnterOrCtrlC(message: string): Promise<void>;
38
+ /**
39
+ * Reset stdin to canonical mode and clear listeners after raw input usage
40
+ */
41
+ export declare function resetStdinState(): void;
42
+ /**
43
+ * Ensure stdin is ready for readline input
44
+ * Call this before using readline after selectMenu
45
+ */
46
+ export declare function ensureStdinReady(): Promise<unknown>;
47
+ /**
48
+ * Ask a question and get user input (for text input)
49
+ */
50
+ export declare function ask(rl: readline.Interface, question: string): Promise<string>;
51
+ /**
52
+ * Ask a question and mask input (for sensitive text like API keys)
53
+ */
54
+ export declare function askMasked(question: string): Promise<string>;
55
+ /**
56
+ * Show an interactive select menu with arrow keys
57
+ */
58
+ export declare function selectMenu(title: string, options: string[], selectedIndex?: number, showBannerText?: boolean): Promise<number>;
59
+ /**
60
+ * Display current settings
61
+ */
62
+ export declare function displaySettings(settings: Settings): void;
63
+ /**
64
+ * Main menu
65
+ */
66
+ export declare function runInteractiveMode(settings?: Settings): Promise<void>;
67
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interactive/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAKrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAK5D,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE;QACH,QAAQ,EAAE,WAAW,CAAC;QACtB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAA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