From 52f51229ce91a02070dfcf3eae1fd1104e1e99a7 Mon Sep 17 00:00:00 2001 From: theprimeagain Date: Sat, 7 Feb 2026 15:24:09 -0700 Subject: search stubbed, and more instructions for visual mode --- lua/99/init.lua | 87 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 43 insertions(+), 44 deletions(-) (limited to 'lua/99/init.lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index 61085ad..e536519 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -254,26 +254,37 @@ local function set_selection_marks() ) end ---- @param cb fun(ok: boolean, o: _99.ops.Opts?): nil +--- @param cb fun(context: _99.RequestContext, o: _99.ops.Opts?): nil --- @param context _99.RequestContext --- @param opts _99.ops.Opts ---- @return fun(ok: boolean, response: string): nil -local function wrap_window_capture(cb, context, opts) - --- @param ok boolean - --- @param response string - return function(ok, response) - context.logger:debug("capture_prompt", "success", ok, "response", response) - if not ok then - return cb(false) - end - local rules_and_names = Agents.by_name(_99_state.rules, response) - opts.additional_rules = opts.additional_rules or {} - for _, r in ipairs(rules_and_names.rules) do - table.insert(opts.additional_rules, r) - end - opts.additional_prompt = response - cb(true, opts) - end +local function capture_prompt(cb, context, opts) + Window.capture_input({ + --- @param ok boolean + --- @param response string + cb = function(ok, response) + context.logger:debug( + "capture_prompt", + "success", + ok, + "response", + response + ) + if not ok then + return + end + local rules_and_names = Agents.by_name(_99_state.rules, response) + opts.additional_rules = opts.additional_rules or {} + for _, r in ipairs(rules_and_names.rules) do + table.insert(opts.additional_rules, r) + end + opts.additional_prompt = response + cb(context, opts) + end, + on_load = function() + Extensions.setup_buffer(_99_state) + end, + rules = _99_state.rules, + }) end --- @param operation_name string @@ -311,25 +322,25 @@ function _99:rule_from_path(path) return Agents.get_rule_by_path(_99_state.rules, path) end +--- @param opts? _99.ops.SearchOpts +function _99.search(opts) + local o = process_opts(opts) --[[ @as _99.ops.SearchOpts ]] + local context = get_context("search") + if o.additional_prompt then + ops.search(context, o) + return + else + capture_prompt(ops.search, context, o) + end +end + --- @param opts? _99.ops.Opts function _99.fill_in_function_prompt(opts) opts = process_opts(opts) local context = get_context("fill-in-function-with-prompt") context.logger:debug("start") - Window.capture_input({ - cb = wrap_window_capture(function(ok, o) - if not ok then - return - end - assert(o ~= nil, "if ok, then opts must exist") - ops.fill_in_function(context, o) - end, context, opts), - on_load = function() - Extensions.setup_buffer(_99_state) - end, - rules = _99_state.rules, - }) + capture_prompt(ops.fill_in_function, context, opts) end --- @param opts? _99.ops.Opts @@ -343,19 +354,7 @@ function _99.visual_prompt(opts) opts = process_opts(opts) local context = get_context("over-range-with-prompt") context.logger:debug("start") - Window.capture_input({ - cb = wrap_window_capture(function(ok, o) - if not ok then - return - end - assert(o ~= nil, "if ok, then opts must exist") - _99.visual(context, o) - end, context, opts), - on_load = function() - Extensions.setup_buffer(_99_state) - end, - rules = _99_state.rules, - }) + capture_prompt(_99.visual, context, opts) end --- @param context _99.RequestContext? -- cgit v1.3-3-g829e From 9488677af394e2134ecf618d72efe35b0c81b439 Mon Sep 17 00:00:00 2001 From: theprimeagain Date: Sat, 7 Feb 2026 16:23:27 -0700 Subject: small cleanup on logic --- lua/99/init.lua | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) (limited to 'lua/99/init.lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index e536519..1921aff 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -334,42 +334,26 @@ function _99.search(opts) end end ---- @param opts? _99.ops.Opts -function _99.fill_in_function_prompt(opts) - opts = process_opts(opts) - local context = get_context("fill-in-function-with-prompt") - - context.logger:debug("start") - capture_prompt(ops.fill_in_function, context, opts) -end - ---- @param opts? _99.ops.Opts -function _99.fill_in_function(opts) - opts = process_opts(opts) - ops.fill_in_function(get_context("fill_in_function"), opts) -end - --- @param opts _99.ops.Opts function _99.visual_prompt(opts) - opts = process_opts(opts) - local context = get_context("over-range-with-prompt") - context.logger:debug("start") - capture_prompt(_99.visual, context, opts) + warn("use visual, visual_prompt has been deprecated") + _99.visual(opts) end ---- @param context _99.RequestContext? --- @param opts _99.ops.Opts? -function _99.visual(context, opts) +function _99.visual(opts) opts = process_opts(opts) - --- TODO: Talk to teej about this. - --- Visual selection marks are only set in place post visual selection. - --- that means for this function to work i must escape out of visual mode - --- which i dislike very much. because maybe you dont want this - set_selection_marks() - - context = context or get_context("over-range") - local range = Range.from_visual_selection() - ops.over_range(context, range, opts) + local context = get_context("visual") + local function perform_range() + set_selection_marks() + local range = Range.from_visual_selection() + ops.over_range(context, range, opts) + end + if opts.additional_prompt then + perform_range() + else + capture_prompt(perform_range, context, opts) + end end --- View all the logs that are currently cached. Cached log count is determined -- cgit v1.3-3-g829e From e341ecf0a2eea90e2948f620903bfc51cbcaac9c Mon Sep 17 00:00:00 2001 From: theprimeagain Date: Sat, 7 Feb 2026 19:38:24 -0700 Subject: fill in function --- lua/99/init.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lua/99/init.lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index 1921aff..35ee85d 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -340,6 +340,14 @@ function _99.visual_prompt(opts) _99.visual(opts) end +function _99.fill_in_function() + error("function has been removed. Just use visual. I really hate fill in function, sorry :)") +end + +function _99.fill_in_function_prompt() + error("function has been removed. Just use visual. I really hate fill in function, sorry :)") +end + --- @param opts _99.ops.Opts? function _99.visual(opts) opts = process_opts(opts) -- cgit v1.3-3-g829e From 489e132d4aec29970e0981ee12252d3925ad49c3 Mon Sep 17 00:00:00 2001 From: theprimeagain Date: Sat, 7 Feb 2026 19:39:45 -0700 Subject: chore: lint and format --- lua/99/init.lua | 8 ++++++-- lua/99/ops/search.lua | 2 ++ lua/99/prompt-settings.lua | 3 ++- lua/99/test/request_status_spec.lua | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) (limited to 'lua/99/init.lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index 35ee85d..2340065 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -341,11 +341,15 @@ function _99.visual_prompt(opts) end function _99.fill_in_function() - error("function has been removed. Just use visual. I really hate fill in function, sorry :)") + error( + "function has been removed. Just use visual. I really hate fill in function, sorry :)" + ) end function _99.fill_in_function_prompt() - error("function has been removed. Just use visual. I really hate fill in function, sorry :)") + error( + "function has been removed. Just use visual. I really hate fill in function, sorry :)" + ) end --- @param opts _99.ops.Opts? diff --git a/lua/99/ops/search.lua b/lua/99/ops/search.lua index dff4abf..aa3d08a 100644 --- a/lua/99/ops/search.lua +++ b/lua/99/ops/search.lua @@ -1,5 +1,7 @@ --- @param context _99.RequestContext ---@param opts _99.ops.SearchOpts return function(context, opts) + _ = context + _ = opts error("search not implemented") end diff --git a/lua/99/prompt-settings.lua b/lua/99/prompt-settings.lua index 295254f..45f46dd 100644 --- a/lua/99/prompt-settings.lua +++ b/lua/99/prompt-settings.lua @@ -27,7 +27,8 @@ X = how many lines should be highlighted Each location is separated by new lines Each path is specified in absolute pathing -You have found 3 locations in files foo.js, bar.js, and baz.js. There are 2 locations in foo.js, 1 in bar.js and baz.js. +You have found 3 locations in files foo.js, bar.js, and baz.js. +There are 2 locations in foo.js, 1 in bar.js and baz.js. /path/to/project/src/foo.js:24:8,3 /path/to/project/src/foo.js:71:12,7 diff --git a/lua/99/test/request_status_spec.lua b/lua/99/test/request_status_spec.lua index 4009cf9..74301b2 100644 --- a/lua/99/test/request_status_spec.lua +++ b/lua/99/test/request_status_spec.lua @@ -35,7 +35,7 @@ describe("request_status", function() return #calls == 1 end) eq(1, #calls) - eq({ "⠹ TITLE", }, calls[1]) + eq({ "⠹ TITLE" }, calls[1]) calls = {} status:push("bar") -- cgit v1.3-3-g829e From 39d43e8876b9d442fb28b91f2677fe3851e9ac28 Mon Sep 17 00:00:00 2001 From: Riley Mathews Date: Tue, 3 Feb 2026 12:54:51 -0600 Subject: add configurable agent option --- lua/99/init.lua | 8 ++++++++ lua/99/providers.lua | 2 +- lua/99/request-context.lua | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'lua/99/init.lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index 2340065..ab7e740 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -57,6 +57,7 @@ end --- @class _99.StateProps --- @field model string +--- @field agent string --- @field md_files string[] --- @field prompts _99.Prompts --- @field ai_stdout_rows number @@ -73,6 +74,7 @@ end local function create_99_state() return { model = "opencode/claude-sonnet-4-5", + agent = "build", md_files = {}, prompts = require("99.prompt-settings"), ai_stdout_rows = 3, @@ -94,6 +96,7 @@ end --- @class _99.Options --- @field logger _99.Logger.Options? --- @field model string? +--- @field agent string? --- @field md_files string[]? --- @field provider _99.Providers.BaseProvider? --- @field debug_log_prefix string? @@ -471,6 +474,11 @@ function _99.setup(opts) end end + if opts.agent then + assert(type(opts.agent) == "string", "opts.agent is not a string") + _99_state.agent = opts.agent + 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 diff --git a/lua/99/providers.lua b/lua/99/providers.lua index ab56738..5b7dfc0 100644 --- a/lua/99/providers.lua +++ b/lua/99/providers.lua @@ -141,7 +141,7 @@ local OpenCodeProvider = setmetatable({}, { __index = BaseProvider }) --- @param request _99.Request --- @return string[] function OpenCodeProvider._build_command(_, query, request) - return { "opencode", "run", "-m", request.context.model, query } + return { "opencode", "run", "--agent", request.context.agent, "-m", request.context.model, query } end --- @return string diff --git a/lua/99/request-context.lua b/lua/99/request-context.lua index 74aaa0b..6260b68 100644 --- a/lua/99/request-context.lua +++ b/lua/99/request-context.lua @@ -47,6 +47,7 @@ function RequestContext.from_current_buffer(_99, xid) logger = Logger:set_id(xid), xid = xid, model = _99.model, + agent = _99.agent, marks = {}, }, RequestContext) end -- cgit v1.3-3-g829e From 50a98f9bde8574145ef1fa9ef6c1c6062b1effd8 Mon Sep 17 00:00:00 2001 From: Riley Mathews Date: Sat, 7 Feb 2026 21:27:04 -0600 Subject: hardcode build as agent --- lua/99/init.lua | 8 -------- lua/99/providers.lua | 2 +- lua/99/request-context.lua | 1 - 3 files changed, 1 insertion(+), 10 deletions(-) (limited to 'lua/99/init.lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index ab7e740..2340065 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -57,7 +57,6 @@ end --- @class _99.StateProps --- @field model string ---- @field agent string --- @field md_files string[] --- @field prompts _99.Prompts --- @field ai_stdout_rows number @@ -74,7 +73,6 @@ end local function create_99_state() return { model = "opencode/claude-sonnet-4-5", - agent = "build", md_files = {}, prompts = require("99.prompt-settings"), ai_stdout_rows = 3, @@ -96,7 +94,6 @@ end --- @class _99.Options --- @field logger _99.Logger.Options? --- @field model string? ---- @field agent string? --- @field md_files string[]? --- @field provider _99.Providers.BaseProvider? --- @field debug_log_prefix string? @@ -474,11 +471,6 @@ function _99.setup(opts) end end - if opts.agent then - assert(type(opts.agent) == "string", "opts.agent is not a string") - _99_state.agent = opts.agent - 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 diff --git a/lua/99/providers.lua b/lua/99/providers.lua index 5b7dfc0..b638999 100644 --- a/lua/99/providers.lua +++ b/lua/99/providers.lua @@ -141,7 +141,7 @@ local OpenCodeProvider = setmetatable({}, { __index = BaseProvider }) --- @param request _99.Request --- @return string[] function OpenCodeProvider._build_command(_, query, request) - return { "opencode", "run", "--agent", request.context.agent, "-m", request.context.model, query } + return { "opencode", "run", "--agent", "build", "-m", request.context.model, query } end --- @return string diff --git a/lua/99/request-context.lua b/lua/99/request-context.lua index 6260b68..74aaa0b 100644 --- a/lua/99/request-context.lua +++ b/lua/99/request-context.lua @@ -47,7 +47,6 @@ function RequestContext.from_current_buffer(_99, xid) logger = Logger:set_id(xid), xid = xid, model = _99.model, - agent = _99.agent, marks = {}, }, RequestContext) end -- cgit v1.3-3-g829e From d9dfb2336364fa0985137b56d8b13dc806fea7a7 Mon Sep 17 00:00:00 2001 From: theprimeagain Date: Sun, 8 Feb 2026 12:58:55 -0700 Subject: small error with warn --- lua/99/init.lua | 2 +- lua/99/prompt-settings.lua | 3 +++ lua/99/window/init.lua | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'lua/99/init.lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index 2340065..dcb1aa3 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -336,7 +336,7 @@ end --- @param opts _99.ops.Opts function _99.visual_prompt(opts) - warn("use visual, visual_prompt has been deprecated") + print("use visual, visual_prompt has been deprecated") _99.visual(opts) end diff --git a/lua/99/prompt-settings.lua b/lua/99/prompt-settings.lua index d6f0de3..0bc564d 100644 --- a/lua/99/prompt-settings.lua +++ b/lua/99/prompt-settings.lua @@ -25,6 +25,9 @@ cnum = starting column number 1 based X = how many lines should be highlighted NOTES = A text description of why this highlight is important +NOTES cannot have new lines +You must adhere to the output format +Double check output format before writing it to the file Each location is separated by new lines Each path is specified in absolute pathing You can provide notes you think are relevant per location diff --git a/lua/99/window/init.lua b/lua/99/window/init.lua index 358b83b..492581e 100644 --- a/lua/99/window/init.lua +++ b/lua/99/window/init.lua @@ -420,4 +420,8 @@ function M.clear_active_popups() M.active_windows = {} end +function M.status_window() + M.clear_active_popups() +end + return M -- cgit v1.3-3-g829e