cli : add /glob command#21084
Conversation
pwilkin
left a comment
There was a problem hiding this comment.
Either add_text_to_file should have a size limit or we should approve the files to read - there's way too much risk of reading some binary or other huge file by accident and poisoning the context IMO.
If you're a dumbass and use Only way to prevent that is to somehow inspect and verify files, that gets way too complicated, and limiting on file size is too arbitrary. It does list the files though, so you can catch the mistake and use |
ngxson
left a comment
There was a problem hiding this comment.
Re. risk of invisibly / accidentally reading more files than needed, I think we can improve the UX by first listing a list of files, then ask Y/N to confirm read. But this can be a follow-up improvement.
| if (pattern[0] == '*' && pattern[1] == '*') { | ||
| const char * p = pattern + 2; | ||
| if (*p == '/') p++; | ||
| if (glob_match(p, str)) return true; | ||
| if (*str != '\0') return glob_match(pattern, str + 1); | ||
| return false; | ||
| } |
There was a problem hiding this comment.
claude gives this suggestion, not sure if that makes sense (feel free to ignore it if it's irrelevant)
if (pattern[0] == '*' && pattern[1] == '*') {
const char * p = pattern + 2;
if (*p == '/') p++;
// try matching the rest of pattern at every position in str
do {
if (glob_match(p, str)) return true;
} while (*str != '\0' && str++);
return false;
}There was a problem hiding this comment.
I thought Claude already wrote this in your PR? :)
There was a problem hiding this comment.
It really makes no sense, I think Claude got confused at the intention.
* add /glob command * output error when max files reached * support globbing outside curdir
* add /glob command * output error when max files reached * support globbing outside curdir
* add /glob command * output error when max files reached * support globbing outside curdir
* add /glob command * output error when max files reached * support globbing outside curdir
Overview
Add /glob command to be able to batch load text files.
Requirements