summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--lua/99/init.lua9
-rw-r--r--lua/99/request-context.lua9
-rw-r--r--lua/99/utils.lua9
4 files changed, 25 insertions, 8 deletions
diff --git a/README.md b/README.md
index 31c97b8..8ab6a93 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,12 @@ I make the assumption you are using Lazy
path = "/tmp/" .. basename .. ".99.debug",
print_on_error = true,
},
+ -- When setting this to something that is not inside the CWD tools
+ -- such as claude code or opencode will have permission issues
+ -- and generation will fail refer to tool documentation to resolve
+ -- https://opencode.ai/docs/permissions/#external-directories
+ -- https://code.claude.com/docs/en/permissions#read-and-edit
+ tmp_dir = "./tmp",
--- Completions: #rules and @files in the prompt buffer
completion = {
diff --git a/lua/99/init.lua b/lua/99/init.lua
index a51cc51..f804f2f 100644
--- a/lua/99/init.lua
+++ b/lua/99/init.lua
@@ -73,6 +73,7 @@ end
--- @field __view_log_idx number
--- @field __request_history _99.RequestEntry[]
--- @field __request_by_id table<number, _99.RequestEntry>
+--- @field tmp_dir string | nil
--- @return _99.StateProps
local function create_99_state()
@@ -89,6 +90,7 @@ local function create_99_state()
__view_log_idx = 1,
__request_history = {},
__request_by_id = {},
+ tmp_dir = nil,
}
end
@@ -107,6 +109,7 @@ end
--- @field display_errors? boolean
--- @field auto_add_skills? boolean
--- @field completion _99.Completion?
+--- @field tmp_dir? string
--- unanswered question -- will i need to queue messages one at a time or
--- just send them all... So to prepare ill be sending around this state object
@@ -128,6 +131,7 @@ end
--- @field __request_history _99.RequestEntry[]
--- @field __request_by_id table<number, _99.RequestEntry>
--- @field __active_marks _99.Mark[]
+--- @field tmp_dir string | nil
local _99_State = {}
_99_State.__index = _99_State
@@ -621,6 +625,11 @@ function _99.setup(opts)
end
end
+ if opts.tmp_dir then
+ assert(type(opts.tmp_dir) == "string", "opts.tmp_dir must be a string")
+ end
+ _99_state.tmp_dir = opts.tmp_dir
+
_99_state.display_errors = opts.display_errors or false
_99_state:refresh_rules()
Languages.initialize(_99_state)
diff --git a/lua/99/request-context.lua b/lua/99/request-context.lua
index 02ac0e1..48d4489 100644
--- a/lua/99/request-context.lua
+++ b/lua/99/request-context.lua
@@ -37,12 +37,17 @@ function RequestContext.from_current_buffer(_99, xid)
table.insert(mds, md)
end
+ local tmp_dir = _99.tmp_dir
+ if tmp_dir then
+ tmp_dir = vim.fn.expand(tmp_dir)
+ end
+
return setmetatable({
_99 = _99,
clean_ups = {},
md_file_names = mds,
ai_context = {},
- tmp_file = random_file(),
+ tmp_file = random_file(tmp_dir),
buffer = buffer,
full_path = full_path,
file_type = file_type,
@@ -120,7 +125,7 @@ function RequestContext:_ready_request_files()
local dir = vim.fs.dirname(prompt_file)
if dir and not vim.uv.fs_stat(dir) then
- pcall(vim.uv.fs_mkdir, dir, 493)
+ vim.fn.mkdir(dir, "p")
end
local files = { prompt_file, response_file }
diff --git a/lua/99/utils.lua b/lua/99/utils.lua
index c308624..0882489 100644
--- a/lua/99/utils.lua
+++ b/lua/99/utils.lua
@@ -3,12 +3,9 @@ local M = {}
--- directories. if this is still the case in neovim land, then we will need
--- to make the _99_state have the project directory.
--- @return string
-function M.random_file()
- return string.format(
- "%s/tmp/99-%d",
- vim.uv.cwd(),
- math.floor(math.random() * 10000)
- )
+function M.random_file(dir)
+ local directory = dir or (vim.uv.cwd() .. "/tmp")
+ return string.format("%s/99-%d", directory, math.floor(math.random() * 10000))
end
return M