Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions BACKLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,16 @@
- [Gap 11]: Missing support for System Fragment (`--sf`, `--system-fragment`).

## Ranked Backlog
1. [Gap 4] - [Medium Impact/Low Effort] - Add functionality to Continue Conversations (`-c`, `--continue`, `--cid`, `--conversation`) easily from previous prompt sessions.
2. [Gap 7] - [Medium Impact/Low Effort] - Add support for Schema Options (`--schema`, `--schema-multi`) in prompts.
3. [Gap 8] - [Medium Impact/Low Effort] - Add support to Save as Template (`--save`).
4. [Tech Debt 5] - [Medium Impact/Medium Effort] - Refactor duplicated command construction logic in `lua/llm/commands.lua`.
5. [Gap 1] - [Medium Impact/Medium Effort] - Implement Multi-modal attachment support for models that accept images or other data types (`-a`, `--attachment`, `--at`, `--attachment-type`).
6. [Gap 3] - [Medium Impact/Medium Effort] - Implement Extended Tool Options (`--functions`, `--td`, `--ta`, `--cl`).
7. [Tech Debt 2] - [Medium Impact/Medium Effort] - Enhance async job handling logic in `job.lua` for edge cases.
8. [Gap 2] - [Low Impact/Low Effort] - Expose token Usage tracking (`-u`, `--usage`) visually after execution.
9. [Gap 5] - [Low Impact/Low Effort] - Enable dynamic Query Selection (`-q`, `--query`).
10. [Gap 6] - [Low Impact/Low Effort] - Add options for explicit Async Execution (`--async`) and blocking Stream Control (`--no-stream`).
11. [Tech Debt 3] - [Low Impact/Low Effort] - Write explicit unit tests for `interactive_prompt_with_fragments` in `commands.lua`.
12. [Gap 9] - [Low Impact/Low Effort] - Add support for Extract Last (`--xl`, `--extract-last`).
13. [Gap 10] - [Low Impact/Low Effort] - Add support for Logging options (`-d`, `--database`, `-n`, `--no-log`, `--log`).
14. [Gap 11] - [Low Impact/Low Effort] - Add support for System Fragment (`--sf`, `--system-fragment`).
1. [Gap 7] - [Medium Impact/Low Effort] - Add support for Schema Options (`--schema`, `--schema-multi`) in prompts.
2. [Gap 8] - [Medium Impact/Low Effort] - Add support to Save as Template (`--save`).
3. [Tech Debt 5] - [Medium Impact/Medium Effort] - Refactor duplicated command construction logic in `lua/llm/commands.lua`.
4. [Gap 1] - [Medium Impact/Medium Effort] - Implement Multi-modal attachment support for models that accept images or other data types (`-a`, `--attachment`, `--at`, `--attachment-type`).
5. [Gap 3] - [Medium Impact/Medium Effort] - Implement Extended Tool Options (`--functions`, `--td`, `--ta`, `--cl`).
6. [Tech Debt 2] - [Medium Impact/Medium Effort] - Enhance async job handling logic in `job.lua` for edge cases.
7. [Gap 2] - [Low Impact/Low Effort] - Expose token Usage tracking (`-u`, `--usage`) visually after execution.
8. [Gap 5] - [Low Impact/Low Effort] - Enable dynamic Query Selection (`-q`, `--query`).
9. [Gap 6] - [Low Impact/Low Effort] - Add options for explicit Async Execution (`--async`) and blocking Stream Control (`--no-stream`).
10. [Tech Debt 3] - [Low Impact/Low Effort] - Write explicit unit tests for `interactive_prompt_with_fragments` in `commands.lua`.
11. [Gap 9] - [Low Impact/Low Effort] - Add support for Extract Last (`--xl`, `--extract-last`).
12. [Gap 10] - [Low Impact/Low Effort] - Add support for Logging options (`-d`, `--database`, `-n`, `--no-log`, `--log`).
13. [Gap 11] - [Low Impact/Low Effort] - Add support for System Fragment (`--sf`, `--system-fragment`).
15 changes: 15 additions & 0 deletions lua/llm/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ function M.get_template_params_args()
return {}
end

-- Get conversation arguments if specified
function M.get_conversation_args()
local args = {}
local cid = config.get("conversation_id")
if cid and cid ~= "" then
return { "--cid", cid }
elseif config.get("continue_conversation") then
return { "-c" }
end
return {}
end

-- Run an llm command and return the result

function M.get_pre_response_message(source, prompt, fragment_paths)
Expand Down Expand Up @@ -261,6 +273,7 @@ function M.prompt(prompt, fragment_paths, bufnr)
vim.list_extend(cmd_parts, M.get_model_options_args())
vim.list_extend(cmd_parts, M.get_template_arg())
vim.list_extend(cmd_parts, M.get_template_params_args())
vim.list_extend(cmd_parts, M.get_conversation_args())

if fragment_paths then
for _, fragment in ipairs(fragment_paths) do
Expand Down Expand Up @@ -316,6 +329,7 @@ function M.prompt_with_current_file(prompt, fragment_paths, bufnr)
vim.list_extend(cmd_parts, M.get_model_options_args())
vim.list_extend(cmd_parts, M.get_template_arg())
vim.list_extend(cmd_parts, M.get_template_params_args())
vim.list_extend(cmd_parts, M.get_conversation_args())

-- Add user-specified fragments
if fragment_paths then
Expand Down Expand Up @@ -375,6 +389,7 @@ function M.prompt_with_selection(prompt, fragment_paths, from_visual_mode, bufnr
vim.list_extend(cmd_parts, M.get_model_options_args())
vim.list_extend(cmd_parts, M.get_template_arg())
vim.list_extend(cmd_parts, M.get_template_params_args())
vim.list_extend(cmd_parts, M.get_conversation_args())
if fragment_paths then
vim.list_extend(cmd_parts, M.get_fragment_args(fragment_paths))
end
Expand Down
10 changes: 10 additions & 0 deletions lua/llm/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ M.defaults = {
type = "table",
desc = "Key/value parameters for the template (e.g., {name = 'World'})"
},
continue_conversation = {
default = false,
type = "boolean",
desc = "Continue the most recent conversation"
},
conversation_id = {
default = nil,
type = "string",
desc = "Continue the conversation with the given ID"
},
-- Add more config options here
}

Expand Down
28 changes: 28 additions & 0 deletions tests/spec/commands_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,34 @@ describe('llm.commands', function() -- This is a new test suite for llm.commands
end)
end)

describe('get_conversation_args', function()
it('should return {--cid, cid} if conversation_id is set', function()
package.loaded['llm.config'].get = spy.new(function(key)
if key == 'conversation_id' then return 'test-id' end
return nil
end)
local result = commands.get_conversation_args()
assert.same({ '--cid', 'test-id' }, result)
end)

it('should return {-c} if continue_conversation is true', function()
package.loaded['llm.config'].get = spy.new(function(key)
if key == 'continue_conversation' then return true end
return nil
end)
local result = commands.get_conversation_args()
assert.same({ '-c' }, result)
end)

it('should return {} if neither are set', function()
package.loaded['llm.config'].get = spy.new(function(key)
return nil
end)
local result = commands.get_conversation_args()
assert.same({}, result)
end)
end)

describe('prompt', function()
it('should call api.run_streaming_command with the correct arguments', function()
commands.prompt('test prompt', {}, 1)
Expand Down
Loading