codemaxxing 1.0.14 → 1.0.15
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/index.js +8 -1
- package/dist/utils/paste.d.ts +1 -0
- package/dist/utils/paste.js +10 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { render, Box, Text, useInput, useApp, useStdout } from "ink";
|
|
|
5
5
|
import { EventEmitter } from "events";
|
|
6
6
|
import { appendFileSync } from "node:fs";
|
|
7
7
|
import TextInput from "ink-text-input";
|
|
8
|
-
import { consumePendingPasteEndMarkerChunk } from "./utils/paste.js";
|
|
8
|
+
import { consumePendingPasteEndMarkerChunk, shouldSwallowPostPasteDebris } from "./utils/paste.js";
|
|
9
9
|
import { CodingAgent } from "./agent.js";
|
|
10
10
|
import { loadConfig, saveConfig, detectLocalProvider, detectLocalProviderDetailed, parseCLIArgs, applyOverrides, listModels } from "./config.js";
|
|
11
11
|
import { listSessions, getSession, loadMessages, deleteSession } from "./utils/sessions.js";
|
|
@@ -1760,7 +1760,9 @@ let inBracketedPaste = false;
|
|
|
1760
1760
|
let burstBuffer = "";
|
|
1761
1761
|
let burstTimer = null;
|
|
1762
1762
|
let pendingPasteEndMarker = { active: false, buffer: "" };
|
|
1763
|
+
let swallowPostPasteDebrisUntil = 0;
|
|
1763
1764
|
const BURST_WINDOW_MS = 50; // Long enough for slow terminals to finish delivering paste
|
|
1765
|
+
const POST_PASTE_DEBRIS_WINDOW_MS = 1200;
|
|
1764
1766
|
// Debug paste: set CODEMAXXING_DEBUG_PASTE=1 to log all stdin chunks to /tmp/codemaxxing-paste-debug.log
|
|
1765
1767
|
const PASTE_DEBUG = process.env.CODEMAXXING_DEBUG_PASTE === "1";
|
|
1766
1768
|
function pasteLog(msg) {
|
|
@@ -1784,6 +1786,7 @@ function handlePasteContent(content) {
|
|
|
1784
1786
|
// one character at a time *after* the paste payload. Arm a tiny
|
|
1785
1787
|
// swallow-state so those trailing fragments never leak into the input.
|
|
1786
1788
|
pendingPasteEndMarker = { active: true, buffer: "" };
|
|
1789
|
+
swallowPostPasteDebrisUntil = Date.now() + POST_PASTE_DEBRIS_WINDOW_MS;
|
|
1787
1790
|
pasteEvents.emit("paste", { content: normalized, lines: lineCount });
|
|
1788
1791
|
return;
|
|
1789
1792
|
}
|
|
@@ -1839,6 +1842,10 @@ process.stdin.emit = function (event, ...args) {
|
|
|
1839
1842
|
pasteLog("PENDING END MARKER swallowed chunk");
|
|
1840
1843
|
return true;
|
|
1841
1844
|
}
|
|
1845
|
+
if (Date.now() < swallowPostPasteDebrisUntil && shouldSwallowPostPasteDebris(data)) {
|
|
1846
|
+
pasteLog(`POST-PASTE DEBRIS swallowed raw=${data}`);
|
|
1847
|
+
return true;
|
|
1848
|
+
}
|
|
1842
1849
|
// Aggressively strip ALL bracketed paste escape sequences from every chunk,
|
|
1843
1850
|
// regardless of context. Some terminals split markers across chunks or send
|
|
1844
1851
|
// them in unexpected positions. We never want \x1b[200~ or \x1b[201~ (or
|
package/dist/utils/paste.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export interface PendingPasteEndState {
|
|
|
2
2
|
active: boolean;
|
|
3
3
|
buffer: string;
|
|
4
4
|
}
|
|
5
|
+
export declare function shouldSwallowPostPasteDebris(chunk: string): boolean;
|
|
5
6
|
export declare function consumePendingPasteEndMarkerChunk(chunk: string, state: PendingPasteEndState): {
|
|
6
7
|
remaining: string;
|
|
7
8
|
nextState: PendingPasteEndState;
|
package/dist/utils/paste.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
export function shouldSwallowPostPasteDebris(chunk) {
|
|
2
|
+
if (!chunk)
|
|
3
|
+
return false;
|
|
4
|
+
if (chunk.length > 8)
|
|
5
|
+
return false;
|
|
6
|
+
// Terminals sometimes leak tiny bracketed-paste marker fragments after the
|
|
7
|
+
// multiline payload is already complete. Be conservative: only swallow short
|
|
8
|
+
// chunks made entirely of characters that belong to those control fragments.
|
|
9
|
+
return /^[\x1b\[\]0-9;~]+$/.test(chunk);
|
|
10
|
+
}
|
|
1
11
|
const END_MARKERS = ["\x1b[201~", "[201~", "201~"];
|
|
2
12
|
function isPrefixOfAnyMarker(value) {
|
|
3
13
|
return END_MARKERS.some((marker) => marker.startsWith(value));
|