editprompt 1.3.0 → 1.4.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/README.md +33 -0
- package/dist/index.js +145 -73
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -202,6 +202,39 @@ This sends the content to the target pane (or clipboard) while keeping your edit
|
|
|
202
202
|
|
|
203
203
|
For Neovim users, we recommend using [editprompt.nvim](https://github.com/eetann/editprompt.nvim) for easy setup. For manual configuration, see [docs/neovim.md](docs/neovim.md).
|
|
204
204
|
|
|
205
|
+
### Key Sending (press)
|
|
206
|
+
|
|
207
|
+
Send individual key inputs to the target pane without leaving your editor. Useful for responding to AI agent selection prompts (e.g., choosing option 1, 2, 3, 4) without switching panes.
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Send a character key
|
|
211
|
+
editprompt press -- 1
|
|
212
|
+
|
|
213
|
+
# Send special keys (tmux format)
|
|
214
|
+
editprompt press -- Tab
|
|
215
|
+
editprompt press -- Up
|
|
216
|
+
editprompt press -- C-m # Enter
|
|
217
|
+
editprompt press -- C-c # Ctrl+C
|
|
218
|
+
|
|
219
|
+
# Send with delay
|
|
220
|
+
editprompt press --delay 500 -- Tab
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Key differences from `input`:**
|
|
224
|
+
|
|
225
|
+
- No Enter key is automatically appended
|
|
226
|
+
- Focus stays on the editor pane (no pane switching)
|
|
227
|
+
- Designed for single key inputs, not text content
|
|
228
|
+
|
|
229
|
+
**Key notation** depends on your multiplexer:
|
|
230
|
+
|
|
231
|
+
| Key | tmux | WezTerm |
|
|
232
|
+
| ------------- | ------------- | ------------------- |
|
|
233
|
+
| Enter | `C-m` | `\r` |
|
|
234
|
+
| Tab | `Tab` | `\t` |
|
|
235
|
+
| Escape | `Escape` | `\x1b` |
|
|
236
|
+
| Arrow Up/Down | `Up` / `Down` | `\x1b[A` / `\x1b[B` |
|
|
237
|
+
|
|
205
238
|
### Quote Workflow Setup
|
|
206
239
|
|
|
207
240
|
#### Collecting Quotes in tmux Copy Mode
|
package/dist/index.js
CHANGED
|
@@ -71,12 +71,12 @@ function setupLogger(options = {}) {
|
|
|
71
71
|
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region package.json
|
|
74
|
-
var version = "1.
|
|
74
|
+
var version = "1.4.0";
|
|
75
75
|
|
|
76
76
|
//#endregion
|
|
77
77
|
//#region src/modules/tmux.ts
|
|
78
78
|
const execAsync$1 = promisify(exec);
|
|
79
|
-
const logger$
|
|
79
|
+
const logger$11 = getLogger(["editprompt", "tmux"]);
|
|
80
80
|
async function getCurrentPaneId$1() {
|
|
81
81
|
const envPaneId = process.env.TMUX_PANE?.trim();
|
|
82
82
|
if (envPaneId) return envPaneId;
|
|
@@ -157,7 +157,7 @@ async function sendKeyToTmuxPane(paneId, key, delay = 1e3) {
|
|
|
157
157
|
async function inputToTmuxPane(paneId, content) {
|
|
158
158
|
await execAsync$1(`tmux if-shell -t '${paneId}' '[ "#{pane_in_mode}" = "1" ]' "copy-mode -q -t '${paneId}'"`);
|
|
159
159
|
await execAsync$1(`tmux send-keys -t '${paneId}' -- '${content.replace(/'/g, "'\\''")}'`);
|
|
160
|
-
logger$
|
|
160
|
+
logger$11.debug("Content sent to tmux pane: {paneId}", { paneId });
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
//#endregion
|
|
@@ -167,7 +167,7 @@ const conf = new Conf({ projectName });
|
|
|
167
167
|
|
|
168
168
|
//#endregion
|
|
169
169
|
//#region src/modules/wezterm.ts
|
|
170
|
-
const logger$
|
|
170
|
+
const logger$10 = getLogger(["editprompt", "wezterm"]);
|
|
171
171
|
const execAsync = promisify(exec);
|
|
172
172
|
async function getCurrentPaneId() {
|
|
173
173
|
try {
|
|
@@ -175,26 +175,26 @@ async function getCurrentPaneId() {
|
|
|
175
175
|
const activePane = JSON.parse(stdout).find((pane) => pane.is_active === true);
|
|
176
176
|
return String(activePane?.pane_id);
|
|
177
177
|
} catch (error) {
|
|
178
|
-
logger$
|
|
178
|
+
logger$10.debug("getCurrentPaneId failed: {error}", { error });
|
|
179
179
|
return "";
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
async function checkPaneExists(paneId) {
|
|
183
183
|
try {
|
|
184
184
|
const { stdout } = await execAsync("wezterm cli list --format json");
|
|
185
|
-
logger$
|
|
185
|
+
logger$10.debug("wezterm cli list output: {stdout}", { stdout });
|
|
186
186
|
return JSON.parse(stdout).some((pane) => String(pane.pane_id) === paneId);
|
|
187
187
|
} catch (error) {
|
|
188
|
-
logger$
|
|
188
|
+
logger$10.debug("checkPaneExists failed: {error}", { error });
|
|
189
189
|
return false;
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
async function saveEditorPaneId(targetPaneId, editorPaneId) {
|
|
193
|
-
logger$
|
|
193
|
+
logger$10.debug("Saving editor pane ID to conf key: wezterm.targetPane.pane_{targetPaneId}", { targetPaneId });
|
|
194
194
|
try {
|
|
195
195
|
conf.set(`wezterm.targetPane.pane_${targetPaneId}`, { editorPaneId });
|
|
196
196
|
} catch (error) {
|
|
197
|
-
logger$
|
|
197
|
+
logger$10.debug("saveEditorPaneId failed: {error}", { error });
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
async function getEditorPaneId(targetPaneId) {
|
|
@@ -203,7 +203,7 @@ async function getEditorPaneId(targetPaneId) {
|
|
|
203
203
|
if (typeof data === "object" && data !== null && "editorPaneId" in data) return String(data.editorPaneId);
|
|
204
204
|
return "";
|
|
205
205
|
} catch (error) {
|
|
206
|
-
logger$
|
|
206
|
+
logger$10.debug("getEditorPaneId failed: {error}", { error });
|
|
207
207
|
return "";
|
|
208
208
|
}
|
|
209
209
|
}
|
|
@@ -213,7 +213,7 @@ async function clearEditorPaneId(targetPaneId) {
|
|
|
213
213
|
conf.delete(`wezterm.targetPane.pane_${targetPaneId}`);
|
|
214
214
|
if (editorPaneId) conf.delete(`wezterm.editorPane.pane_${editorPaneId}`);
|
|
215
215
|
} catch (error) {
|
|
216
|
-
logger$
|
|
216
|
+
logger$10.debug("clearEditorPaneId failed: {error}", { error });
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
async function focusPane(paneId) {
|
|
@@ -225,7 +225,7 @@ async function markAsEditorPane(editorPaneId, targetPaneIds) {
|
|
|
225
225
|
conf.set(`wezterm.editorPane.pane_${editorPaneId}`, { targetPaneIds: uniqueTargetPaneIds });
|
|
226
226
|
for (const targetPaneId of uniqueTargetPaneIds) await saveEditorPaneId(targetPaneId, editorPaneId);
|
|
227
227
|
} catch (error) {
|
|
228
|
-
logger$
|
|
228
|
+
logger$10.debug("markAsEditorPane failed: {error}", { error });
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
async function getTargetPaneIds(editorPaneId) {
|
|
@@ -237,7 +237,7 @@ async function getTargetPaneIds(editorPaneId) {
|
|
|
237
237
|
}
|
|
238
238
|
return [];
|
|
239
239
|
} catch (error) {
|
|
240
|
-
logger$
|
|
240
|
+
logger$10.debug("getTargetPaneIds failed: {error}", { error });
|
|
241
241
|
return [];
|
|
242
242
|
}
|
|
243
243
|
}
|
|
@@ -245,7 +245,7 @@ function isEditorPaneFromConf(paneId) {
|
|
|
245
245
|
try {
|
|
246
246
|
return conf.has(`wezterm.editorPane.pane_${paneId}`);
|
|
247
247
|
} catch (error) {
|
|
248
|
-
logger$
|
|
248
|
+
logger$10.debug("isEditorPaneFromConf failed: {error}", { error });
|
|
249
249
|
return false;
|
|
250
250
|
}
|
|
251
251
|
}
|
|
@@ -263,7 +263,7 @@ async function appendToQuoteText(paneId, content) {
|
|
|
263
263
|
} else newData = { quote_text: content };
|
|
264
264
|
conf.set(`wezterm.targetPane.pane_${paneId}`, newData);
|
|
265
265
|
} catch (error) {
|
|
266
|
-
logger$
|
|
266
|
+
logger$10.debug("appendToQuoteText failed: {error}", { error });
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
async function getQuoteText(paneId) {
|
|
@@ -272,7 +272,7 @@ async function getQuoteText(paneId) {
|
|
|
272
272
|
if (typeof data === "object" && data !== null && "quote_text" in data) return String(data.quote_text);
|
|
273
273
|
return "";
|
|
274
274
|
} catch (error) {
|
|
275
|
-
logger$
|
|
275
|
+
logger$10.debug("getQuoteText failed: {error}", { error });
|
|
276
276
|
return "";
|
|
277
277
|
}
|
|
278
278
|
}
|
|
@@ -281,7 +281,7 @@ async function clearQuoteText(paneId) {
|
|
|
281
281
|
const key = `wezterm.targetPane.pane_${paneId}.quote_text`;
|
|
282
282
|
if (conf.has(key)) conf.delete(key);
|
|
283
283
|
} catch (error) {
|
|
284
|
-
logger$
|
|
284
|
+
logger$10.debug("clearQuoteText failed: {error}", { error });
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
async function sendKeyToWeztermPane(paneId, key, delay = 1e3) {
|
|
@@ -290,7 +290,7 @@ async function sendKeyToWeztermPane(paneId, key, delay = 1e3) {
|
|
|
290
290
|
}
|
|
291
291
|
async function inputToWeztermPane(paneId, content) {
|
|
292
292
|
await execAsync(`wezterm cli send-text --no-paste --pane-id '${paneId}' -- '${content.replace(/'/g, "'\\''")}'`);
|
|
293
|
-
logger$
|
|
293
|
+
logger$10.debug("Content sent to wezterm pane: {paneId}", { paneId });
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
//#endregion
|
|
@@ -432,7 +432,7 @@ function processQuoteText(text, options) {
|
|
|
432
432
|
|
|
433
433
|
//#endregion
|
|
434
434
|
//#region src/modes/common.ts
|
|
435
|
-
const logger$
|
|
435
|
+
const logger$9 = getLogger(["editprompt", "delivery"]);
|
|
436
436
|
function isMuxType(value) {
|
|
437
437
|
return value === "tmux" || value === "wezterm";
|
|
438
438
|
}
|
|
@@ -460,9 +460,9 @@ async function handleContentDelivery(content, mux, targetPanes) {
|
|
|
460
460
|
if (targetPanes.length === 0) {
|
|
461
461
|
try {
|
|
462
462
|
await copyToClipboard(content);
|
|
463
|
-
logger$
|
|
463
|
+
logger$9.info("Content copied to clipboard.");
|
|
464
464
|
} catch (error) {
|
|
465
|
-
logger$
|
|
465
|
+
logger$9.warn(`Failed to copy to clipboard: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
466
466
|
}
|
|
467
467
|
return {
|
|
468
468
|
successCount: 0,
|
|
@@ -480,7 +480,7 @@ async function handleContentDelivery(content, mux, targetPanes) {
|
|
|
480
480
|
success: true
|
|
481
481
|
});
|
|
482
482
|
} catch (error) {
|
|
483
|
-
logger$
|
|
483
|
+
logger$9.warn(`Failed to send to pane ${targetPane}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
484
484
|
results.push({
|
|
485
485
|
pane: targetPane,
|
|
486
486
|
success: false
|
|
@@ -490,13 +490,13 @@ async function handleContentDelivery(content, mux, targetPanes) {
|
|
|
490
490
|
const failedPanes = results.filter((r) => !r.success).map((r) => r.pane);
|
|
491
491
|
const allSuccess = successCount === targetPanes.length;
|
|
492
492
|
const allFailed = successCount === 0;
|
|
493
|
-
if (allSuccess) logger$
|
|
493
|
+
if (allSuccess) logger$9.info("Content sent successfully to all panes!");
|
|
494
494
|
else if (allFailed) {
|
|
495
|
-
logger$
|
|
496
|
-
logger$
|
|
495
|
+
logger$9.error("All target panes failed to receive content.");
|
|
496
|
+
logger$9.info("Falling back to clipboard...");
|
|
497
497
|
await copyToClipboard(content);
|
|
498
|
-
logger$
|
|
499
|
-
} else logger$
|
|
498
|
+
logger$9.info("Content copied to clipboard.");
|
|
499
|
+
} else logger$9.warn(`Content sent to ${successCount}/${targetPanes.length} panes. Failed panes: ${failedPanes.join(", ")}`);
|
|
500
500
|
return {
|
|
501
501
|
successCount,
|
|
502
502
|
totalCount: targetPanes.length,
|
|
@@ -508,7 +508,7 @@ async function handleContentDelivery(content, mux, targetPanes) {
|
|
|
508
508
|
|
|
509
509
|
//#endregion
|
|
510
510
|
//#region src/modes/args.ts
|
|
511
|
-
const logger$
|
|
511
|
+
const logger$8 = getLogger(["editprompt"]);
|
|
512
512
|
const ARG_MUX = {
|
|
513
513
|
short: "m",
|
|
514
514
|
description: "Multiplexer type (tmux or wezterm, default: tmux)",
|
|
@@ -560,14 +560,14 @@ const ARG_VERBOSE = {
|
|
|
560
560
|
function validateMux(value) {
|
|
561
561
|
const muxValue = value || "tmux";
|
|
562
562
|
if (!isMuxType(muxValue)) {
|
|
563
|
-
logger$
|
|
563
|
+
logger$8.error(`Invalid multiplexer type '${muxValue}'. Supported values: ${SUPPORTED_MUXES.join(", ")}`);
|
|
564
564
|
process.exit(1);
|
|
565
565
|
}
|
|
566
566
|
return muxValue;
|
|
567
567
|
}
|
|
568
568
|
function validateTargetPane(value, commandName) {
|
|
569
569
|
if (!value || typeof value !== "string") {
|
|
570
|
-
logger$
|
|
570
|
+
logger$8.error(`--target-pane is required for ${commandName} command`);
|
|
571
571
|
process.exit(1);
|
|
572
572
|
}
|
|
573
573
|
return value;
|
|
@@ -580,7 +580,7 @@ function normalizeTargetPanes(value) {
|
|
|
580
580
|
|
|
581
581
|
//#endregion
|
|
582
582
|
//#region src/modes/collect.ts
|
|
583
|
-
const logger$
|
|
583
|
+
const logger$7 = getLogger(["editprompt", "collect"]);
|
|
584
584
|
const SUPPORTED_OUTPUTS = ["buffer", "stdout"];
|
|
585
585
|
async function readStdin() {
|
|
586
586
|
return new Promise((resolve, reject) => {
|
|
@@ -604,7 +604,7 @@ function normalizeCollectOutputs(value) {
|
|
|
604
604
|
const uniqueOutputs = [...new Set(outputs)];
|
|
605
605
|
const invalid = uniqueOutputs.filter((v) => !SUPPORTED_OUTPUTS.includes(v));
|
|
606
606
|
if (invalid.length > 0) {
|
|
607
|
-
logger$
|
|
607
|
+
logger$7.error(`Invalid output(s) '${invalid.join(", ")}'. Supported values: ${SUPPORTED_OUTPUTS.join(", ")}`);
|
|
608
608
|
process.exit(1);
|
|
609
609
|
}
|
|
610
610
|
return uniqueOutputs;
|
|
@@ -620,7 +620,7 @@ async function runCollectMode(mux, targetPaneId, rawContent, outputs = ["buffer"
|
|
|
620
620
|
else if (mux === "wezterm") await appendToQuoteText(targetPaneId, processedText);
|
|
621
621
|
} else if (output === "stdout") process.stdout.write(processedText);
|
|
622
622
|
} catch (error) {
|
|
623
|
-
logger$
|
|
623
|
+
logger$7.error(`${error instanceof Error ? error.message : "Unknown error"}`);
|
|
624
624
|
process.exit(1);
|
|
625
625
|
}
|
|
626
626
|
}
|
|
@@ -650,7 +650,7 @@ const collectCommand = define({
|
|
|
650
650
|
if (mux === "wezterm") {
|
|
651
651
|
rawContent = extractRawContent(ctx.rest, ctx.positionals);
|
|
652
652
|
if (rawContent === void 0) {
|
|
653
|
-
logger$
|
|
653
|
+
logger$7.error("Text content is required for collect mode with wezterm. Use: editprompt collect --mux wezterm --target-pane <id> -- \"<text>\"");
|
|
654
654
|
process.exit(1);
|
|
655
655
|
}
|
|
656
656
|
}
|
|
@@ -677,7 +677,7 @@ function readSendConfig() {
|
|
|
677
677
|
|
|
678
678
|
//#endregion
|
|
679
679
|
//#region src/modes/dump.ts
|
|
680
|
-
const logger$
|
|
680
|
+
const logger$6 = getLogger(["editprompt", "dump"]);
|
|
681
681
|
async function runDumpMode() {
|
|
682
682
|
try {
|
|
683
683
|
const config = readSendConfig();
|
|
@@ -691,14 +691,14 @@ async function runDumpMode() {
|
|
|
691
691
|
isEditor = isEditorPaneFromConf(currentPaneId);
|
|
692
692
|
}
|
|
693
693
|
if (!isEditor) {
|
|
694
|
-
logger$
|
|
694
|
+
logger$6.error("Current pane is not an editor pane");
|
|
695
695
|
process.exit(1);
|
|
696
696
|
}
|
|
697
697
|
let targetPanes;
|
|
698
698
|
if (config.mux === "tmux") targetPanes = await getTargetPaneIds$1(currentPaneId);
|
|
699
699
|
else targetPanes = await getTargetPaneIds(currentPaneId);
|
|
700
700
|
if (targetPanes.length === 0) {
|
|
701
|
-
logger$
|
|
701
|
+
logger$6.error("No target panes registered for this editor pane");
|
|
702
702
|
process.exit(1);
|
|
703
703
|
}
|
|
704
704
|
const quoteContents = [];
|
|
@@ -717,7 +717,7 @@ async function runDumpMode() {
|
|
|
717
717
|
process.stdout.write(combinedContent.replace(/\n{3,}$/, "\n\n"));
|
|
718
718
|
process.exit(0);
|
|
719
719
|
} catch (error) {
|
|
720
|
-
logger$
|
|
720
|
+
logger$6.error(`${error instanceof Error ? error.message : "Unknown error"}`);
|
|
721
721
|
process.exit(1);
|
|
722
722
|
}
|
|
723
723
|
}
|
|
@@ -749,11 +749,11 @@ function processContent(content) {
|
|
|
749
749
|
|
|
750
750
|
//#endregion
|
|
751
751
|
//#region src/modes/input.ts
|
|
752
|
-
const logger$
|
|
752
|
+
const logger$5 = getLogger(["editprompt", "input"]);
|
|
753
753
|
async function runInputMode(rawContent, autoSend, sendKey, sendKeyDelay) {
|
|
754
754
|
const content = processContent(rawContent);
|
|
755
755
|
if (!content) {
|
|
756
|
-
logger$
|
|
756
|
+
logger$5.info("No content to send. Exiting.");
|
|
757
757
|
return;
|
|
758
758
|
}
|
|
759
759
|
const config = readSendConfig();
|
|
@@ -767,14 +767,14 @@ async function runInputMode(rawContent, autoSend, sendKey, sendKeyDelay) {
|
|
|
767
767
|
isEditor = isEditorPaneFromConf(currentPaneId);
|
|
768
768
|
}
|
|
769
769
|
if (!isEditor) {
|
|
770
|
-
logger$
|
|
770
|
+
logger$5.error("Current pane is not an editor pane");
|
|
771
771
|
process.exit(1);
|
|
772
772
|
}
|
|
773
773
|
let targetPanes;
|
|
774
774
|
if (config.mux === "tmux") targetPanes = await getTargetPaneIds$1(currentPaneId);
|
|
775
775
|
else targetPanes = await getTargetPaneIds(currentPaneId);
|
|
776
776
|
if (targetPanes.length === 0) {
|
|
777
|
-
logger$
|
|
777
|
+
logger$5.error("No target panes registered for this editor pane");
|
|
778
778
|
process.exit(1);
|
|
779
779
|
}
|
|
780
780
|
if (autoSend) {
|
|
@@ -791,15 +791,15 @@ async function runInputMode(rawContent, autoSend, sendKey, sendKeyDelay) {
|
|
|
791
791
|
}
|
|
792
792
|
successCount++;
|
|
793
793
|
} catch (error) {
|
|
794
|
-
logger$
|
|
794
|
+
logger$5.error(`Failed to send to pane ${targetPane}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
795
795
|
}
|
|
796
796
|
if (config.alwaysCopy) {
|
|
797
797
|
await copyToClipboard(content);
|
|
798
|
-
logger$
|
|
798
|
+
logger$5.info("Also copied to clipboard.");
|
|
799
799
|
}
|
|
800
|
-
if (successCount > 0) logger$
|
|
800
|
+
if (successCount > 0) logger$5.info("Content sent and submitted successfully!");
|
|
801
801
|
else {
|
|
802
|
-
logger$
|
|
802
|
+
logger$5.error("All target panes failed to receive content");
|
|
803
803
|
process.exit(1);
|
|
804
804
|
}
|
|
805
805
|
return;
|
|
@@ -808,12 +808,12 @@ async function runInputMode(rawContent, autoSend, sendKey, sendKeyDelay) {
|
|
|
808
808
|
const result = await handleContentDelivery(content, config.mux, targetPanes);
|
|
809
809
|
if (config.alwaysCopy && !result.allFailed) {
|
|
810
810
|
await copyToClipboard(content);
|
|
811
|
-
logger$
|
|
811
|
+
logger$5.info("Also copied to clipboard.");
|
|
812
812
|
}
|
|
813
813
|
if (result.successCount > 0) await focusFirstSuccessPane(config.mux, targetPanes, result.failedPanes);
|
|
814
814
|
if (result.allFailed) process.exit(1);
|
|
815
815
|
} catch (error) {
|
|
816
|
-
logger$
|
|
816
|
+
logger$5.error(`${error instanceof Error ? error.message : "Unknown error"}`);
|
|
817
817
|
process.exit(1);
|
|
818
818
|
}
|
|
819
819
|
}
|
|
@@ -841,13 +841,13 @@ const inputCommand = define({
|
|
|
841
841
|
});
|
|
842
842
|
const rawContent = extractRawContent(ctx.rest, ctx.positionals);
|
|
843
843
|
if (rawContent === void 0) {
|
|
844
|
-
logger$
|
|
845
|
-
logger$
|
|
846
|
-
logger$
|
|
844
|
+
logger$5.error("Content is required for input command");
|
|
845
|
+
logger$5.error("Usage: editprompt input \"your content\"");
|
|
846
|
+
logger$5.error(" or: editprompt input -- \"your content\"");
|
|
847
847
|
process.exit(1);
|
|
848
848
|
}
|
|
849
849
|
if (ctx.values["send-key"] && !ctx.values["auto-send"]) {
|
|
850
|
-
logger$
|
|
850
|
+
logger$5.error("--send-key requires --auto-send to be enabled");
|
|
851
851
|
process.exit(1);
|
|
852
852
|
}
|
|
853
853
|
const config = readSendConfig();
|
|
@@ -947,7 +947,7 @@ async function openEditorAndGetContent(editorOption, envVars, sendConfig) {
|
|
|
947
947
|
|
|
948
948
|
//#endregion
|
|
949
949
|
//#region src/modes/openEditor.ts
|
|
950
|
-
const logger$
|
|
950
|
+
const logger$4 = getLogger(["editprompt", "open"]);
|
|
951
951
|
async function runOpenEditorMode(options) {
|
|
952
952
|
if (options.targetPanes.length > 0 && options.mux === "tmux") try {
|
|
953
953
|
await markAsEditorPane$1(await getCurrentPaneId$1(), options.targetPanes);
|
|
@@ -962,10 +962,10 @@ async function runOpenEditorMode(options) {
|
|
|
962
962
|
alwaysCopy: options.alwaysCopy,
|
|
963
963
|
sendKeyDelay: Number.parseInt(process.env.EDITPROMPT_SEND_KEY_DELAY || "", 10) || 1e3
|
|
964
964
|
};
|
|
965
|
-
logger$
|
|
965
|
+
logger$4.info("Opening editor...");
|
|
966
966
|
const content = await openEditorAndGetContent(options.editor, options.env, sendConfig);
|
|
967
967
|
if (!content) {
|
|
968
|
-
logger$
|
|
968
|
+
logger$4.info("No content entered. Exiting.");
|
|
969
969
|
return;
|
|
970
970
|
}
|
|
971
971
|
try {
|
|
@@ -974,12 +974,12 @@ async function runOpenEditorMode(options) {
|
|
|
974
974
|
console.log(content);
|
|
975
975
|
if (options.alwaysCopy && !result.allFailed) {
|
|
976
976
|
await copyToClipboard(content);
|
|
977
|
-
logger$
|
|
977
|
+
logger$4.info("Also copied to clipboard.");
|
|
978
978
|
}
|
|
979
979
|
if (options.targetPanes.length > 0 && result.successCount > 0) await focusFirstSuccessPane(options.mux, options.targetPanes, result.failedPanes);
|
|
980
980
|
if (!result.allSuccess) process.exit(1);
|
|
981
981
|
} catch (error) {
|
|
982
|
-
logger$
|
|
982
|
+
logger$4.error(`${error instanceof Error ? error.message : "Unknown error"}`);
|
|
983
983
|
process.exit(1);
|
|
984
984
|
}
|
|
985
985
|
} finally {
|
|
@@ -1027,10 +1027,10 @@ const openCommand = define({
|
|
|
1027
1027
|
|
|
1028
1028
|
//#endregion
|
|
1029
1029
|
//#region src/modes/register.ts
|
|
1030
|
-
const logger$
|
|
1030
|
+
const logger$3 = getLogger(["editprompt", "register"]);
|
|
1031
1031
|
async function runRegisterMode(options) {
|
|
1032
1032
|
if (options.targetPanes.length === 0) {
|
|
1033
|
-
logger$
|
|
1033
|
+
logger$3.error("--target-pane is required for register command");
|
|
1034
1034
|
process.exit(1);
|
|
1035
1035
|
}
|
|
1036
1036
|
let editorPaneId;
|
|
@@ -1038,17 +1038,17 @@ async function runRegisterMode(options) {
|
|
|
1038
1038
|
else if (options.mux === "tmux") {
|
|
1039
1039
|
editorPaneId = await getCurrentPaneId$1();
|
|
1040
1040
|
if (!await isEditorPane(editorPaneId)) {
|
|
1041
|
-
logger$
|
|
1041
|
+
logger$3.error("Current pane is not an editor pane. Please run this command from an editor pane or specify --editor-pane.");
|
|
1042
1042
|
process.exit(1);
|
|
1043
1043
|
}
|
|
1044
1044
|
} else if (options.mux === "wezterm") {
|
|
1045
1045
|
editorPaneId = await getCurrentPaneId();
|
|
1046
1046
|
if (!isEditorPaneFromConf(editorPaneId)) {
|
|
1047
|
-
logger$
|
|
1047
|
+
logger$3.error("Current pane is not an editor pane. Please run this command from an editor pane or specify --editor-pane.");
|
|
1048
1048
|
process.exit(1);
|
|
1049
1049
|
}
|
|
1050
1050
|
} else {
|
|
1051
|
-
logger$
|
|
1051
|
+
logger$3.error("Unsupported multiplexer");
|
|
1052
1052
|
process.exit(1);
|
|
1053
1053
|
}
|
|
1054
1054
|
try {
|
|
@@ -1058,9 +1058,9 @@ async function runRegisterMode(options) {
|
|
|
1058
1058
|
const mergedTargetPanes = [...new Set([...existingPanes, ...options.targetPanes])];
|
|
1059
1059
|
if (options.mux === "tmux") await markAsEditorPane$1(editorPaneId, mergedTargetPanes);
|
|
1060
1060
|
else if (options.mux === "wezterm") await markAsEditorPane(editorPaneId, mergedTargetPanes);
|
|
1061
|
-
logger$
|
|
1061
|
+
logger$3.info(`Editor pane ${editorPaneId} registered with target panes: ${mergedTargetPanes.join(", ")}`);
|
|
1062
1062
|
} catch (error) {
|
|
1063
|
-
logger$
|
|
1063
|
+
logger$3.error(`${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1064
1064
|
process.exit(1);
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
@@ -1095,15 +1095,15 @@ const registerCommand = define({
|
|
|
1095
1095
|
|
|
1096
1096
|
//#endregion
|
|
1097
1097
|
//#region src/modes/resume.ts
|
|
1098
|
-
const logger$
|
|
1098
|
+
const logger$2 = getLogger(["editprompt", "resume"]);
|
|
1099
1099
|
async function runResumeMode(targetPane, mux) {
|
|
1100
1100
|
if (mux === "wezterm") {
|
|
1101
1101
|
const currentPaneId = await getCurrentPaneId();
|
|
1102
1102
|
if (isEditorPaneFromConf(currentPaneId)) {
|
|
1103
|
-
logger$
|
|
1103
|
+
logger$2.debug("Current pane is an editor pane");
|
|
1104
1104
|
const originalTargetPaneIds = await getTargetPaneIds(currentPaneId);
|
|
1105
1105
|
if (originalTargetPaneIds.length === 0) {
|
|
1106
|
-
logger$
|
|
1106
|
+
logger$2.debug("No target pane IDs found for editor pane");
|
|
1107
1107
|
process.exit(1);
|
|
1108
1108
|
}
|
|
1109
1109
|
let focused = false;
|
|
@@ -1113,20 +1113,20 @@ async function runResumeMode(targetPane, mux) {
|
|
|
1113
1113
|
break;
|
|
1114
1114
|
}
|
|
1115
1115
|
if (!focused) {
|
|
1116
|
-
logger$
|
|
1116
|
+
logger$2.debug("All target panes do not exist");
|
|
1117
1117
|
process.exit(1);
|
|
1118
1118
|
}
|
|
1119
1119
|
process.exit(0);
|
|
1120
1120
|
}
|
|
1121
|
-
logger$
|
|
1121
|
+
logger$2.debug("Current pane is not an editor pane");
|
|
1122
1122
|
const editorPaneId = await getEditorPaneId(targetPane);
|
|
1123
|
-
logger$
|
|
1123
|
+
logger$2.debug("wezterm editorPaneId: {editorPaneId}", { editorPaneId });
|
|
1124
1124
|
if (editorPaneId === "") {
|
|
1125
|
-
logger$
|
|
1125
|
+
logger$2.debug("Editor pane ID not found");
|
|
1126
1126
|
process.exit(1);
|
|
1127
1127
|
}
|
|
1128
1128
|
if (!await checkPaneExists(editorPaneId)) {
|
|
1129
|
-
logger$
|
|
1129
|
+
logger$2.debug("Editor pane does not exist");
|
|
1130
1130
|
await clearEditorPaneId(targetPane);
|
|
1131
1131
|
process.exit(1);
|
|
1132
1132
|
}
|
|
@@ -1134,7 +1134,7 @@ async function runResumeMode(targetPane, mux) {
|
|
|
1134
1134
|
await focusPane(editorPaneId);
|
|
1135
1135
|
process.exit(0);
|
|
1136
1136
|
} catch (error) {
|
|
1137
|
-
logger$
|
|
1137
|
+
logger$2.debug("Can't focus editorPaneId: {editorPaneId}, error: {error}", {
|
|
1138
1138
|
editorPaneId,
|
|
1139
1139
|
error
|
|
1140
1140
|
});
|
|
@@ -1183,6 +1183,77 @@ const resumeCommand = define({
|
|
|
1183
1183
|
}
|
|
1184
1184
|
});
|
|
1185
1185
|
|
|
1186
|
+
//#endregion
|
|
1187
|
+
//#region src/modes/press.ts
|
|
1188
|
+
const logger$1 = getLogger(["editprompt", "press"]);
|
|
1189
|
+
async function runPressMode(key, delay = 0) {
|
|
1190
|
+
if (!key) {
|
|
1191
|
+
logger$1.error("Key is required");
|
|
1192
|
+
process.exit(1);
|
|
1193
|
+
}
|
|
1194
|
+
const config = readSendConfig();
|
|
1195
|
+
let currentPaneId;
|
|
1196
|
+
let isEditor;
|
|
1197
|
+
if (config.mux === "tmux") {
|
|
1198
|
+
currentPaneId = await getCurrentPaneId$1();
|
|
1199
|
+
isEditor = await isEditorPane(currentPaneId);
|
|
1200
|
+
} else {
|
|
1201
|
+
currentPaneId = await getCurrentPaneId();
|
|
1202
|
+
isEditor = isEditorPaneFromConf(currentPaneId);
|
|
1203
|
+
}
|
|
1204
|
+
if (!isEditor) {
|
|
1205
|
+
logger$1.error("Current pane is not an editor pane");
|
|
1206
|
+
process.exit(1);
|
|
1207
|
+
}
|
|
1208
|
+
let targetPanes;
|
|
1209
|
+
if (config.mux === "tmux") targetPanes = await getTargetPaneIds$1(currentPaneId);
|
|
1210
|
+
else targetPanes = await getTargetPaneIds(currentPaneId);
|
|
1211
|
+
if (targetPanes.length === 0) {
|
|
1212
|
+
logger$1.error("No target panes registered for this editor pane");
|
|
1213
|
+
process.exit(1);
|
|
1214
|
+
}
|
|
1215
|
+
let successCount = 0;
|
|
1216
|
+
for (const targetPane of targetPanes) try {
|
|
1217
|
+
if (config.mux === "wezterm") await sendKeyToWeztermPane(targetPane, key, delay);
|
|
1218
|
+
else await sendKeyToTmuxPane(targetPane, key, delay);
|
|
1219
|
+
successCount++;
|
|
1220
|
+
} catch (error) {
|
|
1221
|
+
logger$1.warn(`Failed to send key to pane ${targetPane}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1222
|
+
}
|
|
1223
|
+
if (successCount > 0) logger$1.info("Key sent successfully!");
|
|
1224
|
+
else {
|
|
1225
|
+
logger$1.error("All target panes failed to receive key");
|
|
1226
|
+
process.exit(1);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
const pressCommand = define({
|
|
1230
|
+
name: "press",
|
|
1231
|
+
description: "Send a key to target pane without Enter",
|
|
1232
|
+
args: {
|
|
1233
|
+
delay: {
|
|
1234
|
+
description: "Delay before sending key (milliseconds)",
|
|
1235
|
+
type: "string"
|
|
1236
|
+
},
|
|
1237
|
+
"log-file": ARG_LOG_FILE,
|
|
1238
|
+
quiet: ARG_QUIET,
|
|
1239
|
+
verbose: ARG_VERBOSE
|
|
1240
|
+
},
|
|
1241
|
+
async run(ctx) {
|
|
1242
|
+
setupLogger({
|
|
1243
|
+
quiet: Boolean(ctx.values.quiet),
|
|
1244
|
+
verbose: Boolean(ctx.values.verbose),
|
|
1245
|
+
logFile: ctx.values["log-file"]
|
|
1246
|
+
});
|
|
1247
|
+
const key = extractRawContent(ctx.rest, ctx.positionals);
|
|
1248
|
+
if (key === void 0 || key === "") {
|
|
1249
|
+
logger$1.error("Key is required for press command");
|
|
1250
|
+
logger$1.error("Usage: editprompt press -- \"Tab\"");
|
|
1251
|
+
process.exit(1);
|
|
1252
|
+
}
|
|
1253
|
+
await runPressMode(key, ctx.values.delay ? Number(ctx.values.delay) : 0);
|
|
1254
|
+
}
|
|
1255
|
+
});
|
|
1256
|
+
|
|
1186
1257
|
//#endregion
|
|
1187
1258
|
//#region src/modes/stash.ts
|
|
1188
1259
|
const logger = getLogger(["editprompt", "stash"]);
|
|
@@ -1395,6 +1466,7 @@ await cli(process.argv.slice(2), {
|
|
|
1395
1466
|
register: registerCommand,
|
|
1396
1467
|
resume: resumeCommand,
|
|
1397
1468
|
input: inputCommand,
|
|
1469
|
+
press: pressCommand,
|
|
1398
1470
|
collect: collectCommand,
|
|
1399
1471
|
dump: dumpCommand,
|
|
1400
1472
|
stash: stashCommand
|