aboutsummaryrefslogtreecommitdiff
path: root/lua/hobs/prompt.lua
blob: 2a1d6a97a88bde4517543a8ba7f81fc62d9e944e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
local M = {}

function M.build(filename, selection, user_prompt)
  return table.concat({
    "You are a coding agent working concurrently with a human in Neovim.",
    "",
    "The human selected this code and gave you a task.",
    "The buffer may continue changing while you work.",
    "",
    "File: " .. filename,
    string.format(
      "Initial selection: %d:%d-%d:%d",
      selection.display_start_line,
      selection.display_start_col,
      selection.display_end_line,
      selection.display_end_col
    ),
    "",
    "Selected text:",
    "<selection>",
    selection.text,
    "</selection>",
    "",
    "Task:",
    user_prompt,
    "",
    "IMPORTANT OUTPUT CONTRACT:",
    "- Do not edit any files yourself.",
    "- You may inspect the project as needed, but your final response must be ONLY a GNU sed script.",
    "- The sed script will be applied to the CURRENT live contents of this Neovim buffer after you finish.",
    "- Do not use absolute line-number addresses; the human may have inserted or removed lines while you were working.",
    "- Address edits by distinctive source text/patterns and keep substitutions narrowly scoped.",
    "- Prefer scripts that fail to change anything rather than matching unrelated code.",
    "- Do not include Markdown fences, prose, explanations, or shell commands.",
    "- Output only the contents of a sed -f program.",
  }, "\n")
end

return M