summaryrefslogtreecommitdiff
path: root/internal/hexaiaction/run.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-09-07 17:54:42 +0300
committerPaul Buetow <paul@buetow.org>2025-09-07 17:54:42 +0300
commit77e41a1018715fa5ac4e6156354710b3b224b4fc (patch)
tree23d847008c34a4c8b1329151fd33ac107fdefe76 /internal/hexaiaction/run.go
parenta240e1e106d3b8028bbb3667b44cf3085875e405 (diff)
feat: add Custom prompt action (p) with editor integration; shared editor helper in internal/editor; hexai CLI opens editor when no args
Diffstat (limited to 'internal/hexaiaction/run.go')
-rw-r--r--internal/hexaiaction/run.go11
1 files changed, 11 insertions, 0 deletions
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
}