Something went wrong. Try again.
A neovim plugin for OpenCode
Something went wrong. Try again.
1.3 kB · 43 lines
Lua
at commit d783bd25
1234567891011121314151617181920212223242526272829303132333435363738394041424344local current = "ses_old"local created = 0local prompted = 0local inherited
package.loaded["brokencode.client"] = { sessions = function(_, callback) callback(nil, { { id = "ses_tui", model = { providerID = "test", id = "working" } }, }) end, create = function(_, model, callback) created = created + 1 inherited = model callback(nil, { id = "ses_new" }) end, prompt = function(session_id, _, callback) prompted = prompted + 1 if session_id == "ses_old" then callback("Session not found: ses_old") return end callback(nil) end, active = function(callback) callback(nil, {}) end, switch_model = function(_, _, callback) callback(nil) end,}package.loaded["brokencode.state"] = { get = function() return current end, set = function(_, value) current = value end, clear = function() current = nil end,}package.loaded["brokencode.ui"] = { refresh = function() end, input = function() end,}
require("brokencode").send("hello")
assert(created == 1, "a replacement session was not created")assert(prompted == 2, "the prompt was not retried once")assert(current == "ses_new", "the replacement session was not saved")assert(inherited and inherited.id == "working", "the recent model was not inherited")