open-research 0.1.21 → 0.1.22
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/cli.js +78 -15
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -811,7 +811,7 @@ function formatDateTime(value) {
|
|
|
811
811
|
}
|
|
812
812
|
|
|
813
813
|
// src/lib/cli/version.ts
|
|
814
|
-
var PACKAGE_VERSION = "0.1.
|
|
814
|
+
var PACKAGE_VERSION = "0.1.22";
|
|
815
815
|
function getPackageVersion() {
|
|
816
816
|
return PACKAGE_VERSION;
|
|
817
817
|
}
|
|
@@ -1384,6 +1384,8 @@ var source_default = chalk;
|
|
|
1384
1384
|
// src/tui/text-input.tsx
|
|
1385
1385
|
import { jsx } from "react/jsx-runtime";
|
|
1386
1386
|
var PASTE_MARKER = "\uFFFC";
|
|
1387
|
+
var BRACKETED_PASTE_START = "[200~";
|
|
1388
|
+
var BRACKETED_PASTE_END = "[201~";
|
|
1387
1389
|
function expandPasteMarkers(value, pasteMap) {
|
|
1388
1390
|
let result = "";
|
|
1389
1391
|
let pasteIdx = 0;
|
|
@@ -1428,6 +1430,7 @@ function TextInput({
|
|
|
1428
1430
|
const cursorOffsetRef = useRef(originalValue.length);
|
|
1429
1431
|
const pasteMapRef = useRef(/* @__PURE__ */ new Map());
|
|
1430
1432
|
const pasteCounterRef = useRef(0);
|
|
1433
|
+
const bracketedPasteBufferRef = useRef(null);
|
|
1431
1434
|
useEffect(() => {
|
|
1432
1435
|
valueRef.current = originalValue;
|
|
1433
1436
|
}, [originalValue]);
|
|
@@ -1498,6 +1501,28 @@ function TextInput({
|
|
|
1498
1501
|
return result;
|
|
1499
1502
|
}
|
|
1500
1503
|
const renderedPlaceholder = showCursor && focus && placeholder.length > 0 ? source_default.inverse(placeholder[0]) + source_default.grey(placeholder.slice(1)) : placeholder ? source_default.grey(placeholder) : void 0;
|
|
1504
|
+
function sanitizeInput(raw) {
|
|
1505
|
+
return raw.replace(/\x1b\[[?>=!]*[0-9;]*[a-zA-Z~]/g, "").replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)?/g, "").replace(/\[20[01]~/g, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/[\x00-\x08\x0b\x0c\x0e-\x1f]/g, "");
|
|
1506
|
+
}
|
|
1507
|
+
function insertCleanText(raw, currentValue, currentCursor) {
|
|
1508
|
+
const clean = sanitizeInput(raw);
|
|
1509
|
+
if (!clean) {
|
|
1510
|
+
return { nextValue: currentValue, nextCursor: currentCursor };
|
|
1511
|
+
}
|
|
1512
|
+
const lineCount = (clean.match(/\n/g) || []).length;
|
|
1513
|
+
if (lineCount >= 2) {
|
|
1514
|
+
const id = ++pasteCounterRef.current;
|
|
1515
|
+
pasteMapRef.current.set(id, { text: clean, lineCount, id });
|
|
1516
|
+
return {
|
|
1517
|
+
nextValue: currentValue.slice(0, currentCursor) + PASTE_MARKER + currentValue.slice(currentCursor),
|
|
1518
|
+
nextCursor: currentCursor + 1
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
return {
|
|
1522
|
+
nextValue: currentValue.slice(0, currentCursor) + clean + currentValue.slice(currentCursor),
|
|
1523
|
+
nextCursor: currentCursor + clean.length
|
|
1524
|
+
};
|
|
1525
|
+
}
|
|
1501
1526
|
useInput(
|
|
1502
1527
|
(input2, key) => {
|
|
1503
1528
|
const currentValue = valueRef.current;
|
|
@@ -1537,10 +1562,12 @@ function TextInput({
|
|
|
1537
1562
|
nextValue = currentValue.slice(0, boundary) + currentValue.slice(currentCursor);
|
|
1538
1563
|
nextCursor = boundary;
|
|
1539
1564
|
} else if (key.ctrl && input2 === "u") {
|
|
1540
|
-
|
|
1541
|
-
|
|
1565
|
+
const lineStart = currentValue.lastIndexOf("\n", currentCursor - 1) + 1;
|
|
1566
|
+
nextValue = currentValue.slice(0, lineStart) + currentValue.slice(currentCursor);
|
|
1567
|
+
nextCursor = lineStart;
|
|
1542
1568
|
} else if (key.ctrl && input2 === "k") {
|
|
1543
|
-
|
|
1569
|
+
const lineEnd = currentValue.indexOf("\n", currentCursor);
|
|
1570
|
+
nextValue = currentValue.slice(0, currentCursor) + (lineEnd === -1 ? "" : currentValue.slice(lineEnd));
|
|
1544
1571
|
} else if (key.meta && key.delete) {
|
|
1545
1572
|
const boundary = nextWordBoundary(currentValue, currentCursor);
|
|
1546
1573
|
nextValue = currentValue.slice(0, currentCursor) + currentValue.slice(boundary);
|
|
@@ -1573,18 +1600,54 @@ function TextInput({
|
|
|
1573
1600
|
} else if (key.rightArrow) {
|
|
1574
1601
|
if (showCursor) nextCursor++;
|
|
1575
1602
|
} else if (!key.ctrl && !key.meta) {
|
|
1576
|
-
const
|
|
1577
|
-
if (
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1603
|
+
const hasPasteMarkers = input2.includes(BRACKETED_PASTE_START) || input2.includes(BRACKETED_PASTE_END) || bracketedPasteBufferRef.current !== null;
|
|
1604
|
+
if (hasPasteMarkers) {
|
|
1605
|
+
let remaining = input2;
|
|
1606
|
+
let workingValue = currentValue;
|
|
1607
|
+
let workingCursor = currentCursor;
|
|
1608
|
+
while (remaining.length > 0) {
|
|
1609
|
+
if (bracketedPasteBufferRef.current === null) {
|
|
1610
|
+
const startIndex = remaining.indexOf(BRACKETED_PASTE_START);
|
|
1611
|
+
if (startIndex === -1) {
|
|
1612
|
+
const inserted2 = insertCleanText(remaining, workingValue, workingCursor);
|
|
1613
|
+
workingValue = inserted2.nextValue;
|
|
1614
|
+
workingCursor = inserted2.nextCursor;
|
|
1615
|
+
remaining = "";
|
|
1616
|
+
break;
|
|
1617
|
+
}
|
|
1618
|
+
const prefix = remaining.slice(0, startIndex);
|
|
1619
|
+
if (prefix) {
|
|
1620
|
+
const inserted2 = insertCleanText(prefix, workingValue, workingCursor);
|
|
1621
|
+
workingValue = inserted2.nextValue;
|
|
1622
|
+
workingCursor = inserted2.nextCursor;
|
|
1623
|
+
}
|
|
1624
|
+
bracketedPasteBufferRef.current = "";
|
|
1625
|
+
remaining = remaining.slice(startIndex + BRACKETED_PASTE_START.length);
|
|
1626
|
+
continue;
|
|
1627
|
+
}
|
|
1628
|
+
const endIndex = remaining.indexOf(BRACKETED_PASTE_END);
|
|
1629
|
+
if (endIndex === -1) {
|
|
1630
|
+
bracketedPasteBufferRef.current += remaining;
|
|
1631
|
+
remaining = "";
|
|
1632
|
+
break;
|
|
1633
|
+
}
|
|
1634
|
+
bracketedPasteBufferRef.current += remaining.slice(0, endIndex);
|
|
1635
|
+
const inserted = insertCleanText(
|
|
1636
|
+
bracketedPasteBufferRef.current,
|
|
1637
|
+
workingValue,
|
|
1638
|
+
workingCursor
|
|
1639
|
+
);
|
|
1640
|
+
workingValue = inserted.nextValue;
|
|
1641
|
+
workingCursor = inserted.nextCursor;
|
|
1642
|
+
bracketedPasteBufferRef.current = null;
|
|
1643
|
+
remaining = remaining.slice(endIndex + BRACKETED_PASTE_END.length);
|
|
1587
1644
|
}
|
|
1645
|
+
nextValue = workingValue;
|
|
1646
|
+
nextCursor = workingCursor;
|
|
1647
|
+
} else {
|
|
1648
|
+
const inserted = insertCleanText(input2, currentValue, currentCursor);
|
|
1649
|
+
nextValue = inserted.nextValue;
|
|
1650
|
+
nextCursor = inserted.nextCursor;
|
|
1588
1651
|
}
|
|
1589
1652
|
}
|
|
1590
1653
|
nextCursor = Math.max(0, Math.min(nextCursor, nextValue.length));
|
package/package.json
CHANGED