feat(tools): add filesystem tools crate with glob pattern support
- Add new tools-fs crate with read, glob, and grep utilities - Fix glob command to support actual glob patterns (**, *) instead of just directory walking - Rename binary from "code" to "owlen" to match package name - Fix test to reference correct binary name "owlen" - Add API key support to OllamaClient for authentication 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
28
crates/tools/fs/tests/fs_tools.rs
Normal file
28
crates/tools/fs/tests/fs_tools.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use tools_fs::{read_file, glob_list, grep};
|
||||
use std::fs;
|
||||
use tempfile::tempdir;
|
||||
|
||||
#[test]
|
||||
fn read_and_glob_respect_gitignore() {
|
||||
let dir = tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
fs::write(root.join("a.txt"), "hello").unwrap();
|
||||
fs::create_dir(root.join("secret")).unwrap();
|
||||
fs::write(root.join("secret/secret.txt"), "token=123").unwrap();
|
||||
fs::write(root.join(".gitignore"), "secret/\n").unwrap();
|
||||
|
||||
let files = glob_list(root.to_str().unwrap()).unwrap();
|
||||
assert!(files.iter().any(|p| p.ends_with("a.txt")));
|
||||
assert!(!files.iter().any(|p| p.contains("secret.txt")));
|
||||
assert_eq!(read_file(root.join("a.txt").to_str().unwrap()).unwrap(), "hello");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grep_finds_lines() {
|
||||
let dir = tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
fs::write(root.join("a.rs"), "fn main() { println!(\"hello\"); }").unwrap();
|
||||
|
||||
let hits = grep(root.to_str().unwrap(), "hello").unwrap();
|
||||
assert!(hits.iter().any(|(_p, _ln, text)| text.contains("hello")));
|
||||
}
|
||||
Reference in New Issue
Block a user