PitchHut
Log in / Sign up
askrepo
31 views
Unlock insights from your code with the power of AI.
Pitch

AskRepo transforms your source code reading experience by leveraging the Google Gemini AI model. By processing Git-managed text files, it provides clear insights and answers to your code-related questions. Simplifying code comprehension has never been easier—just specify your directory and prompt.

Description

askrepo is a powerful tool designed to enhance your understanding of source code by leveraging the capabilities of the Google Gemini API. This innovative program enables users to read and analyze Git-managed text files within a specified directory, providing insightful answers to queries based on the content of those files.

Key Features:

  • Automatic Content Analysis: The program intelligently processes the files in your directory, sending their content to the Google Gemini API to answer questions regarding the code.
  • Customizable Prompts: Users can specify prompts that guide the AI in generating relevant and context-aware responses. The default prompt is: "Explain the code in the files provided".

Usage Example:

To start using askrepo, you can execute commands directly in your terminal. Just specify the prompt and the model you wish to use, for example:

askrepo --prompt "What is the purpose of this code?" --model "gemini-1.5-flash" ./src

How It Works:

The functionality of askrepo is organized into several key modules:

  1. File Processing (src/file_utils.rs): This module is responsible for identifying and reading Git-tracked files. It includes functions to determine file types and extract file content, ensuring that only relevant text files are processed.

    • is_binary_file: Detects binary files based on their content.
    • get_git_tracked_files: Lists all relevant files within the directory.
    • get_files_content: Prepares the content for querying by escaping special characters.
  2. Google API Interaction (src/google_api.rs): Handles communication with the Google AI API, including sending requests and processing responses.

    • get_google_api_data: Sends a request to the API using the defined prompt and model name.
    • parse_google_api_response: Extracts the generated output from the API's JSON response.
  3. Main Application Logic (src/main.rs): Orchestrates the entire data flow, from command-line argument parsing to outputting results. This module ensures the seamless integration of file processing and API interaction.

Summary:

In essence, askrepo serves as a sophisticated question-answering tool for source code, enabling developers to gain valuable insights effortlessly. By harnessing the power of AI, users can improve their comprehension of codebases, making askrepo an essential tool for any developer looking to streamline their coding process.