editprompt 1.4.1 → 1.5.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.
- package/dist/index.js +50 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -72,7 +72,44 @@ function setupLogger(options = {}) {
|
|
|
72
72
|
|
|
73
73
|
//#endregion
|
|
74
74
|
//#region package.json
|
|
75
|
-
var version = "1.
|
|
75
|
+
var version = "1.5.0";
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/config/constants.ts
|
|
79
|
+
const TEMP_FILE_PREFIX = ".editprompt-";
|
|
80
|
+
const TEMP_FILE_EXTENSION = ".md";
|
|
81
|
+
const DEFAULT_EDITOR = "vim";
|
|
82
|
+
const TMUX_IMSG_LIMIT_BYTES = 16 * 1024;
|
|
83
|
+
const TMUX_SEND_CHUNK_BYTES = TMUX_IMSG_LIMIT_BYTES / 2;
|
|
84
|
+
const WEZTERM_SEND_CHUNK_BYTES = TMUX_SEND_CHUNK_BYTES;
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/utils/contentChunker.ts
|
|
88
|
+
/**
|
|
89
|
+
* Split content into chunks not exceeding maxBytes (UTF-8 byte count),
|
|
90
|
+
* never breaking a Unicode code point across chunks.
|
|
91
|
+
*
|
|
92
|
+
* Content shorter than maxBytes is returned as a single chunk, so short
|
|
93
|
+
* input keeps the previous behavior of being sent in one shot.
|
|
94
|
+
*/
|
|
95
|
+
function splitByByteSize(content, maxBytes) {
|
|
96
|
+
if (content === "") return [];
|
|
97
|
+
const chunks = [];
|
|
98
|
+
let current = "";
|
|
99
|
+
let currentBytes = 0;
|
|
100
|
+
for (const char of content) {
|
|
101
|
+
const charBytes = Buffer.byteLength(char, "utf8");
|
|
102
|
+
if (current !== "" && currentBytes + charBytes > maxBytes) {
|
|
103
|
+
chunks.push(current);
|
|
104
|
+
current = "";
|
|
105
|
+
currentBytes = 0;
|
|
106
|
+
}
|
|
107
|
+
current += char;
|
|
108
|
+
currentBytes += charBytes;
|
|
109
|
+
}
|
|
110
|
+
if (current !== "") chunks.push(current);
|
|
111
|
+
return chunks;
|
|
112
|
+
}
|
|
76
113
|
|
|
77
114
|
//#endregion
|
|
78
115
|
//#region src/modules/tmux.ts
|
|
@@ -157,8 +194,12 @@ async function sendKeyToTmuxPane(paneId, key, delay = 1e3) {
|
|
|
157
194
|
}
|
|
158
195
|
async function inputToTmuxPane(paneId, content) {
|
|
159
196
|
await execAsync$1(`tmux if-shell -t '${paneId}' '[ "#{pane_in_mode}" = "1" ]' "copy-mode -q -t '${paneId}'"`);
|
|
160
|
-
|
|
161
|
-
|
|
197
|
+
const chunks = splitByByteSize(content, TMUX_SEND_CHUNK_BYTES);
|
|
198
|
+
for (const chunk of chunks) await execAsync$1(`tmux send-keys -t '${paneId}' -- '${chunk.replace(/'/g, "'\\''")}'`);
|
|
199
|
+
logger$11.debug("Content sent to tmux pane: {paneId} ({chunks} chunk(s))", {
|
|
200
|
+
paneId,
|
|
201
|
+
chunks: chunks.length
|
|
202
|
+
});
|
|
162
203
|
}
|
|
163
204
|
|
|
164
205
|
//#endregion
|
|
@@ -290,8 +331,12 @@ async function sendKeyToWeztermPane(paneId, key, delay = 1e3) {
|
|
|
290
331
|
await execAsync(`wezterm cli send-text --no-paste --pane-id '${paneId}' $'${key}'`);
|
|
291
332
|
}
|
|
292
333
|
async function inputToWeztermPane(paneId, content) {
|
|
293
|
-
|
|
294
|
-
|
|
334
|
+
const chunks = splitByByteSize(content, WEZTERM_SEND_CHUNK_BYTES);
|
|
335
|
+
for (const chunk of chunks) await execAsync(`wezterm cli send-text --no-paste --pane-id '${paneId}' -- '${chunk.replace(/'/g, "'\\''")}'`);
|
|
336
|
+
logger$10.debug("Content sent to wezterm pane: {paneId} ({chunks} chunk(s))", {
|
|
337
|
+
paneId,
|
|
338
|
+
chunks: chunks.length
|
|
339
|
+
});
|
|
295
340
|
}
|
|
296
341
|
|
|
297
342
|
//#endregion
|
|
@@ -856,12 +901,6 @@ const inputCommand = define({
|
|
|
856
901
|
}
|
|
857
902
|
});
|
|
858
903
|
|
|
859
|
-
//#endregion
|
|
860
|
-
//#region src/config/constants.ts
|
|
861
|
-
const TEMP_FILE_PREFIX = ".editprompt-";
|
|
862
|
-
const TEMP_FILE_EXTENSION = ".md";
|
|
863
|
-
const DEFAULT_EDITOR = "vim";
|
|
864
|
-
|
|
865
904
|
//#endregion
|
|
866
905
|
//#region src/utils/envParser.ts
|
|
867
906
|
/**
|