omnibiofex 2.6.1 โ 2.6.3
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/package.json +1 -1
- package/src/utils/display.js +169 -29
package/package.json
CHANGED
package/src/utils/display.js
CHANGED
|
@@ -344,14 +344,136 @@ function addVisualBreak() {
|
|
|
344
344
|
console.log(chalk.gray('\n' + 'ยท'.repeat(60) + '\n'));
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
-
// ====================
|
|
347
|
+
// ==================== INLINE MARKDOWN PARSER ====================
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Parse a line and return array of segments with formatting
|
|
351
|
+
* Handles: **bold**, *italic*, `code`, and combinations
|
|
352
|
+
*/
|
|
353
|
+
function parseInlineMarkdown(text) {
|
|
354
|
+
const segments = [];
|
|
355
|
+
let remaining = text;
|
|
356
|
+
|
|
357
|
+
while (remaining.length > 0) {
|
|
358
|
+
// Find the next markdown pattern
|
|
359
|
+
const boldMatch = remaining.match(/\*\*(.+?)\*\*/);
|
|
360
|
+
const italicMatch = remaining.match(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/);
|
|
361
|
+
const codeMatch = remaining.match(/`([^`]+)`/);
|
|
362
|
+
|
|
363
|
+
// Find earliest match
|
|
364
|
+
let earliest = null;
|
|
365
|
+
let earliestIndex = remaining.length;
|
|
366
|
+
|
|
367
|
+
if (boldMatch && boldMatch.index < earliestIndex) {
|
|
368
|
+
earliest = { type: 'bold', match: boldMatch, index: boldMatch.index };
|
|
369
|
+
earliestIndex = boldMatch.index;
|
|
370
|
+
}
|
|
371
|
+
if (codeMatch && codeMatch.index < earliestIndex) {
|
|
372
|
+
earliest = { type: 'code', match: codeMatch, index: codeMatch.index };
|
|
373
|
+
earliestIndex = codeMatch.index;
|
|
374
|
+
}
|
|
375
|
+
if (italicMatch && italicMatch.index < earliestIndex) {
|
|
376
|
+
earliest = { type: 'italic', match: italicMatch, index: italicMatch.index };
|
|
377
|
+
earliestIndex = italicMatch.index;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
if (!earliest) {
|
|
381
|
+
// No more markdown, add remaining as plain text
|
|
382
|
+
if (remaining.length > 0) {
|
|
383
|
+
segments.push({ text: remaining, style: 'plain' });
|
|
384
|
+
}
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Add text before the match
|
|
389
|
+
if (earliestIndex > 0) {
|
|
390
|
+
segments.push({
|
|
391
|
+
text: remaining.substring(0, earliestIndex),
|
|
392
|
+
style: 'plain'
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// Add the formatted segment
|
|
397
|
+
segments.push({
|
|
398
|
+
text: earliest.match[1],
|
|
399
|
+
style: earliest.type
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
// Continue with remaining text
|
|
403
|
+
remaining = remaining.substring(earliestIndex + earliest.match[0].length);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
return segments;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Type a line with inline markdown formatting (bold, italic, code)
|
|
411
|
+
*/
|
|
412
|
+
async function typeFormattedLine(text, speed = 8) {
|
|
413
|
+
const segments = parseInlineMarkdown(text);
|
|
414
|
+
|
|
415
|
+
for (const segment of segments) {
|
|
416
|
+
let colorFn = chalk.white;
|
|
417
|
+
|
|
418
|
+
switch (segment.style) {
|
|
419
|
+
case 'bold':
|
|
420
|
+
colorFn = chalk.white.bold;
|
|
421
|
+
break;
|
|
422
|
+
case 'italic':
|
|
423
|
+
colorFn = chalk.white.italic;
|
|
424
|
+
break;
|
|
425
|
+
case 'code':
|
|
426
|
+
colorFn = chalk.bgBlack.cyan;
|
|
427
|
+
break;
|
|
428
|
+
case 'plain':
|
|
429
|
+
default:
|
|
430
|
+
colorFn = chalk.white;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
await typeText(segment.text, speed, colorFn);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
process.stdout.write('\n');
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Type a line with inline markdown, but use gray color for plain text
|
|
441
|
+
*/
|
|
442
|
+
async function typeFormattedLineGray(text, speed = 6) {
|
|
443
|
+
const segments = parseInlineMarkdown(text);
|
|
444
|
+
|
|
445
|
+
for (const segment of segments) {
|
|
446
|
+
let colorFn = chalk.gray;
|
|
447
|
+
|
|
448
|
+
switch (segment.style) {
|
|
449
|
+
case 'bold':
|
|
450
|
+
colorFn = chalk.white.bold;
|
|
451
|
+
break;
|
|
452
|
+
case 'italic':
|
|
453
|
+
colorFn = chalk.white.italic;
|
|
454
|
+
break;
|
|
455
|
+
case 'code':
|
|
456
|
+
colorFn = chalk.bgBlack.cyan;
|
|
457
|
+
break;
|
|
458
|
+
case 'plain':
|
|
459
|
+
default:
|
|
460
|
+
colorFn = chalk.gray;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
await typeText(segment.text, speed, colorFn);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
process.stdout.write('\n');
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// ==================== UPDATED AI RESPONSE RENDERER ====================
|
|
470
|
+
|
|
348
471
|
async function typeAIResponse(response) {
|
|
349
472
|
console.log(chalk.hex('#F24E1E').bold('\n๐ Research Report\n'));
|
|
350
473
|
console.log(chalk.gray('โ'.repeat(60)) + '\n');
|
|
351
474
|
|
|
352
475
|
const lines = response.split('\n');
|
|
353
476
|
let inTable = false;
|
|
354
|
-
let tableBuffer = [];
|
|
355
477
|
|
|
356
478
|
for (let i = 0; i < lines.length; i++) {
|
|
357
479
|
const line = lines[i];
|
|
@@ -368,28 +490,53 @@ async function typeAIResponse(response) {
|
|
|
368
490
|
|
|
369
491
|
// Detect table rows (lines with |)
|
|
370
492
|
if (trimmed.includes('|') && trimmed.startsWith('|')) {
|
|
493
|
+
// Skip separator rows like |---|---| or | ---------- |
|
|
494
|
+
if (trimmed.match(/^\|[\s\-:]+\|$/)) {
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
|
|
371
498
|
if (!inTable) {
|
|
372
499
|
inTable = true;
|
|
373
500
|
console.log(chalk.gray('โ' + 'โ'.repeat(58) + 'โ'));
|
|
374
501
|
}
|
|
375
502
|
|
|
376
|
-
// Skip separator rows like |---|---|
|
|
377
|
-
if (trimmed.match(/^\|[\s\-:]+\|$/)) {
|
|
378
|
-
continue;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
503
|
// Parse table cells
|
|
382
504
|
const cells = trimmed.split('|').filter(c => c.trim() !== '').map(c => c.trim());
|
|
383
505
|
|
|
384
|
-
// Format table row
|
|
506
|
+
// Format table row with inline markdown support
|
|
385
507
|
if (cells.length > 0) {
|
|
386
508
|
const isHeader = i === 0 || (i > 0 && lines[i-1].trim() === '');
|
|
387
|
-
const formattedRow = cells.map(cell => {
|
|
388
|
-
const padded = cell.padEnd(14);
|
|
389
|
-
return isHeader ? chalk.white.bold(padded) : chalk.gray(padded);
|
|
390
|
-
}).join(' โ ');
|
|
391
509
|
|
|
392
|
-
|
|
510
|
+
process.stdout.write(chalk.gray('โ '));
|
|
511
|
+
|
|
512
|
+
for (let j = 0; j < cells.length; j++) {
|
|
513
|
+
const cell = cells[j];
|
|
514
|
+
const padded = cell.padEnd(15);
|
|
515
|
+
|
|
516
|
+
if (isHeader) {
|
|
517
|
+
// Header cells - parse markdown and make bold
|
|
518
|
+
const segments = parseInlineMarkdown(padded);
|
|
519
|
+
for (const seg of segments) {
|
|
520
|
+
process.stdout.write(chalk.white.bold(seg.text));
|
|
521
|
+
}
|
|
522
|
+
} else {
|
|
523
|
+
// Regular cells - parse markdown
|
|
524
|
+
const segments = parseInlineMarkdown(padded);
|
|
525
|
+
for (const seg of segments) {
|
|
526
|
+
let colorFn = chalk.gray;
|
|
527
|
+
if (seg.style === 'bold') colorFn = chalk.white.bold;
|
|
528
|
+
else if (seg.style === 'italic') colorFn = chalk.white.italic;
|
|
529
|
+
else if (seg.style === 'code') colorFn = chalk.bgBlack.cyan;
|
|
530
|
+
process.stdout.write(colorFn(seg.text));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
if (j < cells.length - 1) {
|
|
535
|
+
process.stdout.write(chalk.gray(' โ '));
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
console.log(chalk.gray(' โ'));
|
|
393
540
|
await sleep(50);
|
|
394
541
|
}
|
|
395
542
|
|
|
@@ -406,7 +553,8 @@ async function typeAIResponse(response) {
|
|
|
406
553
|
if (trimmed.startsWith('## ')) {
|
|
407
554
|
const header = trimmed.substring(3);
|
|
408
555
|
console.log('');
|
|
409
|
-
|
|
556
|
+
process.stdout.write(chalk.hex('#F24E1E').bold('โธ '));
|
|
557
|
+
await typeFormattedLine(header, 15);
|
|
410
558
|
console.log(chalk.gray('โ'.repeat(60)));
|
|
411
559
|
await sleep(150);
|
|
412
560
|
continue;
|
|
@@ -415,7 +563,8 @@ async function typeAIResponse(response) {
|
|
|
415
563
|
if (trimmed.startsWith('# ')) {
|
|
416
564
|
const header = trimmed.substring(2);
|
|
417
565
|
console.log('');
|
|
418
|
-
|
|
566
|
+
process.stdout.write(chalk.hex('#F24E1E').bold.underline(' '));
|
|
567
|
+
await typeFormattedLine(header, 20);
|
|
419
568
|
console.log('');
|
|
420
569
|
await sleep(200);
|
|
421
570
|
continue;
|
|
@@ -425,8 +574,7 @@ async function typeAIResponse(response) {
|
|
|
425
574
|
if (trimmed.startsWith('โข ') || trimmed.startsWith('- ') || trimmed.startsWith('* ')) {
|
|
426
575
|
const bullet = trimmed.substring(2);
|
|
427
576
|
process.stdout.write(chalk.hex('#F24E1E')(' โธ '));
|
|
428
|
-
await
|
|
429
|
-
console.log('');
|
|
577
|
+
await typeFormattedLine(bullet, 8);
|
|
430
578
|
await sleep(60);
|
|
431
579
|
continue;
|
|
432
580
|
}
|
|
@@ -437,22 +585,14 @@ async function typeAIResponse(response) {
|
|
|
437
585
|
const num = numberedMatch[1];
|
|
438
586
|
const text = numberedMatch[2];
|
|
439
587
|
process.stdout.write(chalk.hex('#F24E1E')(` ${num}. `));
|
|
440
|
-
await
|
|
441
|
-
console.log('');
|
|
588
|
+
await typeFormattedLine(text, 8);
|
|
442
589
|
await sleep(60);
|
|
443
590
|
continue;
|
|
444
591
|
}
|
|
445
592
|
|
|
446
|
-
//
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
await typeLine(` ${bold}`, 10, chalk.white.bold);
|
|
450
|
-
await sleep(80);
|
|
451
|
-
continue;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
// Regular paragraph
|
|
455
|
-
await typeLine(` ${trimmed}`, 6, chalk.gray);
|
|
593
|
+
// Regular paragraph (with inline markdown support)
|
|
594
|
+
process.stdout.write(' ');
|
|
595
|
+
await typeFormattedLineGray(trimmed, 6);
|
|
456
596
|
await sleep(40);
|
|
457
597
|
}
|
|
458
598
|
|