From 77e41a1018715fa5ac4e6156354710b3b224b4fc Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 7 Sep 2025 17:54:42 +0300 Subject: feat: add Custom prompt action (p) with editor integration; shared editor helper in internal/editor; hexai CLI opens editor when no args --- internal/hexaiaction/run.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'internal/hexaiaction/run.go') diff --git a/internal/hexaiaction/run.go b/internal/hexaiaction/run.go index 5417d3f..1325e9d 100644 --- a/internal/hexaiaction/run.go +++ b/internal/hexaiaction/run.go @@ -8,6 +8,7 @@ import ( "strings" "codeberg.org/snonux/hexai/internal/appconfig" + "codeberg.org/snonux/hexai/internal/editor" "codeberg.org/snonux/hexai/internal/logging" "codeberg.org/snonux/hexai/internal/llmutils" ) @@ -74,6 +75,16 @@ func executeAction(ctx context.Context, kind ActionKind, parts InputParts, cfg a cctx, cancel := timeout10s(ctx) defer cancel() return runSimplify(cctx, cfg, client, parts.Selection) + case ActionCustom: + cctx, cancel := timeout10s(ctx) + defer cancel() + // Open editor for free-form instruction + prompt, err := editor.OpenTempAndEdit([]byte("# Enter your instruction below\n\n")) + if err != nil || strings.TrimSpace(prompt) == "" { + fmt.Fprintln(stderr, logging.AnsiBase+"hexai-tmux-action: custom prompt canceled or empty; echoing input"+logging.AnsiReset) + return parts.Selection, nil + } + return runRewrite(cctx, cfg, client, prompt, parts.Selection) default: return parts.Selection, nil } -- cgit v1.2.3