Files Tools
enhancedtoolkits.files.FilesTools ¶
Bases: StrictToolkit
Secure toolkit for file operations with comprehensive security controls.
Source code in src/enhancedtoolkits/files.py
Functions¶
read_file_lines_chunk ¶
Read a chunk of lines from a file with security validation.
Source code in src/enhancedtoolkits/files.py
replace_file_lines_chunk ¶
Replace lines with security validation and atomic operations.
Source code in src/enhancedtoolkits/files.py
insert_lines_into_file_chunk ¶
Insert lines with security validation.
Source code in src/enhancedtoolkits/files.py
delete_lines_from_file_chunk ¶
Delete lines with security validation.
Source code in src/enhancedtoolkits/files.py
save_file_with_validation ¶
Save file with security validation.
Source code in src/enhancedtoolkits/files.py
retrieve_file_metadata ¶
Get file metadata with security validation.
Source code in src/enhancedtoolkits/files.py
list_files_with_pattern ¶
List files with security validation.
Source code in src/enhancedtoolkits/files.py
search_files_by_name_regex ¶
search_files_by_name_regex(regex_pattern: str, recursive: bool = True, max_results: int = 1000) -> str
Search for files with names matching a regex pattern with security validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
regex_pattern | str | Regular expression pattern to match against file names. | required |
recursive | bool | Whether to search recursively in subdirectories. Defaults to True. | True |
max_results | int | Maximum number of results to return. Defaults to 1000. | 1000 |
Returns:
| Name | Type | Description |
|---|---|---|
str | str | JSON string containing the search results and metadata |
Source code in src/enhancedtoolkits/files.py
search_file_contents_by_regex ¶
search_file_contents_by_regex(regex_pattern: str, file_pattern: str = '**/*', recursive: bool = False, max_files: int = 100, max_matches: int = 1000, context_lines: int = 2) -> str
Search for content inside files matching a regex pattern with security validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
regex_pattern | str | Regular expression pattern to match against file content. | required |
file_pattern | str | Glob pattern to filter files. Defaults to "**/*". | '**/*' |
recursive | bool | Whether to search recursively in subdirectories. Defaults to False. | False |
max_files | int | Maximum number of files to search. Defaults to 100. | 100 |
max_matches | int | Maximum number of matches to return. Defaults to 1000. | 1000 |
context_lines | int | Number of context lines to include before and after match. Defaults to 2. | 2 |
Returns:
| Name | Type | Description |
|---|---|---|
str | str | JSON string containing the search results and metadata |
Source code in src/enhancedtoolkits/files.py
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | |
get_llm_usage_instructions staticmethod ¶
Return precise, structured instructions for LLM tool calling.