forked from sudo-tee/opencode.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompt_guard_indicator.lua
More file actions
37 lines (31 loc) · 1.01 KB
/
prompt_guard_indicator.lua
File metadata and controls
37 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
local M = {}
local state = require('opencode.state')
local config = require('opencode.config')
local util = require('opencode.util')
local icons = require('opencode.ui.icons')
local context = require('opencode.context')
---Get the current prompt guard status
---@return boolean allowed
---@return string|nil error_message
function M.get_status()
local mentioned_files = context.context.mentioned_files or {}
return util.check_prompt_allowed(config.prompt_guard, mentioned_files)
end
---Check if guard will deny prompts
---@return boolean denied
function M.is_denied()
local allowed, _ = M.get_status()
return not allowed
end
---Get formatted indicator string with highlight (empty if allowed)
---@return string formatted_indicator
function M.get_formatted()
if not M.is_denied() then
-- Prompts are allowed - don't show anything
return ''
end
-- Prompts will be denied - show red indicator
local icon = icons.get('status_off')
return string.format('%%#OpencodeGuardDenied#%s%%*', icon)
end
return M