Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File type analyzer #73

Merged

Conversation

Johnnyevans32
Copy link
Contributor

@Johnnyevans32 Johnnyevans32 commented Nov 18, 2024

File Type Analyzer Toolkit for Goose

Resolves #74

Overview

The File Type Analyzer Toolkit provides automated file type analysis for directories. It counts and categorizes files by their extensions and calculates percentages, with support for excluding specific files or directories. This is ideal for assessing project structures or identifying file distribution trends.


Features

  • File Type Analysis

    • Scans directories and subdirectories to identify file extensions.
    • Calculates the total number of files and their distribution percentages.
  • Exclusion Support

    • Accepts a list of file paths or directories to exclude, similar to .gitignore functionality.
  • Recursive and Non-Recursive Modes

    • Recursively analyzes subdirectories or limits the analysis to the top-level directory.

Usage

  1. Add the toolkit to your profiles.yaml:
my-profile:
  provider: openai
  processor: gpt-4o
  accelerator: gpt-4o-mini
  moderator: passive
  toolkits:
    - filetype_analyzer
  1. Run Goose with the profile:
goose session start --profile my-profile
  1. Use the toolkit:
analyse this project file types <path_to_directory> and exclude paths <paths_to_exclude>

Output

The toolkit provides the following output for a given directory:

Example Output:

{
  "file_counts": {
    ".py": 10,
    ".md": 2,
    ".json": 1
  },
  "percentages": {
    ".py": 83.33,
    ".md": 16.67,
    ".json": 8.33
  },
  "total_files": 12
}
Screenshot 2024-11-18 at 02 06 06

Testing

Run tests using pytest:

pytest tests/toolkits/test_filetype_analyzer.py

closes #74

@blackgirlbytes
Copy link
Collaborator

please fix merge conflicts for this @Johnnyevans32

@Johnnyevans32
Copy link
Contributor Author

fixed now @blackgirlbytes

@blackgirlbytes blackgirlbytes merged commit 9eaef71 into block-open-source:main Nov 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Your Own Toolkit for Goose! 🛠️
2 participants