18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/kward/editor_prompt.rb', line 18
def input(instruction, context)
document = context[:display_path].to_s
language = context[:language].to_s
language = "text" if language.empty?
content = context[:content].to_s
<<~PROMPT
You are operating inside an interactive editor.
The user requested:
#{instruction}
Active document: #{document.empty? ? "(untitled)" : document}
Language: #{language}
Cursor: line #{context.dig(:cursor, 0).to_i + 1}, column #{context.dig(:cursor, 1).to_i + 1}
Selected text: #{context[:selection].to_s.empty? ? "(none)" : "present; full-buffer replacement is required"}
Current buffer:
<editor_buffer>
#{content}
</editor_buffer>
Satisfy the user's request by calling replace_editor_buffer with the complete desired buffer contents.
The operation changes only the in-memory editor buffer. Do not write files to disk.
If the request is ambiguous, explain the ambiguity instead of changing the buffer.
PROMPT
end
|