summaryrefslogtreecommitdiff
path: root/lua/99/prompt-settings.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/99/prompt-settings.lua')
-rw-r--r--lua/99/prompt-settings.lua151
1 files changed, 55 insertions, 96 deletions
diff --git a/lua/99/prompt-settings.lua b/lua/99/prompt-settings.lua
index a688a0e..c221995 100644
--- a/lua/99/prompt-settings.lua
+++ b/lua/99/prompt-settings.lua
@@ -2,14 +2,14 @@
---@param n number lines of context above and below the selection
---@return string
local function get_surrounding_context(range, n)
- local start_row, _ = range.start:to_vim()
- local end_row, _ = range.end_:to_vim()
- local line_count = vim.api.nvim_buf_line_count(range.buffer)
- local from = math.max(start_row - n, 0)
- local to = math.min(end_row + 1 + n, line_count)
- local lines = vim.api.nvim_buf_get_lines(range.buffer, from, to, false)
+ local start_row, _ = range.start:to_vim()
+ local end_row, _ = range.end_:to_vim()
+ local line_count = vim.api.nvim_buf_line_count(range.buffer)
+ local from = math.max(start_row - n, 0)
+ local to = math.min(end_row + 1 + n, line_count)
+ local lines = vim.api.nvim_buf_get_lines(range.buffer, from, to, false)
- return table.concat(lines, "\n")
+ return table.concat(lines, "\n")
end
--- @class _99.Prompts.SpecificOperations
@@ -17,15 +17,15 @@ end
--- @field semantic_search fun(): string
--- @field vibe fun(): string
--- @field tutorial fun(): string
---- @field prompt fun(prompt: string, action: string, name?: string): string
+--- @field prompt fun(prompt?: string|boolean|nil, action: string, name?: string): string
--- @field role fun(): string
--- @field read_tmp fun(): string
local prompts = {
- role = function()
- return [[ You are a software engineering assistant mean to create robust and conanical code ]]
- end,
- tutorial = function()
- return [[
+ role = function()
+ return [[ You are a strict code completion backend for Neovim. Your input will be a code snippet, function signature, or a comment requesting code. CRITICAL DIRECTIONS: 1. Output ONLY valid, executable programming code. 2. Do NOT wrap your response in code blocks. 3. Do NOT include any conversational filler, explanations, greetings, or sign-offs. 4. If you cannot fulfill the request, output nothing or a code comment explaining why. ]]
+ end,
+ tutorial = function()
+ return [[
You are given a prompt and context and you must craft a tutorial. If a set of
context has links, read through them thoroughly and decide which ones to retrieve.
Once you have fetched all the relavent content, review it thoroughly before
@@ -34,9 +34,9 @@ crafting the tutorial
<Rule>The response format must be valid Markdown</Rule>
<Rule>The first line of the response must be the title of the tutorial</Rule>
]]
- end,
- semantic_search = function()
- return [[
+ end,
+ semantic_search = function()
+ return [[
<Output>
/path/to/project/src/foo.js:24:8,3,Some notes here about some stuff, it can contain commas
/path/to/project/src/foo.js:71:12,7,more notes, everything is great!
@@ -73,9 +73,9 @@ baz.js at line 1, char 1 and the next 51 lines
you are given a prompt and you must search through this project and return code that matches the description provided.
</TaskDescription>
]]
- end,
- vibe = function()
- return [[
+ end,
+ vibe = function()
+ return [[
<Output>
/path/to/project/src/foo.js:24:8,3,Some notes here about some stuff, it can contain commas
/path/to/project/src/foo.js:71:12,7,more notes, everything is great!
@@ -114,22 +114,15 @@ Never respond as output what you have done.
Always use the temporary file as the place to describe your actions according to Output rules
</TaskDescription>
]]
- end,
- output_file = function()
- return [[
-NEVER alter any file other than TEMP_FILE.
-never provide the requested changes as conversational output. Return only the code.
-ONLY provide requested changes by writing the change to TEMP_FILE
-]]
- end,
- --- @param prompt string
- --- @param action string
- --- @param name? string defaults to DIRECTIONS
- --- @return string
- prompt = function(prompt, action, name)
- name = name or "Prompt"
- return string.format(
- [[
+ end,
+ --- @param prompt string
+ --- @param action string
+ --- @param name? string defaults to DIRECTIONS
+ --- @return string
+ prompt = function(prompt, action, name)
+ name = name or "Prompt"
+ return string.format(
+ [[
<Context>
%s
</Context>
@@ -137,77 +130,43 @@ ONLY provide requested changes by writing the change to TEMP_FILE
%s
</%s>
]],
- action,
- name,
- prompt,
- name
- )
- end,
- visual_selection = function(range)
- return string.format(
- [[
-You receive a selection in neovim that you need to replace with new code.
-The selection's contents may contain notes, incorporate the notes every time if there are some.
-consider the context of the selection and what you are suppose to be implementing
-<SELECTION_LOCATION>
-%s
-</SELECTION_LOCATION>
+ action,
+ name,
+ prompt,
+ name
+ )
+ end,
+ visual_selection = function(range)
+ return string.format(
+ [[
<SELECTION_CONTENT>
%s
</SELECTION_CONTENT>
-<SURROUNDING_CONTEXT>
-%s
-</SURROUNDING_CONTEXT>
]],
- range:to_string(),
- range:to_text(),
- get_surrounding_context(range, 100)
- )
- end,
- read_tmp = function()
- return [[
-never attempt to read TEMP_FILE.
-It is purely for output.
-Previous contents, which may not exist, can be written over without worry
-After writing TEMP_FILE once you should be done. Be done and end the session.
-]]
- end,
+ range:to_text()
+ )
+ end,
}
--- @class _99.Prompts
local prompt_settings = {
- prompts = prompts,
-
- --- @param tmp_file string
- --- @return string
- tmp_file_location = function(tmp_file)
- return string.format("<TEMP_FILE>%s</TEMP_FILE>", tmp_file)
- end,
-
- --- @return string
- only_tmp_file_change = function()
- return string.format(
- "<MustObey>\n%s\n%s\n</MustObey>",
- prompts.output_file(),
- prompts.read_tmp()
- )
- end,
+ prompts = prompts,
- ---@param full_path string
- ---@param range _99.Range
- ---@return string
- get_file_location = function(full_path, range)
- return string.format(
- "<Location><File>%s</File><Function>%s</Function></Location>",
- full_path,
- range:to_string()
- )
- end,
+ ---@param full_path string
+ ---@param range _99.Range
+ ---@return string
+ get_file_location = function(full_path, range)
+ return string.format(
+ "<Location><File>%s</File><Function>%s</Function></Location>",
+ full_path,
+ range:to_string()
+ )
+ end,
- --- @param range _99.Range
- get_range_text = function(range)
- return string.format("<FunctionText>%s</FunctionText>", range:to_text())
- end,
+ --- @param range _99.Range
+ get_range_text = function(range)
+ return string.format("<FunctionText>%s</FunctionText>", range:to_text())
+ end,
}
return prompt_settings