codemaxxing 1.0.2 → 1.0.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.
Files changed (2) hide show
  1. package/dist/index.js +40 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1748,6 +1748,9 @@ process.stdout.write("\x1b[?2004h");
1748
1748
  // Bracketed paste: \x1b[200~ ... \x1b[201~
1749
1749
  let pasteBuffer = "";
1750
1750
  let inPaste = false;
1751
+ let rawBurstBuffer = "";
1752
+ let rawBurstTimer = null;
1753
+ const RAW_PASTE_WINDOW_MS = 35;
1751
1754
  function emitPasteChunk(content) {
1752
1755
  const normalized = content.replace(/\r\n/g, "\n").trim();
1753
1756
  if (!normalized)
@@ -1768,17 +1771,48 @@ function looksLikeRawMultilinePaste(data) {
1768
1771
  const newlineMatches = normalized.match(/\r?\n/g) ?? [];
1769
1772
  const newlineCount = newlineMatches.length;
1770
1773
  const contentLength = normalized.replace(/[\r\n]/g, "").trim().length;
1771
- // Avoid swallowing normal Enter presses while still catching terminals that
1772
- // don't support bracketed paste and dump the whole paste as one raw chunk.
1774
+ // Catch real multiline pastes while avoiding normal Enter presses.
1773
1775
  return newlineCount >= 2 || (newlineCount >= 1 && contentLength >= 40);
1774
1776
  }
1777
+ function flushRawBurstBuffer() {
1778
+ if (!rawBurstBuffer)
1779
+ return;
1780
+ const buffered = rawBurstBuffer;
1781
+ rawBurstBuffer = "";
1782
+ if (looksLikeRawMultilinePaste(buffered)) {
1783
+ emitPasteChunk(buffered);
1784
+ return;
1785
+ }
1786
+ origPush(Buffer.from(buffered), undefined);
1787
+ }
1788
+ function scheduleRawBurstFlush() {
1789
+ if (rawBurstTimer)
1790
+ clearTimeout(rawBurstTimer);
1791
+ rawBurstTimer = setTimeout(() => {
1792
+ rawBurstTimer = null;
1793
+ flushRawBurstBuffer();
1794
+ }, RAW_PASTE_WINDOW_MS);
1795
+ }
1775
1796
  const origPush = process.stdin.push.bind(process.stdin);
1776
1797
  process.stdin.push = function (chunk, encoding) {
1777
- if (chunk === null)
1798
+ if (chunk === null) {
1799
+ if (rawBurstTimer) {
1800
+ clearTimeout(rawBurstTimer);
1801
+ rawBurstTimer = null;
1802
+ }
1803
+ flushRawBurstBuffer();
1778
1804
  return origPush(chunk, encoding);
1805
+ }
1779
1806
  let data = typeof chunk === "string" ? chunk : Buffer.isBuffer(chunk) ? chunk.toString("utf-8") : String(chunk);
1780
1807
  const hasStart = data.includes("\x1b[200~");
1781
1808
  const hasEnd = data.includes("\x1b[201~");
1809
+ if (hasStart || hasEnd || inPaste) {
1810
+ if (rawBurstTimer) {
1811
+ clearTimeout(rawBurstTimer);
1812
+ rawBurstTimer = null;
1813
+ }
1814
+ flushRawBurstBuffer();
1815
+ }
1782
1816
  if (hasStart) {
1783
1817
  inPaste = true;
1784
1818
  data = data.replace(/\x1b\[200~/g, "");
@@ -1796,10 +1830,9 @@ process.stdin.push = function (chunk, encoding) {
1796
1830
  return true;
1797
1831
  }
1798
1832
  data = data.replace(/\x1b\[20[01]~/g, "");
1799
- if (looksLikeRawMultilinePaste(data)) {
1800
- return emitPasteChunk(data);
1801
- }
1802
- return origPush(typeof chunk === "string" ? data : Buffer.from(data), encoding);
1833
+ rawBurstBuffer += data;
1834
+ scheduleRawBurstFlush();
1835
+ return true;
1803
1836
  };
1804
1837
  // Disable bracketed paste on exit
1805
1838
  process.on("exit", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codemaxxing",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Open-source terminal coding agent. Connect any LLM. Max your code.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {