editprompt 1.6.0 → 1.7.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.
Files changed (2) hide show
  1. package/dist/index.js +227 -51
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -90,7 +90,7 @@ function setupLogger(options = {}) {
90
90
 
91
91
  //#endregion
92
92
  //#region package.json
93
- var version = "1.6.0";
93
+ var version = "1.7.0";
94
94
 
95
95
  //#endregion
96
96
  //#region src/config/constants.ts
@@ -102,6 +102,7 @@ const TMUX_SEND_CHUNK_BYTES = TMUX_IMSG_LIMIT_BYTES / 2;
102
102
  const WEZTERM_SEND_CHUNK_BYTES = TMUX_SEND_CHUNK_BYTES;
103
103
  const HERDR_REQUEST_LIMIT_BYTES = 1024 * 1024;
104
104
  const HERDR_SEND_CHUNK_BYTES = HERDR_REQUEST_LIMIT_BYTES / 8;
105
+ const NIWATERM_SEND_CHUNK_BYTES = WEZTERM_SEND_CHUNK_BYTES;
105
106
 
106
107
  //#endregion
107
108
  //#region src/utils/contentChunker.ts
@@ -141,26 +142,26 @@ const conf = new Conf({ projectName });
141
142
  var herdr_exports = /* @__PURE__ */ __exportAll({
142
143
  appendToQuoteText: () => appendToQuoteText$1,
143
144
  calculateEditorSplitRatio: () => calculateEditorSplitRatio,
144
- checkPaneExists: () => checkPaneExists$2,
145
- clearEditorPaneId: () => clearEditorPaneId$2,
145
+ checkPaneExists: () => checkPaneExists$3,
146
+ clearEditorPaneId: () => clearEditorPaneId$3,
146
147
  clearQuoteText: () => clearQuoteText$1,
147
148
  closePane: () => closePane,
148
- focusPane: () => focusPane$2,
149
- getCurrentPaneId: () => getCurrentPaneId$2,
150
- getEditorPaneId: () => getEditorPaneId$2,
149
+ focusPane: () => focusPane$3,
150
+ getCurrentPaneId: () => getCurrentPaneId$3,
151
+ getEditorPaneId: () => getEditorPaneId$3,
151
152
  getQuoteText: () => getQuoteText$1,
152
153
  getStorageNamespace: () => getStorageNamespace,
153
- getTargetPaneIds: () => getTargetPaneIds$2,
154
+ getTargetPaneIds: () => getTargetPaneIds$3,
154
155
  inputToHerdrPane: () => inputToHerdrPane,
155
156
  isEditorPaneFromConf: () => isEditorPaneFromConf$1,
156
- markAsEditorPane: () => markAsEditorPane$2,
157
+ markAsEditorPane: () => markAsEditorPane$3,
157
158
  resumeEditorPane: () => resumeEditorPane,
158
159
  runCommandInPane: () => runCommandInPane,
159
- saveEditorPaneId: () => saveEditorPaneId$2,
160
+ saveEditorPaneId: () => saveEditorPaneId$3,
160
161
  sendKeyToHerdrPane: () => sendKeyToHerdrPane,
161
162
  splitEditorPane: () => splitEditorPane
162
163
  });
163
- const logger$13 = getLogger(["editprompt", "herdr"]);
164
+ const logger$14 = getLogger(["editprompt", "herdr"]);
164
165
  const HERDR_REQUEST_TIMEOUT_MS = 6e3;
165
166
  let requestSequence = 0;
166
167
  function getSocketPath() {
@@ -247,21 +248,21 @@ function targetPaneKey(paneId) {
247
248
  function editorPaneKey(paneId) {
248
249
  return `${getStorageNamespace()}.editorPane.pane_${paneId}`;
249
250
  }
250
- async function getCurrentPaneId$2() {
251
+ async function getCurrentPaneId$3() {
251
252
  const paneId = process.env.HERDR_PANE_ID?.trim() || process.env.HERDR_ACTIVE_PANE_ID?.trim();
252
253
  if (!paneId) throw new Error("HERDR_PANE_ID or HERDR_ACTIVE_PANE_ID is not set");
253
254
  return paneId;
254
255
  }
255
- async function checkPaneExists$2(paneId) {
256
+ async function checkPaneExists$3(paneId) {
256
257
  try {
257
258
  await sendRequest("pane.get", { pane_id: paneId });
258
259
  return true;
259
260
  } catch (error) {
260
- logger$13.debug("checkPaneExists failed: {error}", { error });
261
+ logger$14.debug("checkPaneExists failed: {error}", { error });
261
262
  return false;
262
263
  }
263
264
  }
264
- async function focusPane$2(paneId) {
265
+ async function focusPane$3(paneId) {
265
266
  await sendRequest("pane.focus", { pane_id: paneId });
266
267
  }
267
268
  function calculateEditorSplitRatio(paneHeight, editorPaneRows) {
@@ -284,14 +285,14 @@ async function splitEditorPane(targetPaneId, editorPaneRows, cwd, env = {}) {
284
285
  if (typeof editorPaneId !== "string" || editorPaneId === "") throw new Error("Herdr pane.split did not return the new pane ID");
285
286
  return editorPaneId;
286
287
  }
287
- function quoteShellWord(value) {
288
+ function quoteShellWord$1(value) {
288
289
  return `'${value.replace(/'/g, "'\\''")}'`;
289
290
  }
290
291
  async function runCommandInPane(paneId, argv) {
291
292
  if (argv.length === 0) throw new Error("Cannot run an empty command in a Herdr pane");
292
293
  await sendRequest("pane.send_input", {
293
294
  pane_id: paneId,
294
- text: `exec ${argv.map(quoteShellWord).join(" ")}`,
295
+ text: `exec ${argv.map(quoteShellWord$1).join(" ")}`,
295
296
  keys: ["Enter"]
296
297
  });
297
298
  }
@@ -304,7 +305,7 @@ async function inputToHerdrPane(paneId, content) {
304
305
  pane_id: paneId,
305
306
  text: chunk
306
307
  });
307
- logger$13.debug("Content sent to Herdr pane: {paneId} ({chunkCount} chunks)", {
308
+ logger$14.debug("Content sent to Herdr pane: {paneId} ({chunkCount} chunks)", {
308
309
  paneId,
309
310
  chunkCount: chunks.length
310
311
  });
@@ -316,7 +317,7 @@ async function sendKeyToHerdrPane(paneId, key, delay = 1e3) {
316
317
  keys: [key]
317
318
  });
318
319
  }
319
- async function saveEditorPaneId$2(targetPaneId, editorPaneId) {
320
+ async function saveEditorPaneId$3(targetPaneId, editorPaneId) {
320
321
  const data = conf.get(targetPaneKey(targetPaneId));
321
322
  const existing = typeof data === "object" && data !== null ? data : {};
322
323
  conf.set(targetPaneKey(targetPaneId), {
@@ -324,13 +325,13 @@ async function saveEditorPaneId$2(targetPaneId, editorPaneId) {
324
325
  editorPaneId
325
326
  });
326
327
  }
327
- async function getEditorPaneId$2(targetPaneId) {
328
+ async function getEditorPaneId$3(targetPaneId) {
328
329
  const data = conf.get(targetPaneKey(targetPaneId));
329
330
  if (typeof data === "object" && data !== null && "editorPaneId" in data) return String(data.editorPaneId);
330
331
  return "";
331
332
  }
332
- async function clearEditorPaneId$2(targetPaneId, expectedEditorPaneId) {
333
- const editorPaneId = await getEditorPaneId$2(targetPaneId);
333
+ async function clearEditorPaneId$3(targetPaneId, expectedEditorPaneId) {
334
+ const editorPaneId = await getEditorPaneId$3(targetPaneId);
334
335
  if (expectedEditorPaneId && editorPaneId !== expectedEditorPaneId) {
335
336
  conf.delete(editorPaneKey(expectedEditorPaneId));
336
337
  return;
@@ -343,12 +344,12 @@ async function clearEditorPaneId$2(targetPaneId, expectedEditorPaneId) {
343
344
  }
344
345
  if (editorPaneId) conf.delete(editorPaneKey(editorPaneId));
345
346
  }
346
- async function markAsEditorPane$2(editorPaneId, targetPaneIds) {
347
+ async function markAsEditorPane$3(editorPaneId, targetPaneIds) {
347
348
  const uniqueTargetPaneIds = [...new Set(targetPaneIds)];
348
349
  conf.set(editorPaneKey(editorPaneId), { targetPaneIds: uniqueTargetPaneIds });
349
- for (const targetPaneId of uniqueTargetPaneIds) await saveEditorPaneId$2(targetPaneId, editorPaneId);
350
+ for (const targetPaneId of uniqueTargetPaneIds) await saveEditorPaneId$3(targetPaneId, editorPaneId);
350
351
  }
351
- async function getTargetPaneIds$2(editorPaneId) {
352
+ async function getTargetPaneIds$3(editorPaneId) {
352
353
  const data = conf.get(editorPaneKey(editorPaneId));
353
354
  if (typeof data === "object" && data !== null && "targetPaneIds" in data) {
354
355
  const targetPaneIds = data.targetPaneIds;
@@ -360,23 +361,23 @@ function isEditorPaneFromConf$1(paneId) {
360
361
  return conf.has(editorPaneKey(paneId));
361
362
  }
362
363
  async function resumeEditorPane(targetPaneId) {
363
- const currentPaneId = await getCurrentPaneId$2();
364
+ const currentPaneId = await getCurrentPaneId$3();
364
365
  const editorPaneId = isEditorPaneFromConf$1(currentPaneId) ? currentPaneId : isEditorPaneFromConf$1(targetPaneId) ? targetPaneId : "";
365
366
  if (editorPaneId) {
366
- const targetPaneIds = await getTargetPaneIds$2(editorPaneId);
367
- for (const paneId of targetPaneIds) if (await checkPaneExists$2(paneId)) {
368
- await focusPane$2(paneId);
367
+ const targetPaneIds = await getTargetPaneIds$3(editorPaneId);
368
+ for (const paneId of targetPaneIds) if (await checkPaneExists$3(paneId)) {
369
+ await focusPane$3(paneId);
369
370
  return true;
370
371
  }
371
372
  return false;
372
373
  }
373
- const registeredEditorPaneId = await getEditorPaneId$2(targetPaneId);
374
+ const registeredEditorPaneId = await getEditorPaneId$3(targetPaneId);
374
375
  if (registeredEditorPaneId === "") return false;
375
- if (!await checkPaneExists$2(registeredEditorPaneId)) {
376
- await clearEditorPaneId$2(targetPaneId);
376
+ if (!await checkPaneExists$3(registeredEditorPaneId)) {
377
+ await clearEditorPaneId$3(targetPaneId);
377
378
  return false;
378
379
  }
379
- await focusPane$2(registeredEditorPaneId);
380
+ await focusPane$3(registeredEditorPaneId);
380
381
  return true;
381
382
  }
382
383
  async function appendToQuoteText$1(paneId, content) {
@@ -403,6 +404,92 @@ async function clearQuoteText$1(paneId) {
403
404
  }
404
405
  }
405
406
 
407
+ //#endregion
408
+ //#region src/modules/niwaterm.ts
409
+ const execAsync$2 = promisify(exec);
410
+ const logger$13 = getLogger(["editprompt", "niwaterm"]);
411
+ const VAR_EDITOR_PANE = "editprompt_editor_pane";
412
+ const VAR_IS_EDITOR = "editprompt_is_editor";
413
+ const VAR_TARGET_PANES = "editprompt_target_panes";
414
+ const VAR_QUOTE = "editprompt_quote";
415
+ function quoteShellWord(value) {
416
+ return `'${value.replace(/'/g, "'\\''")}'`;
417
+ }
418
+ async function getCurrentPaneId$2() {
419
+ const tabId = process.env.NIWATERM_TAB_ID?.trim();
420
+ if (!tabId) throw new Error("NIWATERM_TAB_ID is not set");
421
+ return tabId;
422
+ }
423
+ async function getTabVar(tabId, key) {
424
+ try {
425
+ const { stdout } = await execAsync$2(`niwa tab var get -t ${quoteShellWord(tabId)} ${quoteShellWord(key)}`);
426
+ return stdout.trim();
427
+ } catch (error) {
428
+ logger$13.debug("getTabVar failed: {error}", { error });
429
+ return "";
430
+ }
431
+ }
432
+ async function setTabVar(tabId, key, value) {
433
+ await execAsync$2(`niwa tab var set -t ${quoteShellWord(tabId)} ${quoteShellWord(key)} ${quoteShellWord(value)}`);
434
+ }
435
+ async function checkPaneExists$2(paneId) {
436
+ try {
437
+ await execAsync$2(`niwa tab var list -t ${quoteShellWord(paneId)}`);
438
+ return true;
439
+ } catch (error) {
440
+ logger$13.debug("checkPaneExists failed: {error}", { error });
441
+ return false;
442
+ }
443
+ }
444
+ async function focusPane$2(paneId) {
445
+ await execAsync$2(`niwa tab focus -t ${quoteShellWord(paneId)}`);
446
+ }
447
+ async function saveEditorPaneId$2(targetPaneId, editorPaneId) {
448
+ await setTabVar(targetPaneId, VAR_EDITOR_PANE, editorPaneId);
449
+ }
450
+ async function clearEditorPaneId$2(targetPaneId) {
451
+ await setTabVar(targetPaneId, VAR_EDITOR_PANE, "");
452
+ }
453
+ async function getEditorPaneId$2(targetPaneId) {
454
+ return getTabVar(targetPaneId, VAR_EDITOR_PANE);
455
+ }
456
+ async function markAsEditorPane$2(editorPaneId, targetPaneIds) {
457
+ const uniqueTargetPaneIds = [...new Set(targetPaneIds)];
458
+ await setTabVar(editorPaneId, VAR_IS_EDITOR, "1");
459
+ await setTabVar(editorPaneId, VAR_TARGET_PANES, uniqueTargetPaneIds.join(","));
460
+ for (const targetPaneId of uniqueTargetPaneIds) await saveEditorPaneId$2(targetPaneId, editorPaneId);
461
+ }
462
+ async function getTargetPaneIds$2(editorPaneId) {
463
+ const value = await getTabVar(editorPaneId, VAR_TARGET_PANES);
464
+ if (value === "") return [];
465
+ return value.split(",").map((id) => id.trim());
466
+ }
467
+ async function isEditorPane$1(paneId) {
468
+ return await getTabVar(paneId, VAR_IS_EDITOR) === "1";
469
+ }
470
+ async function getQuoteVariableContent$1(paneId) {
471
+ return getTabVar(paneId, VAR_QUOTE);
472
+ }
473
+ async function appendToQuoteVariable$1(paneId, content) {
474
+ const existingContent = await getQuoteVariableContent$1(paneId);
475
+ await setTabVar(paneId, VAR_QUOTE, existingContent.trim() !== "" ? `${existingContent}\n${content}` : content);
476
+ }
477
+ async function clearQuoteVariable$1(paneId) {
478
+ await setTabVar(paneId, VAR_QUOTE, "");
479
+ }
480
+ async function sendKeyToNiwatermPane(paneId, key, delay = 1e3) {
481
+ await new Promise((resolve) => setTimeout(resolve, delay));
482
+ await execAsync$2(`niwa tab send-keys -t ${quoteShellWord(paneId)} ${quoteShellWord(key)}`);
483
+ }
484
+ async function inputToNiwatermPane(paneId, content) {
485
+ const chunks = splitByByteSize(content, NIWATERM_SEND_CHUNK_BYTES);
486
+ for (const chunk of chunks) await execAsync$2(`niwa tab send-keys -t ${quoteShellWord(paneId)} ${quoteShellWord(chunk)}`);
487
+ logger$13.debug("Content sent to niwaterm pane: {paneId} ({chunks} chunk(s))", {
488
+ paneId,
489
+ chunks: chunks.length
490
+ });
491
+ }
492
+
406
493
  //#endregion
407
494
  //#region src/modules/tmux.ts
408
495
  const execAsync$1 = promisify(exec);
@@ -768,10 +855,11 @@ function processQuoteText(text, options) {
768
855
  const SUPPORTED_MUXES = [
769
856
  "tmux",
770
857
  "wezterm",
771
- "herdr"
858
+ "herdr",
859
+ "niwaterm"
772
860
  ];
773
861
  function isMuxType(value) {
774
- return value === "tmux" || value === "wezterm" || value === "herdr";
862
+ return value === "tmux" || value === "wezterm" || value === "herdr" || value === "niwaterm";
775
863
  }
776
864
  function hasValue(value) {
777
865
  return typeof value === "string" && value.trim() !== "";
@@ -779,8 +867,11 @@ function hasValue(value) {
779
867
  function isHerdrEnvironment(env = process.env) {
780
868
  return hasValue(env.HERDR_SOCKET_PATH) && (hasValue(env.HERDR_PANE_ID) || hasValue(env.HERDR_ACTIVE_PANE_ID));
781
869
  }
870
+ function isNiwatermEnvironment(env = process.env) {
871
+ return hasValue(env.NIWATERM_TAB_ID);
872
+ }
782
873
  function resolveMux(explicitMux, env = process.env) {
783
- const muxValue = explicitMux || env.EDITPROMPT_MUX || (isHerdrEnvironment(env) ? "herdr" : "tmux");
874
+ const muxValue = explicitMux || env.EDITPROMPT_MUX || (isHerdrEnvironment(env) ? "herdr" : isNiwatermEnvironment(env) ? "niwaterm" : "tmux");
784
875
  if (!isMuxType(muxValue)) {
785
876
  const displayValue = typeof muxValue === "string" ? muxValue : `<${typeof muxValue}>`;
786
877
  throw new Error(`Invalid multiplexer type '${displayValue}'. Supported values: ${SUPPORTED_MUXES.join(", ")}`);
@@ -793,7 +884,7 @@ function resolveMux(explicitMux, env = process.env) {
793
884
  const logger$10 = getLogger(["editprompt"]);
794
885
  const ARG_MUX = {
795
886
  short: "m",
796
- description: "Multiplexer type (tmux, wezterm, or herdr; auto-detects Herdr, otherwise tmux)",
887
+ description: "Multiplexer type (tmux, wezterm, herdr, or niwaterm; auto-detects Herdr and niwaterm, otherwise tmux)",
797
888
  type: "string"
798
889
  };
799
890
  const ARG_TARGET_PANE_SINGLE = {
@@ -905,6 +996,7 @@ async function runCollectMode(mux, targetPaneId, rawContent, outputs = ["buffer"
905
996
  const processedText = processQuoteText(selection, { withQuote });
906
997
  for (const output of outputs) if (output === "buffer") if (mux === "tmux") await appendToQuoteVariable(targetPaneId, processedText);
907
998
  else if (mux === "wezterm") await appendToQuoteText(targetPaneId, processedText);
999
+ else if (mux === "niwaterm") await appendToQuoteVariable$1(targetPaneId, processedText);
908
1000
  else await appendToQuoteText$1(targetPaneId, processedText);
909
1001
  else if (output === "stdout") process.stdout.write(processedText);
910
1002
  } catch (error) {
@@ -935,7 +1027,7 @@ const collectCommand = define({
935
1027
  const outputs = normalizeCollectOutputs(ctx.values.output);
936
1028
  const withQuote = !ctx.values["no-quote"];
937
1029
  let rawContent;
938
- if (mux === "wezterm" || mux === "herdr") {
1030
+ if (mux === "wezterm" || mux === "herdr" || mux === "niwaterm") {
939
1031
  rawContent = extractRawContent(ctx.rest, ctx.positionals);
940
1032
  if (rawContent === void 0) {
941
1033
  logger$9.error(`Text content is required for collect mode with ${mux}. Use: editprompt collect --mux ${mux} --target-pane <id> -- "<text>"`);
@@ -974,8 +1066,11 @@ async function runDumpMode() {
974
1066
  } else if (config.mux === "wezterm") {
975
1067
  currentPaneId = await getCurrentPaneId();
976
1068
  isEditor = isEditorPaneFromConf(currentPaneId);
977
- } else {
1069
+ } else if (config.mux === "niwaterm") {
978
1070
  currentPaneId = await getCurrentPaneId$2();
1071
+ isEditor = await isEditorPane$1(currentPaneId);
1072
+ } else {
1073
+ currentPaneId = await getCurrentPaneId$3();
979
1074
  isEditor = isEditorPaneFromConf$1(currentPaneId);
980
1075
  }
981
1076
  if (!isEditor) {
@@ -985,7 +1080,8 @@ async function runDumpMode() {
985
1080
  let targetPanes;
986
1081
  if (config.mux === "tmux") targetPanes = await getTargetPaneIds$1(currentPaneId);
987
1082
  else if (config.mux === "wezterm") targetPanes = await getTargetPaneIds(currentPaneId);
988
- else targetPanes = await getTargetPaneIds$2(currentPaneId);
1083
+ else if (config.mux === "niwaterm") targetPanes = await getTargetPaneIds$2(currentPaneId);
1084
+ else targetPanes = await getTargetPaneIds$3(currentPaneId);
989
1085
  if (targetPanes.length === 0) {
990
1086
  logger$8.error("No target panes registered for this editor pane");
991
1087
  process.exit(1);
@@ -999,6 +1095,9 @@ async function runDumpMode() {
999
1095
  } else if (config.mux === "wezterm") {
1000
1096
  content = await getQuoteText(targetPane);
1001
1097
  await clearQuoteText(targetPane);
1098
+ } else if (config.mux === "niwaterm") {
1099
+ content = await getQuoteVariableContent$1(targetPane);
1100
+ await clearQuoteVariable$1(targetPane);
1002
1101
  } else {
1003
1102
  content = await getQuoteText$1(targetPane);
1004
1103
  await clearQuoteText$1(targetPane);
@@ -1048,13 +1147,15 @@ async function copyToClipboard(content) {
1048
1147
  async function inputContentToPane(content, mux, targetPaneId) {
1049
1148
  if (mux === "wezterm") await inputToWeztermPane(targetPaneId, content);
1050
1149
  else if (mux === "herdr") await inputToHerdrPane(targetPaneId, content);
1150
+ else if (mux === "niwaterm") await inputToNiwatermPane(targetPaneId, content);
1051
1151
  else await inputToTmuxPane(targetPaneId, content);
1052
1152
  }
1053
1153
  async function focusFirstSuccessPane(mux, targetPanes, failedPanes) {
1054
1154
  const firstSuccessPane = targetPanes.find((p) => !failedPanes.includes(p));
1055
1155
  if (firstSuccessPane) if (mux === "tmux") await focusPane$1(firstSuccessPane);
1056
1156
  else if (mux === "wezterm") await focusPane(firstSuccessPane);
1057
- else await focusPane$2(firstSuccessPane);
1157
+ else if (mux === "niwaterm") await focusPane$2(firstSuccessPane);
1158
+ else await focusPane$3(firstSuccessPane);
1058
1159
  }
1059
1160
  async function handleContentDelivery(content, mux, targetPanes) {
1060
1161
  if (!content) return {
@@ -1131,8 +1232,11 @@ async function runInputMode(rawContent, autoSend, sendKey, sendKeyDelay) {
1131
1232
  } else if (config.mux === "wezterm") {
1132
1233
  currentPaneId = await getCurrentPaneId();
1133
1234
  isEditor = isEditorPaneFromConf(currentPaneId);
1134
- } else {
1235
+ } else if (config.mux === "niwaterm") {
1135
1236
  currentPaneId = await getCurrentPaneId$2();
1237
+ isEditor = await isEditorPane$1(currentPaneId);
1238
+ } else {
1239
+ currentPaneId = await getCurrentPaneId$3();
1136
1240
  isEditor = isEditorPaneFromConf$1(currentPaneId);
1137
1241
  }
1138
1242
  if (!isEditor) {
@@ -1142,7 +1246,8 @@ async function runInputMode(rawContent, autoSend, sendKey, sendKeyDelay) {
1142
1246
  let targetPanes;
1143
1247
  if (config.mux === "tmux") targetPanes = await getTargetPaneIds$1(currentPaneId);
1144
1248
  else if (config.mux === "wezterm") targetPanes = await getTargetPaneIds(currentPaneId);
1145
- else targetPanes = await getTargetPaneIds$2(currentPaneId);
1249
+ else if (config.mux === "niwaterm") targetPanes = await getTargetPaneIds$2(currentPaneId);
1250
+ else targetPanes = await getTargetPaneIds$3(currentPaneId);
1146
1251
  if (targetPanes.length === 0) {
1147
1252
  logger$6.error("No target panes registered for this editor pane");
1148
1253
  process.exit(1);
@@ -1158,6 +1263,9 @@ async function runInputMode(rawContent, autoSend, sendKey, sendKeyDelay) {
1158
1263
  } else if (config.mux === "herdr") {
1159
1264
  await inputToHerdrPane(targetPane, content);
1160
1265
  await sendKeyToHerdrPane(targetPane, key, delay);
1266
+ } else if (config.mux === "niwaterm") {
1267
+ await inputToNiwatermPane(targetPane, content);
1268
+ await sendKeyToNiwatermPane(targetPane, key, delay);
1161
1269
  } else {
1162
1270
  await inputToTmuxPane(targetPane, content);
1163
1271
  await sendKeyToTmuxPane(targetPane, key, delay);
@@ -1325,8 +1433,12 @@ async function runOpenEditorMode(options) {
1325
1433
  await markAsEditorPane(currentPaneId, options.targetPanes);
1326
1434
  } catch {}
1327
1435
  else if (options.targetPanes.length > 0 && options.mux === "herdr") try {
1328
- const currentPaneId = await getCurrentPaneId$2();
1436
+ const currentPaneId = await getCurrentPaneId$3();
1329
1437
  herdrEditorPaneId = currentPaneId;
1438
+ await markAsEditorPane$3(currentPaneId, options.targetPanes);
1439
+ } catch {}
1440
+ else if (options.targetPanes.length > 0 && options.mux === "niwaterm") try {
1441
+ const currentPaneId = await getCurrentPaneId$2();
1330
1442
  await markAsEditorPane$2(currentPaneId, options.targetPanes);
1331
1443
  } catch {}
1332
1444
  try {
@@ -1363,7 +1475,10 @@ async function runOpenEditorMode(options) {
1363
1475
  for (const targetPane of options.targetPanes) await clearEditorPaneId(targetPane);
1364
1476
  } catch {}
1365
1477
  else if (options.targetPanes.length > 0 && options.mux === "herdr") try {
1366
- for (const targetPane of options.targetPanes) await clearEditorPaneId$2(targetPane, herdrEditorPaneId);
1478
+ for (const targetPane of options.targetPanes) await clearEditorPaneId$3(targetPane, herdrEditorPaneId);
1479
+ } catch {}
1480
+ else if (options.targetPanes.length > 0 && options.mux === "niwaterm") try {
1481
+ for (const targetPane of options.targetPanes) await clearEditorPaneId$2(targetPane);
1367
1482
  } catch {}
1368
1483
  }
1369
1484
  }
@@ -1419,11 +1534,17 @@ async function runRegisterMode(options) {
1419
1534
  process.exit(1);
1420
1535
  }
1421
1536
  } else if (options.mux === "herdr") {
1422
- editorPaneId = await getCurrentPaneId$2();
1537
+ editorPaneId = await getCurrentPaneId$3();
1423
1538
  if (!isEditorPaneFromConf$1(editorPaneId)) {
1424
1539
  logger$4.error("Current pane is not an editor pane. Please run this command from an editor pane or specify --editor-pane.");
1425
1540
  process.exit(1);
1426
1541
  }
1542
+ } else if (options.mux === "niwaterm") {
1543
+ editorPaneId = await getCurrentPaneId$2();
1544
+ if (!await isEditorPane$1(editorPaneId)) {
1545
+ logger$4.error("Current pane is not an editor pane. Please run this command from an editor pane or specify --editor-pane.");
1546
+ process.exit(1);
1547
+ }
1427
1548
  } else {
1428
1549
  logger$4.error("Unsupported multiplexer");
1429
1550
  process.exit(1);
@@ -1432,11 +1553,13 @@ async function runRegisterMode(options) {
1432
1553
  let existingPanes = [];
1433
1554
  if (options.mux === "tmux") existingPanes = await getTargetPaneIds$1(editorPaneId);
1434
1555
  else if (options.mux === "wezterm") existingPanes = await getTargetPaneIds(editorPaneId);
1435
- else if (options.mux === "herdr") existingPanes = await getTargetPaneIds$2(editorPaneId);
1556
+ else if (options.mux === "herdr") existingPanes = await getTargetPaneIds$3(editorPaneId);
1557
+ else if (options.mux === "niwaterm") existingPanes = await getTargetPaneIds$2(editorPaneId);
1436
1558
  const mergedTargetPanes = [...new Set([...existingPanes, ...options.targetPanes])];
1437
1559
  if (options.mux === "tmux") await markAsEditorPane$1(editorPaneId, mergedTargetPanes);
1438
1560
  else if (options.mux === "wezterm") await markAsEditorPane(editorPaneId, mergedTargetPanes);
1439
- else if (options.mux === "herdr") await markAsEditorPane$2(editorPaneId, mergedTargetPanes);
1561
+ else if (options.mux === "herdr") await markAsEditorPane$3(editorPaneId, mergedTargetPanes);
1562
+ else if (options.mux === "niwaterm") await markAsEditorPane$2(editorPaneId, mergedTargetPanes);
1440
1563
  logger$4.info(`Editor pane ${editorPaneId} registered with target panes: ${mergedTargetPanes.join(", ")}`);
1441
1564
  } catch (error) {
1442
1565
  logger$4.error(`${error instanceof Error ? error.message : "Unknown error"}`);
@@ -1482,6 +1605,50 @@ async function runResumeMode(targetPane, mux) {
1482
1605
  logger$3.debug("Herdr resume failed: {error}", { error });
1483
1606
  process.exit(1);
1484
1607
  }
1608
+ if (mux === "niwaterm") {
1609
+ const currentPaneId = await getCurrentPaneId$2();
1610
+ if (await isEditorPane$1(currentPaneId)) {
1611
+ logger$3.debug("Current pane is an editor pane");
1612
+ const originalTargetPaneIds = await getTargetPaneIds$2(currentPaneId);
1613
+ if (originalTargetPaneIds.length === 0) {
1614
+ logger$3.debug("No target pane IDs found for editor pane");
1615
+ process.exit(1);
1616
+ }
1617
+ let focused = false;
1618
+ for (const paneId of originalTargetPaneIds) if (await checkPaneExists$2(paneId)) {
1619
+ await focusPane$2(paneId);
1620
+ focused = true;
1621
+ break;
1622
+ }
1623
+ if (!focused) {
1624
+ logger$3.debug("All target panes do not exist");
1625
+ process.exit(1);
1626
+ }
1627
+ process.exit(0);
1628
+ }
1629
+ logger$3.debug("Current pane is not an editor pane");
1630
+ const editorPaneId = await getEditorPaneId$2(targetPane);
1631
+ logger$3.debug("niwaterm editorPaneId: {editorPaneId}", { editorPaneId });
1632
+ if (editorPaneId === "") {
1633
+ logger$3.debug("Editor pane ID not found");
1634
+ process.exit(1);
1635
+ }
1636
+ if (!await checkPaneExists$2(editorPaneId)) {
1637
+ logger$3.debug("Editor pane does not exist");
1638
+ await clearEditorPaneId$2(targetPane);
1639
+ process.exit(1);
1640
+ }
1641
+ try {
1642
+ await focusPane$2(editorPaneId);
1643
+ process.exit(0);
1644
+ } catch (error) {
1645
+ logger$3.debug("Can't focus editorPaneId: {editorPaneId}, error: {error}", {
1646
+ editorPaneId,
1647
+ error
1648
+ });
1649
+ process.exit(1);
1650
+ }
1651
+ }
1485
1652
  if (mux === "wezterm") {
1486
1653
  const currentPaneId = await getCurrentPaneId();
1487
1654
  if (isEditorPaneFromConf(currentPaneId)) {
@@ -1585,8 +1752,11 @@ async function runPressMode(key, delay = 0) {
1585
1752
  } else if (config.mux === "wezterm") {
1586
1753
  currentPaneId = await getCurrentPaneId();
1587
1754
  isEditor = isEditorPaneFromConf(currentPaneId);
1588
- } else {
1755
+ } else if (config.mux === "niwaterm") {
1589
1756
  currentPaneId = await getCurrentPaneId$2();
1757
+ isEditor = await isEditorPane$1(currentPaneId);
1758
+ } else {
1759
+ currentPaneId = await getCurrentPaneId$3();
1590
1760
  isEditor = isEditorPaneFromConf$1(currentPaneId);
1591
1761
  }
1592
1762
  if (!isEditor) {
@@ -1596,7 +1766,8 @@ async function runPressMode(key, delay = 0) {
1596
1766
  let targetPanes;
1597
1767
  if (config.mux === "tmux") targetPanes = await getTargetPaneIds$1(currentPaneId);
1598
1768
  else if (config.mux === "wezterm") targetPanes = await getTargetPaneIds(currentPaneId);
1599
- else targetPanes = await getTargetPaneIds$2(currentPaneId);
1769
+ else if (config.mux === "niwaterm") targetPanes = await getTargetPaneIds$2(currentPaneId);
1770
+ else targetPanes = await getTargetPaneIds$3(currentPaneId);
1600
1771
  if (targetPanes.length === 0) {
1601
1772
  logger$2.error("No target panes registered for this editor pane");
1602
1773
  process.exit(1);
@@ -1605,6 +1776,7 @@ async function runPressMode(key, delay = 0) {
1605
1776
  for (const targetPane of targetPanes) try {
1606
1777
  if (config.mux === "wezterm") await sendKeyToWeztermPane(targetPane, key, delay);
1607
1778
  else if (config.mux === "herdr") await sendKeyToHerdrPane(targetPane, key, delay);
1779
+ else if (config.mux === "niwaterm") await sendKeyToNiwatermPane(targetPane, key, delay);
1608
1780
  else await sendKeyToTmuxPane(targetPane, key, delay);
1609
1781
  successCount++;
1610
1782
  } catch (error) {
@@ -1698,8 +1870,11 @@ async function getTargetPaneForStash() {
1698
1870
  } else if (config.mux === "wezterm") {
1699
1871
  currentPaneId = await getCurrentPaneId();
1700
1872
  isEditor = isEditorPaneFromConf(currentPaneId);
1701
- } else {
1873
+ } else if (config.mux === "niwaterm") {
1702
1874
  currentPaneId = await getCurrentPaneId$2();
1875
+ isEditor = await isEditorPane$1(currentPaneId);
1876
+ } else {
1877
+ currentPaneId = await getCurrentPaneId$3();
1703
1878
  isEditor = isEditorPaneFromConf$1(currentPaneId);
1704
1879
  }
1705
1880
  if (!isEditor) {
@@ -1709,7 +1884,8 @@ async function getTargetPaneForStash() {
1709
1884
  let targetPanes;
1710
1885
  if (config.mux === "tmux") targetPanes = await getTargetPaneIds$1(currentPaneId);
1711
1886
  else if (config.mux === "wezterm") targetPanes = await getTargetPaneIds(currentPaneId);
1712
- else targetPanes = await getTargetPaneIds$2(currentPaneId);
1887
+ else if (config.mux === "niwaterm") targetPanes = await getTargetPaneIds$2(currentPaneId);
1888
+ else targetPanes = await getTargetPaneIds$3(currentPaneId);
1713
1889
  if (targetPanes.length === 0) {
1714
1890
  logger$1.error("No target panes registered for this editor pane");
1715
1891
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "editprompt",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "A CLI tool that lets you write prompts for CLI tools using your favorite text editor",
5
5
  "keywords": [
6
6
  "cli",