diff options
Diffstat (limited to 'internal/hexaiaction/prompts.go')
| -rw-r--r-- | internal/hexaiaction/prompts.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/hexaiaction/prompts.go b/internal/hexaiaction/prompts.go index e9d7fc6..97af32f 100644 --- a/internal/hexaiaction/prompts.go +++ b/internal/hexaiaction/prompts.go @@ -71,6 +71,21 @@ func runGoTest(ctx context.Context, cfg appconfig.App, client chatDoer, funcCode return runOnceWithOpts(ctx, client, sys, user, reqOptsFrom(cfg)) } +func runCustom(ctx context.Context, cfg appconfig.App, client chatDoer, ca appconfig.CustomAction, parts InputParts) (string, error) { + // If user template is provided, prefer it and optional system + if strings.TrimSpace(ca.User) != "" { + sys := cfg.PromptCodeActionRewriteSystem + if strings.TrimSpace(ca.System) != "" { + sys = ca.System + } + // Currently only selection is available in tmux path; diagnostics list not wired + user := Render(ca.User, map[string]string{"selection": parts.Selection, "diagnostics": strings.Join(parts.Diagnostics, "\n")}) + return runOnceWithOpts(ctx, client, sys, user, reqOptsFrom(cfg)) + } + // Else, use fixed instruction through rewrite template + return runRewrite(ctx, cfg, client, ca.Instruction, parts.Selection) +} + func runOnce(ctx context.Context, client chatDoer, sys, user string) (string, error) { msgs := []llm.Message{{Role: "system", Content: sys}, {Role: "user", Content: user}} start := time.Now() |
