pub struct CodeTool { /* private fields */ }Expand description
Repository source code browser.
Downloads and caches GitHub tarballs for browsing repository source code.
Implementations§
Source§impl CodeTool
impl CodeTool
Sourcepub fn new(config: CodeToolConfig, get_sha: ShaCallback) -> Result<Self, Error>
pub fn new(config: CodeToolConfig, get_sha: ShaCallback) -> Result<Self, Error>
Create a new CodeTool instance from configuration.
The get_sha callback is called to determine which git SHA to download/load.
For GitHub sources, this is the commit SHA. For file sources, this can be
used to track file modification (e.g., mtime or a version string).
Sourcepub fn has_summary(&self) -> bool
pub fn has_summary(&self) -> bool
Check if this code tool has a summary available.
Sourcepub async fn ls(&self, path: Option<&str>) -> Result<String, String>
pub async fn ls(&self, path: Option<&str>) -> Result<String, String>
List files in a directory (like ls).
If path is None or empty, lists the root directory.
Sourcepub async fn find(&self, pattern: Option<&str>) -> Result<String, String>
pub async fn find(&self, pattern: Option<&str>) -> Result<String, String>
Find files matching a glob pattern (like find).
Supports glob patterns using the globset crate syntax.
Sourcepub async fn read(
&self,
path: &str,
line_start: Option<usize>,
line_end: Option<usize>,
) -> Result<String, String>
pub async fn read( &self, path: &str, line_start: Option<usize>, line_end: Option<usize>, ) -> Result<String, String>
Read a file’s contents.
If line_range is provided, only returns those lines (1-indexed, inclusive).
Sourcepub async fn search(
&self,
pattern: &str,
context: u32,
path_prefix: Option<&str>,
) -> Result<String, String>
pub async fn search( &self, pattern: &str, context: u32, path_prefix: Option<&str>, ) -> Result<String, String>
Search for a regex pattern in all files.
pattern: The regex pattern to search for.context: Number of context lines to show (likegrep -C).path_prefix: Optional path prefix to limit search scope.
Auto Trait Implementations§
impl !Freeze for CodeTool
impl !RefUnwindSafe for CodeTool
impl Send for CodeTool
impl Sync for CodeTool
impl Unpin for CodeTool
impl !UnwindSafe for CodeTool
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more