feat: load and parse markdown role files as roles#201
feat: load and parse markdown role files as roles#201Konfekt wants to merge 4 commits intomadox2:mainfrom
Conversation
|
Hi, thanks for the contribution! I think the idea is good. Rather than introducing new concept and markdown file syntax, it could use existing aichat file/syntax. Then it would be easy to play around in the chat and make a role out of it. It would also be easier to maintain as the aichat file parsing logic is already implemented and can be reused. |
Implemented:
- Added g:vim_ai_roles_config_path support with fallback to
g:vim_ai_roles_config_file in loader logic: utils.py (./py/utils.py#L452), utils.py (./py/utils.py#L470)
- Directory behavior updated:
- read all *.ini files in lexicographical order (merged like one ini)
- keep current markdown parsing for *.md/*.markdown
- applied in utils.py (./py/
utils.py#L465)
- Renamed default config variable to _path while keeping _file backward-
compatible:
- defaults/compat in vim_ai_config.vim (./autoload/vim_ai_config.vim#L154)
- :AIUtilRolesOpen now prefers _path with _file fallback in vim_ai.vim (./autoload/vim_ai.vim#L468)
- Docs updated to document _path usage and note _file compatibility:
- README.md (./README.md#L145)
- vim-ai.txt (./doc/vim-ai.txt#L274)
- roles-example.ini (./roles-
example.ini#L3)
Regression tests added/updated:
- Mixed directory coverage (*.ini + *.md) and _path precedence:
- roles_test.py (./tests/
roles_test.py#L54)
- context_test.py (./tests/
context_test.py#L299)
- test fixtures: 01-base.ini (./
tests/resources/roles-mixed/01-base.ini), 02-override.ini (./tests/resources/roles-mixed/02-
override.ini), mixed-md-role.md (./tests/resources/roles-mixed/mixed-md-role.md)
- Mock updated for new global key: tests/mocks/vim.py (./tests/mocks/vim.py#L11)
|
Last commit addresses this, now merging all *.ini files and using |
|
I meant something else, having .aichat instead of .md, but nevermind, I think you are right and md files are better for this job. |
|
One thing concerns me - if I had a big collection of potentially big md files, this way it would need to open and parse every single one during vim completion (using tab key). That might cause some performance issues. It could be improved by caching the roles, but I would like to avoid caching if possible. The other solution could be adding some naming convention to the md files, for example: This way it would only need to list directory for markdown files and load ini files to complete roles. It would be also easier to parse header (don't need to assume different command types). It won't be possible to provide different config for chat/complete/edit command types in a single md file but I would accept that limitation. |
|
I wonder at which point the content of each file hat to be parsed? For |
|
I would say for completion it needs to load content of ini files and filenames of md files. When running actual role it needs to load ini files and a particular md file if exists |
So it would not have to for completion, and the concern is luckily unwarranted? |
… compat" This reverts commit 766b820.
In case the config_file parameter happens to be a folder, use one markdown file per role. As these can get long, helps keeping everything in place