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.text, "", "", "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