summaryrefslogtreecommitdiff
path: root/lua/99/ops/context.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/99/ops/context.lua')
-rw-r--r--lua/99/ops/context.lua23
1 files changed, 19 insertions, 4 deletions
diff --git a/lua/99/ops/context.lua b/lua/99/ops/context.lua
index d88a170..0428671 100644
--- a/lua/99/ops/context.lua
+++ b/lua/99/ops/context.lua
@@ -13,9 +13,15 @@ end
local Context = {}
Context.__index = Context
-function Context.new()
+--- @param _99 _99.State
+function Context.new(_99)
+ local mds = {}
+ for _, md in ipairs(_99.md_files) do
+ table.insert(mds, md)
+ end
+
return setmetatable({
- md_file_names = {},
+ md_file_names = mds,
ai_context = {},
tmp_file = random_file(),
}, Context)
@@ -28,13 +34,22 @@ function Context:add_md_file_name(md_file_name)
return self
end
---- @param location _99.Location
-function Context:finalize(location)
+function Context:_read_md_files()
--- @ai use location's buffer's full path and walk back until we are at cwd
--- @ai and read each of the md_file_names. if it exists then add it to
--- @ai ai_context.
end
+--- @param _99 _99.State
+--- @param location _99.Location
+--- @return self
+function Context:finalize(_99, location)
+ table.insert(self.ai_context, _99.prompts.get_file_location(location))
+ table.insert(self.ai_context, _99.prompts.get_range_text(location.range))
+ table.insert(self.ai_context, _99.prompts.tmp_file_location(self.tmp_file))
+ return self
+end
+
--- @param request _99.Request
function Context:add_to_request(request)
for _, context in ipairs(self.ai_context) do