Skip to content

Commit c69581e

Browse files
committed
fix(quick_chat): remove duplicated instructions
1 parent 8ee40a1 commit c69581e

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

lua/opencode/context/plain_text_formatter.lua

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,11 @@ M.format_message = Promise.async(function(prompt, context_instance, opts)
140140
end
141141
end
142142

143-
-- Add selections
144143
for _, sel in ipairs(context_instance:get_selections() or {}) do
145144
table.insert(text_parts, '')
146145
table.insert(text_parts, M.format_selection(sel))
147146
end
148147

149-
-- Add diagnostics
150148
local diagnostics = context_instance:get_diagnostics(buf)
151149
if diagnostics and #diagnostics > 0 then
152150
local diag_range = nil
@@ -160,7 +158,6 @@ M.format_message = Promise.async(function(prompt, context_instance, opts)
160158
end
161159
end
162160

163-
-- Add cursor data
164161
if context_instance:is_context_enabled('cursor_data') then
165162
local current_buf, current_win = context_instance:get_current_buf()
166163
local cursor_data = context_instance:get_current_cursor_data(current_buf or buf, current_win or 0)
@@ -170,7 +167,6 @@ M.format_message = Promise.async(function(prompt, context_instance, opts)
170167
end
171168
end
172169

173-
-- Add git diff
174170
if context_instance:is_context_enabled('git_diff') then
175171
local diff_text = context_instance:get_git_diff():await()
176172
if diff_text and diff_text ~= '' then
@@ -179,13 +175,11 @@ M.format_message = Promise.async(function(prompt, context_instance, opts)
179175
end
180176
end
181177

182-
-- Add instruction
183178
table.insert(text_parts, '')
184-
table.insert(text_parts, 'INSTRUCTION: ' .. prompt)
179+
table.insert(text_parts, 'USER PROMPT: ' .. prompt)
185180

186181
local full_text = table.concat(text_parts, '\n')
187182

188-
-- Return both the plain text and a parts array for the API
189183
return {
190184
text = full_text,
191185
parts = { { type = 'text', text = full_text } },

lua/opencode/quick_chat.lua

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ end
307307
local create_message = Promise.async(function(message, buf, range, context_instance, options)
308308
local quick_chat_config = config.quick_chat or {}
309309

310-
-- Generate instructions (allow user override)
311310
local instructions
312311
if quick_chat_config.instructions then
313312
instructions = quick_chat_config.instructions
@@ -323,12 +322,11 @@ local create_message = Promise.async(function(message, buf, range, context_insta
323322
local result = context.format_message_plain_text(message, context_instance, format_opts):await()
324323

325324
local parts = {
326-
{ type = 'text', text = instructions_text },
327-
{ type = 'text', text = '\n\n' .. string.rep('=', 80) .. '\n\n' .. '# USER REQUEST\n\n' .. result.text },
325+
{ type = 'text', text = table.concat(instructions, '\n') },
326+
{ type = 'text', text = result.text },
328327
}
329328

330-
-- Use instructions as system prompt for models that support it
331-
local params = { parts = parts, system = instructions_text }
329+
local params = { parts = parts }
332330

333331
local current_model = core.initialize_current_model():await()
334332
local target_model = options.model or quick_chat_config.default_model or current_model
@@ -339,13 +337,9 @@ local create_message = Promise.async(function(message, buf, range, context_insta
339337
end
340338
end
341339

342-
-- Set agent if specified
343-
local target_mode = options.agent
344-
or quick_chat_config.default_agent
345-
or state.current_mode
346-
or config.values.default_mode
347-
if target_mode then
348-
params.agent = target_mode
340+
local target_agent = options.agent or quick_chat_config.default_agent or state.current_mode or config.default_mode
341+
if target_agent then
342+
params.agent = target_agent
349343
end
350344

351345
return params

0 commit comments

Comments
 (0)