|
| 1 | +---@module "codecompanion" |
| 2 | + |
| 3 | +return require("vectorcode.config").check_cli_wrap(function() |
| 4 | + local constants = require("codecompanion.config").config.constants |
| 5 | + local rtp = vim.fs.normalize(vim.env.VIMRUNTIME) |
| 6 | + |
| 7 | + if not rtp then |
| 8 | + return error("Failed to locate the neovim runtime!", vim.log.levels.ERROR) |
| 9 | + end |
| 10 | + local stat = vim.uv.fs_stat(rtp) |
| 11 | + if not stat or stat.type ~= "directory" then |
| 12 | + return error( |
| 13 | + string.format( |
| 14 | + "$VIMRUNTIME is %s, which is not a valid directory to be accessed.", |
| 15 | + rtp |
| 16 | + ), |
| 17 | + vim.log.levels.ERROR |
| 18 | + ) |
| 19 | + end |
| 20 | + return { |
| 21 | + name = "Neovim Assistant", |
| 22 | + prompts = { |
| 23 | + strategy = "chat", |
| 24 | + description = "Use VectorCode to index and query from neovim documentation and lua runtime.", |
| 25 | + |
| 26 | + prompts = { |
| 27 | + { |
| 28 | + role = constants.SYSTEM_ROLE, |
| 29 | + content = string.format( |
| 30 | + [[You are an neovim expert. |
| 31 | +You will be given tools to index and query from the neovim runtime library. |
| 32 | +This will include lua APIs for the neovim runtime and documentation for the neovim build that the user is running. |
| 33 | +Use the tools to explain the user's questions related to neovim. |
| 34 | +The runtime files are stored in `%s`. |
| 35 | +You can ONLY use the vectorcode tools to interact with these files or directory. |
| 36 | +DO NOT attempt to read from or write into this directory. |
| 37 | +]], |
| 38 | + rtp |
| 39 | + ), |
| 40 | + }, |
| 41 | + { |
| 42 | + role = constants.USER_ROLE, |
| 43 | + content = string.format( |
| 44 | + [[ |
| 45 | +You are given the @{vectorcode_vectorise} and @{vectorcode_query} tools. |
| 46 | +Vectorrise all lua files and `*.txt` files under this directory using the `vectorcode_vectorise` tool. Use wildcards to match all lua and `txt` files. Use absolute paths when supplying paths to the vectorcode_vectorise tool; |
| 47 | +Use `%s` as the value of the `project_root` argument; |
| 48 | +When you're done, I'll be asking you questions related to these documents. |
| 49 | +Use the vectorcode_query tool to query from the project root and answer my question. |
| 50 | +]], |
| 51 | + rtp, |
| 52 | + rtp |
| 53 | + ), |
| 54 | + }, |
| 55 | + }, |
| 56 | + }, |
| 57 | + } |
| 58 | +end) |
0 commit comments