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
8 changes: 8 additions & 0 deletions lua/99/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ end
--- @field in_flight_options? _99.StatusWindow.Opts
--- @field md_files? string[]
--- @field provider? _99.Providers.BaseProvider
--- @field provider_extra_args? string[]
--- @field display_errors? boolean
--- @field auto_add_skills? boolean
--- @field completion? _99.Completion
Expand Down Expand Up @@ -438,6 +439,13 @@ function _99.setup(opts)
end
end

if opts.provider_extra_args then
assert(
type(opts.provider_extra_args) == "table",
"opts.provider_extra_args must be a table"
)
end

if opts.md_files then
assert(type(opts.md_files) == "table", "opts.md_files is not a table")
for _, md in ipairs(opts.md_files) do
Expand Down
4 changes: 4 additions & 0 deletions lua/99/providers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ function BaseProvider:make_request(query, context, observer)
)

local command = self:_build_command(query, context)
local extra_args = context._99 and context._99.provider_extra_args or {}
if #extra_args > 0 then
vim.list_extend(command, extra_args)
end
Comment thread
cursor[bot] marked this conversation as resolved.
Comment thread
sentry[bot] marked this conversation as resolved.
logger:debug("make_request", "command", command)

local proc = vim.system(
Expand Down
2 changes: 2 additions & 0 deletions lua/99/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ end
--- @field ai_stdout_rows number
--- @field display_errors boolean
--- @field provider_override _99.Providers.BaseProvider?
--- @field provider_extra_args string[]
--- @field rules _99.Agents.Rules
--- @field tracking _99.State.Tracking
--- @field __tmp_dir string | nil
Expand Down Expand Up @@ -73,6 +74,7 @@ function State.new(opts)
local _99_state = setmetatable(props, State) --[[@as _99.State]]

_99_state.provider_override = opts.provider
_99_state.provider_extra_args = opts.provider_extra_args or {}
_99_state.completion = opts.completion or default_completion()
_99_state.completion.custom_rules = _99_state.completion.custom_rules or {}
_99_state.completion.files = _99_state.completion.files or {}
Expand Down
18 changes: 18 additions & 0 deletions lua/99/test/providers_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,24 @@ describe("providers", function()
end)
end)

describe("provider_extra_args", function()
it("stores provider_extra_args on state", function()
local _99 = require("99")
_99.setup({
provider_extra_args = { "--no-session-persistence" },
})
local state = _99.__get_state()
eq({ "--no-session-persistence" }, state.provider_extra_args)
end)

it("defaults provider_extra_args to empty table", function()
local _99 = require("99")
_99.setup({})
local state = _99.__get_state()
eq({}, state.provider_extra_args)
end)
end)

describe("BaseProvider", function()
it("all providers have make_request", function()
eq("function", type(Providers.OpenCodeProvider.make_request))
Expand Down
Loading