minovative-mind-cli 2.8.3 → 2.9.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.
@@ -30,3 +30,219 @@ export function truncateForTerminal(str, maxLen) {
30
30
  // Truncate plain text safely without overflowing terminal columns
31
31
  return plain.slice(0, limit - 3) + '...';
32
32
  }
33
+ import { marked } from 'marked';
34
+ import { markedTerminal } from 'marked-terminal';
35
+ // Configure marked with markedTerminal for CLI rendering
36
+ marked.use(markedTerminal({ reflowText: false }));
37
+ /**
38
+ * Map of common LaTeX symbol and arrow commands to clean UTF-8 Unicode representations.
39
+ */
40
+ const LATEX_SYMBOL_MAP = {
41
+ // Right arrows
42
+ rightarrow: '→',
43
+ to: '→',
44
+ longrightarrow: '→',
45
+ Rightarrow: '⇒',
46
+ Longrightarrow: '⇒',
47
+ implies: '⇒',
48
+ twoheadrightarrow: '↠',
49
+ hookrightarrow: '↪',
50
+ looparrowright: '↬',
51
+ circlearrowright: '↻',
52
+ curvearrowright: '↷',
53
+ dashrightarrow: '⇢',
54
+ Rsh: '↱',
55
+ // Left arrows
56
+ leftarrow: '←',
57
+ longleftarrow: '←',
58
+ Leftarrow: '⇐',
59
+ Longleftarrow: '⇐',
60
+ impliedby: '⇐',
61
+ twoheadleftarrow: '↞',
62
+ hookleftarrow: '↩',
63
+ looparrowleft: '↫',
64
+ circlearrowleft: '↺',
65
+ curvearrowleft: '↶',
66
+ dashleftarrow: '⇠',
67
+ Lsh: '↰',
68
+ // Bidirectional arrows
69
+ leftrightarrow: '↔',
70
+ longleftrightarrow: '↔',
71
+ Leftrightarrow: '⇔',
72
+ LongLeftrightarrow: '⇔',
73
+ iff: '⇔',
74
+ // Up/Down arrows
75
+ uparrow: '↑',
76
+ downarrow: '↓',
77
+ updownarrow: '↕',
78
+ Uparrow: '⇑',
79
+ Downarrow: '⇓',
80
+ Updownarrow: '⇕',
81
+ // Special arrows
82
+ mapsto: '↦',
83
+ nearrow: '↗',
84
+ searrow: '↘',
85
+ swarrow: '↙',
86
+ nwarrow: '↖',
87
+ rightleftarrows: '⇄',
88
+ leftrightharpoons: '⇆',
89
+ rightharpoonup: '⇀',
90
+ // Logic & Set Theory
91
+ forall: '∀',
92
+ exists: '∃',
93
+ nexists: '∄',
94
+ in: '∈',
95
+ notin: '∉',
96
+ subset: '⊂',
97
+ supset: '⊃',
98
+ subseteq: '⊆',
99
+ supseteq: '⊇',
100
+ cap: '∩',
101
+ cup: '∪',
102
+ emptyset: '∅',
103
+ varnothing: '∅',
104
+ land: '∧',
105
+ lor: '∨',
106
+ neg: '¬',
107
+ top: '⊤',
108
+ bot: '⊥',
109
+ // Math operators & relations
110
+ cdot: '•',
111
+ times: '×',
112
+ div: '÷',
113
+ le: '≤',
114
+ leq: '≤',
115
+ ge: '≥',
116
+ geq: '≥',
117
+ neq: '≠',
118
+ ne: '≠',
119
+ approx: '≈',
120
+ equiv: '≡',
121
+ equivalent: '≡',
122
+ sim: '∼',
123
+ simeq: '≃',
124
+ cong: '≅',
125
+ prop: '∝',
126
+ propto: '∝',
127
+ infty: '∞',
128
+ pm: '±',
129
+ mp: '∓',
130
+ dots: '…',
131
+ ldots: '…',
132
+ circ: '∘',
133
+ bullet: '•',
134
+ star: '★',
135
+ ast: '∗',
136
+ partial: '∂',
137
+ nabla: '∇',
138
+ surd: '√',
139
+ sqrt: '√',
140
+ sum: '∑',
141
+ prod: '∏',
142
+ coprod: '∐',
143
+ int: '∫',
144
+ oint: '∮',
145
+ therefore: '∴',
146
+ because: '∵',
147
+ ll: '≪',
148
+ gg: '≫',
149
+ parallel: '∥',
150
+ perp: '⊥',
151
+ angle: '∠',
152
+ // Greek letters (Lowercase & Uppercase)
153
+ alpha: 'α',
154
+ beta: 'β',
155
+ gamma: 'γ',
156
+ delta: 'δ',
157
+ epsilon: 'ε',
158
+ zeta: 'ζ',
159
+ eta: 'η',
160
+ theta: 'θ',
161
+ iota: 'ι',
162
+ kappa: 'κ',
163
+ lambda: 'λ',
164
+ mu: 'μ',
165
+ nu: 'ν',
166
+ xi: 'ξ',
167
+ pi: 'π',
168
+ rho: 'ρ',
169
+ sigma: 'σ',
170
+ tau: 'τ',
171
+ phi: 'φ',
172
+ chi: 'χ',
173
+ psi: 'ψ',
174
+ omega: 'ω',
175
+ Gamma: 'Γ',
176
+ Delta: 'Δ',
177
+ Theta: 'Θ',
178
+ Lambda: 'Λ',
179
+ Xi: 'Ξ',
180
+ Pi: 'Π',
181
+ Sigma: 'Σ',
182
+ Phi: 'Φ',
183
+ Psi: 'Ψ',
184
+ Omega: 'Ω',
185
+ // Miscellaneous Symbols
186
+ checkmark: '✓',
187
+ degree: '°',
188
+ aleph: 'ℵ',
189
+ flat: '♭',
190
+ natural: '♮',
191
+ sharp: '♯',
192
+ };
193
+ /**
194
+ * Preprocesses text to convert LaTeX arrow syntax (e.g. `$\\rightarrow$`, `\\rightarrow`)
195
+ * and common math notation into clean Unicode characters, excluding code blocks and inline code.
196
+ *
197
+ * @param text - The markdown text string to convert.
198
+ * @returns The formatted text string with converted symbols.
199
+ */
200
+ export function replaceLatexSymbols(text) {
201
+ if (!text)
202
+ return '';
203
+ // Split text into code blocks / inline code and normal prose.
204
+ // Matches fenced code blocks ```...``` or inline code `...`
205
+ const codePattern = /(```[\s\S]*?```|`[^`\n]+`)/g;
206
+ const parts = text.split(codePattern);
207
+ return parts
208
+ .map((part) => {
209
+ // Preserve code blocks and inline code intact
210
+ if (part.startsWith('`')) {
211
+ return part;
212
+ }
213
+ let processed = part;
214
+ // 1. Replace math-delimited LaTeX commands: e.g. $\rightarrow$, $$\rightarrow$$, \(\rightarrow\), \[\rightarrow\]
215
+ processed = processed.replace(/(\$\$|\$|\\\(|\\\[)\s*\\([a-zA-Z]+)\s*(\$\$|\$|\\\)|\\\])/g, (fullMatch, _open, cmd) => {
216
+ if (LATEX_SYMBOL_MAP[cmd]) {
217
+ return LATEX_SYMBOL_MAP[cmd];
218
+ }
219
+ return fullMatch;
220
+ });
221
+ // 2. Replace standalone LaTeX commands in prose (not inside paths/words): e.g. \rightarrow, \to, \Rightarrow
222
+ processed = processed.replace(/(?<![a-zA-Z\/\\])\\([a-zA-Z]+)(?![a-zA-Z\/\\])/g, (fullMatch, cmd) => {
223
+ if (LATEX_SYMBOL_MAP[cmd]) {
224
+ return LATEX_SYMBOL_MAP[cmd];
225
+ }
226
+ return fullMatch;
227
+ });
228
+ // 3. Clean up leftover math delimiters around single converted Unicode symbols: e.g. $→$ -> →
229
+ processed = processed.replace(/(\$\$|\$|\\\(|\\\[)\s*([^\x00-\x7F]+)\s*(\$\$|\$|\\\)|\\\])/g, '$2');
230
+ return processed;
231
+ })
232
+ .join('');
233
+ }
234
+ /**
235
+ * Renders Markdown formatted text cleanly for terminal output.
236
+ * Strips excessive empty lines, replaces LaTeX math/arrow symbols with Unicode equivalents,
237
+ * and formats using marked-terminal.
238
+ *
239
+ * @param text - The markdown content to render.
240
+ * @returns The ANSI colorized and formatted terminal output.
241
+ */
242
+ export function renderTerminalMarkdown(text) {
243
+ if (!text)
244
+ return '';
245
+ const cleanText = text.replace(/\n([ \t]*\n){2,}/g, '\n\n');
246
+ const formattedText = replaceLatexSymbols(cleanText);
247
+ return marked.parse(formattedText);
248
+ }
@@ -65,5 +65,5 @@
65
65
  ]
66
66
  }
67
67
  },
68
- "version": "2.8.3"
68
+ "version": "2.9.0"
69
69
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minovative-mind-cli",
3
3
  "description": "An automated AI agent powered by Vertex AI that helps you write software",
4
- "version": "2.8.3",
4
+ "version": "2.9.0",
5
5
  "author": "Daniel Ward",
6
6
  "bin": {
7
7
  "minovative-mind-cli": "bin/run.js"